Skip to content

Commit

Permalink
refactor(build): use find_package when possible
Browse files Browse the repository at this point in the history
Signed-off-by: Gianmatteo Palmieri <[email protected]>
  • Loading branch information
mrgian authored and poiana committed Feb 23, 2024
1 parent 97806a9 commit 1705fc2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
9 changes: 2 additions & 7 deletions cmake/modules/cpp-httplib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ option(USE_BUNDLED_CPPHTTPLIB "Enable building of the bundled cpp-httplib" ${USE
if(CPPHTTPLIB_INCLUDE)
# we already have cpp-httplib
elseif(NOT USE_BUNDLED_CPPHTTPLIB)
find_path(CPPHTTPLIB_INCLUDE NAMES httplib.h)

if(CPPHTTPLIB_INCLUDE)
message(STATUS "Found cpp-httplib: include: ${CPPHTTPLIB_INCLUDE}")
else()
message(FATAL_ERROR "Couldn't find system cpp-httplib")
endif()
find_package(httplib CONFIG REQUIRED)
get_target_property(CPPHTTPLIB_INCLUDE httplib::httplib INTERFACE_INCLUDE_DIRECTORIES)
else()
set(CPPHTTPLIB_SRC "${PROJECT_BINARY_DIR}/cpp-httplib-prefix/src/cpp-httplib")
set(CPPHTTPLIB_INCLUDE "${CPPHTTPLIB_SRC}")
Expand Down
9 changes: 2 additions & 7 deletions cmake/modules/cxxopts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ option(USE_BUNDLED_CXXOPTS "Enable building of the bundled cxxopts" ${USE_BUNDLE
if(CXXOPTS_INCLUDE_DIR)
# we already have cxxopts
elseif(NOT USE_BUNDLED_CXXOPTS)
find_path(CXXOPTS_INCLUDE_DIR NAMES cxxopts.hpp)

if(CXXOPTS_INCLUDE_DIR)
message(STATUS "Found cxxopts: include: ${CXXOPTS_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Couldn't find system cxxopts")
endif()
find_package(cxxopts CONFIG REQUIRED)
get_target_property(CXXOPTS_INCLUDE_DIR cxxopts::cxxopts INTERFACE_INCLUDE_DIRECTORIES)
else()
set(CXXOPTS_SRC "${PROJECT_BINARY_DIR}/cxxopts-prefix/src/cxxopts/")
set(CXXOPTS_INCLUDE_DIR "${CXXOPTS_SRC}/include")
Expand Down
9 changes: 2 additions & 7 deletions cmake/modules/njson.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ option(USE_BUNDLED_NLOHMANN_JSON "Enable building of the bundled nlohmann-json"
if(nlohmann_json_INCLUDE_DIRS)
# we already have nlohmnann-json
elseif(NOT USE_BUNDLED_NLOHMANN_JSON)
find_path(nlohmann_json_INCLUDE_DIRS NAMES nlohmann)

if(nlohmann_json_INCLUDE_DIRS)
message(STATUS "Found nlohmann-json: include: ${nlohmann_json_INCLUDE_DIRS}")
else()
message(FATAL_ERROR "Couldn't find system nlohmann-json")
endif()
find_package(nlohmann_json CONFIG REQUIRED)
get_target_property(nlohmann_json_INCLUDE_DIRS nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
else()
set(nlohmann_json_INCLUDE_DIRS "${PROJECT_BINARY_DIR}/njson-prefix/include")

Expand Down

0 comments on commit 1705fc2

Please sign in to comment.