Skip to content

Commit 1705fc2

Browse files
mrgianpoiana
authored andcommitted
refactor(build): use find_package when possible
Signed-off-by: Gianmatteo Palmieri <[email protected]>
1 parent 97806a9 commit 1705fc2

File tree

3 files changed

+6
-21
lines changed

3 files changed

+6
-21
lines changed

cmake/modules/cpp-httplib.cmake

+2-7
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@ option(USE_BUNDLED_CPPHTTPLIB "Enable building of the bundled cpp-httplib" ${USE
2121
if(CPPHTTPLIB_INCLUDE)
2222
# we already have cpp-httplib
2323
elseif(NOT USE_BUNDLED_CPPHTTPLIB)
24-
find_path(CPPHTTPLIB_INCLUDE NAMES httplib.h)
25-
26-
if(CPPHTTPLIB_INCLUDE)
27-
message(STATUS "Found cpp-httplib: include: ${CPPHTTPLIB_INCLUDE}")
28-
else()
29-
message(FATAL_ERROR "Couldn't find system cpp-httplib")
30-
endif()
24+
find_package(httplib CONFIG REQUIRED)
25+
get_target_property(CPPHTTPLIB_INCLUDE httplib::httplib INTERFACE_INCLUDE_DIRECTORIES)
3126
else()
3227
set(CPPHTTPLIB_SRC "${PROJECT_BINARY_DIR}/cpp-httplib-prefix/src/cpp-httplib")
3328
set(CPPHTTPLIB_INCLUDE "${CPPHTTPLIB_SRC}")

cmake/modules/cxxopts.cmake

+2-7
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@ option(USE_BUNDLED_CXXOPTS "Enable building of the bundled cxxopts" ${USE_BUNDLE
2121
if(CXXOPTS_INCLUDE_DIR)
2222
# we already have cxxopts
2323
elseif(NOT USE_BUNDLED_CXXOPTS)
24-
find_path(CXXOPTS_INCLUDE_DIR NAMES cxxopts.hpp)
25-
26-
if(CXXOPTS_INCLUDE_DIR)
27-
message(STATUS "Found cxxopts: include: ${CXXOPTS_INCLUDE_DIR}")
28-
else()
29-
message(FATAL_ERROR "Couldn't find system cxxopts")
30-
endif()
24+
find_package(cxxopts CONFIG REQUIRED)
25+
get_target_property(CXXOPTS_INCLUDE_DIR cxxopts::cxxopts INTERFACE_INCLUDE_DIRECTORIES)
3126
else()
3227
set(CXXOPTS_SRC "${PROJECT_BINARY_DIR}/cxxopts-prefix/src/cxxopts/")
3328
set(CXXOPTS_INCLUDE_DIR "${CXXOPTS_SRC}/include")

cmake/modules/njson.cmake

+2-7
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@ option(USE_BUNDLED_NLOHMANN_JSON "Enable building of the bundled nlohmann-json"
2121
if(nlohmann_json_INCLUDE_DIRS)
2222
# we already have nlohmnann-json
2323
elseif(NOT USE_BUNDLED_NLOHMANN_JSON)
24-
find_path(nlohmann_json_INCLUDE_DIRS NAMES nlohmann)
25-
26-
if(nlohmann_json_INCLUDE_DIRS)
27-
message(STATUS "Found nlohmann-json: include: ${nlohmann_json_INCLUDE_DIRS}")
28-
else()
29-
message(FATAL_ERROR "Couldn't find system nlohmann-json")
30-
endif()
24+
find_package(nlohmann_json CONFIG REQUIRED)
25+
get_target_property(nlohmann_json_INCLUDE_DIRS nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
3126
else()
3227
set(nlohmann_json_INCLUDE_DIRS "${PROJECT_BINARY_DIR}/njson-prefix/include")
3328

0 commit comments

Comments
 (0)