standalone.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. if(NOT DEFINED OpenCV_BINARY_DIR)
  2. message(FATAL_ERROR "Define OpenCV_BINARY_DIR")
  3. endif()
  4. include("${OpenCV_BINARY_DIR}/opencv_python_config.cmake")
  5. if(NOT DEFINED OpenCV_SOURCE_DIR)
  6. message(FATAL_ERROR "Missing OpenCV_SOURCE_DIR")
  7. endif()
  8. if(DEFINED OPENCV_PYTHON_STANDALONE_INSTALL_PATH)
  9. set(OPENCV_PYTHON_INSTALL_PATH "${OPENCV_PYTHON_STANDALONE_INSTALL_PATH}")
  10. elseif(NOT OPENCV_PYTHON_INSTALL_PATH)
  11. message(FATAL_ERROR "Missing OPENCV_PYTHON_STANDALONE_INSTALL_PATH / OPENCV_PYTHON_INSTALL_PATH")
  12. endif()
  13. include("${OpenCV_SOURCE_DIR}/cmake/OpenCVUtils.cmake")
  14. set(OPENCV_PYTHON_SKIP_DETECTION ON)
  15. include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectPython.cmake")
  16. find_python("${OPENCV_PYTHON_VERSION}" "${OPENCV_PYTHON_VERSION}" PYTHON_LIBRARY PYTHON_INCLUDE_DIR
  17. PYTHONINTERP_FOUND PYTHON_EXECUTABLE PYTHON_VERSION_STRING
  18. PYTHON_VERSION_MAJOR PYTHON_VERSION_MINOR PYTHONLIBS_FOUND
  19. PYTHONLIBS_VERSION_STRING PYTHON_LIBRARIES PYTHON_LIBRARY
  20. PYTHON_DEBUG_LIBRARIES PYTHON_LIBRARY_DEBUG PYTHON_INCLUDE_PATH
  21. PYTHON_INCLUDE_DIR PYTHON_INCLUDE_DIR2 PYTHON_PACKAGES_PATH
  22. PYTHON_NUMPY_INCLUDE_DIRS PYTHON_NUMPY_VERSION)
  23. if(NOT PYTHON_EXECUTABLE OR NOT PYTHON_INCLUDE_DIR)
  24. message(FATAL_ERROR "Can't find Python development files")
  25. endif()
  26. if(NOT PYTHON_NUMPY_INCLUDE_DIRS)
  27. message(FATAL_ERROR "Can't find Python 'numpy' development files")
  28. endif()
  29. status("-----------------------------------------------------------------")
  30. status(" Python:")
  31. status(" Interpreter:" "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_STRING})")
  32. status(" Libraries:" "${PYTHON_LIBRARIES} (ver ${PYTHONLIBS_VERSION_STRING})")
  33. status(" numpy:" "${PYTHON_NUMPY_INCLUDE_DIRS} (ver ${PYTHON_NUMPY_VERSION})")
  34. status("")
  35. status(" Install to:" "${CMAKE_INSTALL_PREFIX}")
  36. status("-----------------------------------------------------------------")
  37. set(OpenCV_DIR "${OpenCV_BINARY_DIR}")
  38. find_package(OpenCV REQUIRED)
  39. set(PYTHON PYTHON)
  40. macro(ocv_add_module module_name)
  41. set(the_module opencv_${module_name})
  42. project(${the_module} CXX)
  43. endmacro()
  44. macro(ocv_module_include_directories module)
  45. include_directories(${ARGN})
  46. endmacro()
  47. set(MODULE_NAME python)
  48. set(MODULE_INSTALL_SUBDIR "")
  49. set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
  50. set(deps ${OpenCV_LIBRARIES})
  51. include("${CMAKE_CURRENT_LIST_DIR}/common.cmake") # generate python target
  52. # done, cleanup
  53. unset(OPENCV_BUILD_INFO_STR CACHE) # remove from cache