FindPythonQt.cmake 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. # XXX Since PythonQt 3.0 is not yet cmakeified, depending
  14. # on how PythonQt is built, headers will not always be
  15. # installed in "include/PythonQt". That is why "src"
  16. # is added as an option. See [1] for more details.
  17. # [1] https://github.com/commontk/CTK/pull/538#issuecomment-86106367
  18. find_path(PYTHONQT_INCLUDE_DIR PythonQt.h
  19. PATHS "${PYTHONQT_INSTALL_DIR}/include/PythonQt"
  20. "${PYTHONQT_INSTALL_DIR}/src"
  21. DOC "Path to the PythonQt include directory")
  22. find_library(PYTHONQT_LIBRARY_RELEASE PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.")
  23. 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.")
  24. set(PYTHONQT_LIBRARY)
  25. if(PYTHONQT_LIBRARY_RELEASE)
  26. list(APPEND PYTHONQT_LIBRARY optimized ${PYTHONQT_LIBRARY_RELEASE})
  27. endif()
  28. if(PYTHONQT_LIBRARY_DEBUG)
  29. list(APPEND PYTHONQT_LIBRARY debug ${PYTHONQT_LIBRARY_DEBUG})
  30. endif()
  31. mark_as_advanced(PYTHONQT_INSTALL_DIR)
  32. mark_as_advanced(PYTHONQT_INCLUDE_DIR)
  33. mark_as_advanced(PYTHONQT_LIBRARY_RELEASE)
  34. mark_as_advanced(PYTHONQT_LIBRARY_DEBUG)
  35. # On linux, also find libutil
  36. if(UNIX AND NOT APPLE)
  37. find_library(PYTHONQT_LIBUTIL util)
  38. mark_as_advanced(PYTHONQT_LIBUTIL)
  39. endif()
  40. # All upper case _FOUND variable is maintained for backwards compatibility.
  41. set(PYTHONQT_FOUND 0)
  42. set(PythonQt_FOUND 0)
  43. if(PYTHONQT_INCLUDE_DIR AND PYTHONQT_LIBRARY)
  44. # Currently CMake'ified PythonQt only supports building against a python Release build.
  45. # This applies independently of CTK build type (Release, Debug, ...)
  46. add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK)
  47. set(PYTHONQT_FOUND 1)
  48. set(PythonQt_FOUND ${PYTHONQT_FOUND})
  49. set(PYTHONQT_LIBRARIES ${PYTHONQT_LIBRARY} ${PYTHONQT_LIBUTIL})
  50. endif()