Add SKIPPYTHON support to cmake

This commit is contained in:
Philippe Teuwen 2020-06-09 00:47:34 +02:00
parent 66505988a2
commit de100fc8e7

View file

@ -42,9 +42,12 @@ endif (NOT SKIPQT EQUAL 1)
find_package(PkgConfig) find_package(PkgConfig)
if (NOT SKIPBT EQUAL 1) if (NOT SKIPBT EQUAL 1)
pkg_search_module(BLUEZ QUIET bluez) pkg_search_module(BLUEZ QUIET bluez)
endif() endif (NOT SKIPBT EQUAL 1)
pkg_search_module(PYTHON3 QUIET python3)
pkg_search_module(PYTHON3EMBED QUIET python3-embed) if (NOT SKIPPYTHON EQUAL 1)
pkg_search_module(PYTHON3 QUIET python3)
pkg_search_module(PYTHON3EMBED QUIET python3-embed)
endif (NOT SKIPPYTHON EQUAL 1)
add_subdirectory(${PM3_ROOT}/client/deps deps) add_subdirectory(${PM3_ROOT}/client/deps deps)
@ -229,19 +232,19 @@ if (NOT SKIPBT EQUAL 1)
endif (BLUEZ_FOUND) endif (BLUEZ_FOUND)
endif(NOT SKIPBT EQUAL 1) endif(NOT SKIPBT EQUAL 1)
if (PYTHON3EMBED_FOUND) if (NOT SKIPPYTHON EQUAL 1)
message("Python3-embed library found, building with python3 support :)") if (PYTHON3EMBED_FOUND)
add_definitions(-DHAVE_PYTHON) add_definitions(-DHAVE_PYTHON)
set(ADDITIONAL_DIRS ${PYTHON3EMBED_INCLUDE_DIRS} ${ADDITIONAL_DIRS}) set(ADDITIONAL_DIRS ${PYTHON3EMBED_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
set(ADDITIONAL_LNK ${PYTHON3EMBED_LIBRARIES} ${ADDITIONAL_LNK}) set(ADDITIONAL_LNK ${PYTHON3EMBED_LIBRARIES} ${ADDITIONAL_LNK})
set(ADDITIONAL_LNKDIRS ${PYTHON3EMBED_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS}) set(ADDITIONAL_LNKDIRS ${PYTHON3EMBED_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
elseif (PYTHON3_FOUND) elseif (PYTHON3_FOUND)
message("Python3 library found, building with python3 support :)") add_definitions(-DHAVE_PYTHON)
add_definitions(-DHAVE_PYTHON) set(ADDITIONAL_DIRS ${PYTHON3_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
set(ADDITIONAL_DIRS ${PYTHON3_INCLUDE_DIRS} ${ADDITIONAL_DIRS}) set(ADDITIONAL_LNK ${PYTHON3_LIBRARIES} ${ADDITIONAL_LNK})
set(ADDITIONAL_LNK ${PYTHON3_LIBRARIES} ${ADDITIONAL_LNK}) set(ADDITIONAL_LNKDIRS ${PYTHON3_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
set(ADDITIONAL_LNKDIRS ${PYTHON3_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS}) endif (PYTHON3EMBED_FOUND)
endif (PYTHON3EMBED_FOUND) endif (NOT SKIPPYTHON EQUAL 1)
message("===================================================================") message("===================================================================")
if (SKIPQT EQUAL 1) if (SKIPQT EQUAL 1)
@ -263,6 +266,18 @@ else (SKIPBT EQUAL 1)
message("native BT support: Bluez not found, disabled") message("native BT support: Bluez not found, disabled")
endif (BLUEZ_FOUND) endif (BLUEZ_FOUND)
endif(SKIPBT EQUAL 1) endif(SKIPBT EQUAL 1)
if (SKIPPYTHON EQUAL 1)
message("Python3 library: skipped")
else (SKIPPYTHON EQUAL 1)
if (PYTHON3EMBED_FOUND)
message("Python3 library: Python3 embed found, enabled")
elseif (PYTHON_FOUND)
message("Python3 library: Python3 found, enabled")
else (PYTHON3EMBED_FOUND)
message("Python3 library: Python3 not found, disabled")
endif (PYTHON3EMBED_FOUND)
endif(SKIPPYTHON EQUAL 1)
message("===================================================================") message("===================================================================")
add_executable(proxmark3 add_executable(proxmark3
@ -330,14 +345,16 @@ if (NOT SKIPPTHREAD EQUAL 1)
target_link_libraries(proxmark3 PRIVATE pthread) target_link_libraries(proxmark3 PRIVATE pthread)
endif (NOT SKIPPTHREAD EQUAL 1) endif (NOT SKIPPTHREAD EQUAL 1)
# OSX have a hard time compiling python3 dependency with older cmake. if (NOT SKIPPYTHON EQUAL 1)
if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND) # OSX have a hard time compiling python3 dependency with older cmake.
if (NOT CMAKE_VERSION VERSION_LESS 3.13) if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
target_link_directories(proxmark3 PRIVATE ${ADDITIONAL_LNKDIRS}) if (NOT CMAKE_VERSION VERSION_LESS 3.13)
elseif (APPLE) target_link_directories(proxmark3 PRIVATE ${ADDITIONAL_LNKDIRS})
message( SEND_ERROR "Your CMAKE version is too old for Apple platform, please update to a version >=3.13" ) elseif (APPLE)
endif (NOT CMAKE_VERSION VERSION_LESS 3.13) message( SEND_ERROR "Your CMAKE version is too old for Apple platform, please update to a version >=3.13" )
endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND) endif (NOT CMAKE_VERSION VERSION_LESS 3.13)
endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
endif (NOT SKIPPYTHON EQUAL 1)
install(TARGETS proxmark3 DESTINATION "bin") install(TARGETS proxmark3 DESTINATION "bin")
install(DIRECTORY cmdscripts lualibs luascripts pyscripts resources dictionaries DESTINATION "share/proxmark3") install(DIRECTORY cmdscripts lualibs luascripts pyscripts resources dictionaries DESTINATION "share/proxmark3")