Skip to content

Commit

Permalink
Make finding packages more flexible
Browse files Browse the repository at this point in the history
Calls to find_package now first try to find packages in CONFIG mode and
fallback on MODULE mode in case of lookup failure.
  • Loading branch information
robomics committed Aug 3, 2023
1 parent 3fd4005 commit 6b20f80
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ set(ENABLE_DEVELOPER_MODE
OFF
CACHE BOOL "Enable 'developer mode'")

if(NOT CMAKE_FIND_PACKAGE_PREFER_CONFIG)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
endif()

include(cmake/Versioning.cmake)

project(
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fetch_and_sum/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MIT

find_package(CLI11 CONFIG REQUIRED)
find_package(CLI11 REQUIRED)
find_package(Filesystem REQUIRED)

add_executable(hictk_fetch_and_sum_bench fetch_and_sum.cpp)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/hic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MIT

find_package(CLI11 CONFIG REQUIRED)
find_package(CLI11 REQUIRED)
find_package(Filesystem REQUIRED)

add_executable(hictk_hic_dump_bench dump.cpp)
Expand Down
10 changes: 5 additions & 5 deletions src/hictk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#
# SPDX-License-Identifier: MIT

find_package(Boost CONFIG REQUIRED COMPONENTS headers filesystem)
find_package(CLI11 CONFIG REQUIRED)
find_package(FMT CONFIG REQUIRED)
find_package(readerwriterqueue CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(Boost REQUIRED COMPONENTS headers filesystem)
find_package(CLI11 REQUIRED)
find_package(FMT REQUIRED)
find_package(readerwriterqueue REQUIRED)
find_package(spdlog REQUIRED)
find_package(Filesystem REQUIRED)
find_package(Threads REQUIRED)

Expand Down
2 changes: 1 addition & 1 deletion src/libhictk/balancing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MIT

find_package(phmap CONFIG REQUIRED)
find_package(phmap REQUIRED)

add_library(balancing INTERFACE)
add_library(hictk::balancing ALIAS balancing)
Expand Down
2 changes: 1 addition & 1 deletion src/libhictk/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MIT

find_package(FMT CONFIG REQUIRED)
find_package(FMT REQUIRED)

add_library(common INTERFACE)
add_library(hictk::common ALIAS common)
Expand Down
23 changes: 7 additions & 16 deletions src/libhictk/cooler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,15 @@
#
# SPDX-License-Identifier: MIT

find_package(FastFloat CONFIG REQUIRED)
find_package(FMT CONFIG REQUIRED)
find_package(
HDF5
CONFIG
REQUIRED
QUIET
COMPONENTS C)
find_package(HighFive CONFIG REQUIRED)
find_package(phmap CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(FastFloat REQUIRED)
find_package(FMT REQUIRED)
find_package(HDF5 REQUIRED QUIET COMPONENTS C)
find_package(HighFive REQUIRED)
find_package(phmap REQUIRED)
find_package(spdlog REQUIRED)

if(HICTK_WITH_EIGEN)
find_package(
Eigen3
CONFIG
REQUIRED
QUIET)
find_package(Eigen3 REQUIRED QUIET)
endif()

add_library(cooler INTERFACE)
Expand Down
2 changes: 1 addition & 1 deletion src/libhictk/file/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MIT

find_package(FMT CONFIG REQUIRED)
find_package(FMT REQUIRED)

add_library(file INTERFACE)
add_library(hictk::file ALIAS file)
Expand Down
2 changes: 1 addition & 1 deletion src/libhictk/formatting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MIT

find_package(FMT CONFIG REQUIRED)
find_package(FMT REQUIRED)

add_library(formatting INTERFACE)
add_library(hictk::format ALIAS formatting)
Expand Down
12 changes: 4 additions & 8 deletions src/libhictk/hic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
#
# SPDX-License-Identifier: MIT

find_package(FMT CONFIG REQUIRED)
find_package(libdeflate CONFIG REQUIRED)
find_package(phmap CONFIG REQUIRED)
find_package(FMT REQUIRED)
find_package(libdeflate REQUIRED)
find_package(phmap REQUIRED)

if(HICTK_WITH_EIGEN)
find_package(
Eigen3
CONFIG
QUIET
REQUIRED)
find_package(Eigen3 QUIET REQUIRED)
endif()

add_library(hic INTERFACE)
Expand Down
2 changes: 1 addition & 1 deletion src/libhictk/numeric/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MIT

find_package(FastFloat CONFIG REQUIRED)
find_package(FastFloat REQUIRED)

add_library(numeric INTERFACE)
add_library(hictk::numeric ALIAS numeric)
Expand Down
2 changes: 1 addition & 1 deletion src/libhictk/reference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MIT

find_package(phmap CONFIG REQUIRED)
find_package(phmap REQUIRED)

add_library(reference INTERFACE)
add_library(hictk::reference ALIAS reference)
Expand Down
2 changes: 1 addition & 1 deletion test/packaging/test_find_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

project(hictk_test_find_package)

find_package(hictk CONFIG REQUIRED)
find_package(hictk REQUIRED)

add_executable(hictk_test_find_package main.cpp)
target_link_libraries(hictk_test_find_package PRIVATE hictk::libhictk)
2 changes: 1 addition & 1 deletion test/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MIT

find_package(CLI11 CONFIG REQUIRED)
find_package(CLI11 REQUIRED)
find_package(Filesystem REQUIRED)

add_executable(hictk_test_compare_coolers)
Expand Down

0 comments on commit 6b20f80

Please sign in to comment.