You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FindThirdPartyPython3.cmake 1.4KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # ---------------------------------
  2. # Finds Python
  3. # Adds library to target
  4. # Adds include path
  5. # ---------------------------------
  6. GET_PROPERTY(OV_PRINTED GLOBAL PROPERTY OV_TRIED_ThirdPartyPython3)
  7. SET(Python_ADDITIONAL_VERSIONS 3.7)
  8. # Stops lookup as soon as a version satisfying the version constraints is found.
  9. # Important when building both 32bits andd 64bits versions on the same machine.
  10. # CMake might go for the 64bits version of Python when building 32bits, making the compilation fail.
  11. # To work, you need to ensure that 32bits versions of Python appearing first in the Path.
  12. # This is only needed for windows.
  13. SET(Python3_FIND_STRATEGY LOCATION)
  14. FIND_PACKAGE(Python3 COMPONENTS Development)
  15. IF(Python3_FOUND)
  16. OV_PRINT(OV_PRINTED " Found Python 3 at ${Python3_LIBRARIES}")
  17. INCLUDE_DIRECTORIES(${Python3_INCLUDE_DIRS})
  18. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Python3_LIBRARIES})
  19. IF(WIN32)
  20. # These are needed not to cause a popup on machines missing the dll
  21. TARGET_LINK_LIBRARIES(${PROJECT_NAME} optimized Delayimp )
  22. SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DELAYLOAD:python37.dll")
  23. ENDIF()
  24. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyPython3)
  25. ELSE()
  26. OV_PRINT(OV_PRINTED " FAILED to find Python 3 (needs v3.7 with bitness matching build target ${PLATFORM_TARGET})")
  27. ENDIF()
  28. SET_PROPERTY(GLOBAL PROPERTY OV_TRIED_ThirdPartyPython3 "Yes")