build: Fix yara system lib detection and add support for fmt and curl (#241)
* find yara with pkgconfig * Use system fmt and curl. * Flip/unify system library conditional
This commit is contained in:
parent
db5402dc09
commit
e688d34587
@ -33,7 +33,8 @@ endif()
|
||||
if (NOT USE_SYSTEM_YARA)
|
||||
add_subdirectory(external/yara)
|
||||
else()
|
||||
find_package(yara REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(YARA REQUIRED IMPORTED_TARGET yara)
|
||||
endif()
|
||||
|
||||
# Add bundled dependencies
|
||||
|
@ -6,21 +6,31 @@ set(CMAKE_CXX_STANDARD 20)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/ImGui ${CMAKE_CURRENT_BINARY_DIR}/external/ImGui)
|
||||
|
||||
if(USE_SYSTEM_NLOHMANN_JSON)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
else()
|
||||
if(NOT USE_SYSTEM_NLOHMANN_JSON)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/nlohmann_json ${CMAKE_CURRENT_BINARY_DIR}/external/nlohmann_json)
|
||||
else()
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/nativefiledialog ${CMAKE_CURRENT_BINARY_DIR}/external/nativefiledialog EXCLUDE_FROM_ALL)
|
||||
if(NOT USE_SYSTEM_FMT)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/fmt ${CMAKE_CURRENT_BINARY_DIR}/external/fmt)
|
||||
else()
|
||||
find_package(fmt REQUIRED)
|
||||
endif()
|
||||
|
||||
set(XDGPP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../external/xdgpp")
|
||||
set(CMAKE_USE_MBEDTLS ON)
|
||||
set(BUILD_CURL_EXE OFF)
|
||||
set(FPHSA_NAME_MISMATCHED ON CACHE BOOL "")
|
||||
|
||||
if(NOT USE_SYSTEM_CURL)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/curl ${CMAKE_CURRENT_BINARY_DIR}/external/curl EXCLUDE_FROM_ALL)
|
||||
set_target_properties(libcurl PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
else()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(LIBCURL REQUIRED IMPORTED_TARGET libcurl)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
|
||||
@ -65,11 +75,32 @@ endif ()
|
||||
add_library(libimhex SHARED ${LIBIMHEX_SOURCES})
|
||||
|
||||
target_include_directories(libimhex PUBLIC include ${MBEDTLS_INCLUDE_DIR} ${XDGPP_INCLUDE_DIRS})
|
||||
|
||||
if (USE_SYSTEM_FMT)
|
||||
target_include_directories(libimhex PUBLIC include ${FMT_INCLUDE_DIRS})
|
||||
endif()
|
||||
if (USE_SYSTEM_CURL)
|
||||
target_include_directories(libimhex PUBLIC include ${CURL_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
target_link_directories(libimhex PUBLIC ${MBEDTLS_LIBRARY_DIR})
|
||||
|
||||
if (APPLE)
|
||||
find_library(FOUNDATION NAMES Foundation)
|
||||
target_link_libraries(libimhex PUBLIC imgui nlohmann_json mbedcrypto ${FOUNDATION} nfd fmt-header-only libcurl)
|
||||
else ()
|
||||
target_link_libraries(libimhex PUBLIC imgui nlohmann_json mbedcrypto nfd fmt-header-only libcurl)
|
||||
target_link_libraries(libimhex PUBLIC imgui nlohmann_json mbedcrypto nfd)
|
||||
|
||||
if (NOT USE_SYSTEM_FMT)
|
||||
target_link_libraries(libimhex PUBLIC fmt-header-only)
|
||||
else()
|
||||
target_link_libraries(libimhex PUBLIC fmt)
|
||||
endif()
|
||||
|
||||
if (NOT USE_SYSTEM_CURL)
|
||||
target_link_libraries(libimhex PUBLIC libcurl)
|
||||
else()
|
||||
target_link_libraries(libimhex PUBLIC curl)
|
||||
endif()
|
||||
|
||||
endif ()
|
Loading…
Reference in New Issue
Block a user