Browse Source

Merge topic 'package-dispatch-apple'

dc5098429b CMakePackageConfigHelpers: Clarify Apple platform selection usage error
3b9586671c CMakePackageConfigHelpers: Clarify Apple platform selection template name

Acked-by: Kitware Robot <[email protected]>
Merge-request: !9087
Brad King 1 year ago
parent
commit
d2cbadf3b4

+ 5 - 1
Modules/CMakePackageConfigHelpers.cmake

@@ -430,6 +430,10 @@ function(generate_apple_platform_selection_file _output_file)
   set(_multi)
   cmake_parse_arguments(PARSE_ARGV 0 _gpsf "${_options}" "${_single}" "${_multi}")
 
+  if(NOT _gpsf_INSTALL_DESTINATION)
+    message(FATAL_ERROR "No INSTALL_DESTINATION given to generate_apple_platform_selection_file()")
+  endif()
+
   set(_have_relative 0)
   foreach(_opt IN LISTS _config_file_options)
     if(_gpsf_${_opt})
@@ -444,7 +448,7 @@ function(generate_apple_platform_selection_file _output_file)
     endif()
   endforeach()
 
-  configure_package_config_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Internal/PlatformSelectionFile.cmake.in" "${_output_file}"
+  configure_package_config_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Internal/ApplePlatformSelection.cmake.in" "${_output_file}"
     INSTALL_DESTINATION "${_gpsf_INSTALL_DESTINATION}"
     NO_SET_AND_CHECK_MACRO
     NO_CHECK_REQUIRED_COMPONENTS_MACRO

+ 0 - 0
Modules/Internal/PlatformSelectionFile.cmake.in → Modules/Internal/ApplePlatformSelection.cmake.in


+ 1 - 0
Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-stderr.txt

@@ -0,0 +1,6 @@
+^CMake Error at [^
+]*/Modules/CMakePackageConfigHelpers\.cmake:[0-9]+ \(message\):
+  No INSTALL_DESTINATION given to generate_apple_platform_selection_file\(\)
+Call Stack \(most recent call first\):
+  ApplePlatformMissingDest\.cmake:[0-9]+ \(generate_apple_platform_selection_file\)
+  CMakeLists.txt:[0-9]+ \(include\)$

+ 4 - 0
Tests/RunCMake/CMakePackage/ApplePlatformMissingDest.cmake

@@ -0,0 +1,4 @@
+include(CMakePackageConfigHelpers)
+generate_apple_platform_selection_file(mylib-config-install.cmake
+  #missing: INSTALL_DESTINATION lib/cmake/mylib
+  )

+ 4 - 0
Tests/RunCMake/CMakePackage/RunCMakeTest.cmake

@@ -33,6 +33,10 @@ function(apple_import platform system_name archs sysroot)
   run_cmake_command(apple-import-${platform}-build ${CMAKE_COMMAND} --build . --config Release)
 endfunction()
 
+if(APPLE)
+  run_cmake(ApplePlatformMissingDest)
+endif()
+
 if(APPLE AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
   set(apple_install ${RunCMake_BINARY_DIR}/apple-install)
   file(REMOVE_RECURSE "${apple_install}")