Updated for cmake 2.8.8

pull/13383/head
Andrey Kamaev 13 years ago
parent 3a4c14e549
commit 247e2d085f
  1. 22
      CMakeLists.txt
  2. 34
      cmake/OpenCVDetectPython.cmake
  3. 4
      cmake/OpenCVIOLibs.cmake
  4. 9
      modules/python/CMakeLists.txt

@ -42,10 +42,12 @@ endif(NOT CMAKE_TOOLCHAIN_FILE)
# -------------------------------------------------------------- # --------------------------------------------------------------
# Top level OpenCV project # Top level OpenCV project
# -------------------------------------------------------------- # --------------------------------------------------------------
if(NOT IOS) if(CMAKE_GENERATOR MATCHES Xcode AND XCODE_VERSION VERSION_GREATER 4.3)
cmake_minimum_required(VERSION 2.6.3) cmake_minimum_required(VERSION 2.8.8)
elseif(IOS)
cmake_minimum_required(VERSION 2.8.0)
else() else()
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.6.3)
endif() endif()
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE) set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
@ -53,7 +55,7 @@ if(DEFINED CMAKE_BUILD_TYPE AND CMAKE_VERSION VERSION_GREATER "2.8")
set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} ) set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} )
endif() endif()
project(OpenCV) project(OpenCV CXX C)
include(cmake/OpenCVUtils.cmake REQUIRED) include(cmake/OpenCVUtils.cmake REQUIRED)
@ -780,7 +782,11 @@ else()
status(" PNG:" "NO") status(" PNG:" "NO")
endif() endif()
if(WITH_TIFF) if(WITH_TIFF)
status(" TIFF:" TIFF_FOUND THEN "${TIFF_LIBRARY} (ver ${TIFF_VERSION})" ELSE "build (ver ${TIFF_VERSION})") if(TIFF_VERSION_STRING AND TIFF_FOUND)
status(" TIFF:" "${TIFF_LIBRARY} (ver ${TIFF_VERSION} - ${TIFF_VERSION_STRING})")
else()
status(" TIFF:" TIFF_FOUND THEN "${TIFF_LIBRARY} (ver ${TIFF_VERSION})" ELSE "build (ver ${TIFF_VERSION})")
endif()
else() else()
status(" TIFF:" "NO") status(" TIFF:" "NO")
endif() endif()
@ -885,7 +891,11 @@ status("")
status(" Python:") status(" Python:")
status(" Interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_FULL})" ELSE NO) status(" Interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_FULL})" ELSE NO)
if(BUILD_opencv_python) if(BUILD_opencv_python)
status(" Libraries:" HAVE_opencv_python THEN ${PYTHON_LIBRARIES} ELSE NO) if(PYTHONLIBS_VERSION_STRING)
status(" Libraries:" HAVE_opencv_python THEN "${PYTHON_LIBRARIES} (ver ${PYTHONLIBS_VERSION_STRING})" ELSE NO)
else()
status(" Libraries:" HAVE_opencv_python THEN ${PYTHON_LIBRARIES} ELSE NO)
endif()
status(" numpy:" PYTHON_USE_NUMPY THEN "${PYTHON_NUMPY_INCLUDE_DIR} (ver ${PYTHON_NUMPY_VERSION})" ELSE "NO (Python wrappers can not be generated)") status(" numpy:" PYTHON_USE_NUMPY THEN "${PYTHON_NUMPY_INCLUDE_DIR} (ver ${PYTHON_NUMPY_VERSION})" ELSE "NO (Python wrappers can not be generated)")
status(" packages path:" PYTHON_EXECUTABLE THEN "${PYTHON_PACKAGES_PATH}" ELSE "-") status(" packages path:" PYTHON_EXECUTABLE THEN "${PYTHON_PACKAGES_PATH}" ELSE "-")
endif() endif()

@ -1,35 +1,44 @@
if(MSVC AND NOT PYTHON_EXECUTABLE) if(MSVC AND NOT PYTHON_EXECUTABLE)
# search for executable with the same bitness as resulting binaries # search for executable with the same bitness as resulting binaries
# standard FindPythonInterp always prefers executable from system path # standard FindPythonInterp always prefers executable from system path
foreach(_CURRENT_VERSION ${Python_ADDITIONAL_VERSIONS} 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) # this is really important because we are using the interpreter for numpy search and for choosing the install location
foreach(_CURRENT_VERSION ${Python_ADDITIONAL_VERSIONS} 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
find_host_program(PYTHON_EXECUTABLE find_host_program(PYTHON_EXECUTABLE
NAMES python${_CURRENT_VERSION} python NAMES python${_CURRENT_VERSION} python
PATHS [HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath] PATHS
[HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath]
[HKEY_CURRENT_USER\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath]
NO_SYSTEM_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH
) )
endforeach() endforeach()
endif() endif()
find_host_package(PythonInterp)
find_host_package(PythonInterp 2.0)
unset(PYTHON_USE_NUMPY CACHE) unset(PYTHON_USE_NUMPY CACHE)
unset(HAVE_SPHINX CACHE) unset(HAVE_SPHINX CACHE)
if(PYTHON_EXECUTABLE) if(PYTHON_EXECUTABLE)
if(PYTHON_VERSION_STRING)
set(PYTHON_VERSION_FULL "${PYTHON_VERSION_STRING}")
set(PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
else()
execute_process(COMMAND ${PYTHON_EXECUTABLE} --version
ERROR_VARIABLE PYTHON_VERSION_FULL
ERROR_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[0-9]+.[0-9]+" PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_FULL}")
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" PYTHON_VERSION_FULL "${PYTHON_VERSION_FULL}")
endif()
if(NOT ANDROID AND NOT IOS) if(NOT ANDROID AND NOT IOS)
find_host_package(PythonLibs) find_host_package(PythonLibs ${PYTHON_VERSION_FULL})
# cmake 2.4 (at least on Ubuntu 8.04 (hardy)) don't define PYTHONLIBS_FOUND # cmake 2.4 (at least on Ubuntu 8.04 (hardy)) don't define PYTHONLIBS_FOUND
if(NOT PYTHONLIBS_FOUND AND PYTHON_INCLUDE_PATH) if(NOT PYTHONLIBS_FOUND AND PYTHON_INCLUDE_PATH)
set(PYTHONLIBS_FOUND ON) set(PYTHONLIBS_FOUND ON)
endif() endif()
endif() endif()
execute_process(COMMAND ${PYTHON_EXECUTABLE} --version
ERROR_VARIABLE PYTHON_VERSION_FULL
ERROR_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[0-9]+.[0-9]+" PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_FULL}")
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" PYTHON_VERSION_FULL "${PYTHON_VERSION_FULL}")
if(NOT ANDROID AND NOT IOS) if(NOT ANDROID AND NOT IOS)
if(CMAKE_HOST_UNIX) if(CMAKE_HOST_UNIX)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_python_lib()" execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_python_lib()"
@ -53,6 +62,9 @@ if(PYTHON_EXECUTABLE)
if(NOT EXISTS "${PYTHON_PATH}/Lib/site-packages") if(NOT EXISTS "${PYTHON_PATH}/Lib/site-packages")
unset(PYTHON_PATH) unset(PYTHON_PATH)
get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE) get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE)
if(NOT PYTHON_PATH)
get_filename_component(PYTHON_PATH "[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE)
endif()
file(TO_CMAKE_PATH "${PYTHON_PATH}" PYTHON_PATH) file(TO_CMAKE_PATH "${PYTHON_PATH}" PYTHON_PATH)
endif() endif()
set(PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages") set(PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages")

@ -98,7 +98,9 @@ if(WITH_JASPER AND NOT JASPER_FOUND)
set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}") set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}")
endif() endif()
ocv_parse_header2(JASPER "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" JAS_VERSION "") if(NOT JASPER_VERSION_STRING)
ocv_parse_header2(JASPER "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" JAS_VERSION "")
endif()
################### libpng - optional (should be searched after zlib) ################### libpng - optional (should be searched after zlib)
if(WITH_PNG) if(WITH_PNG)

@ -60,7 +60,12 @@ add_custom_command(
DEPENDS ${opencv_hdrs}) DEPENDS ${opencv_hdrs})
add_library(${the_module} SHARED src2/cv2.cpp ${CMAKE_CURRENT_BINARY_DIR}/generated0.i ${cv2_generated_hdrs} src2/cv2.cv.hpp) add_library(${the_module} SHARED src2/cv2.cpp ${CMAKE_CURRENT_BINARY_DIR}/generated0.i ${cv2_generated_hdrs} src2/cv2.cv.hpp)
target_link_libraries(${the_module} ${PYTHON_LIBRARIES} ${OPENCV_MODULE_${the_module}_DEPS}) if(PYTHON_DEBUG_LIBRARIES)
target_link_libraries(${the_module} debug ${PYTHON_DEBUG_LIBRARIES} optimized ${PYTHON_LIBRARIES})
else()
target_link_libraries(${the_module} ${PYTHON_LIBRARIES})
endif()
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS})
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('SO')" execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('SO')"
RESULT_VARIABLE PYTHON_CVPY_PROCESS RESULT_VARIABLE PYTHON_CVPY_PROCESS
@ -87,7 +92,7 @@ if(MSVC AND NOT BUILD_SHARED_LIBS)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG") set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif() endif()
if(MSVC) if(MSVC AND NOT PYTHON_DEBUG_LIBRARIES)
set(PYTHON_INSTALL_CONFIGURATIONS CONFIGURATIONS Release) set(PYTHON_INSTALL_CONFIGURATIONS CONFIGURATIONS Release)
else() else()
set(PYTHON_INSTALL_CONFIGURATIONS "") set(PYTHON_INSTALL_CONFIGURATIONS "")

Loading…
Cancel
Save