cmake: use system libwhereami if available

This commit is contained in:
Philippe Teuwen 2020-06-18 01:51:36 +02:00
commit cdf1bc3ce7
2 changed files with 32 additions and 7 deletions

View file

@ -123,6 +123,14 @@ else()
find_package (BZip2 REQUIRED) find_package (BZip2 REQUIRED)
endif(ANDROID) endif(ANDROID)
if (NOT SKIPWHEREAMISYSTEM EQUAL 1)
find_path(WHEREAMI_INCLUDE_DIRS whereami.h)
find_library(WHEREAMI_LIBRARIES whereami)
if (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
set(WHEREAMI_FOUND ON)
endif (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
endif (NOT SKIPWHEREAMISYSTEM EQUAL 1)
add_subdirectory(${PM3_ROOT}/client/deps deps) add_subdirectory(${PM3_ROOT}/client/deps deps)
set (TARGET_SOURCES set (TARGET_SOURCES
@ -327,13 +335,17 @@ if (NOT SKIPREADLINE EQUAL 1)
set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK}) set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK})
endif (READLINE_FOUND) endif (READLINE_FOUND)
endif(NOT SKIPREADLINE EQUAL 1) endif(NOT SKIPREADLINE EQUAL 1)
if (BZIP2_FOUND) if (BZIP2_FOUND)
set(ADDITIONAL_DIRS ${BZIP2_INCLUDE_DIRS} ${ADDITIONAL_DIRS}) set(ADDITIONAL_DIRS ${BZIP2_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
set(ADDITIONAL_LNK ${BZIP2_LIBRARIES} ${ADDITIONAL_LNK}) set(ADDITIONAL_LNK ${BZIP2_LIBRARIES} ${ADDITIONAL_LNK})
else (BZIP2_FOUND)
message(FATAL_ERROR "Bzip2 not found")
endif (BZIP2_FOUND) endif (BZIP2_FOUND)
if (WHEREAMI_FOUND)
set(ADDITIONAL_DIRS ${WHEREAMI_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
set(ADDITIONAL_LNK ${WHEREAMI_LIBRARIES} ${ADDITIONAL_LNK})
endif (WHEREAMI_FOUND)
message("===================================================================") message("===================================================================")
if (SKIPQT EQUAL 1) if (SKIPQT EQUAL 1)
message("GUI support: skipped") message("GUI support: skipped")
@ -376,6 +388,16 @@ else (SKIPREADLINE EQUAL 1)
message("Readline library: Readline not found, disabled") message("Readline library: Readline not found, disabled")
endif (READLINE_FOUND) endif (READLINE_FOUND)
endif(SKIPREADLINE EQUAL 1) endif(SKIPREADLINE EQUAL 1)
if (SKIPWHEREAMISYSTEM EQUAL 1)
message("Whereami library: local library forced")
else (SKIPWHEREAMISYSTEM EQUAL 1)
if (WHEREAMI_FOUND)
message("Whereami library: system library found")
else (WHEREAMI_FOUND)
message("Whereami library: system library not found, using local library")
endif (WHEREAMI_FOUND)
endif (SKIPWHEREAMISYSTEM EQUAL 1)
message("===================================================================") message("===================================================================")
add_executable(proxmark3 add_executable(proxmark3
@ -425,7 +447,11 @@ find_library(pm3rrg_rdv4_lua REQUIRED)
find_library(pm3rrg_rdv4_mbedtls REQUIRED) find_library(pm3rrg_rdv4_mbedtls REQUIRED)
find_library(pm3rrg_rdv4_reveng REQUIRED) find_library(pm3rrg_rdv4_reveng REQUIRED)
find_library(pm3rrg_rdv4_hardnested REQUIRED) find_library(pm3rrg_rdv4_hardnested REQUIRED)
find_library(pm3rrg_rdv4_whereami REQUIRED)
if (NOT WHEREAMI_FOUND)
find_library(pm3rrg_rdv4_whereami REQUIRED)
set(ADDITIONAL_LNK pm3rrg_rdv4_whereami ${ADDITIONAL_LNK})
endif (NOT WHEREAMI_FOUND)
target_link_libraries(proxmark3 PRIVATE target_link_libraries(proxmark3 PRIVATE
m m
@ -437,7 +463,6 @@ target_link_libraries(proxmark3 PRIVATE
pm3rrg_rdv4_amiibo pm3rrg_rdv4_amiibo
pm3rrg_rdv4_reveng pm3rrg_rdv4_reveng
pm3rrg_rdv4_hardnested pm3rrg_rdv4_hardnested
pm3rrg_rdv4_whereami
${ADDITIONAL_LNK}) ${ADDITIONAL_LNK})
if (NOT SKIPPTHREAD EQUAL 1) if (NOT SKIPPTHREAD EQUAL 1)

View file

@ -58,9 +58,9 @@ At the moment both are maintained because they don't perfectly overlap yet.
| dep reveng | in_deps | in_deps | | | dep reveng | in_deps | in_deps | |
| `SKIPREVENGTEST` | yes(1) | **no**(2) | (1) e.g. if cross-compilation (2) tests aren't compiled/ran with cmake | | `SKIPREVENGTEST` | yes(1) | **no**(2) | (1) e.g. if cross-compilation (2) tests aren't compiled/ran with cmake |
| dep tinycbor | in_deps | in_deps | | | dep tinycbor | in_deps | in_deps | |
| dep whereami | sys / in_deps | **in_deps only** | | | dep whereami | sys / in_deps | sys / in_deps | |
| whereami detection | **search /usr/include/whereami.h** | **none** | no .pc available | | whereami detection | **search /usr/include/whereami.h** | find* | no .pc available |
| `SKIPWHEREAMISYSTEM` | yes | **no** | | | `SKIPWHEREAMISYSTEM` | yes | yes | |
| version | mkversion | mkversion | | | version | mkversion | mkversion | |
| install | yes (1) | **no** | (1) supports `DESTDIR`, `PREFIX`, `UDEV_PREFIX`. Installs resources as well, `INSTALL*RELPATH` | | install | yes (1) | **no** | (1) supports `DESTDIR`, `PREFIX`, `UDEV_PREFIX`. Installs resources as well, `INSTALL*RELPATH` |
| deb | no | partial? | | | deb | no | partial? | |