Skip to content

Commit 434ac4c

Browse files
committed
Make config files be found case-insensitively
By using the <lowercasePackageName>-config.cmake and <lowercasePackageName>-config-version.cmake naming schemes for the generated CMake config files, we make it possible for these config files to be found, irrespective of the capitalization used in the original find_package call. That is, find_package(NaMe) and find_package(name) will both find the same config file. This is already the case no case-insensitive filesystems (e.g. under Windows). However, on case-sensitive filesystems (e.g. most Linux setups) the used capitalization makes a difference. This can be a source of confusion and annoyance in cross-platform development. With this commit, this platform differences will vanish.
1 parent 7753711 commit 434ac4c

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ function(packageProject)
126126
set(INSTALL_DIR_FOR_CMAKE_CONFIGS ${CMAKE_INSTALL_LIBDIR})
127127
endif()
128128

129+
string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER)
129130
write_basic_package_version_file(
130-
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
131+
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config-version.cmake"
131132
VERSION ${PROJECT_VERSION}
132133
COMPATIBILITY ${PROJECT_COMPATIBILITY} ${wbpvf_extra_args}
133134
)
@@ -163,7 +164,7 @@ function(packageProject)
163164

164165
configure_file(
165166
${PACKAGE_PROJECT_ROOT_PATH}/Config.cmake.in
166-
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" @ONLY
167+
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config.cmake" @ONLY
167168
)
168169

169170
install(
@@ -174,8 +175,8 @@ function(packageProject)
174175
)
175176

176177
install(
177-
FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
178-
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
178+
FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config-version.cmake"
179+
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config.cmake"
179180
DESTINATION "${${PROJECT_NAME}_INSTALL_CMAKEDIR}"
180181
COMPONENT "${PROJECT_NAME}_Development"
181182
)

0 commit comments

Comments
 (0)