Skip to content

Commit e454072

Browse files
committed
Merge #103: cmake: Fix package configuration file
c373a94 cmake: Fix package configuration file (Hennadii Stepanov) Pull request description: When loading a package configuration file, `find_package` defines variables to provide information about the call arguments. In particular, `CMAKE_FIND_PACKAGE_NAME` represents the package name. This PR uses this variable instead of a hardcoded name, making the use case suggested in #98 (comment) workable: ```cmake find_package(Libmultiprocess COMPONENTS Lib) find_package(LibmultiprocessNative COMPONENTS Bin NAMES Libmultiprocess ) ``` ACKs for top commit: ryanofsky: Code review ACK c373a94 Tree-SHA512: 493cfd62c4992c9753772844c0a96004d45eb1c807986b7ce7871fdf0debede79d9f9fbe22ecce0a92d4d0b5a2d24f0067c2b5816f5210a8f5bcbb41d04fb917
2 parents 8b8a476 + c373a94 commit e454072

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

cmake/Config.cmake.in

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
set(_Libmultiprocess_supported_components Bin Lib)
88

99
# If no components specified, include all components.
10-
list(LENGTH Libmultiprocess_FIND_COMPONENTS Libmultiprocess_FIND_COMPONENTS_len)
11-
if(Libmultiprocess_FIND_COMPONENTS_len EQUAL 0)
12-
set(Libmultiprocess_FIND_COMPONENTS ${_Libmultiprocess_supported_components})
10+
list(LENGTH ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS_len)
11+
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS_len EQUAL 0)
12+
set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS ${_Libmultiprocess_supported_components})
1313
endif()
1414

15-
if ("Bin" IN_LIST Libmultiprocess_FIND_COMPONENTS)
15+
if ("Bin" IN_LIST ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
1616
include("${CMAKE_CURRENT_LIST_DIR}/TargetCapnpSources.cmake")
1717
endif()
1818

19-
if ("Lib" IN_LIST Libmultiprocess_FIND_COMPONENTS)
19+
if ("Lib" IN_LIST ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
2020
include(CMakeFindDependencyMacro)
2121
find_dependency(CapnProto)
2222
endif()
2323

24-
foreach(_comp ${Libmultiprocess_FIND_COMPONENTS})
24+
foreach(_comp ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS})
2525
if (NOT _comp IN_LIST _Libmultiprocess_supported_components)
26-
set(Libmultiprocess_FOUND False)
27-
set(Libmultiprocess_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
26+
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
27+
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
2828
endif()
2929
include("${CMAKE_CURRENT_LIST_DIR}/${_comp}Targets.cmake")
3030
endforeach()

0 commit comments

Comments
 (0)