FindPythonQt.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Find PythonQt
  2. #
  3. # Sets PYTHONQT_FOUND, PYTHONQT_INCLUDE_DIR, PYTHONQT_LIBRARY, PYTHONQT_LIBRARIES
  4. #
  5. # Python is required
  6. find_package(PythonLibs)
  7. if(NOT PYTHONLIBS_FOUND)
  8. message(FATAL_ERROR "error: Python is required to build PythonQt")
  9. endif()
  10. find_path(PYTHONQT_INSTALL_DIR include/PythonQt/PythonQt.h DOC "Directory where PythonQt was installed.")
  11. find_path(PYTHONQT_INCLUDE_DIR PythonQt.h "${PYTHONQT_INSTALL_DIR}/include/PythonQt" DOC "Path to the PythonQt include directory")
  12. find_library(PYTHONQT_LIBRARY_RELEASE PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.")
  13. find_library(PYTHONQT_LIBRARY_DEBUG NAMES PythonQt${CTK_CMAKE_DEBUG_POSTFIX} PythonQt${CMAKE_DEBUG_POSTFIX} PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.")
  14. set(PYTHONQT_LIBRARY)
  15. if(PYTHONQT_LIBRARY_RELEASE)
  16. list(APPEND PYTHONQT_LIBRARY optimized ${PYTHONQT_LIBRARY_RELEASE})
  17. endif()
  18. if(PYTHONQT_LIBRARY_DEBUG)
  19. list(APPEND PYTHONQT_LIBRARY debug ${PYTHONQT_LIBRARY_DEBUG})
  20. endif()
  21. mark_as_advanced(PYTHONQT_INSTALL_DIR)
  22. mark_as_advanced(PYTHONQT_INCLUDE_DIR)
  23. mark_as_advanced(PYTHONQT_LIBRARY_RELEASE)
  24. mark_as_advanced(PYTHONQT_LIBRARY_DEBUG)
  25. # On linux, also find libutil
  26. if(UNIX AND NOT APPLE)
  27. find_library(PYTHONQT_LIBUTIL util)
  28. mark_as_advanced(PYTHONQT_LIBUTIL)
  29. endif()
  30. set(PYTHONQT_FOUND 0)
  31. if(PYTHONQT_INCLUDE_DIR AND PYTHONQT_LIBRARY)
  32. # Currently CMake'ified PythonQt only supports building against a python Release build.
  33. # This applies independently of CTK build type (Release, Debug, ...)
  34. add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK)
  35. set(PYTHONQT_FOUND 1)
  36. set(PYTHONQT_LIBRARIES ${PYTHONQT_LIBRARY} ${PYTHONQT_LIBUTIL})
  37. endif()