Skip to content

Commit ab5170c

Browse files
committed
Fix find modules with built-in checks
Some libraries are built in the default (C) library. This adjusts checks for Intl, Iconv, Crypt, ACL a bit further.
1 parent 5808d5a commit ab5170c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+388
-138
lines changed

cmake/cmake/modules/FindACL.cmake

Lines changed: 68 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,34 @@ This module provides the following imported targets:
1515
1616
## Result variables
1717
18+
This module defines the following variables:
19+
1820
* `ACL_FOUND` - Boolean indicating whether (the requested version of) package
1921
was found.
2022
* `ACL_VERSION` - The version of package found.
2123
2224
## Cache variables
2325
24-
* `ACL_IS_BUILT_IN` - Whether ACL is a part of the C library (BSD-based
25-
systems).
26+
The following cache variables may also be set:
27+
28+
* `ACL_IS_BUILT_IN` - Whether ACL is a part of the C library (for example, on
29+
BSD-based systems).
2630
* `ACL_INCLUDE_DIR` - Directory containing package library headers.
2731
* `ACL_LIBRARY` - The path to the package library.
2832
2933
## Hints
3034
31-
* Set `ACL_USE_USER_GROUP` to `TRUE` before calling `find_package(ACL)` to also
32-
check if the ACL library supports `ACL_USER` and `ACL_GROUP`. For example,
33-
macOS doesn't have support for user/group.
35+
This module accepts the following variables before calling `find_package(ACL)`:
36+
37+
* `ACL_USE_USER_GROUP` - When set to boolean true a check is performed whether
38+
the ACL library supports `ACL_USER` and `ACL_GROUP`. For example, macOS
39+
doesn't have support for user/group.
3440
3541
## Examples
3642
37-
Basic usage:
43+
### Example: Basic usage
44+
45+
Finding ACL library and linking its imported target to the project target:
3846
3947
```cmake
4048
# CMakeLists.txt
@@ -63,15 +71,17 @@ set_package_properties(
6371
function(_acl_check result)
6472
cmake_push_check_state(RESET)
6573
set(CMAKE_REQUIRED_QUIET TRUE)
74+
6675
if(ACL_INCLUDE_DIR)
6776
set(CMAKE_REQUIRED_INCLUDES ${ACL_INCLUDE_DIR})
6877
endif()
78+
6979
if(ACL_LIBRARY)
7080
set(CMAKE_REQUIRED_LIBRARIES ${ACL_LIBRARY})
7181
endif()
7282

7383
if(NOT ACL_USE_USER_GROUP)
74-
check_symbol_exists(acl_free sys/acl.h _acl_successful)
84+
check_symbol_exists(acl_free sys/acl.h ${result})
7585
else()
7686
check_source_compiles(C [[
7787
#include <sys/acl.h>
@@ -88,71 +98,73 @@ function(_acl_check result)
8898
acl_free(acl);
8999
return 0;
90100
}
91-
]] _acl_successful)
101+
]] ${result})
92102
endif()
93103
cmake_pop_check_state()
94-
95-
if(_acl_successful)
96-
set(${result} TRUE PARENT_SCOPE)
97-
else()
98-
set(${result} FALSE PARENT_SCOPE)
99-
endif()
100-
101-
unset(_acl_successful CACHE)
102104
endfunction()
103105

104106
################################################################################
105-
# Disable built-in ACL when overriding search paths in FindACL.
107+
# Find package.
106108
################################################################################
107-
if(CMAKE_PREFIX_PATH OR ACL_ROOT)
109+
110+
# Disable searching for built-in ACL when overriding search paths.
111+
if(
112+
NOT DEFINED ACL_IS_BUILT_IN
113+
AND NOT DEFINED ACL_INCLUDE_DIR
114+
AND NOT DEFINED ACL_LIBRARY
115+
AND (
116+
CMAKE_PREFIX_PATH
117+
OR ACL_ROOT
118+
OR DEFINED ENV{ACL_ROOT}
119+
)
120+
)
108121
find_path(
109-
_acl_INCLUDE_DIR
110-
NAMES
111-
sys/acl.h
112-
PATHS
113-
${CMAKE_PREFIX_PATH}
114-
${ACL_ROOT}
115-
PATH_SUFFIXES
116-
include
117-
NO_DEFAULT_PATH
122+
ACL_INCLUDE_DIR
123+
NAMES sys/acl.h
124+
DOC "Directory containing ACL library headers"
125+
NO_CMAKE_ENVIRONMENT_PATH
126+
NO_SYSTEM_ENVIRONMENT_PATH
127+
NO_CMAKE_INSTALL_PREFIX
128+
NO_CMAKE_SYSTEM_PATH
118129
)
119130

120-
if(_acl_INCLUDE_DIR)
121-
set(ACL_INCLUDE_DIR ${_acl_INCLUDE_DIR})
131+
find_library(
132+
ACL_LIBRARY
133+
NAMES acl
134+
DOC "The path to the ACL library"
135+
NO_CMAKE_ENVIRONMENT_PATH
136+
NO_SYSTEM_ENVIRONMENT_PATH
137+
NO_CMAKE_INSTALL_PREFIX
138+
NO_CMAKE_SYSTEM_PATH
139+
)
140+
141+
if(ACL_INCLUDE_DIR AND ACL_LIBRARY)
122142
set(ACL_IS_BUILT_IN FALSE)
143+
else()
144+
unset(ACL_INCLUDE_DIR CACHE)
145+
unset(ACL_LIBRARY CACHE)
123146
endif()
124147
endif()
125148

126-
################################################################################
127-
# Find package.
128-
################################################################################
129-
130149
set(_reason "")
150+
set(_ACL_REQUIRED_VARS "")
131151

132152
# If no compiler is loaded C library can't be checked anyway.
133153
if(NOT CMAKE_C_COMPILER_LOADED AND NOT CMAKE_CXX_COMPILER_LOADED)
134154
set(ACL_IS_BUILT_IN FALSE)
135155
endif()
136156

137157
if(NOT DEFINED ACL_IS_BUILT_IN)
138-
block(PROPAGATE ACL_IS_BUILT_IN _acl_works)
139-
_acl_check(_acl_works)
140-
141-
if(_acl_works)
142-
set(
143-
ACL_IS_BUILT_IN
144-
TRUE
145-
CACHE INTERNAL
146-
"Whether ACL is a part of the C library."
147-
)
148-
else()
149-
set(ACL_IS_BUILT_IN FALSE)
150-
endif()
151-
endblock()
158+
_acl_check(ACL_IS_BUILT_IN)
159+
160+
if(ACL_IS_BUILT_IN)
161+
set(ACL_SANITY_CHECK TRUE)
162+
endif()
152163
endif()
153164

154-
set(_ACL_REQUIRED_VARS "")
155165
if(ACL_IS_BUILT_IN)
166+
_acl_check(ACL_SANITY_CHECK)
167+
156168
set(_ACL_REQUIRED_VARS _ACL_IS_BUILT_IN_MSG)
157169
set(_ACL_IS_BUILT_IN_MSG "built in to C library")
158170
else()
@@ -169,9 +181,10 @@ else()
169181
HINTS ${PC_ACL_INCLUDE_DIRS}
170182
DOC "Directory containing ACL library headers"
171183
)
184+
mark_as_advanced(ACL_INCLUDE_DIR)
172185

173186
if(NOT ACL_INCLUDE_DIR)
174-
string(APPEND _reason "sys/acl.h not found. ")
187+
string(APPEND _reason "<sys/acl.h> not found. ")
175188
endif()
176189

177190
find_library(
@@ -180,6 +193,7 @@ else()
180193
HINTS ${PC_ACL_LIBRARY_DIRS}
181194
DOC "The path to the ACL library"
182195
)
196+
mark_as_advanced(ACL_LIBRARY)
183197

184198
if(NOT ACL_LIBRARY)
185199
string(APPEND _reason "ACL library not found. ")
@@ -190,35 +204,26 @@ else()
190204
set(ACL_VERSION ${PC_ACL_VERSION})
191205
endif()
192206

193-
_acl_check(_acl_works)
194-
195-
mark_as_advanced(ACL_INCLUDE_DIR ACL_LIBRARY)
207+
_acl_check(ACL_SANITY_CHECK)
196208
endif()
197209

198-
if(NOT _acl_works)
210+
if(NOT ACL_SANITY_CHECK)
199211
if(ACL_USE_USER_GROUP)
200-
string(APPEND _reason "ACL_USER and ACL_GROUP check failed. ")
212+
string(APPEND _reason "ACL_USER and ACL_GROUP sanity check failed. ")
201213
else()
202-
string(APPEND _reason "acl_free check failed. ")
214+
string(APPEND _reason "ACL sanity check failed. ")
203215
endif()
204216
endif()
205217

206-
################################################################################
207-
# Handle find_package arguments.
208-
################################################################################
209-
210218
find_package_handle_standard_args(
211219
ACL
212-
REQUIRED_VARS
213-
${_ACL_REQUIRED_VARS}
214-
_acl_works
220+
REQUIRED_VARS ${_ACL_REQUIRED_VARS} ACL_SANITY_CHECK
215221
VERSION_VAR ACL_VERSION
216222
HANDLE_VERSION_RANGE
217223
REASON_FAILURE_MESSAGE "${_reason}"
218224
)
219225

220226
unset(_reason)
221-
unset(_acl_works)
222227
unset(_ACL_REQUIRED_VARS)
223228
unset(_ACL_IS_BUILT_IN_MSG)
224229

cmake/cmake/modules/FindApache.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ This module provides the following imported targets:
1919
2020
## Result variables
2121
22+
This module defines the following variables:
23+
2224
* `Apache_FOUND` - Boolean indicating whether (the requested version of) package
2325
was found.
2426
* `Apache_VERSION` - The version of package found.
@@ -28,6 +30,8 @@ This module provides the following imported targets:
2830
2931
## Cache variables
3032
33+
The following cache variables may also be set:
34+
3135
* `Apache_APXS_EXECUTABLE` - Path to the APache eXtenSion tool command-line tool
3236
(`apxs`).
3337
* `Apache_APXS_DEFINITIONS` - A list of compile definitions (`-D`) from the
@@ -44,7 +48,9 @@ This module provides the following imported targets:
4448
4549
## Examples
4650
47-
Basic usage:
51+
### Example: Basic usage
52+
53+
Finding Apache and linking its imported target to a project target:
4854
4955
```cmake
5056
# CMakeLists.txt
@@ -389,10 +395,6 @@ block(PROPAGATE Apache_THREADED)
389395
endif()
390396
endblock()
391397

392-
################################################################################
393-
# Handle package arguments.
394-
################################################################################
395-
396398
find_package_handle_standard_args(
397399
Apache
398400
REQUIRED_VARS

cmake/cmake/modules/FindAppArmor.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ This module provides the following imported targets:
1515
1616
## Result variables
1717
18+
This module defines the following variables:
19+
1820
* `AppArmor_FOUND` - Boolean indicating whether (the requested version of)
1921
package was found.
2022
* `AppArmor_VERSION` - The version of package found.
2123
2224
## Cache variables
2325
26+
The following cache variables may also be set:
27+
2428
* `AppArmor_INCLUDE_DIR` - Directory containing package library headers.
2529
* `AppArmor_LIBRARY` - The path to the package library.
2630

cmake/cmake/modules/FindArgon2.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ This module provides the following imported targets:
1515
1616
## Result variables
1717
18+
This module defines the following variables:
19+
1820
* `Argon2_FOUND` - Boolean indicating whether (the requested version of) package
1921
was found.
2022
* `Argon2_VERSION` - The version of package found.
2123
2224
## Cache variables
2325
26+
The following cache variables may also be set:
27+
2428
* `Argon2_INCLUDE_DIR` - Directory containing package library headers.
2529
* `Argon2_LIBRARY` - The path to the package library.
2630

cmake/cmake/modules/FindAtomic.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ This module provides the following imported targets:
1515
1616
## Result variables
1717
18+
This module defines the following variables:
19+
1820
* `Atomic_FOUND` - Whether atomic instructions are available.
1921
2022
## Examples

cmake/cmake/modules/FindBerkeleyDB.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ This module provides the following imported targets:
1515
1616
## Result variables
1717
18+
This module defines the following variables:
19+
1820
* `BerkeleyDB_FOUND` - Boolean indicating whether (the requested version of)
1921
package was found.
2022
* `BerkeleyDB_VERSION` - The version of package found.
2123
2224
## Cache variables
2325
26+
The following cache variables may also be set:
27+
2428
* `BerkeleyDB_INCLUDE_DIR` - Directory containing package library headers.
2529
* `BerkeleyDB_LIBRARY` - The path to the package library.
2630
* `BerkeleyDB_DB1_INCLUDE_DIR` - Directory containing headers for DB1 emulation

cmake/cmake/modules/FindCapstone.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ This module provides the following imported targets:
1515
1616
## Result variables
1717
18+
This module defines the following variables:
19+
1820
* `Capstone_FOUND` - Boolean indicating whether (the requested version of)
1921
package was found.
2022
* `Capstone_VERSION` - The version of package found.
2123
2224
## Cache variables
2325
26+
The following cache variables may also be set:
27+
2428
* `Capstone_INCLUDE_DIR` - Directory containing package library headers.
2529
* `Capstone_LIBRARY` - The path to the package library.
2630

cmake/cmake/modules/FindCcache.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ find_package(Ccache [<version>] [...])
99
1010
## Result variables
1111
12+
This module defines the following variables:
13+
1214
* `Ccache_FOUND` - Boolean indicating whether (the requested version of) package
1315
was found.
1416
* `Ccache_VERSION` - The version of package found.
1517
1618
## Cache variables
1719
20+
The following cache variables may also be set:
21+
1822
* `Ccache_EXECUTABLE` - The path to the ccache executable.
1923
2024
## Hints

cmake/cmake/modules/FindCclient.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ This module provides the following imported targets:
1919
2020
## Result variables
2121
22+
This module defines the following variables:
23+
2224
* `Cclient_FOUND` - Boolean indicating whether the package was found.
2325
* `HAVE_IMAP2000` - Whether c-client version is 2000 or newer. If true,
2426
c-client.h should be included instead of only rfc822.h on prior versions.
@@ -32,6 +34,8 @@ This module provides the following imported targets:
3234
3335
## Cache variables
3436
37+
The following cache variables may also be set:
38+
3539
* `Cclient_INCLUDE_DIR` - Directory containing package library headers.
3640
* `Cclient_LIBRARY` - The path to the package library.
3741
@@ -330,10 +334,6 @@ if(NOT Cclient_SANITY_CHECK_2)
330334
string(APPEND _reason "Sanity check failed: 'mail_newbody()' not found. ")
331335
endif()
332336

333-
################################################################################
334-
# Handle package arguments.
335-
################################################################################
336-
337337
find_package_handle_standard_args(
338338
Cclient
339339
REQUIRED_VARS

0 commit comments

Comments
 (0)