Skip to content

Commit ca7d9b9

Browse files
committed
Find modules: Remove redundant result variables
These result variables were not clear enough at the beginning when should be used and set. When using imported targets, such result variables are redundant in find modules. If some case needs to get all libraries or include directories, imported target properties should be retrieved instead. For example, get_target_property(result Foo::Foo INTERFACE_INCLUDE_DIRECTORIES)
1 parent cfb8658 commit ca7d9b9

Some content is hidden

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

45 files changed

+172
-413
lines changed

cmake/cmake/modules/FindACL.cmake

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Finds the ACL library:
55
66
```cmake
7-
find_package(ACL)
7+
find_package(ACL [<version>] [...])
88
```
99
1010
## Imported targets
@@ -15,10 +15,8 @@ This module defines the following imported targets:
1515
1616
## Result variables
1717
18-
* `ACL_FOUND` - Whether the package has been found.
19-
* `ACL_INCLUDE_DIRS` - Include directories needed to use this package.
20-
* `ACL_LIBRARIES` - Libraries needed to link to the package library.
21-
* `ACL_VERSION` - Package version, if found.
18+
* `ACL_FOUND` - Boolean indicating whether the package is found.
19+
* `ACL_VERSION` - The version of package found.
2220
2321
## Cache variables
2422
@@ -228,22 +226,14 @@ if(NOT ACL_FOUND)
228226
return()
229227
endif()
230228

231-
if(ACL_IS_BUILT_IN)
232-
set(ACL_INCLUDE_DIRS "")
233-
set(ACL_LIBRARIES "")
234-
else()
235-
set(ACL_INCLUDE_DIRS ${ACL_INCLUDE_DIR})
236-
set(ACL_LIBRARIES ${ACL_LIBRARY})
237-
endif()
238-
239229
if(NOT TARGET ACL::ACL)
240230
add_library(ACL::ACL UNKNOWN IMPORTED)
241231

242-
if(ACL_INCLUDE_DIRS)
232+
if(ACL_INCLUDE_DIR)
243233
set_target_properties(
244234
ACL::ACL
245235
PROPERTIES
246-
INTERFACE_INCLUDE_DIRECTORIES "${ACL_INCLUDE_DIRS}"
236+
INTERFACE_INCLUDE_DIRECTORIES "${ACL_INCLUDE_DIR}"
247237
)
248238
endif()
249239

cmake/cmake/modules/FindApache.cmake

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Finds the Apache packages and tools:
55
66
```cmake
7-
find_package(Apache)
7+
find_package(Apache [<version>] [...])
88
```
99
1010
The Apache development package usually contains Apache header files, the `apr`
@@ -19,10 +19,8 @@ This module defines the following imported targets:
1919
2020
## Result variables
2121
22-
* `Apache_FOUND` - Whether the package has been found.
23-
* `Apache_INCLUDE_DIRS` - Include directories needed to use this package.
24-
* `Apache_LIBRARIES` - Libraries needed to link to the package library.
25-
* `Apache_VERSION` - Package version, if found.
22+
* `Apache_FOUND` - Boolean indicating whether the package is found.
23+
* `Apache_VERSION` - The version of package found.
2624
* `Apache_THREADED` - Whether Apache requires thread safety.
2725
* `Apache_LIBEXECDIR` - Path to the directory containing all Apache modules and
2826
`httpd.exp` file (list of exported symbols).
@@ -410,17 +408,14 @@ if(NOT Apache_FOUND)
410408
return()
411409
endif()
412410

413-
set(Apache_INCLUDE_DIRS ${Apache_INCLUDE_DIR} ${Apache_APR_INCLUDE_DIR})
414-
set(Apache_LIBRARIES ${Apache_APR_LIBRARY})
415-
416411
if(NOT TARGET Apache::Apache)
417412
add_library(Apache::Apache INTERFACE IMPORTED)
418413

419414
set_target_properties(
420415
Apache::Apache
421416
PROPERTIES
422-
INTERFACE_LINK_LIBRARIES "${Apache_LIBRARIES}"
423-
INTERFACE_INCLUDE_DIRECTORIES "${Apache_INCLUDE_DIRS}"
417+
INTERFACE_LINK_LIBRARIES "${Apache_APR_LIBRARY}"
418+
INTERFACE_INCLUDE_DIRECTORIES "${Apache_INCLUDE_DIR};${Apache_APR_INCLUDE_DIR}"
424419
)
425420

426421
target_compile_definitions(

cmake/cmake/modules/FindAppArmor.cmake

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Finds the AppArmor library:
55
66
```cmake
7-
find_package(AppArmor)
7+
find_package(AppArmor [<version>] [...])
88
```
99
1010
## Imported targets
@@ -15,10 +15,8 @@ This module defines the following imported targets:
1515
1616
## Result variables
1717
18-
* `AppArmor_FOUND` - Whether the package has been found.
19-
* `AppArmor_INCLUDE_DIRS` - Include directories needed to use this package.
20-
* `AppArmor_LIBRARIES` - Libraries needed to link to the package library.
21-
* `AppArmor_VERSION` - Package version, if found.
18+
* `AppArmor_FOUND` - Boolean indicating whether the package is found.
19+
* `AppArmor_VERSION` - The version of package found.
2220
2321
## Cache variables
2422
@@ -120,9 +118,6 @@ if(NOT AppArmor_FOUND)
120118
return()
121119
endif()
122120

123-
set(AppArmor_INCLUDE_DIRS ${AppArmor_INCLUDE_DIR})
124-
set(AppArmor_LIBRARIES ${AppArmor_LIBRARY})
125-
126121
if(NOT TARGET AppArmor::AppArmor)
127122
if(IS_ABSOLUTE "${AppArmor_LIBRARY}")
128123
add_library(AppArmor::AppArmor UNKNOWN IMPORTED)
@@ -144,6 +139,6 @@ if(NOT TARGET AppArmor::AppArmor)
144139
set_target_properties(
145140
AppArmor::AppArmor
146141
PROPERTIES
147-
INTERFACE_INCLUDE_DIRECTORIES "${AppArmor_INCLUDE_DIRS}"
142+
INTERFACE_INCLUDE_DIRECTORIES "${AppArmor_INCLUDE_DIR}"
148143
)
149144
endif()

cmake/cmake/modules/FindArgon2.cmake

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Finds the Argon2 library:
55
66
```cmake
7-
find_package(Argon2)
7+
find_package(Argon2 [<version>] [...])
88
```
99
1010
## Imported targets
@@ -15,10 +15,8 @@ This module defines the following imported targets:
1515
1616
## Result variables
1717
18-
* `Argon2_FOUND` - Whether the package has been found.
19-
* `Argon2_INCLUDE_DIRS` - Include directories needed to use this package.
20-
* `Argon2_LIBRARIES` - Libraries needed to link to the package library.
21-
* `Argon2_VERSION` - Package version, if found.
18+
* `Argon2_FOUND` - Boolean indicating whether the package is found.
19+
* `Argon2_VERSION` - The version of package found.
2220
2321
## Cache variables
2422
@@ -142,9 +140,6 @@ if(NOT Argon2_FOUND)
142140
return()
143141
endif()
144142

145-
set(Argon2_INCLUDE_DIRS ${Argon2_INCLUDE_DIR})
146-
set(Argon2_LIBRARIES ${Argon2_LIBRARY})
147-
148143
if(NOT TARGET Argon2::Argon2)
149144
if(IS_ABSOLUTE "${Argon2_LIBRARY}")
150145
add_library(Argon2::Argon2 UNKNOWN IMPORTED)
@@ -166,6 +161,6 @@ if(NOT TARGET Argon2::Argon2)
166161
set_target_properties(
167162
Argon2::Argon2
168163
PROPERTIES
169-
INTERFACE_INCLUDE_DIRECTORIES "${Argon2_INCLUDE_DIRS}"
164+
INTERFACE_INCLUDE_DIRECTORIES "${Argon2_INCLUDE_DIR}"
170165
)
171166
endif()

cmake/cmake/modules/FindAtomic.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ This module defines the following imported targets:
1616
## Result variables
1717
1818
* `Atomic_FOUND` - Whether atomic instructions are available.
19-
* `Atomic_LIBRARIES` - A list of libraries needed in order to use atomic
20-
functionality.
2119
2220
## Examples
2321
@@ -66,7 +64,7 @@ if(_atomic_found OR _atomic_found_in_library)
6664
endif()
6765

6866
if(_atomic_found_in_library)
69-
list(APPEND ATOMIC_LIBRARIES atomic)
67+
set(Atomic_LIBRARY atomic)
7068
endif()
7169

7270
find_package_handle_standard_args(
@@ -86,6 +84,6 @@ if(NOT TARGET Atomic::Atomic)
8684
set_target_properties(
8785
Atomic::Atomic
8886
PROPERTIES
89-
INTERFACE_LINK_LIBRARIES "${Atomic_LIBRARIES}"
87+
INTERFACE_LINK_LIBRARIES "${Atomic_LIBRARY}"
9088
)
9189
endif()

cmake/cmake/modules/FindBerkeleyDB.cmake

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Finds the Berkeley DB library:
55
66
```cmake
7-
find_package(BerkeleyDB)
7+
find_package(BerkeleyDB [<version>] [...])
88
```
99
1010
## Imported targets
@@ -15,10 +15,8 @@ This module defines the following imported targets:
1515
1616
## Result variables
1717
18-
* `BerkeleyDB_FOUND` - Whether the package has been found.
19-
* `BerkeleyDB_INCLUDE_DIRS` - Include directories needed to use this package.
20-
* `BerkeleyDB_LIBRARIES` - Libraries needed to link to the package library.
21-
* `BerkeleyDB_VERSION` - Package version, if found.
18+
* `BerkeleyDB_FOUND` - Boolean indicating whether the package is found.
19+
* `BerkeleyDB_VERSION` - The version of package found.
2220
2321
## Cache variables
2422
@@ -182,14 +180,6 @@ if(NOT BerkeleyDB_FOUND)
182180
return()
183181
endif()
184182

185-
set(
186-
BerkeleyDB_INCLUDE_DIRS
187-
${BerkeleyDB_INCLUDE_DIR}
188-
${BerkeleyDB_DB1_INCLUDE_DIR}
189-
)
190-
list(REMOVE_DUPLICATES BerkeleyDB_INCLUDE_DIRS)
191-
set(BerkeleyDB_LIBRARIES ${BerkeleyDB_LIBRARY})
192-
193183
if(NOT TARGET BerkeleyDB::BerkeleyDB)
194184
if(IS_ABSOLUTE "${BerkeleyDB_LIBRARY}")
195185
add_library(BerkeleyDB::BerkeleyDB UNKNOWN IMPORTED)
@@ -208,9 +198,10 @@ if(NOT TARGET BerkeleyDB::BerkeleyDB)
208198
)
209199
endif()
210200

211-
set_target_properties(
212-
BerkeleyDB::BerkeleyDB
213-
PROPERTIES
214-
INTERFACE_INCLUDE_DIRECTORIES "${BerkeleyDB_INCLUDE_DIRS}"
201+
set_property(
202+
TARGET BerkeleyDB::BerkeleyDB
203+
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
204+
${BerkeleyDB_INCLUDE_DIR}
205+
${BerkeleyDB_DB1_INCLUDE_DIR}
215206
)
216207
endif()

cmake/cmake/modules/FindCapstone.cmake

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Finds the Capstone library:
55
66
```cmake
7-
find_package(Capstone)
7+
find_package(Capstone [<version>] [...])
88
```
99
1010
## Imported targets
@@ -15,10 +15,8 @@ This module defines the following imported targets:
1515
1616
## Result variables
1717
18-
* `Capstone_FOUND` - Whether the package has been found.
19-
* `Capstone_INCLUDE_DIRS` - Include directories needed to use this package.
20-
* `Capstone_LIBRARIES` - Libraries needed to link to the package library.
21-
* `Capstone_VERSION` - Package version, if found.
18+
* `Capstone_FOUND` - Boolean indicating whether the package is found.
19+
* `Capstone_VERSION` - The version of package found.
2220
2321
## Cache variables
2422
@@ -128,17 +126,6 @@ if(NOT Capstone_FOUND)
128126
return()
129127
endif()
130128

131-
# Capstone might be included with <capstone.h> instead of the recommended
132-
# <capstone/capstone.h>. Here both include directories are added so the code can
133-
# work with both includes. The "subdir" can be removed and simplified in the
134-
# future. See: https://github.com/capstone-engine/capstone/issues/1982
135-
set(
136-
Capstone_INCLUDE_DIRS
137-
${Capstone_INCLUDE_DIR}
138-
${Capstone_INCLUDE_DIR}/capstone
139-
)
140-
set(Capstone_LIBRARIES ${Capstone_LIBRARY})
141-
142129
if(NOT TARGET Capstone::Capstone)
143130
if(IS_ABSOLUTE "${Capstone_LIBRARY}")
144131
add_library(Capstone::Capstone UNKNOWN IMPORTED)
@@ -157,9 +144,15 @@ if(NOT TARGET Capstone::Capstone)
157144
)
158145
endif()
159146

160-
set_target_properties(
161-
Capstone::Capstone
162-
PROPERTIES
163-
INTERFACE_INCLUDE_DIRECTORIES "${Capstone_INCLUDE_DIRS}"
147+
set_property(
148+
TARGET Capstone::Capstone
149+
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
150+
${Capstone_INCLUDE_DIR}
151+
# Capstone might be included with <capstone.h> instead of the recommended
152+
# <capstone/capstone.h>. Here both include directories are added so the
153+
# code can work with both includes. The following "subdir" can be removed
154+
# and simplified in the future.
155+
# See: https://github.com/capstone-engine/capstone/issues/1982
156+
${Capstone_INCLUDE_DIR}/capstone
164157
)
165158
endif()

cmake/cmake/modules/FindCcache.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
Finds the Ccache compiler cache tool for faster compilation times:
55
66
```cmake
7-
find_package(Ccache)
7+
find_package(Ccache [<version>] [...])
88
```
99
1010
## Result variables
1111
12-
* `Ccache_FOUND` - Whether the package has been found.
13-
* `Ccache_VERSION` - Package version, if found.
12+
* `Ccache_FOUND` - Boolean indicating whether the package is found.
13+
* `Ccache_VERSION` - The version of package found.
1414
1515
## Cache variables
1616

cmake/cmake/modules/FindCclient.cmake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ This module defines the following imported targets:
1919
2020
## Result variables
2121
22-
* `Cclient_FOUND` - Whether the package has been found.
23-
* `Cclient_INCLUDE_DIRS` - Include directories needed to use this package.
24-
* `Cclient_LIBRARIES` - Libraries needed to link to the package library.
22+
* `Cclient_FOUND` - Boolean indicating whether the package is found.
2523
* `HAVE_IMAP2000` - Whether c-client version is 2000 or newer. If true,
2624
c-client.h should be included instead of only rfc822.h on prior versions.
2725
* `HAVE_IMAP2001` - Whether c-client version is 2001 to 2004.
@@ -354,17 +352,14 @@ endif()
354352
# Post-find configuration.
355353
################################################################################
356354

357-
set(Cclient_INCLUDE_DIRS ${Cclient_INCLUDE_DIR})
358-
set(Cclient_LIBRARIES ${Cclient_LIBRARY})
359-
360355
if(NOT TARGET Cclient::Cclient)
361356
add_library(Cclient::Cclient UNKNOWN IMPORTED)
362357

363358
set_target_properties(
364359
Cclient::Cclient
365360
PROPERTIES
366361
IMPORTED_LOCATION "${Cclient_LIBRARY}"
367-
INTERFACE_INCLUDE_DIRECTORIES "${Cclient_INCLUDE_DIRS}"
362+
INTERFACE_INCLUDE_DIRECTORIES "${Cclient_INCLUDE_DIR}"
368363
)
369364
endif()
370365

cmake/cmake/modules/FindCdb.cmake

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Finds the cdb library:
55
66
```cmake
7-
find_package(Cdb)
7+
find_package(Cdb [<version>] [...])
88
```
99
1010
## Imported targets
@@ -15,10 +15,8 @@ This module defines the following imported targets:
1515
1616
## Result variables
1717
18-
* `Cdb_FOUND` - Whether the package has been found.
19-
* `Cdb_INCLUDE_DIRS` - Include directories needed to use this package.
20-
* `Cdb_LIBRARIES` - Libraries needed to link to the package library.
21-
* `Cdb_VERSION` - Package version, if found.
18+
* `Cdb_FOUND` - Boolean indicating whether the package is found.
19+
* `Cdb_VERSION` - The version of package found.
2220
2321
## Cache variables
2422
@@ -125,16 +123,13 @@ if(NOT Cdb_FOUND)
125123
return()
126124
endif()
127125

128-
set(Cdb_INCLUDE_DIRS ${Cdb_INCLUDE_DIR})
129-
set(Cdb_LIBRARIES ${Cdb_LIBRARY})
130-
131126
if(NOT TARGET Cdb::Cdb)
132127
add_library(Cdb::Cdb UNKNOWN IMPORTED)
133128

134129
set_target_properties(
135130
Cdb::Cdb
136131
PROPERTIES
137132
IMPORTED_LOCATION "${Cdb_LIBRARY}"
138-
INTERFACE_INCLUDE_DIRECTORIES "${Cdb_INCLUDE_DIRS}"
133+
INTERFACE_INCLUDE_DIRECTORIES "${Cdb_INCLUDE_DIR}"
139134
)
140135
endif()

0 commit comments

Comments
 (0)