Skip to content

Commit a7d4ed7

Browse files
committed
Cleanup CMake find modules
1 parent 2d298e6 commit a7d4ed7

24 files changed

+69
-421
lines changed

cmake/FindAmplifier.cmake

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,25 @@
66
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
77

88
if(NOT TARGET Amplifier::amplifier)
9-
# compatibility with older CMake versions
10-
if(AMPLIFIER_ROOT AND NOT Amplifier_ROOT)
11-
set(Amplifier_ROOT
12-
${AMPLIFIER_ROOT}
13-
CACHE PATH "Amplifier base directory"
14-
)
15-
unset(AMPLIFIER_ROOT CACHE)
16-
endif()
179

1810
find_package(PkgConfig QUIET)
1911
pkg_check_modules(PC_AMPLIFIER QUIET amplifier)
2012

2113
find_path(
2214
Amplifier_INCLUDE_DIR ittnotify.h
23-
HINTS ${Amplifier_ROOT} ENV AMPLIFIER_ROOT ${PC_Amplifier_INCLUDEDIR}
15+
HINTS ${AMPLIFIER_ROOT} ENV AMPLIFIER_ROOT ${PC_Amplifier_INCLUDEDIR}
2416
${PC_Amplifier_INCLUDE_DIRS}
2517
PATH_SUFFIXES include
2618
)
2719

2820
find_library(
2921
Amplifier_LIBRARY
3022
NAMES ittnotify libittnotify
31-
HINTS ${Amplifier_ROOT} ENV AMPLIFIER_ROOT ${PC_Amplifier_LIBDIR}
23+
HINTS ${AMPLIFIER_ROOT} ENV AMPLIFIER_ROOT ${PC_Amplifier_LIBDIR}
3224
${PC_Amplifier_LIBRARY_DIRS}
3325
PATH_SUFFIXES lib lib64
3426
)
3527

36-
# Set Amplifier_ROOT in case the other hints are used
37-
if(Amplifier_ROOT)
38-
# The call to file is for compatibility for windows paths
39-
file(TO_CMAKE_PATH ${Amplifier_ROOT} Amplifier_ROOT)
40-
elseif(DEFINED ENV{AMPLIFIER_ROOT})
41-
file(TO_CMAKE_PATH $ENV{AMPLIFIER_ROOT} Amplifier_ROOT)
42-
else()
43-
file(TO_CMAKE_PATH "${Amplifier_INCLUDE_DIR}" Amplifier_INCLUDE_DIR)
44-
string(REPLACE "/include" "" Amplifier_ROOT "${Amplifier_INCLUDE_DIR}")
45-
endif()
46-
4728
set(Amplifier_LIBRARIES ${Amplifier_LIBRARY})
4829
set(Amplifier_INCLUDE_DIRS ${Amplifier_INCLUDE_DIR})
4930

@@ -70,4 +51,8 @@ if(NOT TARGET Amplifier::amplifier)
7051
Amplifier::amplifier SYSTEM INTERFACE ${Amplifier_INCLUDE_DIR}
7152
)
7253
target_link_libraries(Amplifier::amplifier INTERFACE ${Amplifier_LIBRARIES})
54+
mark_as_advanced(Amplifier_LIBRARIES, Amplifier_INCLUDE_DIRS)
55+
56+
# Set Amplifier_ROOT
57+
get_filename_component(Amplifier_ROOT ${Amplifier_INCLUDE_DIR} DIRECTORY)
7358
endif()

cmake/FindAsio.cmake

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,13 @@
88
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
99

1010
if(NOT TARGET Asio::asio)
11-
# compatibility with older CMake versions
12-
if(ASIO_ROOT AND NOT Asio_ROOT)
13-
set(Asio_ROOT
14-
${ASIO_ROOT}
15-
CACHE PATH "Asio base directory"
16-
)
17-
unset(ASIO_ROOT CACHE)
18-
endif()
1911

2012
find_path(
2113
Asio_INCLUDE_DIR asio.hpp
22-
HINTS "${Asio_ROOT}" ENV ASIO_ROOT "${HPX_ASIO_ROOT}"
14+
HINTS "${ASIO_ROOT}" ENV ASIO_ROOT "${HPX_ASIO_ROOT}"
2315
PATH_SUFFIXES include
2416
)
2517

26-
if(NOT Asio_INCLUDE_DIR)
27-
hpx_error(
28-
"Could not find Asio. Set Asio_ROOT as a CMake or environment variable to point to the Asio root install directory. Alternatively, set HPX_WITH_FETCH_ASIO=ON to fetch Asio using CMake's FetchContent (when using this option Asio will be installed together with HPX, be careful about conflicts with separately installed versions of Asio)."
29-
)
30-
endif()
31-
32-
# Set Asio_ROOT in case the other hints are used
33-
if(Asio_ROOT)
34-
# The call to file is for compatibility with windows paths
35-
file(TO_CMAKE_PATH ${Asio_ROOT} Asio_ROOT)
36-
elseif(DEFINED ENV{ASIO_ROOT})
37-
file(TO_CMAKE_PATH $ENV{ASIO_ROOT} Asio_ROOT)
38-
else()
39-
file(TO_CMAKE_PATH "${Asio_INCLUDE_DIR}" Asio_INCLUDE_DIR)
40-
string(REPLACE "/include" "" Asio_ROOT "${Asio_INCLUDE_DIR}")
41-
endif()
42-
4318
if(Asio_INCLUDE_DIR AND EXISTS "${Asio_INCLUDE_DIR}/asio/version.hpp")
4419
# Matches a line of the form:
4520
#
@@ -64,11 +39,13 @@ if(NOT TARGET Asio::asio)
6439
Asio
6540
REQUIRED_VARS Asio_INCLUDE_DIR
6641
VERSION_VAR Asio_VERSION_STRING
67-
FOUND_VAR Asio_FOUND
6842
)
6943

7044
add_library(Asio::asio INTERFACE IMPORTED)
7145
target_include_directories(Asio::asio SYSTEM INTERFACE ${Asio_INCLUDE_DIR})
7246

73-
mark_as_advanced(Asio_ROOT Asio_INCLUDE_DIR Asio_VERSION_STRING)
47+
mark_as_advanced(Asio_INCLUDE_DIR Asio_VERSION_STRING)
48+
49+
# Set Asio_ROOT
50+
get_filename_component(Asio_ROOT ${Asio_INCLUDE_DIR} DIRECTORY)
7451
endif()

cmake/FindBreathe.cmake

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,16 @@
44
# Distributed under the Boost Software License, Version 1.0. (See accompanying
55
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
66

7-
# compatibility with older CMake versions
8-
if(BREATHE_APIDOC_ROOT AND NOT Breathe_APIDOC_ROOT)
9-
set(Breathe_APIDOC_ROOT
10-
${BREATHE_APIDOC_ROOT}
11-
CACHE PATH "Breathe base directory"
12-
)
13-
unset(BREATHE_ROOT CACHE)
14-
endif()
15-
167
find_program(
178
Breathe_APIDOC_EXECUTABLE
189
NAMES breathe-apidoc
19-
PATHS ${Breathe_APIDOC_ROOT} ENV Breathe_APIDOC_ROOT
10+
PATHS ${BREATHE_APIDOC_ROOT} ENV BREATHE_APIDOC_ROOT
2011
DOC "Path to breathe-apidoc executable"
2112
)
2213

23-
if(Breathe_APIDOC_ROOT)
24-
file(TO_CMAKE_PATH ${Breathe_APIDOC_ROOT} Breathe_APIDOC_ROOT)
25-
endif()
14+
include(FindPackageHandleStandardArgs)
15+
find_package_handle_standard_args(
16+
Breathe DEFAULT_MESSAGE Breathe_APIDOC_EXECUTABLE
17+
)
2618

27-
if(Breathe_APIDOC_EXECUTABLE)
28-
include(FindPackageHandleStandardArgs)
29-
find_package_handle_standard_args(
30-
Breathe DEFAULT_MESSAGE Breathe_APIDOC_EXECUTABLE
31-
)
32-
endif()
19+
mark_as_advanced(Breathe_APIDOC_EXECUTABLE)

cmake/FindHwloc.cmake

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,13 @@
88
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
99

1010
if(NOT TARGET Hwloc::hwloc)
11-
# compatibility with older CMake versions
12-
if(HWLOC_ROOT AND NOT Hwloc_ROOT)
13-
set(Hwloc_ROOT
14-
${HWLOC_ROOT}
15-
CACHE PATH "Hwloc base directory"
16-
)
17-
unset(HWLOC_ROOT CACHE)
18-
endif()
1911

2012
find_package(PkgConfig QUIET)
2113
pkg_check_modules(PC_HWLOC QUIET hwloc)
2214

2315
find_path(
2416
Hwloc_INCLUDE_DIR hwloc.h
25-
HINTS ${Hwloc_ROOT}
17+
HINTS ${HWLOC_ROOT}
2618
ENV
2719
HWLOC_ROOT
2820
${HPX_HWLOC_ROOT}
@@ -36,7 +28,7 @@ if(NOT TARGET Hwloc::hwloc)
3628
find_library(
3729
Hwloc_LIBRARY
3830
NAMES libhwloc.so libhwloc.lib hwloc
39-
HINTS ${Hwloc_ROOT}
31+
HINTS ${HWLOC_ROOT}
4032
ENV
4133
HWLOC_ROOT
4234
${HPX_Hwloc_ROOT}
@@ -46,17 +38,8 @@ if(NOT TARGET Hwloc::hwloc)
4638
${PC_Hwloc_LIBRARY_DIRS}
4739
PATH_SUFFIXES lib lib64
4840
)
49-
50-
# Set Hwloc_ROOT in case the other hints are used
51-
if(Hwloc_ROOT)
52-
# The call to file is for compatibility with windows paths
53-
file(TO_CMAKE_PATH ${Hwloc_ROOT} Hwloc_ROOT)
54-
elseif(DEFINED ENV{HWLOC_ROOT})
55-
file(TO_CMAKE_PATH $ENV{HWLOC_ROOT} Hwloc_ROOT)
56-
else()
57-
file(TO_CMAKE_PATH "${Hwloc_INCLUDE_DIR}" Hwloc_INCLUDE_DIR)
58-
string(REPLACE "/include" "" Hwloc_ROOT "${Hwloc_INCLUDE_DIR}")
59-
endif()
41+
# Set Hwloc_ROOT
42+
get_filename_component(Hwloc_ROOT ${Hwloc_INCLUDE_DIR} DIRECTORY)
6043

6144
set(Hwloc_LIBRARIES ${Hwloc_LIBRARY})
6245
set(Hwloc_INCLUDE_DIRS ${Hwloc_INCLUDE_DIR})
@@ -80,7 +63,6 @@ if(NOT TARGET Hwloc::hwloc)
8063
add_library(Hwloc::hwloc INTERFACE IMPORTED)
8164
target_include_directories(Hwloc::hwloc SYSTEM INTERFACE ${Hwloc_INCLUDE_DIR})
8265
target_link_libraries(Hwloc::hwloc INTERFACE ${Hwloc_LIBRARIES})
83-
mark_as_advanced(HWLOC_ROOT HWLOC_LIBRARY HWLOC_INCLUDE_DIR)
8466

85-
mark_as_advanced(Hwloc_ROOT Hwloc_LIBRARY Hwloc_INCLUDE_DIR)
67+
mark_as_advanced(Hwloc_LIBRARY Hwloc_INCLUDE_DIR)
8668
endif()

cmake/FindJemalloc.cmake

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,12 @@
77
# Distributed under the Boost Software License, Version 1.0. (See accompanying
88
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
99

10-
# compatibility with older CMake versions
11-
if(JEMALLOC_ROOT AND NOT Jemalloc_ROOT)
12-
set(Jemalloc_ROOT
13-
${JEMALLOC_ROOT}
14-
CACHE PATH "Jemalloc base directory"
15-
)
16-
unset(JEMALLOC_ROOT CACHE)
17-
endif()
18-
1910
find_package(PkgConfig QUIET)
2011
pkg_check_modules(PC_JEMALLOC QUIET jemalloc)
2112

2213
find_path(
2314
Jemalloc_INCLUDE_DIR jemalloc/jemalloc.h
24-
HINTS ${Jemalloc_ROOT}
15+
HINTS ${JEMALLOC_ROOT}
2516
ENV
2617
JEMALLOC_ROOT
2718
${HPX_JEMALLOC_ROOT}
@@ -37,7 +28,7 @@ if(MSVC)
3728
# missing posix headers
3829
find_path(
3930
Jemalloc_ADDITIONAL_INCLUDE_DIR msvc_compat/strings.h
40-
HINTS ${Jemalloc_ROOT}
31+
HINTS ${JEMALLOC_ROOT}
4132
ENV
4233
JEMALLOC_ROOT
4334
${HPX_JEMALLOC_ROOT}
@@ -49,21 +40,10 @@ if(MSVC)
4940
)
5041
endif()
5142

52-
# Set Jemalloc_ROOT in case the other hints are used
53-
if(Jemalloc_ROOT)
54-
# The call to file is for compatibility with windows paths
55-
file(TO_CMAKE_PATH ${Jemalloc_ROOT} Jemalloc_ROOT)
56-
elseif(DEFINED ENV{JEMALLOC_ROOT})
57-
file(TO_CMAKE_PATH $ENV{JEMALLOC_ROOT} Jemalloc_ROOT)
58-
else()
59-
file(TO_CMAKE_PATH "${Jemalloc_INCLUDE_DIR}" Jemalloc_INCLUDE_DIR)
60-
string(REPLACE "/include" "" Jemalloc_ROOT "${Jemalloc_INCLUDE_DIR}")
61-
endif()
62-
6343
find_library(
6444
Jemalloc_LIBRARY
6545
NAMES jemalloc libjemalloc
66-
HINTS ${Jemalloc_ROOT}
46+
HINTS ${JEMALLOC_ROOT}
6747
ENV
6848
JEMALLOC_ROOT
6949
${HPX_JEMALLOC_ROOT}
@@ -74,13 +54,6 @@ find_library(
7454
PATH_SUFFIXES lib lib64
7555
)
7656

77-
# Set Jemalloc_ROOT in case the other hints are used
78-
if(NOT Jemalloc_ROOT AND DEFINED ENV{JEMALLOC_ROOT})
79-
set(Jemalloc_ROOT $ENV{JEMALLOC_ROOT})
80-
elseif(NOT Jemalloc_ROOT)
81-
string(REPLACE "/include" "" Jemalloc_ROOT "${Jemalloc_INCLUDE_DIR}")
82-
endif()
83-
8457
set(Jemalloc_LIBRARIES ${Jemalloc_LIBRARY})
8558
set(Jemalloc_INCLUDE_DIRS ${Jemalloc_INCLUDE_DIR})
8659

cmake/FindLibSigSegv.cmake

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,14 @@
44
# Distributed under the Boost Software License, Version 1.0. (See accompanying
55
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
66

7-
# compatibility with older CMake versions
8-
if(LIBSIGSEGV_ROOT AND NOT Libsigsegv_ROOT)
9-
set(Libsigsegv_ROOT
10-
${LIBSIGSEGV_ROOT}
11-
CACHE PATH "Libsigsegv base directory"
12-
)
13-
unset(LIBSIGSEGV_ROOT CACHE)
14-
endif()
15-
167
find_package(PkgConfig QUIET)
178
pkg_check_modules(PC_LIBSIGSEGV QUIET libsigsegv)
189

1910
find_path(
2011
Libsigsegv_INCLUDE_DIR sigsegv.h
21-
HINTS ${Libsigsegv_ROOT}
12+
HINTS ${LIBSIGSEGV_ROOT}
2213
ENV
23-
Libsigsegv_ROOT
14+
LIBSIGSEGV_ROOT
2415
${PC_Libsigsegv_MINIMAL_INCLUDEDIR}
2516
${PC_Libsigsegv_MINIMAL_INCLUDE_DIRS}
2617
${PC_Libsigsegv_INCLUDEDIR}
@@ -31,27 +22,16 @@ find_path(
3122
find_library(
3223
Libsigsegv_LIBRARY
3324
NAMES sigsegv libsigsegv
34-
HINTS ${Libsigsegv_ROOT}
25+
HINTS ${LIBSIGSEGV_ROOT}
3526
ENV
36-
Libsigsegv_ROOT
27+
LIBSIGSEGV_ROOT
3728
${PC_Libsigsegv_MINIMAL_LIBDIR}
3829
${PC_Libsigsegv_MINIMAL_LIBRARY_DIRS}
3930
${PC_Libsigsegv_LIBDIR}
4031
${PC_Libsigsegv_LIBRARY_DIRS}
4132
PATH_SUFFIXES lib lib64
4233
)
4334

44-
# Set Libsigsegv_ROOT in case the other hints are used
45-
if(Libsigsegv_ROOT)
46-
# The call to file is for compatibility with windows paths
47-
file(TO_CMAKE_PATH ${Libsigsegv_ROOT} Libsigsegv_ROOT)
48-
elseif(DEFINED ENV{LIBSIGSEGV_ROOT})
49-
file(TO_CMAKE_PATH $ENV{LIBSIGSEGV_ROOT} Libsigsegv_ROOT)
50-
else()
51-
file(TO_CMAKE_PATH "${Libsigsegv_INCLUDE_DIR}" Libsigsegv_INCLUDE_DIR)
52-
string(REPLACE "/include" "" Libsigsegv_ROOT "${Libsigsegv_INCLUDE_DIR}")
53-
endif()
54-
5535
set(Libsigsegv_LIBRARIES ${Libsigsegv_LIBRARY})
5636
set(Libsigsegv_INCLUDE_DIRS ${Libsigsegv_INCLUDE_DIR})
5737

cmake/FindLibfabric.cmake

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,25 @@
44
# Distributed under the Boost Software License, Version 1.0. (See accompanying
55
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
66

7-
# compatibility with older CMake versions
8-
if(LIBFABRIC_ROOT AND NOT Libfabric_ROOT)
9-
set(Libfabric_ROOT
10-
${LIBFABRIC_ROOT}
11-
CACHE PATH "Libfabric base directory"
12-
)
13-
unset(LIBFABRIC_ROOT CACHE)
14-
endif()
15-
167
find_package(PkgConfig QUIET)
178
pkg_check_modules(PC_LIBFABRIC QUIET libfabric)
189

1910
find_path(
2011
Libfabric_INCLUDE_DIR rdma/fabric.h
21-
HINTS ${Libfabric_ROOT} ENV LIBFABRIC_ROOT ${Libfabric_DIR} ENV LIBFABRIC_DIR
12+
HINTS ${LIBFABRIC_ROOT} ENV LIBFABRIC_ROOT ${Libfabric_DIR} ENV LIBFABRIC_DIR
2213
PATH_SUFFIXES include
2314
)
2415

2516
find_library(
2617
Libfabric_LIBRARY
2718
NAMES fabric
28-
HINTS ${Libfabric_ROOT} ENV LIBFABRIC_ROOT
19+
HINTS ${LIBFABRIC_ROOT} ENV LIBFABRIC_ROOT
2920
PATH_SUFFIXES lib lib64
3021
)
3122

32-
# Set Libfabric_ROOT in case the other hints are used
33-
if(Libfabric_ROOT)
34-
# The call to file is for compatibility with windows paths
35-
file(TO_CMAKE_PATH ${Libfabric_ROOT} Libfabric_ROOT)
36-
elseif(DEFINED ENV{LIBFABRIC_ROOT})
37-
file(TO_CMAKE_PATH $ENV{LIBFABRIC_ROOT} Libfabric_ROOT)
38-
else()
39-
file(TO_CMAKE_PATH "${Libfabric_INCLUDE_DIR}" Libfabric_INCLUDE_DIR)
40-
string(REPLACE "/include" "" Libfabric_ROOT "${Libfabric_INCLUDE_DIR}")
41-
endif()
42-
43-
if(NOT Libfabric_INCLUDE_DIR OR NOT Libfabric_LIBRARY)
44-
hpx_error("Could not find Libfabric_INCLUDE_DIR or Libfabric_LIBRARY please \
45-
set the Libfabric_ROOT environment variable"
46-
)
47-
endif()
48-
4923
include(FindPackageHandleStandardArgs)
5024
find_package_handle_standard_args(
5125
Libfabric DEFAULT_MSG Libfabric_LIBRARY Libfabric_INCLUDE_DIR
5226
)
5327

54-
mark_as_advanced(Libfabric_ROOT)
28+
mark_as_advanced(Libfabric_ROOT Libfabric_LIBRARY Libfabric_INCLUDE_DIR)

0 commit comments

Comments
 (0)