summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-03-05 15:50:00 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-03-05 15:50:15 (GMT)
commite484b4289d41ff6f72aa84cdce638ea1f071a8af (patch)
tree357d37093af22fdd0af984c8483b383eb2d894f8 /Tests
parentfee2b209b822cd26fb2156e6f0859290b4eaa5e5 (diff)
parentad3f69c86eb27abd16d2a8534a7b90d59c0d74ed (diff)
downloadCMake-e484b4289d41ff6f72aa84cdce638ea1f071a8af.zip
CMake-e484b4289d41ff6f72aa84cdce638ea1f071a8af.tar.gz
CMake-e484b4289d41ff6f72aa84cdce638ea1f071a8af.tar.bz2
Merge topic 'macos_framework_postfix'
ad3f69c86e Add support for FRAMEWORK_MULTI_CONFIG_POSTFIX_<CONFIG> Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4289
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/Framework/FrameworkMultiConfigPostfix-build-final-check.cmake45
-rw-r--r--Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake25
-rw-r--r--Tests/RunCMake/Framework/RunCMakeTest.cmake36
3 files changed, 106 insertions, 0 deletions
diff --git a/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix-build-final-check.cmake b/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix-build-final-check.cmake
new file mode 100644
index 0000000..76fe6b8
--- /dev/null
+++ b/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix-build-final-check.cmake
@@ -0,0 +1,45 @@
+include("${RunCMake_TEST_BINARY_DIR}/FrameworkMultiConfigPostfixInfo.cmake")
+
+get_filename_component(framework_location "${framework_dir}" DIRECTORY)
+set(non_existent_debug_framework_dir "${framework_location}/${target_file_name}_debug.framework")
+set(framework_resources "${framework_dir}/Resources")
+set(plist_file "${framework_resources}/Info.plist")
+
+set(symlink_release_path "${framework_dir}/${target_file_name}")
+set(framework_release_path "${framework_dir}/Versions/A/${target_file_name}")
+
+# When using a multi config generator (like Ninja Multi-Config and Xcode),
+# the postfix will be applied to the debug framework library name and the symlink name.
+# For single config generators, the name stays the same as the the release framework.
+if(is_multi_config)
+ set(symlink_debug_path "${framework_dir}/${target_file_name}_debug")
+ set(framework_debug_path "${framework_dir}/Versions/A/${target_file_name}_debug")
+else()
+ set(symlink_debug_path "${framework_dir}/${target_file_name}")
+ set(framework_debug_path "${framework_dir}/Versions/A/${target_file_name}")
+endif()
+
+if(NOT IS_DIRECTORY ${framework_dir})
+ message(SEND_ERROR "Framework dir not found at ${framework_dir}")
+endif()
+
+if(IS_DIRECTORY ${non_existent_debug_framework_dir})
+ message(SEND_ERROR
+ "A framework dir with a debug suffix should not exist at ${non_existent_debug_framework_dir}")
+endif()
+
+if(NOT IS_SYMLINK "${symlink_release_path}")
+ message(SEND_ERROR "Release framework symlink not found at ${symlink_release_path}")
+endif()
+
+if(NOT IS_SYMLINK "${symlink_debug_path}")
+ message(SEND_ERROR "Debug framework symlink not found at ${symlink_debug_path}")
+endif()
+
+if(NOT EXISTS "${framework_release_path}")
+ message(SEND_ERROR "Release framework not found at ${framework_release_path}")
+endif()
+
+if(NOT EXISTS "${framework_debug_path}")
+ message(SEND_ERROR "Debug framework not found at ${framework_debug_path}")
+endif()
diff --git a/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake b/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake
new file mode 100644
index 0000000..51e627d
--- /dev/null
+++ b/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix.cmake
@@ -0,0 +1,25 @@
+enable_language(C)
+
+set(CMAKE_FRAMEWORK_MULTI_CONFIG_POSTFIX_DEBUG "_debug")
+
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/lib)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}/lib)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/bin)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}/bin)
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/lib)
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}/lib)
+
+set(target_name "mylib")
+add_library(${target_name} SHARED foo.c)
+set_property(TARGET ${target_name} PROPERTY FRAMEWORK ON)
+get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+
+string(APPEND content
+ "set(is_multi_config \"${is_multi_config}\")\n"
+ "set(framework_dir \"$<TARGET_BUNDLE_DIR:${target_name}>\")\n"
+ "set(target_file_name ${target_name})\n")
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkMultiConfigPostfixInfo.cmake
+ CONTENT "${content}")
diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake
index 965fbf4..6ee61a3 100644
--- a/Tests/RunCMake/Framework/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake
@@ -45,3 +45,39 @@ framework_type_test(ios SHARED YES)
framework_type_test(ios STATIC YES)
framework_type_test(osx SHARED YES)
framework_type_test(osx STATIC YES)
+
+function(framework_multi_config_postfix_test)
+ set(configure_name "FrameworkMultiConfigPostfix")
+ set(build_name "${configure_name}-build-intermediate")
+ set(build_name_final "${configure_name}-build-final")
+
+ if(RunCMake_GENERATOR MATCHES "Ninja Multi-Config")
+ set(RunCMake_TEST_OPTIONS
+ "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=all")
+ elseif(RunCMake_GENERATOR MATCHES "Xcode")
+ set(RunCMake_TEST_OPTIONS
+ "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release")
+ else()
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_BUILD_TYPE=Debug")
+ endif()
+
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${configure_name})
+ set(RunCMake_TEST_NO_CLEAN 1)
+
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(${configure_name})
+ unset(RunCMake_TEST_OPTIONS)
+
+ if(RunCMake_GENERATOR MATCHES "Ninja Multi-Config")
+ run_cmake_command(${build_name_final} ${CMAKE_COMMAND} --build . --target all:all)
+ elseif(RunCMake_GENERATOR MATCHES "Xcode")
+ run_cmake_command(${build_name} ${CMAKE_COMMAND} --build . --config Release)
+ run_cmake_command(${build_name} ${CMAKE_COMMAND} --build . --config Debug)
+ run_cmake_command(${build_name_final} ${CMAKE_COMMAND} --build . --config Debug)
+ else()
+ run_cmake_command(${build_name_final} ${CMAKE_COMMAND} --build .)
+ endif()
+endfunction()
+
+framework_multi_config_postfix_test()