FindPythonQt.cmake 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. if(NOT EXISTS "${PYTHONQT_INSTALL_DIR}")
  11. find_path(PYTHONQT_INSTALL_DIR include/PythonQt/PythonQt.h DOC "Directory where PythonQt was installed.")
  12. endif()
  13. find_path(PYTHONQT_INCLUDE_DIR PythonQt.h "${PYTHONQT_INSTALL_DIR}/include/PythonQt" DOC "Path to the PythonQt include directory")
  14. find_library(PYTHONQT_LIBRARY_RELEASE PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.")
  15. 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.")
  16. set(PYTHONQT_LIBRARY)
  17. if(PYTHONQT_LIBRARY_RELEASE)
  18. list(APPEND PYTHONQT_LIBRARY optimized ${PYTHONQT_LIBRARY_RELEASE})
  19. endif()
  20. if(PYTHONQT_LIBRARY_DEBUG)
  21. list(APPEND PYTHONQT_LIBRARY debug ${PYTHONQT_LIBRARY_DEBUG})
  22. endif()
  23. mark_as_advanced(PYTHONQT_INSTALL_DIR)
  24. mark_as_advanced(PYTHONQT_INCLUDE_DIR)
  25. mark_as_advanced(PYTHONQT_LIBRARY_RELEASE)
  26. mark_as_advanced(PYTHONQT_LIBRARY_DEBUG)
  27. # On linux, also find libutil
  28. if(UNIX AND NOT APPLE)
  29. find_library(PYTHONQT_LIBUTIL util)
  30. mark_as_advanced(PYTHONQT_LIBUTIL)
  31. endif()
  32. # All upper case _FOUND variable is maintained for backwards compatibility.
  33. set(PYTHONQT_FOUND 0)
  34. set(PythonQt_FOUND 0)
  35. if(PYTHONQT_INCLUDE_DIR AND PYTHONQT_LIBRARY)
  36. # Currently CMake'ified PythonQt only supports building against a python Release build.
  37. # This applies independently of CTK build type (Release, Debug, ...)
  38. add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK)
  39. set(PYTHONQT_FOUND 1)
  40. set(PythonQt_FOUND ${PYTHONQT_FOUND})
  41. set(PYTHONQT_LIBRARIES ${PYTHONQT_LIBRARY} ${PYTHONQT_LIBUTIL})
  42. endif()