cmake: add SDL_INSTALL_CMAKEDIR cache variable to override location of cmake config files
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6c07a9d..baa25e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3346,15 +3346,16 @@ if(NOT SDL2_DISABLE_INSTALL)
##### Export files #####
if (WINDOWS AND NOT MINGW)
- set(PKG_PREFIX "cmake")
+ set(SDL_INSTALL_CMAKEDIR_DEFAULT "cmake")
else ()
- set(PKG_PREFIX "${CMAKE_INSTALL_LIBDIR}/cmake/SDL2")
+ set(SDL_INSTALL_CMAKEDIR_DEFAULT "${CMAKE_INSTALL_LIBDIR}/cmake/SDL2")
endif ()
+ set(SDL_INSTALL_CMAKEDIR "${SDL_INSTALL_CMAKEDIR_DEFAULT}" CACHE STRING "Location where to install SDL2Config.cmake")
include(CMakePackageConfigHelpers)
configure_package_config_file(SDL2Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/SDL2Config.cmake"
PATH_VARS CMAKE_INSTALL_PREFIX CMAKE_INSTALL_FULL_BINDIR CMAKE_INSTALL_FULL_INCLUDEDIR CMAKE_INSTALL_FULL_LIBDIR
- INSTALL_DESTINATION ${PKG_PREFIX}
+ INSTALL_DESTINATION "${SDL_INSTALL_CMAKEDIR}"
)
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/SDL2ConfigVersion.cmake"
VERSION ${SDL_VERSION}
@@ -3365,7 +3366,7 @@ if(NOT SDL2_DISABLE_INSTALL)
install(EXPORT SDL2Targets
FILE SDL2Targets.cmake
NAMESPACE SDL2::
- DESTINATION ${PKG_PREFIX}
+ DESTINATION "${SDL_INSTALL_CMAKEDIR}"
)
if(ANDROID AND NOT CMAKE_VERSION VERSION_LESS 3.7)
install(EXPORT_ANDROID_MK SDL2Targets
@@ -3377,7 +3378,7 @@ if(NOT SDL2_DISABLE_INSTALL)
install(EXPORT SDL2mainTargets
FILE SDL2mainTargets.cmake
NAMESPACE SDL2::
- DESTINATION ${PKG_PREFIX}
+ DESTINATION "${SDL_INSTALL_CMAKEDIR}"
)
if(ANDROID AND NOT CMAKE_VERSION VERSION_LESS 3.7)
install(EXPORT_ANDROID_MK SDL2mainTargets
@@ -3389,7 +3390,7 @@ if(NOT SDL2_DISABLE_INSTALL)
install(EXPORT SDL2staticTargets
FILE SDL2staticTargets.cmake
NAMESPACE SDL2::
- DESTINATION ${PKG_PREFIX}
+ DESTINATION "${SDL_INSTALL_CMAKEDIR}"
)
if(ANDROID AND NOT CMAKE_VERSION VERSION_LESS 3.7)
install(EXPORT_ANDROID_MK SDL2staticTargets
@@ -3401,7 +3402,7 @@ if(NOT SDL2_DISABLE_INSTALL)
install(EXPORT SDL2testTargets
FILE SDL2testTargets.cmake
NAMESPACE SDL2::
- DESTINATION ${PKG_PREFIX}
+ DESTINATION "${SDL_INSTALL_CMAKEDIR}"
)
if(ANDROID AND NOT CMAKE_VERSION VERSION_LESS 3.7)
install(EXPORT_ANDROID_MK SDL2testTargets
@@ -3413,7 +3414,7 @@ if(NOT SDL2_DISABLE_INSTALL)
FILES
${CMAKE_CURRENT_BINARY_DIR}/SDL2Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/SDL2ConfigVersion.cmake
- DESTINATION ${PKG_PREFIX}
+ DESTINATION "${SDL_INSTALL_CMAKEDIR}"
COMPONENT Devel
)