From cdf1bc3ce78380af647acac4696a7520c3c90ca5 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 18 Jun 2020 01:51:36 +0200 Subject: [PATCH] cmake: use system libwhereami if available --- client/CMakeLists.txt | 33 ++++++++++++++++++++++--- doc/md/Development/Makefile-vs-CMake.md | 6 ++--- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 5cfe0e4df..21fa6f83d 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -123,6 +123,14 @@ else() find_package (BZip2 REQUIRED) 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) set (TARGET_SOURCES @@ -327,13 +335,17 @@ if (NOT SKIPREADLINE EQUAL 1) set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK}) endif (READLINE_FOUND) endif(NOT SKIPREADLINE EQUAL 1) + if (BZIP2_FOUND) set(ADDITIONAL_DIRS ${BZIP2_INCLUDE_DIRS} ${ADDITIONAL_DIRS}) set(ADDITIONAL_LNK ${BZIP2_LIBRARIES} ${ADDITIONAL_LNK}) -else (BZIP2_FOUND) - message(FATAL_ERROR "Bzip2 not 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("===================================================================") if (SKIPQT EQUAL 1) message("GUI support: skipped") @@ -376,6 +388,16 @@ else (SKIPREADLINE EQUAL 1) message("Readline library: Readline not found, disabled") endif (READLINE_FOUND) 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("===================================================================") add_executable(proxmark3 @@ -425,7 +447,11 @@ find_library(pm3rrg_rdv4_lua REQUIRED) find_library(pm3rrg_rdv4_mbedtls REQUIRED) find_library(pm3rrg_rdv4_reveng 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 m @@ -437,7 +463,6 @@ target_link_libraries(proxmark3 PRIVATE pm3rrg_rdv4_amiibo pm3rrg_rdv4_reveng pm3rrg_rdv4_hardnested - pm3rrg_rdv4_whereami ${ADDITIONAL_LNK}) if (NOT SKIPPTHREAD EQUAL 1) diff --git a/doc/md/Development/Makefile-vs-CMake.md b/doc/md/Development/Makefile-vs-CMake.md index 6f17eca87..2cdc969bd 100644 --- a/doc/md/Development/Makefile-vs-CMake.md +++ b/doc/md/Development/Makefile-vs-CMake.md @@ -58,9 +58,9 @@ At the moment both are maintained because they don't perfectly overlap yet. | 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 | | dep tinycbor | in_deps | in_deps | | -| dep whereami | sys / in_deps | **in_deps only** | | -| whereami detection | **search /usr/include/whereami.h** | **none** | no .pc available | -| `SKIPWHEREAMISYSTEM` | yes | **no** | | +| dep whereami | sys / in_deps | sys / in_deps | | +| whereami detection | **search /usr/include/whereami.h** | find* | no .pc available | +| `SKIPWHEREAMISYSTEM` | yes | yes | | | version | mkversion | mkversion | | | install | yes (1) | **no** | (1) supports `DESTDIR`, `PREFIX`, `UDEV_PREFIX`. Installs resources as well, `INSTALL*RELPATH` | | deb | no | partial? | |