diff options
Diffstat (limited to 'Tests/RunCMake')
604 files changed, 4822 insertions, 600 deletions
diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake index 75130f2..9f65219 100644 --- a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake +++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake @@ -10,6 +10,9 @@ unset(RunCMake_TEST_OPTIONS) if(RunCMake_GENERATOR MATCHES "Watcom WMake|Borland Makefiles") return() endif() +if(CMAKE_CXX_COMPILER_ID STREQUAL "OrangeC") + return() +endif() if(RunCMake_GENERATOR MATCHES "Ninja|Visual Studio" AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(EXPORTS TRUE) diff --git a/Tests/RunCMake/Autogen/AutoMocExecutableConfig.cmake b/Tests/RunCMake/Autogen/AutoMocExecutableConfig.cmake new file mode 100644 index 0000000..3ee9be9 --- /dev/null +++ b/Tests/RunCMake/Autogen/AutoMocExecutableConfig.cmake @@ -0,0 +1,15 @@ +include(MocExample.cmake) + +if(NOT TARGET Qt${with_qt_version}::moc) + message(FATAL_ERROR "Qt${with_qt_version}::moc not found") +endif() + +get_target_property(moc_location Qt${with_qt_version}::moc IMPORTED_LOCATION) +set_target_properties(dummy PROPERTIES AUTOMOC_MOC_OPTIONS "EXE_PATH=${moc_location}") + +add_executable(mymoc $<$<CONFIG:Debug>:exe_debug.cpp> + $<$<CONFIG:Release>:exe_release.cpp> + $<$<CONFIG:RelWithDebInfo>:exe_relwithdebinfo.cpp> +) + +set_target_properties(dummy PROPERTIES AUTOMOC_EXECUTABLE $<TARGET_FILE:mymoc>) diff --git a/Tests/RunCMake/Autogen/AutoRccExecutableConfig.cmake b/Tests/RunCMake/Autogen/AutoRccExecutableConfig.cmake new file mode 100644 index 0000000..0e46420 --- /dev/null +++ b/Tests/RunCMake/Autogen/AutoRccExecutableConfig.cmake @@ -0,0 +1,15 @@ +include(RccExample.cmake) + +if(NOT TARGET Qt${with_qt_version}::rcc) + message(FATAL_ERROR "Qt${with_qt_version}::rcc not found") +endif() + +get_target_property(rcc_location Qt${with_qt_version}::rcc IMPORTED_LOCATION) +set_target_properties(dummy PROPERTIES AUTORCC_OPTIONS "EXE_PATH=${rcc_location}") + +add_executable(myrcc $<$<CONFIG:Debug>:exe_debug.cpp> + $<$<CONFIG:Release>:exe_release.cpp> + $<$<CONFIG:RelWithDebInfo>:exe_relwithdebinfo.cpp> +) + +set_target_properties(dummy PROPERTIES AUTORCC_EXECUTABLE $<TARGET_FILE:myrcc>) diff --git a/Tests/RunCMake/Autogen/AutoUicExecutableConfig.cmake b/Tests/RunCMake/Autogen/AutoUicExecutableConfig.cmake new file mode 100644 index 0000000..55b88b8 --- /dev/null +++ b/Tests/RunCMake/Autogen/AutoUicExecutableConfig.cmake @@ -0,0 +1,15 @@ +include(UicExample.cmake) + +if(NOT TARGET Qt${with_qt_version}::uic) + message(FATAL_ERROR "Qt${with_qt_version}::uic not found") +endif() + +get_target_property(uic_location Qt${with_qt_version}::uic IMPORTED_LOCATION) +set_target_properties(dummy PROPERTIES AUTOUIC_OPTIONS "EXE_PATH=${uic_location}") + +add_executable(myuic $<$<CONFIG:Debug>:exe_debug.cpp> + $<$<CONFIG:Release>:exe_release.cpp> + $<$<CONFIG:RelWithDebInfo>:exe_relwithdebinfo.cpp> +) + +set_target_properties(dummy PROPERTIES AUTOUIC_EXECUTABLE $<TARGET_FILE:myuic>) diff --git a/Tests/RunCMake/Autogen/MocExample.cmake b/Tests/RunCMake/Autogen/MocExample.cmake new file mode 100644 index 0000000..f06f8f6 --- /dev/null +++ b/Tests/RunCMake/Autogen/MocExample.cmake @@ -0,0 +1,11 @@ +enable_language(CXX) + +set(CMAKE_CXX_STANDARD 11) +find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets Gui) + +add_library(dummy STATIC example.cpp) +target_link_libraries(dummy Qt${with_qt_version}::Core + Qt${with_qt_version}::Widgets + Qt${with_qt_version}::Gui) + +set_target_properties(dummy PROPERTIES AUTOMOC ON) diff --git a/Tests/RunCMake/Autogen/MyWindow.cpp b/Tests/RunCMake/Autogen/MyWindow.cpp new file mode 100644 index 0000000..d87c2e9 --- /dev/null +++ b/Tests/RunCMake/Autogen/MyWindow.cpp @@ -0,0 +1,7 @@ +#include "MyWindow.h" + +MyWindow::MyWindow(QWidget* parent) + : QWidget(parent) +{ + this->m_ui.setupUi(this); +} diff --git a/Tests/RunCMake/Autogen/MyWindow.h b/Tests/RunCMake/Autogen/MyWindow.h new file mode 100644 index 0000000..c267610 --- /dev/null +++ b/Tests/RunCMake/Autogen/MyWindow.h @@ -0,0 +1,16 @@ +#pragma once + +#include <QWidget> + +#include "ui_MyWindow.h" + +class MyWindow : public QWidget +{ + Q_OBJECT + +public: + explicit MyWindow(QWidget* parent = nullptr); + +private: + Ui::MyWindow m_ui; +}; diff --git a/Tests/RunCMake/Autogen/MyWindow.ui b/Tests/RunCMake/Autogen/MyWindow.ui new file mode 100644 index 0000000..fbf294c --- /dev/null +++ b/Tests/RunCMake/Autogen/MyWindow.ui @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MyWindow</class> + <widget class="QWidget" name="MyWindow"/> +</ui> diff --git a/Tests/RunCMake/Autogen/QtAutoMocDeps-stderr.txt b/Tests/RunCMake/Autogen/QtAutoMocDeps-stderr.txt new file mode 100644 index 0000000..6024984 --- /dev/null +++ b/Tests/RunCMake/Autogen/QtAutoMocDeps-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at QtSubDir1/CMakeLists\.txt:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0116 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\.$ diff --git a/Tests/RunCMake/Ninja/QtAutoMocDeps.cmake b/Tests/RunCMake/Autogen/QtAutoMocDeps.cmake index c441169..fc3b2f2 100644 --- a/Tests/RunCMake/Ninja/QtAutoMocDeps.cmake +++ b/Tests/RunCMake/Autogen/QtAutoMocDeps.cmake @@ -1,27 +1,23 @@ enable_language(CXX) -set(QtX Qt${with_qt_version}) - -find_package(${QtX} REQUIRED COMPONENTS Core) +find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets Gui) set(CMAKE_AUTOMOC ON) add_library(simple_lib SHARED simple_lib.cpp) add_executable(app_with_qt app.cpp app_qt.cpp) -target_link_libraries(app_with_qt PRIVATE simple_lib ${QtX}::Core) +target_link_libraries(app_with_qt PRIVATE simple_lib Qt${with_qt_version}::Core) -if(${QtX}Widgets_DIR) - find_package(${QtX} REQUIRED COMPONENTS Widgets) +if(${with_qt_version}Widgets_DIR) if(with_qt_version STREQUAL 5) qt5_wrap_ui(_headers MyWindow.ui) else() qt_wrap_ui(_headers MyWindow.ui) endif() add_executable(app_with_widget app.cpp MyWindow.cpp ${_headers}) - target_link_libraries(app_with_widget PRIVATE ${QtX}::Widgets) + target_link_libraries(app_with_widget PRIVATE Qt${with_qt_version}::Widgets) target_include_directories(app_with_widget PRIVATE "${CMAKE_BINARY_DIR}") endif() - add_subdirectory(QtSubDir1) add_subdirectory(QtSubDir2) add_subdirectory(QtSubDir3) diff --git a/Tests/RunCMake/Ninja/QtSubDir1/CMakeLists.txt b/Tests/RunCMake/Autogen/QtSubDir1/CMakeLists.txt index 3a12dcd..f215b9e 100644 --- a/Tests/RunCMake/Ninja/QtSubDir1/CMakeLists.txt +++ b/Tests/RunCMake/Autogen/QtSubDir1/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_policy(SET CMP0116 OLD) add_executable(sub_exe_1 ../app.cpp) -target_link_libraries(sub_exe_1 PRIVATE ${QtX}::Core) +target_link_libraries(sub_exe_1 PRIVATE Qt${with_qt_version}::Core) diff --git a/Tests/RunCMake/Ninja/QtSubDir2/CMakeLists.txt b/Tests/RunCMake/Autogen/QtSubDir2/CMakeLists.txt index a2f77e4..cccb1e0 100644 --- a/Tests/RunCMake/Ninja/QtSubDir2/CMakeLists.txt +++ b/Tests/RunCMake/Autogen/QtSubDir2/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_policy(SET CMP0116 NEW) add_executable(sub_exe_2 ../app.cpp) -target_link_libraries(sub_exe_2 PRIVATE ${QtX}::Core) +target_link_libraries(sub_exe_2 PRIVATE Qt${with_qt_version}::Core) diff --git a/Tests/RunCMake/Autogen/QtSubDir3/CMakeLists.txt b/Tests/RunCMake/Autogen/QtSubDir3/CMakeLists.txt new file mode 100644 index 0000000..d268bfe --- /dev/null +++ b/Tests/RunCMake/Autogen/QtSubDir3/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(sub_exe_3 ../app.cpp) +target_link_libraries(sub_exe_3 PRIVATE Qt${with_qt_version}::Core) diff --git a/Tests/RunCMake/Autogen/RccExample.cmake b/Tests/RunCMake/Autogen/RccExample.cmake new file mode 100644 index 0000000..4554eb0 --- /dev/null +++ b/Tests/RunCMake/Autogen/RccExample.cmake @@ -0,0 +1,11 @@ +enable_language(CXX) + +set(CMAKE_CXX_STANDARD 11) +find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets Gui) + +add_library(dummy STATIC example.cpp data.qrc) +target_link_libraries(dummy Qt${with_qt_version}::Core + Qt${with_qt_version}::Widgets + Qt${with_qt_version}::Gui) + +set_target_properties(dummy PROPERTIES AUTORCC ON) diff --git a/Tests/RunCMake/Autogen/RunCMakeTest.cmake b/Tests/RunCMake/Autogen/RunCMakeTest.cmake index 4fe9406..38987b9 100644 --- a/Tests/RunCMake/Autogen/RunCMakeTest.cmake +++ b/Tests/RunCMake/Autogen/RunCMakeTest.cmake @@ -122,4 +122,336 @@ if (DEFINED with_qt_version) endblock() endif() endif() + + if(RunCMake_GENERATOR MATCHES "Make|Ninja") + block() + if(QtCore_VERSION VERSION_GREATER_EQUAL 5.15.0) + if (RunCMake_GENERATOR MATCHES "Ninja Multi-Config") + set(config_list Debug Release RelWithDebInfo) + else() + set(config_list single-config) + endif() + foreach(config IN ITEMS ${config_list}) + block() + if (config STREQUAL "single-config") + set(config_suffix "") + else() + set(config_suffix "_${config}") + endif() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/QtAutoMocDeps${config_suffix}-build) + run_cmake(QtAutoMocDeps) + set(RunCMake_TEST_NO_CLEAN 1) + # Build the project. + if (config STREQUAL "single-config") + set(config_param "") + else() + set(config_param "--config ${config}") + endif() + run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose ${config_param}) + # Touch just the library source file, which shouldn't cause a rerun of AUTOMOC + # for app_with_qt target. + file(TOUCH "${RunCMake_SOURCE_DIR}/simple_lib.cpp") + set(RunCMake_TEST_NOT_EXPECT_stdout "Automatic MOC for target app_with_qt|\ +Automatic MOC for target sub_exe_1|\ +Automatic MOC for target sub_exe_2") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-Don't execute AUTOMOC for 'app_with_qt', 'sub_exe_1' and 'sub_exe_2'") + # Build and assert that AUTOMOC was not run for app_with_qt, sub_exe_1 and sub_exe_2. + run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose ${config_param}) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + unset(RunCMake_TEST_NOT_EXPECT_stdout) + + macro(check_file_exists file) + if (EXISTS "${file}") + set(check_result "PASSED") + set(message_type "STATUS") + else() + set(check_result "FAILED") + set(message_type "FATAL_ERROR") + endif() + + message(${message_type} "QtAutoMocDeps-build-\"${file}\" was generated - ${check_result}") + endmacro() + + check_file_exists("${RunCMake_TEST_BINARY_DIR}/app_with_qt_autogen/deps${config_suffix}") + check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir1/sub_exe_1_autogen/deps${config_suffix}") + check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir2/sub_exe_2_autogen/deps${config_suffix}") + + check_file_exists("${RunCMake_TEST_BINARY_DIR}/app_with_qt_autogen/timestamp${config_suffix}") + check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir1/sub_exe_1_autogen/timestamp${config_suffix}") + check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir2/sub_exe_2_autogen/timestamp${config_suffix}") + + # Touch a header file to make sure an automoc dependency cycle is not introduced. + file(TOUCH "${RunCMake_SOURCE_DIR}/MyWindow.h") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-First build after touch to detect dependency cycle") + run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose) + # Need to run a second time to hit the dependency cycle. + set(RunCMake_TEST_VARIANT_DESCRIPTION "-Don't hit dependency cycle") + run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose) + endblock() + endforeach() + endif() + endblock() + endif() + + function(run_make_program dir) + execute_process( + COMMAND "${RunCMake_MAKE_PROGRAM}" ${ARGN} + WORKING_DIRECTORY "${dir}" + OUTPUT_VARIABLE make_program_stdout + ERROR_VARIABLE make_program_stderr + RESULT_VARIABLE make_program_result + ) + if (NOT DEFINED RunMakeProgram_expected_result) + set(RunMakeProgram_expected_result 0) + endif() + if(NOT "${make_program_result}" MATCHES "${RunMakeProgram_expected_result}") + message(STATUS " +============ beginning of ${RunCMake_MAKE_PROGRAM}'s stdout ============ +${make_program_stdout} +=============== end of ${RunCMake_MAKE_PROGRAM}'s stdout =============== +") + message(STATUS " +============ beginning of ${RunCMake_MAKE_PROGRAM}'s stderr ============ +${make_program_stderr} +=============== end of ${RunCMake_MAKE_PROGRAM}'s stderr =============== +") + message(FATAL_ERROR + "top ${RunCMake_MAKE_PROGRAM} build failed exited with status ${make_program_result}") + endif() + set(make_program_stdout "${make_program_stdout}" PARENT_SCOPE) + endfunction(run_make_program) + + function(count_substring STRING SUBSTRING COUNT_VAR) + string(LENGTH "${STRING}" STRING_LENGTH) + string(LENGTH "${SUBSTRING}" SUBSTRING_LENGTH) + if (SUBSTRING_LENGTH EQUAL 0) + message(FATAL_ERROR "SUBSTRING_LENGTH is 0") + endif() + + if (STRING_LENGTH EQUAL 0) + message(FATAL_ERROR "STRING_LENGTH is 0") + endif() + + if (STRING_LENGTH LESS SUBSTRING_LENGTH) + message(FATAL_ERROR "STRING_LENGTH is less than SUBSTRING_LENGTH") + endif() + + set(COUNT 0) + string(FIND "${STRING}" "${SUBSTRING}" SUBSTRING_START) + while(SUBSTRING_START GREATER_EQUAL 0) + math(EXPR COUNT "${COUNT} + 1") + math(EXPR SUBSTRING_START "${SUBSTRING_START} + ${SUBSTRING_LENGTH}") + string(SUBSTRING "${STRING}" ${SUBSTRING_START} -1 STRING) + string(FIND "${STRING}" "${SUBSTRING}" SUBSTRING_START) + endwhile() + + set(${COUNT_VAR} ${COUNT} PARENT_SCOPE) + endfunction() + + function(expect_only_once make_program_stdout expected_output test_name) + count_substring("${make_program_stdout}" "${expected_output}" count) + if(NOT count EQUAL 1) + message(STATUS "${test_name}-expect_only_once - FAILED") + message(FATAL_ERROR "Expected to find ${expected_output} exactly once in ${make_program_stdout} but found ${count} occurrences of ${expected_output}") + else() + message(STATUS "${test_name}-expect_only_once - PASSED") + endif() + endfunction() + + function(expect_n_times string_to_check expected_output expected_count test_name) + count_substring("${string_to_check}" "${expected_output}" count) + if(NOT count EQUAL ${expected_count}) + message(STATUS "${test_name}-expect_${expected_count}_times - FAILED") + message(FATAL_ERROR "Expected to find ${expected_output} exactly ${expected_count} times in ${string_to_check} but found ${count} occurrences of ${expected_output}") + else() + message(STATUS "${test_name}-expect_${expected_count}_times - PASSED") + endif() + endfunction() + + function(not_expect make_program_stdout unexpected_output test_name) + count_substring("${make_program_stdout}" "${unexpected_output}" count) + if(NOT count EQUAL 0) + message(STATUS "${test_name}-not_expect - FAILED") + message(FATAL_ERROR "Expected to find ${unexpected_output} exactly 0 times in ${make_program_stdout} but found ${count} occurrences of ${unexpected_output}") + else() + message(STATUS "${test_name}-not_expect - PASSED") + endif() + endfunction() + + if (QtCore_VERSION VERSION_GREATER_EQUAL 5.15.0) + foreach(exe IN ITEMS Moc Uic Rcc) + if(RunCMake_GENERATOR MATCHES "Ninja Multi-Config") + block() + set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMake-configure") + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig-multi-config-build) + run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + set(RunCMake_TEST_NO_CLEAN 1) + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + set(RunCMake_TEST_EXPECT_stdout ".*running_exe_${config}*") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}-expect_running_exe_${config}") + run_cmake_command(Auto${exe}ExecutableConfig-multi-config-build ${CMAKE_COMMAND} --build . --config ${config}) + endblock() + endforeach() + set(RunCMake_TEST_EXPECT_stdout "ninja: no work to do") + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}-expect_no_work_to_do") + run_cmake_command(Auto${exe}ExecutableConfig-multi-config-build ${CMAKE_COMMAND} --build . --config ${config}) + endblock() + endforeach() + endblock() + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig-build) + run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON) + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + run_make_program(${RunCMake_TEST_BINARY_DIR} --verbose -f build-${config}.ninja) + + set(expected_output "running_exe_${config}") + expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig-${config}-${expected_output}") + + foreach(sub_config IN ITEMS Debug Release RelWithDebInfo) + if(NOT sub_config STREQUAL config) + set(unexpected_output "running_exe_${sub_config}") + not_expect("${make_program_stdout}" "${unexpected_output}" "Auto${exe}ExecutableConfig-${config}-${unexpected_output}") + endif() + endforeach() + + if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") + set(expected_output "cmake_autogen") + else() + set(expected_output "cmake_autorcc") + endif() + expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig-${config}-${expected_output}") + endblock() + endforeach() + endblock() + block() + foreach(ninja_config IN ITEMS Debug Release RelWithDebInfo) + foreach(target_config IN ITEMS Debug Release RelWithDebInfo) + block() + set(TEST_SUFFIX "-CrossConfig-${ninja_config}-${target_config}") + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig${TEST_SUFFIX}-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION ${TEST_SUFFIX}) + run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_CROSS_CONFIGS=all -DCMAKE_DEFAULT_BUILD_TYPE=${ninja_config}) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + + run_make_program(${RunCMake_TEST_BINARY_DIR} --verbose -f build-${ninja_config}.ninja dummy:${target_config}) + + set(expected_output "running_exe_${ninja_config}") + expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig${TEST_SUFFIX}-${expected_output}") + + foreach(sub_config IN ITEMS Debug Release RelWithDebInfo) + if(NOT sub_config STREQUAL ninja_config) + set(unexpected_output "running_exe_${sub_config}") + not_expect("${make_program_stdout}" "${unexpected_output}" "Auto${exe}ExecutableConfig${TEST_SUFFIX}-${unexpected_output}") + endif() + endforeach() + + if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") + set(expected_output "cmake_autogen") + else() + set(expected_output "cmake_autorcc") + endif() + expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig${TEST_SUFFIX}-${expected_output}") + endblock() + endforeach() + endforeach() + endblock() + block() + foreach(ninja_config IN ITEMS Debug Release RelWithDebInfo) + set(TEST_SUFFIX "-CrossConfig-${ninja_config}-all-all") + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig${TEST_SUFFIX}-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION ${TEST_SUFFIX}) + run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_CROSS_CONFIGS=all) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + run_make_program(${RunCMake_TEST_BINARY_DIR} --verbose -f build-${ninja_config}.ninja all:all) + endforeach() + endblock() + elseif (RunCMake_GENERATOR MATCHES "Ninja|Make") + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig-build) + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}") + run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_BUILD_TYPE=${config} -DCMAKE_AUTOGEN_VERBOSE=ON) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_EXPECT_stdout ".*running_exe_${config}*") + run_cmake_command(Auto${exe}ExecutableConfig-${config}-build ${CMAKE_COMMAND} --build .) + endblock() + endforeach() + endblock() + endif() + endforeach() + endif() + + # Visual Studio specific dependency tests + if (RunCMake_GENERATOR MATCHES "Visual Studio") + foreach(exe IN ITEMS Moc Uic Rcc) + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${exe}Example-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMake-configure") + run_cmake_with_options(${exe}Example ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + set(RunCMake_TEST_NO_CLEAN 1) + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}-first-build") + run_cmake_command(${exe}Example-build ${CMAKE_COMMAND} --build . --config ${config}) + endblock() + endforeach() + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") + set(RunCMake_TEST_NOT_EXPECT_stdout "Auto${exe}") + set(not_expect_descripton "Auto${exe}") + else () + set(RunCMake_TEST_NOT_EXPECT_stdout "qrc_data.cpp|Auto${exe}") + set(not_expect_descripton "qrc_data.cpp_and_Auto${exe}") + endif() + set(RunCMake_TEST_VARIANT_DESCRIPTION "-second-build-${config}_expect_no_${not_expect_descripton}") + run_cmake_command(${exe}Example-build ${CMAKE_COMMAND} --build . --config ${config}) + endblock() + endforeach() + endblock() + endforeach() + endif() + + if (RunCMake_GENERATOR MATCHES "Xcode") + foreach(exe IN ITEMS Moc Uic Rcc) + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${exe}Example-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMake-configure") + set(RunCMake_TEST_EXPECT_stderr ".*") + run_cmake_with_options(${exe}Example ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_MAKE_PROGRAM ${CMAKE_COMMAND}) + run_make_program(${RunCMake_TEST_BINARY_DIR} --build . --config Debug) + if (exe STREQUAL "Moc") + set(expected_count 16) + elseif (exe STREQUAL "Uic") + set(expected_count 4) + else() + set(expected_count 12) + endif() + expect_n_times("${make_program_stdout}" "Auto${exe}:" ${expected_count} "${exe}Example-build-Auto${exe}") + expect_n_times("${make_program_stdout}" "Auto${exe}:" ${expected_count} "${exe}Example-build-Auto${exe}") + + if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") + expect_n_times("${make_program_stdout}" "AutoGen:" 20 "${exe}Example-build-AutoGen:") + endif() + + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + run_make_program(${RunCMake_TEST_BINARY_DIR} --build . --config ${config}) + not_expect("${make_program_stdout}" "Auto${exe}" "${exe}Example-${config}_Auto${exe}") + not_expect("${make_program_stdout}" "AutoGen:" "${exe}Example-${config}_AutoGen") + endblock() + endforeach() + endblock() + endforeach() + endif() endif () diff --git a/Tests/RunCMake/Autogen/UicExample.cmake b/Tests/RunCMake/Autogen/UicExample.cmake new file mode 100644 index 0000000..4b1f8c1 --- /dev/null +++ b/Tests/RunCMake/Autogen/UicExample.cmake @@ -0,0 +1,11 @@ +enable_language(CXX) + +set(CMAKE_CXX_STANDARD 11) +find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets Gui) + +add_library(dummy STATIC example_ui.cpp uiA.ui) +target_link_libraries(dummy Qt${with_qt_version}::Core + Qt${with_qt_version}::Widgets + Qt${with_qt_version}::Gui) + +set_target_properties(dummy PROPERTIES AUTOUIC ON) diff --git a/Tests/RunCMake/Autogen/app.cpp b/Tests/RunCMake/Autogen/app.cpp new file mode 100644 index 0000000..57380e4 --- /dev/null +++ b/Tests/RunCMake/Autogen/app.cpp @@ -0,0 +1,6 @@ +int main(int argc, char* argv[]) +{ + (void)argc; + (void)argv; + return 0; +} diff --git a/Tests/RunCMake/Autogen/app_qt.cpp b/Tests/RunCMake/Autogen/app_qt.cpp new file mode 100644 index 0000000..302c672 --- /dev/null +++ b/Tests/RunCMake/Autogen/app_qt.cpp @@ -0,0 +1,11 @@ +#include <QObject> + +class Mango : public QObject +{ + Q_OBJECT +public: +Q_SIGNALS: + void eatFruit(); +}; + +#include "app_qt.moc" diff --git a/Tests/RunCMake/Autogen/data.qrc b/Tests/RunCMake/Autogen/data.qrc new file mode 100644 index 0000000..9bd068c --- /dev/null +++ b/Tests/RunCMake/Autogen/data.qrc @@ -0,0 +1,4 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/res/affine"> +</qresource> +</RCC> diff --git a/Tests/RunCMake/Autogen/example.cpp b/Tests/RunCMake/Autogen/example.cpp new file mode 100644 index 0000000..7f1a781 --- /dev/null +++ b/Tests/RunCMake/Autogen/example.cpp @@ -0,0 +1,5 @@ +#include "example.h" + +Example::Example() +{ +} diff --git a/Tests/RunCMake/Autogen/example.h b/Tests/RunCMake/Autogen/example.h new file mode 100644 index 0000000..e8bfa42 --- /dev/null +++ b/Tests/RunCMake/Autogen/example.h @@ -0,0 +1,12 @@ +#ifndef EXAMPLE_H +#define EXAMPLE_H + +#include <QObject> + +class Example : public QObject +{ + Q_OBJECT + Example(); +}; + +#endif diff --git a/Tests/RunCMake/Autogen/example_ui.cpp b/Tests/RunCMake/Autogen/example_ui.cpp new file mode 100644 index 0000000..fb97c32 --- /dev/null +++ b/Tests/RunCMake/Autogen/example_ui.cpp @@ -0,0 +1,5 @@ +#include "example_ui.h" + +Example::Example() +{ +} diff --git a/Tests/RunCMake/Autogen/example_ui.h b/Tests/RunCMake/Autogen/example_ui.h new file mode 100644 index 0000000..d691133 --- /dev/null +++ b/Tests/RunCMake/Autogen/example_ui.h @@ -0,0 +1,14 @@ +#ifndef EXAMPLE_UI_H +#define EXAMPLE_UI_H + +#include <QObject> + +#include "ui_uiA.h" + +class Example : public QObject +{ + Q_OBJECT + Example(); +}; + +#endif diff --git a/Tests/RunCMake/Autogen/exe.cpp b/Tests/RunCMake/Autogen/exe.cpp new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/Autogen/exe.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/Autogen/exe_common.h b/Tests/RunCMake/Autogen/exe_common.h new file mode 100644 index 0000000..15311c6 --- /dev/null +++ b/Tests/RunCMake/Autogen/exe_common.h @@ -0,0 +1,48 @@ +#ifndef EXE_COMMON_H +#define EXE_COMMON_H + +#include <cstdlib> +#include <fstream> +#include <string> +#include <vector> + +inline int runRealExe(const int argc, char** argv) +{ + std::vector<std::string> args; + std::string realMocPath; + std::string const pathArg = "EXE_PATH="; + std::string cmd; + if (argc > 1) { + for (int i = 1; i < argc; ++i) { + std::string const arg = argv[i]; + if (arg.find(pathArg) != std::string::npos) { + realMocPath = arg.substr(pathArg.length()); + // if EXE_PATH contains spaces, wrap it in quotes + if (realMocPath.find(" ") != std::string::npos) { + realMocPath = "\"" + realMocPath + "\""; + } + } else { + args.push_back(arg); + } + } + } +#ifdef _WIN32 + cmd += "cmd /C \""; +#endif + cmd += realMocPath + " "; + for (auto arg : args) { + // if arg contains spaces, wrap it in quotes + if (arg.find(' ') != std::string::npos) { + cmd += " \"" + arg + "\""; + } else { + cmd += " " + arg; + } + } +#ifdef _WIN32 + cmd += "\""; +#endif + std::cout << "Running real exe:" << cmd << std::endl; + return std::system(cmd.c_str()); +} + +#endif diff --git a/Tests/RunCMake/Autogen/exe_debug.cpp b/Tests/RunCMake/Autogen/exe_debug.cpp new file mode 100644 index 0000000..ae5185b --- /dev/null +++ b/Tests/RunCMake/Autogen/exe_debug.cpp @@ -0,0 +1,10 @@ +#include <fstream> +#include <iostream> + +#include "exe_common.h" + +int main(int argc, char* argv[]) +{ + std::cout << "running_exe_Debug\n"; + return runRealExe(argc, argv); +} diff --git a/Tests/RunCMake/Autogen/exe_release.cpp b/Tests/RunCMake/Autogen/exe_release.cpp new file mode 100644 index 0000000..384c992 --- /dev/null +++ b/Tests/RunCMake/Autogen/exe_release.cpp @@ -0,0 +1,10 @@ +#include <fstream> +#include <iostream> + +#include "exe_common.h" + +int main(int argc, char* argv[]) +{ + std::cout << "running_exe_Release\n"; + return runRealExe(argc, argv); +} diff --git a/Tests/RunCMake/Autogen/exe_relwithdebinfo.cpp b/Tests/RunCMake/Autogen/exe_relwithdebinfo.cpp new file mode 100644 index 0000000..aa6c558 --- /dev/null +++ b/Tests/RunCMake/Autogen/exe_relwithdebinfo.cpp @@ -0,0 +1,10 @@ +#include <fstream> +#include <iostream> + +#include "exe_common.h" + +int main(int argc, char* argv[]) +{ + std::cout << "running_exe_RelWithDebInfo\n"; + return runRealExe(argc, argv); +} diff --git a/Tests/RunCMake/Autogen/simple_lib.cpp b/Tests/RunCMake/Autogen/simple_lib.cpp new file mode 100644 index 0000000..cf8d689 --- /dev/null +++ b/Tests/RunCMake/Autogen/simple_lib.cpp @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + void dummy_symbol() +{ +} diff --git a/Tests/RunCMake/Autogen/uiA.ui b/Tests/RunCMake/Autogen/uiA.ui new file mode 100644 index 0000000..4c5762e --- /dev/null +++ b/Tests/RunCMake/Autogen/uiA.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UiA</class> + <widget class="QWidget" name="UiA"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/RunCMake/BuildDepends/FortranInclude.cmake b/Tests/RunCMake/BuildDepends/FortranInclude.cmake index fa9f399..ad5fd0a 100644 --- a/Tests/RunCMake/BuildDepends/FortranInclude.cmake +++ b/Tests/RunCMake/BuildDepends/FortranInclude.cmake @@ -1,5 +1,10 @@ enable_language(Fortran) +if("${CMAKE_Fortran_COMPILER_ID};${CMAKE_Fortran_SIMULATE_ID}" MATCHES "^Intel(LLVM)?;MSVC$") + string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -Z7") + string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO " -Z7") +endif() + set(check_pairs "") add_executable(preprocess FortranIncludePreprocess.F) diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt index 7230a07..07c17e2 100644 --- a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt +++ b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt @@ -6,7 +6,7 @@ Some library files are in directories implicitly searched by the linker when invoked for C: - .*/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-build/lib/(lib)?CMP0060.(a|lib) + .*/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-build/lib/(lib)?CMP0060.(a|lib|l) For compatibility with older versions of CMake, the generated link line will ask the linker to search for these by library name. diff --git a/Tests/RunCMake/CMP0111/CMP0111-Common.cmake b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake index c31e4ba..ab9e405 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-Common.cmake +++ b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake @@ -1,6 +1,3 @@ -# Prevent duplicate errors on some platforms. -set(CMAKE_IMPORT_LIBRARY_SUFFIX "placeholder") - add_library(unknown_lib UNKNOWN IMPORTED) add_library(static_lib STATIC IMPORTED) add_library(shared_lib SHARED IMPORTED) diff --git a/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt index 91a90e5..c6439e2 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt +++ b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt @@ -1,17 +1,6 @@ -^CMake Error in CMakeLists.txt: - IMPORTED_LOCATION not set for imported target "unknown_lib"( configuration +^(CMake Error in CMakeLists.txt: + IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static)_lib"( configuration "[^"]+")?. -+ -CMake Error in CMakeLists.txt: - IMPORTED_LOCATION not set for imported target "static_lib"( configuration - "[^"]+")?. -+ -CMake Error in CMakeLists.txt: - IMPORTED_IMPLIB not set for imported target "shared_lib"( configuration - "[^"]+")?.( -+ -CMake Error in CMakeLists.txt: - IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static|shared)_lib"( configuration - "[^"]+")?.)* -+ +)+ +.*(IMPORTED_LOCATION or )?IMPORTED_IMPLIB not set for imported target.*"shared_lib".* CMake Generate step failed. Build files cannot be regenerated correctly.$ diff --git a/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt index 27af911..7a46c41 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt @@ -1,39 +1,19 @@ -^CMake Warning \(dev\) in CMakeLists.txt: +^(CMake Warning \(dev\) in CMakeLists.txt: Policy CMP0111 is not set: An imported target missing its location property fails during generation. Run "cmake --help-policy CMP0111" for policy details. Use the cmake_policy command to set the policy and suppress this warning. - IMPORTED_LOCATION not set for imported target "unknown_lib"( configuration + IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static)_lib"( configuration "[^"]+")?. This warning is for project developers. Use -Wno-dev to suppress it. -+ -CMake Warning \(dev\) in CMakeLists.txt: ++)+CMake Warning \(dev\) in CMakeLists.txt: Policy CMP0111 is not set: An imported target missing its location property fails during generation. Run "cmake --help-policy CMP0111" for policy details. Use the cmake_policy command to set the policy and suppress this warning. - IMPORTED_LOCATION not set for imported target "static_lib"( configuration + IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static)_lib"( configuration "[^"]+")?. -This warning is for project developers. Use -Wno-dev to suppress it. -+ -CMake Warning \(dev\) in CMakeLists.txt: - Policy CMP0111 is not set: An imported target missing its location property - fails during generation. Run "cmake --help-policy CMP0111" for policy - details. Use the cmake_policy command to set the policy and suppress this - warning. - - IMPORTED_IMPLIB not set for imported target "shared_lib"( configuration - "[^"]+")?. -This warning is for project developers. Use -Wno-dev to suppress it.( -+ -CMake Warning \(dev\) in CMakeLists.txt: - Policy CMP0111 is not set: An imported target missing its location property - fails during generation. Run "cmake --help-policy CMP0111" for policy - details. Use the cmake_policy command to set the policy and suppress this - warning. - - IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static|shared)_lib"( configuration - "[^"]+")?. -This warning is for project developers. Use -Wno-dev to suppress it.)*$ +.*(IMPORTED_LOCATION or )?IMPORTED_IMPLIB not set for imported target.*"shared_lib".* +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMP0115/CMP0115-OLD-stderr.txt b/Tests/RunCMake/CMP0115/CMP0115-OLD-stderr.txt index 67d00f7..3472f33 100644 --- a/Tests/RunCMake/CMP0115/CMP0115-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0115/CMP0115-OLD-stderr.txt @@ -1,4 +1,13 @@ -^CMake Error at CMP0115\.cmake:[0-9]+ \(add_executable\): +^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\): + The OLD behavior for policy CMP0115 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. ++ +CMake Error at CMP0115\.cmake:[0-9]+ \(add_executable\): Cannot find source file: noexist diff --git a/Tests/RunCMake/CMP0116/CMP0116-Mixed-stderr.txt b/Tests/RunCMake/CMP0116/CMP0116-Mixed-stderr.txt index 10e83a9..930dd3c 100644 --- a/Tests/RunCMake/CMP0116/CMP0116-Mixed-stderr.txt +++ b/Tests/RunCMake/CMP0116/CMP0116-Mixed-stderr.txt @@ -1,4 +1,15 @@ -^CMake Warning \(dev\) at CMP0116-Mixed\.cmake:1 \(add_custom_command\): +^CMake Deprecation Warning at CMP0116-Mixed\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0116 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Warning \(dev\) at CMP0116-Mixed\.cmake:1 \(add_custom_command\): Policy CMP0116 is not set: Ninja generators transform DEPFILEs from add_custom_command\(\)\. Run "cmake --help-policy CMP0116" for policy details\. Use the cmake_policy command to set the policy and suppress this diff --git a/Tests/RunCMake/CMP0116/CMP0116-OLD-NOWARN-stderr.txt b/Tests/RunCMake/CMP0116/CMP0116-OLD-NOWARN-stderr.txt new file mode 100644 index 0000000..887601c --- /dev/null +++ b/Tests/RunCMake/CMP0116/CMP0116-OLD-NOWARN-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\): + The OLD behavior for policy CMP0116 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\.$ diff --git a/Tests/RunCMake/CMP0116/CMP0116-OLD-WARN-stderr.txt b/Tests/RunCMake/CMP0116/CMP0116-OLD-WARN-stderr.txt new file mode 100644 index 0000000..887601c --- /dev/null +++ b/Tests/RunCMake/CMP0116/CMP0116-OLD-WARN-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at CMakeLists\.txt:[0-9]+ \(cmake_minimum_required\): + The OLD behavior for policy CMP0116 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\.$ diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test1-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test1-stderr.txt index 2af72a4..9285f9d 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test1-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test1-stderr.txt @@ -1,4 +1,15 @@ -^prop: `0` +^CMake Deprecation Warning at CMP0118-OLD-Test1\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +prop: `0` CMake Error at CMP0118-Common-Test1\.cmake:[0-9]+ \(target_sources\): Cannot find source file: diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test10-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test10-stderr.txt index 6109f65..9bd3d33 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test10-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test10-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source0\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test10\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_source0\.txt: # 1a # GENERATED = `1` Generated_source0\.txt: # 1b # GENERATED = `1` Generated_source0\.txt: # 2a # GENERATED = `1` Generated_source0\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test11-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test11-stderr.txt index e5e97de..4730caf 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test11-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test11-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source0\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test11\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_source0\.txt: # 1a # GENERATED = `1` Generated_source0\.txt: # 1b # GENERATED = `1` Generated_source0\.txt: # 2a # GENERATED = `1` Generated_source0\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test12-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test12-stderr.txt index e6c429c..69a07e1 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test12-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test12-stderr.txt @@ -1,4 +1,15 @@ -^CMake Error at subdir-Common-Test12/CMakeLists\.txt:[0-9]+ \(add_custom_command\): +^CMake Deprecation Warning at CMP0118-OLD-Test12\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at subdir-Common-Test12/CMakeLists\.txt:[0-9]+ \(add_custom_command\): TARGET 'custom[4-6]' was not created in this directory\. + CMake Error at subdir-Common-Test12/CMakeLists\.txt:[0-9]+ \(add_custom_command\): diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test13-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test13-stderr.txt index 75dbf23..45c1dcb 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test13-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test13-stderr.txt @@ -1,4 +1,15 @@ -^CMake Error at subdir-Common-Test13/CMakeLists\.txt:[0-9]+ \(add_custom_command\): +^CMake Deprecation Warning at CMP0118-OLD-Test13\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at subdir-Common-Test13/CMakeLists\.txt:[0-9]+ \(add_custom_command\): TARGET 'custom[4-6]' was not created in this directory\. + CMake Error at subdir-Common-Test13/CMakeLists\.txt:[0-9]+ \(add_custom_command\): diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test14-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test14-stderr.txt index f5b3d1a..7ade0cf 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test14-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test14-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source0\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test14\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_source0\.txt: # 1a # GENERATED = `1` Generated_source0\.txt: # 1b # GENERATED = `1` Generated_source0\.txt: # 2a # GENERATED = `1` Generated_source0\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test15-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test15-stderr.txt index a30bc84..5735539 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test15-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test15-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source0\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test15\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_source0\.txt: # 1a # GENERATED = `1` Generated_source0\.txt: # 1b # GENERATED = `1` Generated_source0\.txt: # 2a # GENERATED = `1` Generated_source0\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test2-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test2-stderr.txt index 403ce5a..74eb3e1 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test2-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test2-stderr.txt @@ -1 +1,12 @@ -^prop: `1`$ +^CMake Deprecation Warning at CMP0118-OLD-Test2\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +prop: `1`$ diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3-stderr.txt index 4f4fea3..cce5b19 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3-stderr.txt @@ -1,4 +1,15 @@ -^Generated_with_full_path1\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test3\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_with_full_path1\.txt: # 1a # GENERATED = `1` Generated_with_full_path1\.txt: # 1b # GENERATED = `1` Generated_with_full_path1\.txt: # 2a # GENERATED = `1` Generated_with_full_path1\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3b-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3b-stderr.txt index 3c80531..47eee2e 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3b-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test3b-stderr.txt @@ -1,4 +1,15 @@ -^Generated_with_full_path1\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test3b\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_with_full_path1\.txt: # 1a # GENERATED = `1` Generated_with_full_path1\.txt: # 1b # GENERATED = `1` Generated_with_full_path1\.txt: # 2a # GENERATED = `1` Generated_with_full_path1\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4-stderr.txt index 9600fee..f17c9be 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4-stderr.txt @@ -1,4 +1,15 @@ -^Generated_with_full_path1\.txt: # 1a # GENERATED = `0` +^CMake Deprecation Warning at CMP0118-OLD-Test4\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_with_full_path1\.txt: # 1a # GENERATED = `0` Generated_with_full_path1\.txt: # 1b # GENERATED = `0` Generated_with_full_path1\.txt: # 2a # GENERATED = `0` Generated_with_full_path1\.txt: # 2b # GENERATED = `0` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4b-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4b-stderr.txt index e638660..388e90e 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4b-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test4b-stderr.txt @@ -1,4 +1,15 @@ -^Generated_with_full_path1\.txt: # 1a # GENERATED = `0` +^CMake Deprecation Warning at CMP0118-OLD-Test4b\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_with_full_path1\.txt: # 1a # GENERATED = `0` Generated_with_full_path1\.txt: # 1b # GENERATED = `0` Generated_with_full_path1\.txt: # 2a # GENERATED = `0` Generated_with_full_path1\.txt: # 2b # GENERATED = `0` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test5-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test5-stderr.txt index 18e6a8c..4a67fa7 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test5-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test5-stderr.txt @@ -1,4 +1,15 @@ -^Generated_with_full_path1\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test5\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_with_full_path1\.txt: # 1a # GENERATED = `1` Generated_with_full_path1\.txt: # 1b # GENERATED = `1` Generated_with_full_path1\.txt: # 2a # GENERATED = `1` Generated_with_full_path1\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test6-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test6-stderr.txt index a60545f..0cad373 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test6-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test6-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source1\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test6\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_source1\.txt: # 1a # GENERATED = `1` Generated_source1\.txt: # 1b # GENERATED = `1` Generated_source1\.txt: # 2a # GENERATED = `1` Generated_source1\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test7-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test7-stderr.txt index fd496cb..7f232d5 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test7-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test7-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source1\.txt: # 1a # GENERATED = `1` +^CMake Deprecation Warning at CMP0118-OLD-Test7\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_source1\.txt: # 1a # GENERATED = `1` Generated_source1\.txt: # 1b # GENERATED = `1` Generated_source1\.txt: # 2a # GENERATED = `1` Generated_source1\.txt: # 2b # GENERATED = `1` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test8-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test8-stderr.txt index 3505242..dd9d2ef 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test8-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test8-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source1\.txt: # 1a # GENERATED = `0` +^CMake Deprecation Warning at CMP0118-OLD-Test8\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_source1\.txt: # 1a # GENERATED = `0` Generated_source1\.txt: # 1b # GENERATED = `0` Generated_source1\.txt: # 2a # GENERATED = `0` Generated_source1\.txt: # 2b # GENERATED = `0` diff --git a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test9-stderr.txt b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test9-stderr.txt index 63a9341..e01f782 100644 --- a/Tests/RunCMake/CMP0118/CMP0118-OLD-Test9-stderr.txt +++ b/Tests/RunCMake/CMP0118/CMP0118-OLD-Test9-stderr.txt @@ -1,4 +1,15 @@ -^Generated_source1\.txt: # 1a # GENERATED = `0` +^CMake Deprecation Warning at CMP0118-OLD-Test9\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +Generated_source1\.txt: # 1a # GENERATED = `0` Generated_source1\.txt: # 1b # GENERATED = `0` Generated_source1\.txt: # 2a # GENERATED = `0` Generated_source1\.txt: # 2b # GENERATED = `0` diff --git a/Tests/RunCMake/CMP0118/GenInSubdir-OLD-stderr.txt b/Tests/RunCMake/CMP0118/GenInSubdir-OLD-stderr.txt index 5e9cf6c..2fc472b 100644 --- a/Tests/RunCMake/CMP0118/GenInSubdir-OLD-stderr.txt +++ b/Tests/RunCMake/CMP0118/GenInSubdir-OLD-stderr.txt @@ -1,4 +1,15 @@ -^CMake Error at GenInSubdir/CMakeLists\.txt:[0-9]+ \(target_sources\): +^CMake Deprecation Warning at GenInSubdir-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0118 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at GenInSubdir/CMakeLists\.txt:[0-9]+ \(target_sources\): Cannot find source file: [^ diff --git a/Tests/RunCMake/CMP0119/CMP0119-OLD-stderr.txt b/Tests/RunCMake/CMP0119/CMP0119-OLD-stderr.txt new file mode 100644 index 0000000..86eac41 --- /dev/null +++ b/Tests/RunCMake/CMP0119/CMP0119-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0119-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0119 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0119/RunCMakeTest.cmake b/Tests/RunCMake/CMP0119/RunCMakeTest.cmake index 7395827..2576a28 100644 --- a/Tests/RunCMake/CMP0119/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0119/RunCMakeTest.cmake @@ -8,10 +8,10 @@ function(run_CMP0119 status) endfunction() if(NOT RunCMake_GENERATOR MATCHES "Visual Studio|Xcode" AND - NOT CMAKE_C_COMPILER_ID MATCHES "(Borland|Embarcadero|Watcom)") + NOT CMAKE_C_COMPILER_ID MATCHES "(Borland|Embarcadero|Watcom|OrangeC)") run_CMP0119(WARN) run_CMP0119(OLD) endif() -if((CMAKE_C_COMPILER_ID MATCHES "(GNU|LCC|Clang|MSVC|Borland|Embarcadero|Intel|TI)")) +if((CMAKE_C_COMPILER_ID MATCHES "(GNU|LCC|Clang|MSVC|Borland|Embarcadero|Intel|TI|OrangeC)")) run_CMP0119(NEW) endif() diff --git a/Tests/RunCMake/CMP0152/CMP0152-Common.cmake b/Tests/RunCMake/CMP0152/CMP0152-Common.cmake new file mode 100644 index 0000000..6429cca --- /dev/null +++ b/Tests/RunCMake/CMP0152/CMP0152-Common.cmake @@ -0,0 +1,5 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dir/") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dir/nested/") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dir/nested/bin/") +file(CREATE_LINK "${CMAKE_CURRENT_BINARY_DIR}/dir/nested/bin" "${CMAKE_CURRENT_BINARY_DIR}/dir/bin" SYMBOLIC) +file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/dir/bin/../" real_path) diff --git a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON.cmake b/Tests/RunCMake/CMP0152/CMP0152-NEW-stdout.txt index e69de29..e69de29 100644 --- a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON.cmake +++ b/Tests/RunCMake/CMP0152/CMP0152-NEW-stdout.txt diff --git a/Tests/RunCMake/CMP0152/CMP0152-NEW.cmake b/Tests/RunCMake/CMP0152/CMP0152-NEW.cmake new file mode 100644 index 0000000..86a3b55 --- /dev/null +++ b/Tests/RunCMake/CMP0152/CMP0152-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0152 NEW) +include(CMP0152-Common.cmake) diff --git a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-OFF.cmake b/Tests/RunCMake/CMP0152/CMP0152-OLD-stderr.txt index e69de29..e69de29 100644 --- a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-OFF.cmake +++ b/Tests/RunCMake/CMP0152/CMP0152-OLD-stderr.txt diff --git a/Tests/RunCMake/CMP0152/CMP0152-OLD.cmake b/Tests/RunCMake/CMP0152/CMP0152-OLD.cmake new file mode 100644 index 0000000..62ac300 --- /dev/null +++ b/Tests/RunCMake/CMP0152/CMP0152-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0152 OLD) +include(CMP0152-Common.cmake) diff --git a/Tests/RunCMake/CMP0152/CMP0152-WARN-stderr.txt b/Tests/RunCMake/CMP0152/CMP0152-WARN-stderr.txt new file mode 100644 index 0000000..8d63168 --- /dev/null +++ b/Tests/RunCMake/CMP0152/CMP0152-WARN-stderr.txt @@ -0,0 +1,27 @@ +^CMake Warning \(dev\) at CMP0152-Common\.cmake:[0-9]+ \(file\): + Policy CMP0152 is not set: file\(REAL_PATH\) resolves symlinks before + collapsing \.\./ components\. Run "cmake --help-policy CMP0152" for policy + details\. Use the cmake_policy command to set the policy and suppress this + warning\. + + From input path: + + [^ +]*/Tests/RunCMake/CMP0152/CMP0152-WARN-build/dir/bin/\.\./ + + the policy OLD behavior produces path: + + [^ +]*/Tests/RunCMake/CMP0152/CMP0152-WARN-build/dir + + but the policy NEW behavior produces path: + + [^ +]*/Tests/RunCMake/CMP0152/CMP0152-WARN-build/dir/nested + + Since the policy is not set, CMake is using the OLD behavior for + compatibility. +Call Stack \(most recent call first\): + CMP0152-WARN\.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers\. Use -Wno-dev to suppress it\.$ diff --git a/Tests/RunCMake/CMP0152/CMP0152-WARN.cmake b/Tests/RunCMake/CMP0152/CMP0152-WARN.cmake new file mode 100644 index 0000000..e85589e --- /dev/null +++ b/Tests/RunCMake/CMP0152/CMP0152-WARN.cmake @@ -0,0 +1,2 @@ + +include(CMP0152-Common.cmake) diff --git a/Tests/RunCMake/CMP0152/CMakeLists.txt b/Tests/RunCMake/CMP0152/CMakeLists.txt new file mode 100644 index 0000000..5ff8d3e --- /dev/null +++ b/Tests/RunCMake/CMP0152/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.23) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0152/RunCMakeTest.cmake b/Tests/RunCMake/CMP0152/RunCMakeTest.cmake new file mode 100644 index 0000000..7a9bab3 --- /dev/null +++ b/Tests/RunCMake/CMP0152/RunCMakeTest.cmake @@ -0,0 +1,7 @@ +include(RunCMake) + +if(NOT CMAKE_GENERATOR_NO_COMPILER_ENV) + run_cmake(CMP0152-WARN) + run_cmake(CMP0152-OLD) + run_cmake(CMP0152-NEW) +endif() diff --git a/Tests/RunCMake/CMP0153/CMP0153-NEW-result.txt b/Tests/RunCMake/CMP0153/CMP0153-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0153/CMP0153-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt b/Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt new file mode 100644 index 0000000..e24eee7 --- /dev/null +++ b/Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt @@ -0,0 +1,3 @@ +^CMake Error at [^ +]*/Tests/RunCMake/CMP0153/CMP0153-NEW\.cmake:[0-9]+ \(exec_program\): + The exec_program command should not be called; see CMP0153\.$ diff --git a/Tests/RunCMake/CMP0153/CMP0153-NEW-stdout.txt b/Tests/RunCMake/CMP0153/CMP0153-NEW-stdout.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0153/CMP0153-NEW-stdout.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0153/CMP0153-NEW.cmake b/Tests/RunCMake/CMP0153/CMP0153-NEW.cmake new file mode 100644 index 0000000..d252b46 --- /dev/null +++ b/Tests/RunCMake/CMP0153/CMP0153-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0153 NEW) +exec_program("${CMAKE_COMMAND}" ARGS "-E echo \"exec_program() called\"") diff --git a/Tests/RunCMake/CMP0153/CMP0153-OLD-stdout.txt b/Tests/RunCMake/CMP0153/CMP0153-OLD-stdout.txt new file mode 100644 index 0000000..1aa5183 --- /dev/null +++ b/Tests/RunCMake/CMP0153/CMP0153-OLD-stdout.txt @@ -0,0 +1 @@ +exec_program\(\) called diff --git a/Tests/RunCMake/CMP0153/CMP0153-OLD.cmake b/Tests/RunCMake/CMP0153/CMP0153-OLD.cmake new file mode 100644 index 0000000..d3c47a7 --- /dev/null +++ b/Tests/RunCMake/CMP0153/CMP0153-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0153 OLD) +exec_program("${CMAKE_COMMAND}" ARGS "-E echo \"exec_program() called\"") diff --git a/Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt b/Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt new file mode 100644 index 0000000..8f22d4e --- /dev/null +++ b/Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt @@ -0,0 +1,6 @@ +^CMake Warning \(dev\) at [^ +]*/Tests/RunCMake/CMP0153/CMP0153-WARN\.cmake:[0-9]+ \(exec_program\): + Policy CMP0153 is not set: The exec_program command should not be called\. + Run "cmake --help-policy CMP0153" for policy details\. Use the cmake_policy + command to set the policy and suppress this warning\. +This warning is for project developers\. Use -Wno-dev to suppress it\.$ diff --git a/Tests/RunCMake/CMP0153/CMP0153-WARN-stdout.txt b/Tests/RunCMake/CMP0153/CMP0153-WARN-stdout.txt new file mode 100644 index 0000000..1aa5183 --- /dev/null +++ b/Tests/RunCMake/CMP0153/CMP0153-WARN-stdout.txt @@ -0,0 +1 @@ +exec_program\(\) called diff --git a/Tests/RunCMake/CMP0153/CMP0153-WARN.cmake b/Tests/RunCMake/CMP0153/CMP0153-WARN.cmake new file mode 100644 index 0000000..ba81501 --- /dev/null +++ b/Tests/RunCMake/CMP0153/CMP0153-WARN.cmake @@ -0,0 +1 @@ +exec_program("${CMAKE_COMMAND}" ARGS "-E echo \"exec_program() called\"") diff --git a/Tests/RunCMake/CMP0153/CMakeLists.txt b/Tests/RunCMake/CMP0153/CMakeLists.txt new file mode 100644 index 0000000..922aad6 --- /dev/null +++ b/Tests/RunCMake/CMP0153/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.27) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0153/RunCMakeTest.cmake b/Tests/RunCMake/CMP0153/RunCMakeTest.cmake new file mode 100644 index 0000000..3d01dbf --- /dev/null +++ b/Tests/RunCMake/CMP0153/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCMake) + +function(run_cmp0153 name) + run_cmake_command(${name} ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/${name}.cmake") +endfunction() + +run_cmp0153(CMP0153-WARN) +run_cmp0153(CMP0153-OLD) +run_cmp0153(CMP0153-NEW) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 63b7568..4387c5b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -165,14 +165,21 @@ if(GIT_EXECUTABLE) add_RunCMake_test(CMP0150) endif() +if(NOT WIN32 OR CYGWIN) + add_RunCMake_test(CMP0152) +endif() + +add_RunCMake_test(CMP0153) + # The test for Policy 65 requires the use of the # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode # generators ignore. The policy will have no effect on those generators. if(NOT CMAKE_GENERATOR MATCHES "Visual Studio|Xcode") add_RunCMake_test(CMP0065 -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) endif() +add_executable(detect_jobserver detect_jobserver.c) if(CMAKE_GENERATOR MATCHES "Make") - add_RunCMake_test(Make -DMAKE_IS_GNU=${MAKE_IS_GNU}) + add_RunCMake_test(Make -DMAKE_IS_GNU=${MAKE_IS_GNU} -DDETECT_JOBSERVER=$<TARGET_FILE:detect_jobserver>) endif() unset(ninja_test_with_qt_version) unset(ninja_qt_args) @@ -194,6 +201,7 @@ elseif(CMake_TEST_Qt5) endif() if(CMAKE_GENERATOR MATCHES "Ninja") set(Ninja_ARGS + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} -DCMAKE_C_OUTPUT_EXTENSION=${CMAKE_C_OUTPUT_EXTENSION} -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX} -DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}) @@ -235,6 +243,9 @@ if(CMAKE_GENERATOR MATCHES "Ninja") add_RunCMake_test(NinjaMultiConfig) set_property(TEST RunCMake.NinjaMultiConfig APPEND PROPERTY LABELS "CUDA") + add_RunCMake_test(NinjaPrivateDeps + -DCMAKE_C_OUTPUT_EXTENSION=${CMAKE_C_OUTPUT_EXTENSION} + -DRunCMake_GENERATOR_IS_MULTI_CONFIG=${_isMultiConfig}) endif() add_RunCMake_test(CTest) @@ -267,6 +278,7 @@ if(CMake_TEST_Qt6 AND Qt6Widgets_FOUND) cmake_path(GET base_dir PARENT_PATH base_dir) # <base> add_RunCMake_test(AutogenQt6 TEST_DIR Autogen -Dwith_qt_version=6 + -DQtCore_VERSION=${Qt6Core_VERSION} "-DQt6_DIR:PATH=${Qt6_DIR}" "-DCMAKE_PREFIX_PATH:STRING=${base_dir}" -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy> @@ -279,6 +291,7 @@ endif () if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND) add_RunCMake_test(AutogenQt5 TEST_DIR Autogen -Dwith_qt_version=5 + -DQtCore_VERSION=${Qt5Core_VERSION} "-DQt5_DIR:PATH=${Qt5_DIR}" ) set(want_NoQt_test FALSE) @@ -363,7 +376,8 @@ if(CMake_TEST_FindOpenSSL) endif() if(CMake_TEST_UseSWIG) add_RunCMake_test(FindSWIG) - add_RunCMake_test(UseSWIG -DCMake_TEST_FindPython=${CMake_TEST_FindPython}) + add_RunCMake_test(UseSWIG -DCMake_TEST_FindPython2=${CMake_TEST_FindPython2} + -DCMake_TEST_FindPython3=${CMake_TEST_FindPython3}) endif() if(NOT CMAKE_C_COMPILER_ID MATCHES "Watcom") add_RunCMake_test(GenerateExportHeader) @@ -385,6 +399,7 @@ add_RunCMake_test(GenEx-PATH) add_RunCMake_test(GenEx-PATH_EQUAL) add_RunCMake_test(GenEx-LIST) add_RunCMake_test(GeneratorExpression) +add_RunCMake_test(GeneratorExpressionShortCircuit) add_RunCMake_test(GeneratorInstance) add_RunCMake_test(GeneratorPlatform) if(XCODE_VERSION) @@ -458,6 +473,7 @@ add_RunCMake_test(build_command) add_executable(exit_code exit_code.c) set(execute_process_ARGS -DEXIT_CODE_EXE=$<TARGET_FILE:exit_code> + -DPRINT_STDIN_EXE=$<TARGET_FILE:print_stdin> -DPython_EXECUTABLE=${Python_EXECUTABLE} ) if(NOT CMake_TEST_EXTERNAL_CMAKE) @@ -465,6 +481,9 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) endif() add_RunCMake_test(execute_process) add_RunCMake_test(export) +if(CMake_TEST_MSYSTEM_PREFIX) + list(APPEND cmake_host_system_information_ARGS -DCMake_TEST_MSYSTEM_PREFIX=${CMake_TEST_MSYSTEM_PREFIX}) +endif() add_RunCMake_test(cmake_host_system_information) add_RunCMake_test(cmake_language) add_RunCMake_test(cmake_minimum_required) @@ -506,10 +525,10 @@ foreach(var endforeach() add_RunCMake_test(file-DOWNLOAD) add_RunCMake_test(file-RPATH -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) -add_RunCMake_test(find_file) -add_RunCMake_test(find_library -DCYGWIN=${CYGWIN} -DMSYS=${MSYS}) -add_RunCMake_test(find_package -DMSYS=${MSYS}) -add_RunCMake_test(find_path) +add_RunCMake_test(find_file -DMINGW=${MINGW}) +add_RunCMake_test(find_library -DMINGW=${MINGW} -DCYGWIN=${CYGWIN} -DMSYS=${MSYS}) +add_RunCMake_test(find_package -DMINGW=${MINGW} -DMSYS=${MSYS}) +add_RunCMake_test(find_path -DMINGW=${MINGW}) add_RunCMake_test(find_program -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) add_RunCMake_test(foreach) add_RunCMake_test(function) @@ -528,6 +547,7 @@ add_RunCMake_test(option) add_RunCMake_test(PrintHelpers) add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES}) add_RunCMake_test(project_injected) +add_RunCMake_test(property_init) add_RunCMake_test(DependencyProviders) add_RunCMake_test(return) add_RunCMake_test(separate_arguments) @@ -625,8 +645,10 @@ else() message(STATUS "Could not find ctresalloc") endif() +get_filename_component(real_binary_dir "${CMake_BINARY_DIR}" REALPATH) if(NOT WIN32 AND NOT MSYS # FIXME: This works on CYGWIN but not on MSYS + AND real_binary_dir STREQUAL CMake_BINARY_DIR ) add_RunCMake_test(SymlinkTrees) endif () @@ -692,9 +714,27 @@ if(XCODE_VERSION) set_property(TEST RunCMake.XcodeProject PROPERTY TIMEOUT ${CMake_TEST_XcodeProject_TIMEOUT}) endif() -if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" +if((CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0) - add_RunCMake_test(Framework) + OR (APPLE AND CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)) + add_RunCMake_test(Framework -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) + if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND NOT DEFINED CMake_TEST_XcFramework) + set(CMake_TEST_XcFramework ON) + endif() + if(CMake_TEST_XcFramework AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 11.0) + set(XcFramework_ARGS -DCMake_TEST_XCODE_VERSION=${CMake_TEST_XCODE_VERSION}) + add_RunCMake_test(XcFramework) + + # This test can take a very long time due to lots of combinations. + # Use a long default timeout and provide an option to customize it. + if(NOT DEFINED CMake_TEST_XcFramework_TIMEOUT) + set(CMake_TEST_XcFramework_TIMEOUT 3000) + endif() + set_tests_properties(RunCMake.XcFramework PROPERTIES + TIMEOUT "${CMake_TEST_XcFramework_TIMEOUT}" + RUN_SERIAL TRUE + ) + endif() endif() add_RunCMake_test(File_Archive) @@ -825,7 +865,7 @@ endif() if(CMake_TEST_RunCMake_ExternalProject_DOWNLOAD_SERVER_TIMEOUT) list(APPEND ExternalProject_ARGS -DDOWNLOAD_SERVER_TIMEOUT=${CMake_TEST_RunCMake_ExternalProject_DOWNLOAD_SERVER_TIMEOUT}) endif() -add_RunCMake_test(ExternalProject) +add_RunCMake_test(ExternalProject -DDETECT_JOBSERVER=$<TARGET_FILE:detect_jobserver>) add_RunCMake_test(FetchContent) add_RunCMake_test(FetchContent_find_package) set(CTestCommandLine_ARGS -DPython_EXECUTABLE=${Python_EXECUTABLE}) @@ -1038,6 +1078,7 @@ add_RunCMake_test(CMakePresetsWorkflow ) add_RunCMake_test(VerifyHeaderSets) +add_RunCMake_test(set_tests_properties) if(${CMAKE_GENERATOR} MATCHES "Make|Ninja") add_RunCMake_test(TransformDepfile) diff --git a/Tests/RunCMake/CMakePresets/GoodNoSCache.cmake b/Tests/RunCMake/CMakePresets/GoodNoSCache.cmake index d9e399f..df58e72 100644 --- a/Tests/RunCMake/CMakePresets/GoodNoSCache.cmake +++ b/Tests/RunCMake/CMakePresets/GoodNoSCache.cmake @@ -1,5 +1,4 @@ include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) get_filename_component(_parent "${CMAKE_SOURCE_DIR}" DIRECTORY) -file(REAL_PATH "${_parent}" _parent) test_variable(CMAKE_BINARY_DIR "" "${_parent}/GoodNoSCachePrep-build") diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index c4a8b3f..88027fb 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -153,6 +153,13 @@ run_cmake_presets(ConditionFuture) run_cmake_presets(SubConditionNull) run_cmake_presets(TraceNotSupported) +set(CMakePresets_NO_PRESET 1) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +run_cmake_presets(SchemaSupported --list-presets) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) +run_cmake_presets(SchemaNotSupported --list-presets) +unset(CMakePresets_NO_PRESET) + # Test cmakeMinimumRequired field run_cmake_presets(MinimumRequiredInvalid) set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) diff --git a/Tests/RunCMake/CMakePresets/SchemaNotSupported-result.txt b/Tests/RunCMake/CMakePresets/SchemaNotSupported-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/SchemaNotSupported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/SchemaNotSupported-stderr.txt b/Tests/RunCMake/CMakePresets/SchemaNotSupported-stderr.txt new file mode 100644 index 0000000..2df4b3d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/SchemaNotSupported-stderr.txt @@ -0,0 +1,3 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/SchemaNotSupported: +File version must be 8 or higher for [$]schema support$ diff --git a/Tests/RunCMake/CMakePresets/SchemaNotSupported.json.in b/Tests/RunCMake/CMakePresets/SchemaNotSupported.json.in new file mode 100644 index 0000000..736f307 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/SchemaNotSupported.json.in @@ -0,0 +1,4 @@ +{ + "version": 7, + "$schema": "https://example.com/schema.json" +} diff --git a/Tests/RunCMake/CMakePresets/SchemaSupported-result.txt b/Tests/RunCMake/CMakePresets/SchemaSupported-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/SchemaSupported-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMakePresets/SchemaSupported.json.in b/Tests/RunCMake/CMakePresets/SchemaSupported.json.in new file mode 100644 index 0000000..5426131 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/SchemaSupported.json.in @@ -0,0 +1,4 @@ +{ + "version": 8, + "$schema": "https://example.com/schema.json" +} diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index c90d543..223a61c 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -472,7 +472,7 @@ add_test(test1 \"${CMAKE_COMMAND}\" -E false) add_test(test2 \"${CMAKE_COMMAND}\" -E echo \"hello world\") add_test(test3 \"${CMAKE_COMMAND}\" -E true) set_tests_properties(test3 PROPERTIES DISABLED \"ON\") -add_test(test4 \"${CMAKE_COMMAND}/doesnt_exist\") +add_test(test4 \"${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist\") add_test(test5 \"${CMAKE_COMMAND}\" -E echo \"please skip\") set_tests_properties(test5 PROPERTIES SKIP_REGULAR_EXPRESSION \"please skip\") ") diff --git a/Tests/RunCMake/CTestCommandLine/output-junit-stderr.txt b/Tests/RunCMake/CTestCommandLine/output-junit-stderr.txt index ce30dc8..c57c378 100644 --- a/Tests/RunCMake/CTestCommandLine/output-junit-stderr.txt +++ b/Tests/RunCMake/CTestCommandLine/output-junit-stderr.txt @@ -1 +1,2 @@ -Unable to find executable: .*doesnt_exist +Unable to find executable:[^ +]*does_not_exist diff --git a/Tests/RunCMake/CTestResourceAllocation/CMakeLists.txt.in b/Tests/RunCMake/CTestResourceAllocation/CMakeLists.txt.in index 9984421..7c08dcc 100644 --- a/Tests/RunCMake/CTestResourceAllocation/CMakeLists.txt.in +++ b/Tests/RunCMake/CTestResourceAllocation/CMakeLists.txt.in @@ -4,6 +4,8 @@ if(CASE_NAME MATCHES "^(.*)-ctest-s") set(projname "${CMAKE_MATCH_1}") project(${projname} NONE) include(CTest) - include("@RunCMake_SOURCE_DIR@/ResourceCommon.cmake") + if(NOT CASE_NAME MATCHES "^dynamic-resource-") + include("@RunCMake_SOURCE_DIR@/resource-common.cmake") + endif() include("@RunCMake_SOURCE_DIR@/${projname}.cmake") endif() diff --git a/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake b/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake index f5f0699..42e13fc 100644 --- a/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake @@ -179,3 +179,19 @@ run_ctest_resource(ensure_parallel 2 0 0) set(ENV{CTEST_RESOURCE_GROUP_COUNT} 2) run_ctest_resource(process_count 1 0 0) unset(ENV{CTEST_RESOURCE_GROUP_COUNT}) + +function(run_ctest_resource_dynamic name) + run_ctest("${name}-ctest-s" ${ARGN}) +endfunction() + +run_ctest_resource_dynamic(dynamic-resource -VV) +run_ctest_resource_dynamic(dynamic-resource-notenough) +run_ctest_resource_dynamic(dynamic-resource-nofile) +run_ctest_resource_dynamic(dynamic-resource-multiple-generators) +run_ctest_resource_dynamic(dynamic-resource-no-setup-fixture) +run_ctest_resource_dynamic(dynamic-resource-multiple-setup-fixtures) +run_ctest_resource_dynamic(dynamic-resource-no-required-fixture) +run_ctest_resource_dynamic(dynamic-resource-conflicting-spec -DCTEST_RESOURCE_SPEC_SOURCE=CACHE) +run_ctest_resource_dynamic(dynamic-resource-circular) +run_ctest_resource_dynamic(dynamic-resource-circular-no-required-fixtures) +run_ctest_resource_dynamic(dynamic-resource-relative-path) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-ctest-s-result.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-ctest-s-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-ctest-s-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-ctest-s-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-ctest-s-stderr.txt new file mode 100644 index 0000000..397ca38 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-ctest-s-stderr.txt @@ -0,0 +1,3 @@ +^Error: a cycle exists in the test dependency graph for the test "GenerateSpecFile"\. +Please fix the cycle and run ctest again. +No tests were found!!!$ diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-no-required-fixtures-ctest-s-result.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-no-required-fixtures-ctest-s-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-no-required-fixtures-ctest-s-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-no-required-fixtures-ctest-s-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-no-required-fixtures-ctest-s-stderr.txt new file mode 100644 index 0000000..06ea90f --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-no-required-fixtures-ctest-s-stderr.txt @@ -0,0 +1,2 @@ +^All tests that have RESOURCE_GROUPS must include the resource spec generator fixture in their FIXTURES_REQUIRED +No tests were found!!!$ diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-no-required-fixtures.cmake b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-no-required-fixtures.cmake new file mode 100644 index 0000000..9accdf3 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular-no-required-fixtures.cmake @@ -0,0 +1,11 @@ +add_test(NAME RealTest COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile COMMAND "${CMAKE_COMMAND}" -E copy "${CTEST_DYNAMIC_RESOURCE_SPEC_FILE}" "${CMAKE_BINARY_DIR}") +set_tests_properties(GenerateSpecFile PROPERTIES + GENERATED_RESOURCE_SPEC_FILE "${CMAKE_BINARY_DIR}/dynamic-resspec.json" + FIXTURES_SETUP "ResourceSpec" + RESOURCE_GROUPS "widgets:1" + ) +set_tests_properties(RealTest PROPERTIES + FIXTURES_REQUIRED "ResourceSpec" + RESOURCE_GROUPS "widgets:1" + ) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular.cmake b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular.cmake new file mode 100644 index 0000000..4917e30 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-circular.cmake @@ -0,0 +1,12 @@ +add_test(NAME RealTest COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile COMMAND "${CMAKE_COMMAND}" -E copy "${CTEST_DYNAMIC_RESOURCE_SPEC_FILE}" "${CMAKE_BINARY_DIR}") +set_tests_properties(GenerateSpecFile PROPERTIES + GENERATED_RESOURCE_SPEC_FILE "${CMAKE_BINARY_DIR}/dynamic-resspec.json" + FIXTURES_SETUP "ResourceSpec" + FIXTURES_REQUIRED "ResourceSpec" + RESOURCE_GROUPS "widgets:1" + ) +set_tests_properties(RealTest PROPERTIES + FIXTURES_REQUIRED "ResourceSpec" + RESOURCE_GROUPS "widgets:1" + ) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-conflicting-spec-ctest-s-result.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-conflicting-spec-ctest-s-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-conflicting-spec-ctest-s-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-conflicting-spec-ctest-s-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-conflicting-spec-ctest-s-stderr.txt new file mode 100644 index 0000000..4e4c01c --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-conflicting-spec-ctest-s-stderr.txt @@ -0,0 +1,2 @@ +^GENERATED_RESOURCE_SPEC_FILE test property cannot be used in conjunction with ResourceSpecFile option +No tests were found!!!$ diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-conflicting-spec.cmake b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-conflicting-spec.cmake new file mode 100644 index 0000000..668b049 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-conflicting-spec.cmake @@ -0,0 +1,10 @@ +add_test(NAME RealTest COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile COMMAND "${CMAKE_COMMAND}" -E copy "${CTEST_DYNAMIC_RESOURCE_SPEC_FILE}" "${CMAKE_BINARY_DIR}") +set_tests_properties(GenerateSpecFile PROPERTIES + GENERATED_RESOURCE_SPEC_FILE "${CMAKE_BINARY_DIR}/dynamic-resspec.json" + FIXTURES_SETUP "ResourceSpec" + ) +set_tests_properties(RealTest PROPERTIES + FIXTURES_REQUIRED "ResourceSpec" + RESOURCE_GROUPS "widgets:1" + ) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-ctest-s-stdout.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-ctest-s-stdout.txt new file mode 100644 index 0000000..ec97787 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-ctest-s-stdout.txt @@ -0,0 +1,24 @@ +test 2 + Start 2: GenerateSpecFile + +2: Test command: "?[^ +]*[\\/]bin([\\/][^\\/ +]+)?[\\/]cmake(\.exe)?"? "-E" "copy" "[^ +]*/Tests/RunCMake/CTestResourceAllocation/dynamic-resspec\.json" "[^ +]*/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-ctest-s-build" +2: Working Directory: [^ +]*/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-ctest-s-build +2: Test timeout computed to be: 600 +1/2 Test #2: GenerateSpecFile ................. Passed +[0-9]+\.[0-9]+ sec +Using generated resource spec file [^ +]*/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-ctest-s-build/dynamic-resspec\.json +test 1 + Start 1: RealTest + +1: Test command: "?[^ +]*[\\/]bin([\\/][^\\/ +]+)?[\\/]cmake(\.exe)?"? "-E" "true" +1: Working Directory: [^ +]*/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-ctest-s-build +1: Test timeout computed to be: 600 +2/2 Test #1: RealTest ......................... Passed +[0-9]+\.[0-9]+ sec diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-generators-ctest-s-result.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-generators-ctest-s-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-generators-ctest-s-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-generators-ctest-s-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-generators-ctest-s-stderr.txt new file mode 100644 index 0000000..273cb80 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-generators-ctest-s-stderr.txt @@ -0,0 +1,2 @@ +^Only one test may define the GENERATED_RESOURCE_SPEC_FILE property +No tests were found!!!$ diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-generators.cmake b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-generators.cmake new file mode 100644 index 0000000..7ee58d4 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-generators.cmake @@ -0,0 +1,11 @@ +add_test(NAME RealTest COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile1 COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile2 COMMAND "${CMAKE_COMMAND}" -E true) +set_tests_properties(GenerateSpecFile1 GenerateSpecFile2 PROPERTIES + GENERATED_RESOURCE_SPEC_FILE "${CMAKE_BINARY_DIR}/dynamic-resspec.json" + FIXTURES_SETUP "ResourceSpec" + ) +set_tests_properties(RealTest PROPERTIES + FIXTURES_REQUIRED "ResourceSpec" + RESOURCE_GROUPS "widgets:1" + ) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-setup-fixtures-ctest-s-result.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-setup-fixtures-ctest-s-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-setup-fixtures-ctest-s-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-setup-fixtures-ctest-s-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-setup-fixtures-ctest-s-stderr.txt new file mode 100644 index 0000000..39ee275 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-setup-fixtures-ctest-s-stderr.txt @@ -0,0 +1,2 @@ +^Test that defines GENERATED_RESOURCE_SPEC_FILE must have exactly one FIXTURES_SETUP +No tests were found!!!$ diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-setup-fixtures.cmake b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-setup-fixtures.cmake new file mode 100644 index 0000000..a9e72ea --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-multiple-setup-fixtures.cmake @@ -0,0 +1,10 @@ +add_test(NAME RealTest COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile COMMAND "${CMAKE_COMMAND}" -E copy "${CTEST_DYNAMIC_RESOURCE_SPEC_FILE}" "${CMAKE_BINARY_DIR}") +set_tests_properties(GenerateSpecFile PROPERTIES + GENERATED_RESOURCE_SPEC_FILE "${CMAKE_BINARY_DIR}/dynamic-resspec.json" + FIXTURES_SETUP "ResourceSpec;InvalidResourceSpec" + ) +set_tests_properties(RealTest PROPERTIES + FIXTURES_REQUIRED "ResourceSpec" + RESOURCE_GROUPS "widgets:1" + ) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-required-fixture-ctest-s-result.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-required-fixture-ctest-s-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-required-fixture-ctest-s-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-required-fixture-ctest-s-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-required-fixture-ctest-s-stderr.txt new file mode 100644 index 0000000..06ea90f --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-required-fixture-ctest-s-stderr.txt @@ -0,0 +1,2 @@ +^All tests that have RESOURCE_GROUPS must include the resource spec generator fixture in their FIXTURES_REQUIRED +No tests were found!!!$ diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-required-fixture.cmake b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-required-fixture.cmake new file mode 100644 index 0000000..1983678 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-required-fixture.cmake @@ -0,0 +1,9 @@ +add_test(NAME RealTest COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile COMMAND "${CMAKE_COMMAND}" -E copy "${CTEST_DYNAMIC_RESOURCE_SPEC_FILE}" "${CMAKE_BINARY_DIR}") +set_tests_properties(GenerateSpecFile PROPERTIES + GENERATED_RESOURCE_SPEC_FILE "${CMAKE_BINARY_DIR}/dynamic-resspec.json" + FIXTURES_SETUP "ResourceSpec" + ) +set_tests_properties(RealTest PROPERTIES + RESOURCE_GROUPS "widgets:1" + ) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-setup-fixture-ctest-s-result.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-setup-fixture-ctest-s-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-setup-fixture-ctest-s-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-setup-fixture-ctest-s-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-setup-fixture-ctest-s-stderr.txt new file mode 100644 index 0000000..39ee275 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-setup-fixture-ctest-s-stderr.txt @@ -0,0 +1,2 @@ +^Test that defines GENERATED_RESOURCE_SPEC_FILE must have exactly one FIXTURES_SETUP +No tests were found!!!$ diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-setup-fixture.cmake b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-setup-fixture.cmake new file mode 100644 index 0000000..b6dec5e --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-no-setup-fixture.cmake @@ -0,0 +1,9 @@ +add_test(NAME RealTest COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile COMMAND "${CMAKE_COMMAND}" -E copy "${CTEST_DYNAMIC_RESOURCE_SPEC_FILE}" "${CMAKE_BINARY_DIR}") +set_tests_properties(GenerateSpecFile PROPERTIES + GENERATED_RESOURCE_SPEC_FILE "${CMAKE_BINARY_DIR}/dynamic-resspec.json" + ) +set_tests_properties(RealTest PROPERTIES + FIXTURES_REQUIRED "ResourceSpec" + RESOURCE_GROUPS "widgets:1" + ) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s-result.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s-stderr.txt new file mode 100644 index 0000000..343f632 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s-stderr.txt @@ -0,0 +1,7 @@ +^Could not read/parse resource spec file [^ +]*/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s-build/dynamic-resspec\.json:[ ] +File not found: [^ +]*/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s-build/dynamic-resspec\.json +CMake Error at [^ +]*/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s/test\.cmake:[0-9]+ \(message\): + Tests did not pass$ diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s-stdout.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s-stdout.txt new file mode 100644 index 0000000..fcf8ace --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile-ctest-s-stdout.txt @@ -0,0 +1,5 @@ + Start 2: GenerateSpecFile +1/2 Test #2: GenerateSpecFile .................\*\*\*Failed Invalid resource spec file +[0-9]+\.[0-9]+ sec + Start 1: RealTest +Failed test dependencies: GenerateSpecFile +2/2 Test #1: RealTest .........................\*\*\*Not Run +[0-9]+\.[0-9]+ sec diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile.cmake b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile.cmake new file mode 100644 index 0000000..e771c60 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-nofile.cmake @@ -0,0 +1,10 @@ +add_test(NAME RealTest COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile COMMAND "${CMAKE_COMMAND}" -E true) +set_tests_properties(GenerateSpecFile PROPERTIES + GENERATED_RESOURCE_SPEC_FILE "${CMAKE_BINARY_DIR}/dynamic-resspec.json" + FIXTURES_SETUP "ResourceSpec" + ) +set_tests_properties(RealTest PROPERTIES + FIXTURES_REQUIRED "ResourceSpec" + RESOURCE_GROUPS "widgets:1" + ) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough-ctest-s-result.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough-ctest-s-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough-ctest-s-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough-ctest-s-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough-ctest-s-stderr.txt new file mode 100644 index 0000000..393ab84 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough-ctest-s-stderr.txt @@ -0,0 +1,14 @@ +^Insufficient resources for test RealTest: + + Test requested resources of type 'widgets' in the following amounts: + 2 slots + but only the following units were available: + '0': 1 slot + +Resource spec file: + + [^ +]*/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough-ctest-s-build/dynamic-resspec\.json +CMake Error at [^ +]*/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough-ctest-s/test\.cmake:[0-9]+ \(message\): + Tests did not pass$ diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough-ctest-s-stdout.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough-ctest-s-stdout.txt new file mode 100644 index 0000000..b411a74 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough-ctest-s-stdout.txt @@ -0,0 +1,4 @@ + Start 2: GenerateSpecFile +1/2 Test #2: GenerateSpecFile ................. Passed +[0-9]+\.[0-9]+ sec + Start 1: RealTest +2/2 Test #1: RealTest .........................\*\*\*Not Run +[0-9]+\.[0-9]+ sec diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough.cmake b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough.cmake new file mode 100644 index 0000000..c8e1313 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-notenough.cmake @@ -0,0 +1,10 @@ +add_test(NAME RealTest COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile COMMAND "${CMAKE_COMMAND}" -E copy "${CTEST_DYNAMIC_RESOURCE_SPEC_FILE}" "${CMAKE_BINARY_DIR}") +set_tests_properties(GenerateSpecFile PROPERTIES + GENERATED_RESOURCE_SPEC_FILE "${CMAKE_BINARY_DIR}/dynamic-resspec.json" + FIXTURES_SETUP "ResourceSpec" + ) +set_tests_properties(RealTest PROPERTIES + FIXTURES_REQUIRED "ResourceSpec" + RESOURCE_GROUPS "widgets:2" + ) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-relative-path-ctest-s-result.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-relative-path-ctest-s-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-relative-path-ctest-s-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-relative-path-ctest-s-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-relative-path-ctest-s-stderr.txt new file mode 100644 index 0000000..2c4dff8 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-relative-path-ctest-s-stderr.txt @@ -0,0 +1,2 @@ +^GENERATED_RESOURCE_SPEC_FILE must be an absolute path +No tests were found!!!$ diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-relative-path.cmake b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-relative-path.cmake new file mode 100644 index 0000000..3ee83d7 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource-relative-path.cmake @@ -0,0 +1,10 @@ +add_test(NAME RealTest COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile COMMAND "${CMAKE_COMMAND}" -E copy "${CTEST_DYNAMIC_RESOURCE_SPEC_FILE}" "${CMAKE_BINARY_DIR}") +set_tests_properties(GenerateSpecFile PROPERTIES + GENERATED_RESOURCE_SPEC_FILE "dynamic-resspec.json" + FIXTURES_SETUP "ResourceSpec" + ) +set_tests_properties(RealTest PROPERTIES + FIXTURES_REQUIRED "ResourceSpec" + RESOURCE_GROUPS "widgets:1" + ) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resource.cmake b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource.cmake new file mode 100644 index 0000000..668b049 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resource.cmake @@ -0,0 +1,10 @@ +add_test(NAME RealTest COMMAND "${CMAKE_COMMAND}" -E true) +add_test(NAME GenerateSpecFile COMMAND "${CMAKE_COMMAND}" -E copy "${CTEST_DYNAMIC_RESOURCE_SPEC_FILE}" "${CMAKE_BINARY_DIR}") +set_tests_properties(GenerateSpecFile PROPERTIES + GENERATED_RESOURCE_SPEC_FILE "${CMAKE_BINARY_DIR}/dynamic-resspec.json" + FIXTURES_SETUP "ResourceSpec" + ) +set_tests_properties(RealTest PROPERTIES + FIXTURES_REQUIRED "ResourceSpec" + RESOURCE_GROUPS "widgets:1" + ) diff --git a/Tests/RunCMake/CTestResourceAllocation/dynamic-resspec.json b/Tests/RunCMake/CTestResourceAllocation/dynamic-resspec.json new file mode 100644 index 0000000..f9bedaf --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/dynamic-resspec.json @@ -0,0 +1,16 @@ +{ + "version": { + "major": 1, + "minor": 0 + }, + "local": [ + { + "widgets": [ + { + "id": "0", + "slots": 1 + } + ] + } + ] +} diff --git a/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake b/Tests/RunCMake/CTestResourceAllocation/resource-common.cmake index ef79dce..ef79dce 100644 --- a/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake +++ b/Tests/RunCMake/CTestResourceAllocation/resource-common.cmake diff --git a/Tests/RunCMake/CTestResourceAllocation/test.cmake.in b/Tests/RunCMake/CTestResourceAllocation/test.cmake.in index 9ad9ac8..319ebf1 100644 --- a/Tests/RunCMake/CTestResourceAllocation/test.cmake.in +++ b/Tests/RunCMake/CTestResourceAllocation/test.cmake.in @@ -8,9 +8,15 @@ set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") -set(config_options - "-DCTEST_RESOURCE_ALLOC_ENABLED=${CTEST_RESOURCE_ALLOC_ENABLED};-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}" - ) +if("@CASE_NAME@" MATCHES "^dynamic-resource-") + set(config_options + "-DCTEST_DYNAMIC_RESOURCE_SPEC_FILE=@RunCMake_SOURCE_DIR@/dynamic-resspec.json" + ) +else() + set(config_options + "-DCTEST_RESOURCE_ALLOC_ENABLED=${CTEST_RESOURCE_ALLOC_ENABLED};-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}" + ) +endif() if(CTEST_RESOURCE_SPEC_SOURCE STREQUAL "CMDLINE") list(APPEND config_options "-DCTEST_RESOURCE_SPEC_FILE=@RunCMake_SOURCE_DIR@/noexist.json") diff --git a/Tests/RunCMake/CUDA_architectures/architectures-empty-stderr.txt b/Tests/RunCMake/CUDA_architectures/architectures-empty-stderr.txt index 6c42612..dbadd048 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-empty-stderr.txt +++ b/Tests/RunCMake/CUDA_architectures/architectures-empty-stderr.txt @@ -1,5 +1,7 @@ -^CMake Error at .*/Modules/CMakeDetermineCUDACompiler\.cmake:[0-9]+ \(message\): +^CMake Error at .*/Internal/CMakeCUDAArchitecturesValidate\.cmake:[0-9]+ \(message\): CMAKE_CUDA_ARCHITECTURES must be non-empty if set\. Call Stack \(most recent call first\): + [^ +]*/Modules/CMakeDetermineCUDACompiler.cmake:[0-9]+ \(cmake_cuda_architectures_validate\) architectures-empty\.cmake:2 \(enable_language\) CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt b/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt index 14c76d2..891aa40 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt +++ b/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt @@ -1,4 +1,4 @@ -^CMake Error at .*/Modules/CMakeDetermineCUDACompiler\.cmake:[0-9]+ \(message\): +^CMake Error at .*/Internal/CMakeCUDAArchitecturesValidate\.cmake:[0-9]+ \(message\): CMAKE_CUDA_ARCHITECTURES: invalid @@ -10,5 +10,7 @@ \* a special value: all, all-major, native Call Stack \(most recent call first\): + [^ +]*/Modules/CMakeDetermineCUDACompiler.cmake:[0-9]+ \(cmake_cuda_architectures_validate\) architectures-invalid\.cmake:2 \(enable_language\) CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/CXXModules/CMakeLists.txt b/Tests/RunCMake/CXXModules/CMakeLists.txt index 88eb282..e23023d 100644 --- a/Tests/RunCMake/CXXModules/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.23) project(${RunCMake_TEST} NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CXXModules/ExportBuildCxxModules-stderr.txt b/Tests/RunCMake/CXXModules/ExportBuildCxxModules-stderr.txt index a82791b..49e869a 100644 --- a/Tests/RunCMake/CXXModules/ExportBuildCxxModules-stderr.txt +++ b/Tests/RunCMake/CXXModules/ExportBuildCxxModules-stderr.txt @@ -1,6 +1,6 @@ -CMake Warning \(dev\) at ExportBuildCxxModules.cmake:5 \(target_sources\): +CMake Warning \(dev\) at ExportBuildCxxModules.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/ExportInstallCxxModules-stderr.txt b/Tests/RunCMake/CXXModules/ExportInstallCxxModules-stderr.txt index db02227..4a6969d 100644 --- a/Tests/RunCMake/CXXModules/ExportInstallCxxModules-stderr.txt +++ b/Tests/RunCMake/CXXModules/ExportInstallCxxModules-stderr.txt @@ -1,6 +1,6 @@ -CMake Warning \(dev\) at ExportInstallCxxModules.cmake:5 \(target_sources\): +CMake Warning \(dev\) at ExportInstallCxxModules.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/FileSetModulesInterface-stderr.txt b/Tests/RunCMake/CXXModules/FileSetModulesInterface-stderr.txt index dfcdbec..cb21e2c 100644 --- a/Tests/RunCMake/CXXModules/FileSetModulesInterface-stderr.txt +++ b/Tests/RunCMake/CXXModules/FileSetModulesInterface-stderr.txt @@ -1,12 +1,12 @@ -CMake Warning \(dev\) at FileSetModulesInterface.cmake:2 \(target_sources\): +CMake Warning \(dev\) at FileSetModulesInterface.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. -CMake Error at FileSetModulesInterface.cmake:2 \(target_sources\): +CMake Error at FileSetModulesInterface.cmake:[0-9]+ \(target_sources\): target_sources File set TYPE "CXX_MODULES" may not have "INTERFACE" visibility Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported-stderr.txt b/Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported-stderr.txt index 4420bbc..aae763b 100644 --- a/Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported-stderr.txt +++ b/Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported-stderr.txt @@ -1,6 +1,6 @@ -CMake Warning \(dev\) at FileSetModulesInterfaceImported.cmake:2 \(target_sources\): +CMake Warning \(dev\) at FileSetModulesInterfaceImported.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/FileSetModulesPrivate-stderr.txt b/Tests/RunCMake/CXXModules/FileSetModulesPrivate-stderr.txt index 0c82ccc..a6e778a 100644 --- a/Tests/RunCMake/CXXModules/FileSetModulesPrivate-stderr.txt +++ b/Tests/RunCMake/CXXModules/FileSetModulesPrivate-stderr.txt @@ -1,6 +1,6 @@ -CMake Warning \(dev\) at FileSetModulesPrivate.cmake:5 \(target_sources\): +CMake Warning \(dev\) at FileSetModulesPrivate.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/FileSetModulesPublic-stderr.txt b/Tests/RunCMake/CXXModules/FileSetModulesPublic-stderr.txt index a27a28e..7fa8aa4 100644 --- a/Tests/RunCMake/CXXModules/FileSetModulesPublic-stderr.txt +++ b/Tests/RunCMake/CXXModules/FileSetModulesPublic-stderr.txt @@ -1,6 +1,6 @@ -CMake Warning \(dev\) at FileSetModulesPublic.cmake:5 \(target_sources\): +CMake Warning \(dev\) at FileSetModulesPublic.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/InstallBMI-stderr.txt b/Tests/RunCMake/CXXModules/InstallBMI-stderr.txt index fc3c7db..0f50963 100644 --- a/Tests/RunCMake/CXXModules/InstallBMI-stderr.txt +++ b/Tests/RunCMake/CXXModules/InstallBMI-stderr.txt @@ -1,6 +1,6 @@ -CMake Warning \(dev\) at InstallBMI.cmake:8 \(install\): +CMake Warning \(dev\) at InstallBMI.cmake:[0-9]+ \(install\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/InstallBMIGenericArgs-stderr.txt b/Tests/RunCMake/CXXModules/InstallBMIGenericArgs-stderr.txt index 44c961f..52b9c35 100644 --- a/Tests/RunCMake/CXXModules/InstallBMIGenericArgs-stderr.txt +++ b/Tests/RunCMake/CXXModules/InstallBMIGenericArgs-stderr.txt @@ -1,6 +1,6 @@ -CMake Warning \(dev\) at InstallBMIGenericArgs.cmake:8 \(install\): +CMake Warning \(dev\) at InstallBMIGenericArgs.cmake:[0-9]+ \(install\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/InstallBMIIgnore-stderr.txt b/Tests/RunCMake/CXXModules/InstallBMIIgnore-stderr.txt index d9d2c2d..bfff34c 100644 --- a/Tests/RunCMake/CXXModules/InstallBMIIgnore-stderr.txt +++ b/Tests/RunCMake/CXXModules/InstallBMIIgnore-stderr.txt @@ -1,6 +1,6 @@ -CMake Warning \(dev\) at InstallBMIIgnore.cmake:5 \(install\): +CMake Warning \(dev\) at InstallBMIIgnore.cmake:[0-9]+ \(install\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-check.cmake b/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-check.cmake index 0d08c44..6de2e1e 100644 --- a/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-check.cmake +++ b/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-check.cmake @@ -2,19 +2,19 @@ include("${CMAKE_CURRENT_LIST_DIR}/check-json.cmake") if (RunCMake_GENERATOR_IS_MULTI_CONFIG) set(have_file 0) - foreach (config IN ITEMS Release Debug RelWithDebInfo MinSizeRel) - if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-public.dir/${config}/CXXDependInfo.json") + foreach (CXXModules_config IN ITEMS Release Debug RelWithDebInfo MinSizeRel) + if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-public.dir/${CXXModules_config}/CXXDependInfo.json") continue () endif () set(have_file 1) - set(CMAKE_BUILD_TYPE "${config}") + set(CMAKE_BUILD_TYPE "${CXXModules_config}") - file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-public.dir/${config}/CXXDependInfo.json" actual_contents) + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-public.dir/${CXXModules_config}/CXXDependInfo.json" actual_contents) file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoBMIInstall-public.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") - file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-private.dir/${config}/CXXDependInfo.json" actual_contents) + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-private.dir/${CXXModules_config}/CXXDependInfo.json" actual_contents) file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoBMIInstall-private.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") endforeach () @@ -24,6 +24,9 @@ if (RunCMake_GENERATOR_IS_MULTI_CONFIG) "No recognized build configurations found.") endif () else () + set(CXXModules_config "${CXXModules_default_build_type}") + set(CMAKE_BUILD_TYPE "${CXXModules_default_build_type}") + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-public.dir/CXXDependInfo.json" actual_contents) file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoBMIInstall-public.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") @@ -32,3 +35,5 @@ else () file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoBMIInstall-private.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") endif () + +string(REPLACE ";" "\n " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}") diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-stderr.txt b/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-stderr.txt index 9a7c1f9..e5bd1ec 100644 --- a/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-stderr.txt +++ b/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-stderr.txt @@ -1,6 +1,6 @@ -CMake Warning \(dev\) at NinjaDependInfoBMIInstall.cmake:13 \(target_sources\): +CMake Warning \(dev\) at NinjaDependInfoBMIInstall.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoExport-check.cmake b/Tests/RunCMake/CXXModules/NinjaDependInfoExport-check.cmake index 7720257..0c933c9 100644 --- a/Tests/RunCMake/CXXModules/NinjaDependInfoExport-check.cmake +++ b/Tests/RunCMake/CXXModules/NinjaDependInfoExport-check.cmake @@ -2,19 +2,19 @@ include("${CMAKE_CURRENT_LIST_DIR}/check-json.cmake") if (RunCMake_GENERATOR_IS_MULTI_CONFIG) set(have_file 0) - foreach (config IN ITEMS Release Debug RelWithDebInfo MinSizeRel) - if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-public.dir/${config}/CXXDependInfo.json") + foreach (CXXModules_config IN ITEMS Release Debug RelWithDebInfo MinSizeRel) + if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-public.dir/${CXXModules_config}/CXXDependInfo.json") continue () endif () set(have_file 1) - set(CMAKE_BUILD_TYPE "${config}") + set(CMAKE_BUILD_TYPE "${CXXModules_config}") - file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-public.dir/${config}/CXXDependInfo.json" actual_contents) + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-public.dir/${CXXModules_config}/CXXDependInfo.json" actual_contents) file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoExport-public.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") - file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-private.dir/${config}/CXXDependInfo.json" actual_contents) + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-private.dir/${CXXModules_config}/CXXDependInfo.json" actual_contents) file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoExport-private.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") endforeach () @@ -24,6 +24,9 @@ if (RunCMake_GENERATOR_IS_MULTI_CONFIG) "No recognized build configurations found.") endif () else () + set(CXXModules_config "${CXXModules_default_build_type}") + set(CMAKE_BUILD_TYPE "${CXXModules_default_build_type}") + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-public.dir/CXXDependInfo.json" actual_contents) file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoExport-public.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") @@ -32,3 +35,5 @@ else () file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoExport-private.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") endif () + +string(REPLACE ";" "\n " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}") diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoExport-stderr.txt b/Tests/RunCMake/CXXModules/NinjaDependInfoExport-stderr.txt index b66005b..ce0e55a 100644 --- a/Tests/RunCMake/CXXModules/NinjaDependInfoExport-stderr.txt +++ b/Tests/RunCMake/CXXModules/NinjaDependInfoExport-stderr.txt @@ -1,6 +1,6 @@ -CMake Warning \(dev\) at NinjaDependInfoExport.cmake:13 \(target_sources\): +CMake Warning \(dev\) at NinjaDependInfoExport.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoFileSet-check.cmake b/Tests/RunCMake/CXXModules/NinjaDependInfoFileSet-check.cmake index b9a1315..4eaa891 100644 --- a/Tests/RunCMake/CXXModules/NinjaDependInfoFileSet-check.cmake +++ b/Tests/RunCMake/CXXModules/NinjaDependInfoFileSet-check.cmake @@ -2,19 +2,19 @@ include("${CMAKE_CURRENT_LIST_DIR}/check-json.cmake") if (RunCMake_GENERATOR_IS_MULTI_CONFIG) set(have_file 0) - foreach (config IN ITEMS Release Debug RelWithDebInfo MinSizeRel) - if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-file-sets-public.dir/${config}/CXXDependInfo.json") + foreach (CXXModules_config IN ITEMS Release Debug RelWithDebInfo MinSizeRel) + if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-file-sets-public.dir/${CXXModules_config}/CXXDependInfo.json") continue () endif () set(have_file 1) - set(CMAKE_BUILD_TYPE "${config}") + set(CMAKE_BUILD_TYPE "${CXXModules_config}") - file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-file-sets-public.dir/${config}/CXXDependInfo.json" actual_contents) + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-file-sets-public.dir/${CXXModules_config}/CXXDependInfo.json" actual_contents) file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoFileSet-public.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") - file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-file-sets-private.dir/${config}/CXXDependInfo.json" actual_contents) + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-file-sets-private.dir/${CXXModules_config}/CXXDependInfo.json" actual_contents) file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoFileSet-private.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") endforeach () @@ -24,6 +24,9 @@ if (RunCMake_GENERATOR_IS_MULTI_CONFIG) "No recognized build configurations found.") endif () else () + set(CXXModules_config "${CXXModules_default_build_type}") + set(CMAKE_BUILD_TYPE "${CXXModules_default_build_type}") + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-file-sets-public.dir/CXXDependInfo.json" actual_contents) file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoFileSet-public.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") @@ -32,3 +35,5 @@ else () file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoFileSet-private.json" expect_contents) check_json("${actual_contents}" "${expect_contents}") endif () + +string(REPLACE ";" "\n " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}") diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoFileSet-stderr.txt b/Tests/RunCMake/CXXModules/NinjaDependInfoFileSet-stderr.txt index 949b7af..055e741 100644 --- a/Tests/RunCMake/CXXModules/NinjaDependInfoFileSet-stderr.txt +++ b/Tests/RunCMake/CXXModules/NinjaDependInfoFileSet-stderr.txt @@ -1,6 +1,6 @@ -CMake Warning \(dev\) at NinjaDependInfoFileSet.cmake:13 \(target_sources\): +CMake Warning \(dev\) at NinjaDependInfoFileSet.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/NoCXX-stderr.txt b/Tests/RunCMake/CXXModules/NoCXX-stderr.txt index 7e8f384..c261e8c 100644 --- a/Tests/RunCMake/CXXModules/NoCXX-stderr.txt +++ b/Tests/RunCMake/CXXModules/NoCXX-stderr.txt @@ -1,20 +1,20 @@ -CMake Warning \(dev\) at NoCXX.cmake:4 \(target_sources\): +CMake Warning \(dev\) at NoCXX.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. CMake Error in CMakeLists.txt: - The "nocxx" target has C\+\+ module sources but the "CXX" language has not - been enabled + The target named "nocxx" has C\+\+ sources that export modules but the "CXX" + language has not been enabled ( CMake Error in CMakeLists.txt: -( The "nocxx" target has C\+\+ module sources but the "CXX" language has not - been enabled -| The "nocxx" target contains C\+\+ module sources which are not supported by - the generator +( The target named "nocxx" has C\+\+ sources that export modules but the "CXX" + language has not been enabled +| The target named "nocxx" contains C\+\+ sources that export modules which is + not supported by the generator | Target "nocxx" has source file .*/Tests/RunCMake/CXXModules/sources/module.cxx diff --git a/Tests/RunCMake/CXXModules/NoCXX20-stderr.txt b/Tests/RunCMake/CXXModules/NoCXX20-stderr.txt index 95d73b1..aba0c89 100644 --- a/Tests/RunCMake/CXXModules/NoCXX20-stderr.txt +++ b/Tests/RunCMake/CXXModules/NoCXX20-stderr.txt @@ -1,20 +1,22 @@ -CMake Warning \(dev\) at NoCXX20.cmake:4 \(target_sources\): +CMake Warning \(dev\) at NoCXX20.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. CMake Error in CMakeLists.txt: - The "nocxx20" target has C\+\+ module sources but is not using at least - "cxx_std_20" + The target named "nocxx20" has C\+\+ sources that export modules but does not + include "cxx_std_20" \(or newer\) among its `target_compile_features`; found + "cxx_std_17" ( CMake Error in CMakeLists.txt: -( The "nocxx20" target has C\+\+ module sources but is not using at least - "cxx_std_20" -| The "nocxx20" target contains C\+\+ module sources which are not supported by - the generator +( The target named "nocxx20" has C\+\+ sources that export modules but does not + include "cxx_std_20" \(or newer\) among its `target_compile_features`; found + "cxx_std_17" +| The target named "nocxx20" contains C\+\+ sources that export modules which + is not supported by the generator ) )* CMake Generate step failed. Build files cannot be regenerated correctly. diff --git a/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag-stderr.txt b/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag-stderr.txt index aa99af0..06174b5 100644 --- a/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag-stderr.txt +++ b/Tests/RunCMake/CXXModules/NoCXX20ModuleFlag-stderr.txt @@ -1,20 +1,20 @@ -CMake Warning \(dev\) at NoCXX20ModuleFlag.cmake:6 \(target_sources\): +CMake Warning \(dev\) at NoCXX20ModuleFlag.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. CMake Error in CMakeLists.txt: - The "noexperimentalflag" target has C\+\+ module sources but its experimental - support has not been requested + The target named "noexperimentalflag" has C\+\+ sources that export modules + but its experimental support has not been requested ( CMake Error in CMakeLists.txt: -( The "noexperimentalflag" target has C\+\+ module sources but its experimental - support has not been requested -| The "noexperimentalflag" target contains C\+\+ module sources which are not - supported by the generator +( The target named "noexperimentalflag" has C\+\+ sources that export modules + but its experimental support has not been requested +| The target named "noexperimentalflag" contains C\+\+ sources that export + modules which is not supported by the generator ) )* CMake Generate step failed. Build files cannot be regenerated correctly. diff --git a/Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt b/Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt index b63d291..8d15c19 100644 --- a/Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt +++ b/Tests/RunCMake/CXXModules/NoDyndepSupport-stderr.txt @@ -1,8 +1,8 @@ -CMake Warning \(dev\) at NoDyndepSupport.cmake:9 \(target_sources\): +CMake Warning \(dev\) at NoDyndepSupport.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. (CMake Error: @@ -13,13 +13,13 @@ This warning is for project developers. Use -Wno-dev to suppress it. due to lack of required features. Ninja 1.11 or higher is required. |CMake Error in CMakeLists.txt: - The "nodyndep" target contains C\+\+ module sources which are not supported - by the generator + The target named "nodyndep" contains C\+\+ sources that export modules which + is not supported by the generator ( CMake Error in CMakeLists.txt: - The "nodyndep" target contains C\+\+ module sources which are not supported - by the generator + The target named "nodyndep" contains C\+\+ sources that export modules which + is not supported by the generator )*) CMake Generate step failed. Build files cannot be regenerated correctly. diff --git a/Tests/RunCMake/CXXModules/NotCXXSourceModules-stderr.txt b/Tests/RunCMake/CXXModules/NotCXXSourceModules-stderr.txt index 78d3dc6..d73ff98 100644 --- a/Tests/RunCMake/CXXModules/NotCXXSourceModules-stderr.txt +++ b/Tests/RunCMake/CXXModules/NotCXXSourceModules-stderr.txt @@ -1,8 +1,8 @@ -CMake Warning \(dev\) at NotCXXSourceModules.cmake:6 \(target_sources\): +CMake Warning \(dev\) at NotCXXSourceModules.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. CMake Error in CMakeLists.txt: diff --git a/Tests/RunCMake/CXXModules/NotCompiledSourceModules-stderr.txt b/Tests/RunCMake/CXXModules/NotCompiledSourceModules-stderr.txt index 52f4072..c963ce7 100644 --- a/Tests/RunCMake/CXXModules/NotCompiledSourceModules-stderr.txt +++ b/Tests/RunCMake/CXXModules/NotCompiledSourceModules-stderr.txt @@ -1,8 +1,8 @@ -CMake Warning \(dev\) at NotCompiledSourceModules.cmake:5 \(target_sources\): +CMake Warning \(dev\) at NotCompiledSourceModules.cmake:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. Call Stack \(most recent call first\): - CMakeLists.txt:6 \(include\) + CMakeLists.txt:[0-9]+ \(include\) This warning is for project developers. Use -Wno-dev to suppress it. (CMake Error in CMakeLists.txt: diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index 89c198f..f111b74 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -149,6 +149,8 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(duplicate) set(RunCMake_CXXModules_NO_TEST 1) run_cxx_module_test(circular) + run_cxx_module_test(try-compile) + run_cxx_module_test(try-run) unset(RunCMake_CXXModules_NO_TEST) run_cxx_module_test(same-src-name) run_cxx_module_test(scan_properties) @@ -186,7 +188,24 @@ endif () if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(export-interface-no-properties-build) run_cxx_module_test(export-interface-build) + run_cxx_module_test(export-include-directories-build) + run_cxx_module_test(export-usage-build) run_cxx_module_test(export-bmi-and-interface-build) + + if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND + "bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION) + set(test_suffix export-interface-build) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-build") + + set(test_suffix export-interface-no-properties-build) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-build" -DNO_PROPERTIES=1) + + set(test_suffix export-include-directories-build) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-build" -DINCLUDE_PROPERTIES=1) + + set(test_suffix export-bmi-and-interface-build) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-build" -DWITH_BMIS=1) + endif () endif () # All of the following tests perform installation. @@ -200,6 +219,25 @@ if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION) if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(export-interface-no-properties-install) run_cxx_module_test(export-interface-install) + run_cxx_module_test(export-include-directories-install) + run_cxx_module_test(export-usage-install) run_cxx_module_test(export-bmi-and-interface-install) + + if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND + "bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION) + set(RunCMake_CXXModules_INSTALL 0) + set(test_suffix export-interface-install) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-install") + + set(test_suffix export-interface-no-properties-install) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-install" -DNO_PROPERTIES=1) + + set(test_suffix export-include-directories-install) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-install" -DINCLUDE_PROPERTIES=1) + + set(test_suffix export-bmi-and-interface-install) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-install" -DWITH_BMIS=1) + set(RunCMake_CXXModules_INSTALL 1) + endif () endif () endif () diff --git a/Tests/RunCMake/CXXModules/check-json.cmake b/Tests/RunCMake/CXXModules/check-json.cmake index 19d0c8a..bb04b36 100644 --- a/Tests/RunCMake/CXXModules/check-json.cmake +++ b/Tests/RunCMake/CXXModules/check-json.cmake @@ -2,19 +2,20 @@ cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) function (json_placeholders in out) - string(REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" in "${in}") + string(REPLACE "<CONFIG>" "${CXXModules_config}" in "${in}") if (RunCMake_GENERATOR_IS_MULTI_CONFIG) - string(REPLACE "<CONFIG_DIR>" "${CMAKE_BUILD_TYPE}/" in "${in}") + string(REPLACE "<CONFIG_DIR>" "/${CXXModules_config}" in "${in}") else () string(REPLACE "<CONFIG_DIR>" "" in "${in}") endif () if (CMAKE_BUILD_TYPE) - string(REPLACE "<CONFIG_FORCE>" "${CMAKE_BUILD_TYPE}" in "${in}") + string(REPLACE "<CONFIG_FORCE>" "${CXXModules_config}" in "${in}") else () string(REPLACE "<CONFIG_FORCE>" "noconfig" in "${in}") endif () string(REPLACE "<SOURCE_DIR>" "${RunCMake_SOURCE_DIR}" in "${in}") string(REPLACE "<BINARY_DIR>" "${RunCMake_TEST_BINARY_DIR}" in "${in}") + string(REPLACE "<OBJEXT>" "${CMAKE_CXX_OUTPUT_EXTENSION}" in "${in}") set("${out}" "${in}" PARENT_SCOPE) endfunction () @@ -22,6 +23,7 @@ function (check_json_value path actual_type expect_type actual_value expect_valu if (NOT actual_type STREQUAL expect_type) list(APPEND RunCMake_TEST_FAILED "Type mismatch at ${path}: ${actual_type} vs. ${expect_type}") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) return () endif () @@ -53,6 +55,8 @@ function (check_json_value path actual_type expect_type actual_value expect_valu elseif (actual_type STREQUAL OBJECT) check_json_object("${path}" "${actual_value}" "${expect_value}") endif () + + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) endfunction () # Check that two arrays are the same. @@ -82,6 +86,8 @@ function (check_json_array path actual expect) string(JSON expect_value GET "${expect}" "${idx}") check_json_value("${new_path}" "${actual_type}" "${expect_type}" "${actual_value}" "${expect_value}") endforeach () + + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) endfunction () # Check that two inner objects are the same. @@ -131,12 +137,12 @@ function (check_json_object path actual expect) if (actual_keys_missed) string(REPLACE ";" ", " actual_keys_missed_text "${actual_keys_missed}") list(APPEND RunCMake_TEST_FAILED - "Missing expected members at ${path}: ${actual_keys_missed_text}") + "Extra unexpected members at ${path}: ${actual_keys_missed_text}") endif () if (expect_keys_missed) string(REPLACE ";" ", " expect_keys_missed_text "${expect_keys_missed}") list(APPEND RunCMake_TEST_FAILED - "Extra unexpected members at ${path}: ${expect_keys_missed_text}") + "Missing expected members at ${path}: ${expect_keys_missed_text}") endif () foreach (key IN LISTS common_keys) @@ -148,13 +154,15 @@ function (check_json_object path actual expect) string(JSON expect_value GET "${expect}" "${key}") check_json_value("${new_path}" "${actual_type}" "${expect_type}" "${actual_value}" "${expect_value}") endforeach () + + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) endfunction () # Check that two JSON objects are the same. function (check_json actual expect) check_json_object("" "${actual}" "${expect}") -endfunction () -string(REPLACE ";" "; " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) +endfunction () cmake_policy(POP) diff --git a/Tests/RunCMake/CXXModules/compiler_introspection.cmake b/Tests/RunCMake/CXXModules/compiler_introspection.cmake index 0e61383..8c74940 100644 --- a/Tests/RunCMake/CXXModules/compiler_introspection.cmake +++ b/Tests/RunCMake/CXXModules/compiler_introspection.cmake @@ -21,6 +21,8 @@ set(CMAKE_CXX_COMPILE_FEATURES \"${CMAKE_CXX_COMPILE_FEATURES}\") set(CMAKE_MAKE_PROGRAM \"${CMAKE_MAKE_PROGRAM}\") set(forced_cxx_standard \"${forced_cxx_standard}\") set(CMAKE_CXX_COMPILER_VERSION \"${CMAKE_CXX_COMPILER_VERSION}\") +set(CMAKE_CXX_OUTPUT_EXTENSION \"${CMAKE_CXX_OUTPUT_EXTENSION}\") +set(CXXModules_default_build_type \"${CMAKE_BUILD_TYPE}\") ") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}") diff --git a/Tests/RunCMake/CXXModules/examples/circular-stderr.txt b/Tests/RunCMake/CXXModules/examples/circular-stderr.txt index 78bdf2b..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/circular-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/circular-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake b/Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake index ff7219a..5f32364 100644 --- a/Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake +++ b/Tests/RunCMake/CXXModules/examples/cxx-modules-rules.cmake @@ -1,4 +1,4 @@ -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") if (NOT EXISTS "${CMake_TEST_MODULE_COMPILATION_RULES}") message(FATAL_ERROR diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain-stderr.txt b/Tests/RunCMake/CXXModules/examples/deep-chain-stderr.txt index 78bdf2b..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/deep-chain-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/deep-chain-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/deep-chain/CMakeLists.txt index 515b240..78a1d0b 100644 --- a/Tests/RunCMake/CXXModules/examples/deep-chain/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/deep-chain/CMakeLists.txt @@ -3,6 +3,14 @@ project(cxx_modules_deep_chain CXX) include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + include(CheckCompilerFlag) + check_compiler_flag(CXX "-Wread-modules-implicitly" have_implicit_module_warning) + if (have_implicit_module_warning) + add_compile_options(-Werror=read-modules-implicitly) + endif () +endif () + add_library(a STATIC) target_sources(a PUBLIC diff --git a/Tests/RunCMake/CXXModules/examples/duplicate-stderr.txt b/Tests/RunCMake/CXXModules/examples/duplicate-stderr.txt index 78bdf2b..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/duplicate-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/duplicate-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt index d227e55..c17577c 100644 --- a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") find_package(export_bmi_and_interfaces REQUIRED) diff --git a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt index d46d28b..d608d67 100644 --- a/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") find_package(export_bmi_and_interfaces REQUIRED) diff --git a/Tests/RunCMake/CXXModules/examples/export-compile-commands-stderr.txt b/Tests/RunCMake/CXXModules/examples/export-compile-commands-stderr.txt index e868787..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/export-compile-commands-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/export-compile-commands-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:9 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-build-stderr.txt b/Tests/RunCMake/CXXModules/examples/export-include-directories-build-stderr.txt new file mode 100644 index 0000000..28a7b1f --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-build-stderr.txt @@ -0,0 +1,4 @@ +CMake Warning \(dev\) at CMakeLists.txt:[0-9] \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-build/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/CMakeLists.txt new file mode 100644 index 0000000..bc2ae7f --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_export_include_directories CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_library(export_include_directories STATIC + include/include.h) +target_sources(export_include_directories + PRIVATE + forward.cxx + PRIVATE + FILE_SET modules_private TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + private.cxx + PUBLIC + FILE_SET modules TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + importable.cxx + subdir/importable.cxx + ) +target_compile_features(export_include_directories PUBLIC cxx_std_20) +target_include_directories(export_include_directories + PRIVATE + "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>") + +add_library(no_modules STATIC no_modules.cxx) + +install(TARGETS export_include_directories no_modules + EXPORT CXXModules + FILE_SET modules DESTINATION "lib/cxx/miu") +export(EXPORT CXXModules + NAMESPACE CXXModules:: + FILE "${CMAKE_CURRENT_BINARY_DIR}/export_include_directories-targets.cmake" + CXX_MODULES_DIRECTORY "export_include_directories-cxx-modules") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_include_directories-config.cmake" + "include(\"\${CMAKE_CURRENT_LIST_DIR}/export_include_directories-targets.cmake\") +set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1) +") + +set(generator + -G "${CMAKE_GENERATOR}") +if (CMAKE_GENERATOR_TOOLSET) + list(APPEND generator + -T "${CMAKE_GENERATOR_TOOLSET}") +endif () +if (CMAKE_GENERATOR_PLATFORM) + list(APPEND generator + -A "${CMAKE_GENERATOR_PLATFORM}") +endif () + +add_test(NAME export_include_directories_build + COMMAND + "${CMAKE_COMMAND}" + "-Dexpected_source_dir=${CMAKE_CURRENT_SOURCE_DIR}" + "-Dexpected_binary_dir=${CMAKE_CURRENT_BINARY_DIR}" + "-Dexport_include_directories_DIR=${CMAKE_CURRENT_BINARY_DIR}" + ${generator} + -S "${CMAKE_CURRENT_SOURCE_DIR}/test" + -B "${CMAKE_CURRENT_BINARY_DIR}/test") diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-build/forward.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/forward.cxx new file mode 100644 index 0000000..7f53271 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/forward.cxx @@ -0,0 +1,6 @@ +import priv; + +int forwarding() +{ + return from_private(); +} diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-build/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/importable.cxx new file mode 100644 index 0000000..6a1d83e --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/importable.cxx @@ -0,0 +1,18 @@ +module; + +#include "include/include.h" + +#ifndef include_h_included +# error "include define not found" +#endif + +export module importable; + +extern "C++" { +int forwarding(); +} + +export int from_import() +{ + return forwarding(); +} diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-build/include/include.h b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/include/include.h new file mode 100644 index 0000000..e3eee34 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/include/include.h @@ -0,0 +1,3 @@ +#pragma once + +#define include_h_included diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-build/no_modules.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/no_modules.cxx new file mode 100644 index 0000000..eea854f --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/no_modules.cxx @@ -0,0 +1,3 @@ +void no_modules() +{ +} diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-build/private.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/private.cxx new file mode 100644 index 0000000..c5b719a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/private.cxx @@ -0,0 +1,6 @@ +export module priv; + +export int from_private() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-build/subdir/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/subdir/importable.cxx new file mode 100644 index 0000000..07d6af6 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/subdir/importable.cxx @@ -0,0 +1,6 @@ +export module subdir_importable; + +export int from_subdir() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/test/CMakeLists.txt new file mode 100644 index 0000000..f5bdfd4 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-build/test/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_library NONE) + +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") + +find_package(export_include_directories REQUIRED) + +if (NOT TARGET CXXModules::export_include_directories) + message(FATAL_ERROR + "Missing imported target") +endif () + +get_property(include_directories TARGET CXXModules::export_include_directories + PROPERTY IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES) +foreach (include_directory IN LISTS include_directories) + if (NOT EXISTS "${include_directory}") + message(FATAL_ERROR + "Missing include directory in C++ module interface CXXModules::export_include_directories:\n ${include_directory}") + endif () +endforeach () diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-install-stderr.txt b/Tests/RunCMake/CXXModules/examples/export-include-directories-install-stderr.txt new file mode 100644 index 0000000..be89b8c --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-install-stderr.txt @@ -0,0 +1,4 @@ +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-install/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/CMakeLists.txt new file mode 100644 index 0000000..444882d --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_export_include_directories CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_library(export_include_directories STATIC + include/include.h) +target_sources(export_include_directories + PRIVATE + forward.cxx + PRIVATE + FILE_SET modules_private TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + private.cxx + PUBLIC + FILE_SET modules TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + importable.cxx + subdir/importable.cxx + ) +target_compile_features(export_include_directories PUBLIC cxx_std_20) +target_include_directories(export_include_directories + PRIVATE + "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" + "$<INSTALL_INTERFACE:include>") + +add_library(no_modules STATIC no_modules.cxx) + +install(TARGETS export_include_directories no_modules + EXPORT CXXModules + FILE_SET modules DESTINATION "lib/cxx/miu") +install(DIRECTORY include + DESTINATION "include") +install(EXPORT CXXModules + NAMESPACE CXXModules:: + DESTINATION "lib/cmake/export_include_directories" + FILE "export_include_directories-targets.cmake" + CXX_MODULES_DIRECTORY "export_include_directories-cxx-modules") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_include_directories-config.cmake" + "include(\"\${CMAKE_CURRENT_LIST_DIR}/export_include_directories-targets.cmake\") +set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1) +") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/export_include_directories-config.cmake" + DESTINATION "lib/cmake/export_include_directories") + +set(generator + -G "${CMAKE_GENERATOR}") +if (CMAKE_GENERATOR_TOOLSET) + list(APPEND generator + -T "${CMAKE_GENERATOR_TOOLSET}") +endif () +if (CMAKE_GENERATOR_PLATFORM) + list(APPEND generator + -A "${CMAKE_GENERATOR_PLATFORM}") +endif () + +add_test(NAME export_include_directories_build + COMMAND + "${CMAKE_COMMAND}" + "-Dexpected_source_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu" + "-Dexpected_binary_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/bmi" + "-Dexport_include_directories_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_include_directories" + ${generator} + -S "${CMAKE_CURRENT_SOURCE_DIR}/test" + -B "${CMAKE_CURRENT_BINARY_DIR}/test") diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-install/forward.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/forward.cxx new file mode 100644 index 0000000..7f53271 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/forward.cxx @@ -0,0 +1,6 @@ +import priv; + +int forwarding() +{ + return from_private(); +} diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-install/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/importable.cxx new file mode 100644 index 0000000..6a1d83e --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/importable.cxx @@ -0,0 +1,18 @@ +module; + +#include "include/include.h" + +#ifndef include_h_included +# error "include define not found" +#endif + +export module importable; + +extern "C++" { +int forwarding(); +} + +export int from_import() +{ + return forwarding(); +} diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-install/include/include.h b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/include/include.h new file mode 100644 index 0000000..e3eee34 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/include/include.h @@ -0,0 +1,3 @@ +#pragma once + +#define include_h_included diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-install/no_modules.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/no_modules.cxx new file mode 100644 index 0000000..eea854f --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/no_modules.cxx @@ -0,0 +1,3 @@ +void no_modules() +{ +} diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-install/private.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/private.cxx new file mode 100644 index 0000000..c5b719a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/private.cxx @@ -0,0 +1,6 @@ +export module priv; + +export int from_private() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-install/subdir/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/subdir/importable.cxx new file mode 100644 index 0000000..07d6af6 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/subdir/importable.cxx @@ -0,0 +1,6 @@ +export module subdir_importable; + +export int from_subdir() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/test/CMakeLists.txt new file mode 100644 index 0000000..9cdb7ff --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-install/test/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_library NONE) + +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") + +find_package(export_include_directories REQUIRED) + +if (NOT TARGET CXXModules::export_include_directories) + message(FATAL_ERROR + "Missing imported target") +endif () + +get_property(file_sets TARGET CXXModules::export_include_directories + PROPERTY INTERFACE_CXX_MODULE_SETS) +if (NOT file_sets STREQUAL "modules") + message(FATAL_ERROR + "Incorrect exported file sets in CXXModules::export_include_directories:\n ${file_sets}") +endif () diff --git a/Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt index 3cd156a..106bd1e 100644 --- a/Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-interface-build/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") find_package(export_interfaces REQUIRED) diff --git a/Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt index 71bf86c..c19283b 100644 --- a/Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-interface-install/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") find_package(export_interfaces REQUIRED) diff --git a/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build/test/CMakeLists.txt index 0c094ac..fba05f4 100644 --- a/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") find_package(export_interfaces_no_properties REQUIRED) diff --git a/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install/test/CMakeLists.txt index 0c094ac..fba05f4 100644 --- a/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) project(cxx_modules_library NONE) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") find_package(export_interfaces_no_properties REQUIRED) diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-build-stderr.txt b/Tests/RunCMake/CXXModules/examples/export-usage-build-stderr.txt new file mode 100644 index 0000000..be89b8c --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-build-stderr.txt @@ -0,0 +1,4 @@ +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-build/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-usage-build/CMakeLists.txt new file mode 100644 index 0000000..86a608b --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-build/CMakeLists.txt @@ -0,0 +1,110 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_export_usage CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_library(export_usage STATIC) +target_sources(export_usage + PRIVATE + forward.cxx + PRIVATE + FILE_SET modules_private TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + private.cxx + PUBLIC + FILE_SET modules TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + importable.cxx) +target_compile_features(export_usage PUBLIC cxx_std_20) + +list(APPEND CMAKE_CXX_KNOWN_FEATURES + exported + buildiface + installiface + buildlocaliface) + +target_include_directories(export_usage + PRIVATE + "/usr/exported" + "$<BUILD_INTERFACE:/usr/buildiface>" + "$<INSTALL_INTERFACE:/usr/installiface>" + "$<BUILD_LOCAL_INTERFACE:/usr/buildlocaliface>") +target_compile_definitions(export_usage + PRIVATE + "exported" + "$<BUILD_INTERFACE:buildiface>" + "$<INSTALL_INTERFACE:installiface>" + "$<BUILD_LOCAL_INTERFACE:buildlocaliface>") +target_compile_features(export_usage + PRIVATE + "cxx_std_11" + "$<BUILD_INTERFACE:cxx_std_14>" + "$<INSTALL_INTERFACE:cxx_std_17>" + "$<BUILD_LOCAL_INTERFACE:cxx_std_20>") + +if (MSVC) + set(variable_flag "-constexpr:depth") +else () + set(variable_flag "-fconstexpr-depth=") +endif () + +target_compile_options(export_usage + PRIVATE + "${variable_flag}100" + "$<BUILD_INTERFACE:${variable_flag}200>" + "$<INSTALL_INTERFACE:${variable_flag}300>" + "$<BUILD_LOCAL_INTERFACE:${variable_flag}400>") + +add_library(export_used INTERFACE) +add_library(export_build INTERFACE) +add_library(export_install INTERFACE) +add_library(export_never INTERFACE) + +target_link_libraries(export_usage + PRIVATE + "export_used" + "$<BUILD_INTERFACE:export_build>" + "$<INSTALL_INTERFACE:export_install>" + "$<BUILD_LOCAL_INTERFACE:export_never>") + +install(TARGETS export_usage + EXPORT CXXModules + FILE_SET modules DESTINATION "lib/cxx/miu") +export(EXPORT CXXModules + NAMESPACE CXXModules:: + FILE "${CMAKE_CURRENT_BINARY_DIR}/export_usage-targets.cmake") +install(TARGETS export_used export_build export_install + EXPORT CXXModulesDeps) +export(EXPORT CXXModulesDeps + NAMESPACE CXXModules:: + FILE "${CMAKE_CURRENT_BINARY_DIR}/export_usage-dep-targets.cmake") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_usage-config.cmake" + "include(\"\${CMAKE_CURRENT_LIST_DIR}/export_usage-dep-targets.cmake\") +include(\"\${CMAKE_CURRENT_LIST_DIR}/export_usage-targets.cmake\") +set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1) +") + +set(generator + -G "${CMAKE_GENERATOR}") +if (CMAKE_GENERATOR_TOOLSET) + list(APPEND generator + -T "${CMAKE_GENERATOR_TOOLSET}") +endif () +if (CMAKE_GENERATOR_PLATFORM) + list(APPEND generator + -A "${CMAKE_GENERATOR_PLATFORM}") +endif () + +add_test(NAME export_usage_build + COMMAND + "${CMAKE_COMMAND}" + "-Dexpected_dir=${CMAKE_CURRENT_SOURCE_DIR}" + "-Dexport_interfaces_flag=${variable_flag}" + "-Dexport_usage_DIR=${CMAKE_CURRENT_BINARY_DIR}" + ${generator} + -S "${CMAKE_CURRENT_SOURCE_DIR}/test" + -B "${CMAKE_CURRENT_BINARY_DIR}/test") diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-build/forward.cxx b/Tests/RunCMake/CXXModules/examples/export-usage-build/forward.cxx new file mode 100644 index 0000000..7f53271 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-build/forward.cxx @@ -0,0 +1,6 @@ +import priv; + +int forwarding() +{ + return from_private(); +} diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-build/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-usage-build/importable.cxx new file mode 100644 index 0000000..8dfc41b --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-build/importable.cxx @@ -0,0 +1,10 @@ +export module importable; + +extern "C++" { +int forwarding(); +} + +export int from_import() +{ + return forwarding(); +} diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-build/private.cxx b/Tests/RunCMake/CXXModules/examples/export-usage-build/private.cxx new file mode 100644 index 0000000..c5b719a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-build/private.cxx @@ -0,0 +1,6 @@ +export module priv; + +export int from_private() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-usage-build/test/CMakeLists.txt new file mode 100644 index 0000000..adec9e7 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-build/test/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_library NONE) + +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") + +find_package(export_usage REQUIRED) + +if (NOT TARGET CXXModules::export_usage) + message(FATAL_ERROR + "Missing imported target") +endif () + +if (NOT TARGET CXXModules::export_used) + message(FATAL_ERROR + "Missing imported target") +endif () + +if (NOT TARGET CXXModules::export_build) + message(FATAL_ERROR + "Missing imported target") +endif () + +if (NOT TARGET CXXModules::export_install) + message(FATAL_ERROR + "Missing imported target") +endif () + +if (TARGET CXXModules::export_never) + message(FATAL_ERROR + "Extra imported target") +endif () + +function (check_property expected property) + get_property(actual TARGET CXXModules::export_usage + PROPERTY "${property}") + if (NOT actual STREQUAL expected) + message(SEND_ERROR + "Mismatch for ${property}:\n expected: ${expected}\n actual: ${actual}") + endif () +endfunction () + +check_property("/usr/exported;/usr/buildiface" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES") +check_property("exported;buildiface" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS") +check_property("cxx_std_20;cxx_std_11;cxx_std_14" "IMPORTED_CXX_MODULES_COMPILE_FEATURES") +check_property("${export_interfaces_flag}100;${export_interfaces_flag}200" "IMPORTED_CXX_MODULES_COMPILE_OPTIONS") +check_property("$<COMPILE_ONLY:CXXModules::export_used>;$<COMPILE_ONLY:CXXModules::export_build>" "IMPORTED_CXX_MODULES_LINK_LIBRARIES") + +# Extract the export-dependent targets from the export file. +file(STRINGS "${export_usage_DIR}/export_usage-targets.cmake" usage_dependent_targets + REGEX "foreach._target ") +# Rudimentary argument splitting. +string(REPLACE " " ";" usage_dependent_targets "${usage_dependent_targets}") +# Keep only "target" names. +list(FILTER usage_dependent_targets INCLUDE REGEX "CXXModules::") +# Strip quotes. +string(REPLACE "\"" "" usage_dependent_targets "${usage_dependent_targets}") + +if (NOT "CXXModules::export_used" IN_LIST usage_dependent_targets) + message(SEND_ERROR + "The main export does not require the 'CXXModules::export_used' target") +endif () +if (NOT "CXXModules::export_build" IN_LIST usage_dependent_targets) + message(SEND_ERROR + "The main export does not require the 'CXXModules::export_build' target") +endif () +if ("CXXModules::export_install" IN_LIST usage_dependent_targets) + message(SEND_ERROR + "The main export requires the 'CXXModules::export_install' target") +endif () diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-install-stderr.txt b/Tests/RunCMake/CXXModules/examples/export-usage-install-stderr.txt new file mode 100644 index 0000000..be89b8c --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-install-stderr.txt @@ -0,0 +1,4 @@ +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-install/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-usage-install/CMakeLists.txt new file mode 100644 index 0000000..11f53b0 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-install/CMakeLists.txt @@ -0,0 +1,114 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_export_usage CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_library(export_usage STATIC) +target_sources(export_usage + PRIVATE + forward.cxx + PRIVATE + FILE_SET modules_private TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + private.cxx + PUBLIC + FILE_SET modules TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + importable.cxx) +target_compile_features(export_usage PUBLIC cxx_std_20) + +list(APPEND CMAKE_CXX_KNOWN_FEATURES + exported + buildiface + installiface + buildlocaliface) + +target_include_directories(export_usage + PRIVATE + "/usr/exported" + "$<BUILD_INTERFACE:/usr/buildiface>" + "$<INSTALL_INTERFACE:/usr/installiface>" + "$<BUILD_LOCAL_INTERFACE:/usr/buildlocaliface>") +target_compile_definitions(export_usage + PRIVATE + "exported" + "$<BUILD_INTERFACE:buildiface>" + "$<INSTALL_INTERFACE:installiface>" + "$<BUILD_LOCAL_INTERFACE:buildlocaliface>") +target_compile_features(export_usage + PRIVATE + "cxx_std_11" + "$<BUILD_INTERFACE:cxx_std_14>" + "$<INSTALL_INTERFACE:cxx_std_17>" + "$<BUILD_LOCAL_INTERFACE:cxx_std_20>") + +if (MSVC) + set(variable_flag "-constexpr:depth") +else () + set(variable_flag "-fconstexpr-depth=") +endif () + +target_compile_options(export_usage + PRIVATE + "${variable_flag}100" + "$<BUILD_INTERFACE:${variable_flag}200>" + "$<INSTALL_INTERFACE:${variable_flag}300>" + "$<BUILD_LOCAL_INTERFACE:${variable_flag}400>") + +add_library(export_used INTERFACE) +add_library(export_build INTERFACE) +add_library(export_install INTERFACE) +add_library(export_never INTERFACE) + +target_link_libraries(export_usage + PRIVATE + "export_used" + "$<BUILD_INTERFACE:export_build>" + "$<INSTALL_INTERFACE:export_install>" + "$<BUILD_LOCAL_INTERFACE:export_never>") + +install(TARGETS export_usage + EXPORT CXXModules + FILE_SET modules DESTINATION "lib/cxx/miu") +install(EXPORT CXXModules + NAMESPACE CXXModules:: + DESTINATION "lib/cmake/export_usage" + FILE "export_usage-targets.cmake") +install(TARGETS export_used export_build export_install + EXPORT CXXModulesDeps) +install(EXPORT CXXModulesDeps + NAMESPACE CXXModules:: + DESTINATION "lib/cmake/export_usage" + FILE "export_usage-dep-targets.cmake") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_usage-config.cmake" + "include(\"\${CMAKE_CURRENT_LIST_DIR}/export_usage-dep-targets.cmake\") +include(\"\${CMAKE_CURRENT_LIST_DIR}/export_usage-targets.cmake\") +set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1) +") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/export_usage-config.cmake" + DESTINATION "lib/cmake/export_usage") + +set(generator + -G "${CMAKE_GENERATOR}") +if (CMAKE_GENERATOR_TOOLSET) + list(APPEND generator + -T "${CMAKE_GENERATOR_TOOLSET}") +endif () +if (CMAKE_GENERATOR_PLATFORM) + list(APPEND generator + -A "${CMAKE_GENERATOR_PLATFORM}") +endif () + +add_test(NAME export_usage_build + COMMAND + "${CMAKE_COMMAND}" + "-Dexpected_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu" + "-Dexport_interfaces_flag=${variable_flag}" + "-Dexport_usage_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_usage" + ${generator} + -S "${CMAKE_CURRENT_SOURCE_DIR}/test" + -B "${CMAKE_CURRENT_BINARY_DIR}/test") diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-install/forward.cxx b/Tests/RunCMake/CXXModules/examples/export-usage-install/forward.cxx new file mode 100644 index 0000000..7f53271 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-install/forward.cxx @@ -0,0 +1,6 @@ +import priv; + +int forwarding() +{ + return from_private(); +} diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-install/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-usage-install/importable.cxx new file mode 100644 index 0000000..8dfc41b --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-install/importable.cxx @@ -0,0 +1,10 @@ +export module importable; + +extern "C++" { +int forwarding(); +} + +export int from_import() +{ + return forwarding(); +} diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-install/private.cxx b/Tests/RunCMake/CXXModules/examples/export-usage-install/private.cxx new file mode 100644 index 0000000..c5b719a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-install/private.cxx @@ -0,0 +1,6 @@ +export module priv; + +export int from_private() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-usage-install/test/CMakeLists.txt new file mode 100644 index 0000000..9ccd63a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-usage-install/test/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_library NONE) + +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") + +find_package(export_usage REQUIRED) + +if (NOT TARGET CXXModules::export_usage) + message(FATAL_ERROR + "Missing imported target") +endif () + +if (NOT TARGET CXXModules::export_used) + message(FATAL_ERROR + "Missing imported target") +endif () + +if (NOT TARGET CXXModules::export_build) + message(FATAL_ERROR + "Missing imported target") +endif () + +if (NOT TARGET CXXModules::export_install) + message(FATAL_ERROR + "Missing imported target") +endif () + +if (TARGET CXXModules::export_never) + message(FATAL_ERROR + "Extra imported target") +endif () + +function (check_property expected property) + get_property(actual TARGET CXXModules::export_usage + PROPERTY "${property}") + if (NOT actual STREQUAL expected) + message(SEND_ERROR + "Mismatch for ${property}:\n expected: ${expected}\n actual : ${actual}") + endif () +endfunction () + +check_property("/usr/exported;/usr/installiface" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES") +check_property("exported;installiface" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS") +check_property("cxx_std_20;cxx_std_11;cxx_std_17" "IMPORTED_CXX_MODULES_COMPILE_FEATURES") +check_property("${export_interfaces_flag}100;${export_interfaces_flag}300" "IMPORTED_CXX_MODULES_COMPILE_OPTIONS") +check_property("$<COMPILE_ONLY:CXXModules::export_used>;$<COMPILE_ONLY:CXXModules::export_install>" "IMPORTED_CXX_MODULES_LINK_LIBRARIES") + +# Extract the export-dependent targets from the export file. +file(STRINGS "${export_usage_DIR}/export_usage-targets.cmake" usage_dependent_targets + REGEX "foreach._target ") +# Rudimentary argument splitting. +string(REPLACE " " ";" usage_dependent_targets "${usage_dependent_targets}") +# Keep only "target" names. +list(FILTER usage_dependent_targets INCLUDE REGEX "CXXModules::") +# Strip quotes. +string(REPLACE "\"" "" usage_dependent_targets "${usage_dependent_targets}") + +if (NOT "CXXModules::export_used" IN_LIST usage_dependent_targets) + message(SEND_ERROR + "The main export does not require the 'CXXModules::export_used' target") +endif () +if ("CXXModules::export_build" IN_LIST usage_dependent_targets) + message(SEND_ERROR + "The main export requires the 'CXXModules::export_build' target") +endif () +if (NOT "CXXModules::export_install" IN_LIST usage_dependent_targets) + message(SEND_ERROR + "The main export does not require the 'CXXModules::export_install' target") +endif () diff --git a/Tests/RunCMake/CXXModules/examples/generated-stderr.txt b/Tests/RunCMake/CXXModules/examples/generated-stderr.txt index 1dd9876..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/generated-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/generated-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:12 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/generated/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/generated/CMakeLists.txt index 73f7ff7..9a8da3d 100644 --- a/Tests/RunCMake/CXXModules/examples/generated/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/generated/CMakeLists.txt @@ -3,10 +3,14 @@ project(cxx_modules_generated CXX) include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/importable.cxx.in" - "${CMAKE_CURRENT_BINARY_DIR}/importable.cxx" - COPYONLY) +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/importable.cxx" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/importable.cxx.in" + COMMAND "${CMAKE_COMMAND}" + -E copy_if_different + "${CMAKE_CURRENT_SOURCE_DIR}/importable.cxx.in" + "${CMAKE_CURRENT_BINARY_DIR}/importable.cxx" + COMMENT "Copying 'importable.cxx'") add_executable(generated) target_sources(generated diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-build-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-build-stderr.txt new file mode 100644 index 0000000..e2970ec --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-build-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build-build/export_bmi_and_interfaces-targets.cmake:[0-9]+ \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build-build/export_bmi_and_interfaces-config.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-install-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-install-stderr.txt new file mode 100644 index 0000000..ec5dd1f --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-install-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install-install/lib/cmake/export_bmi_and_interfaces/export_bmi_and_interfaces-targets.cmake:[0-9]+ \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install-install/lib/cmake/export_bmi_and_interfaces/export_bmi_and_interfaces-config.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-include-directories-build-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-include-directories-build-stderr.txt new file mode 100644 index 0000000..4ea3679 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-include-directories-build-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-include-directories-build-build/export_include_directories-targets.cmake:[0-9]+ \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-include-directories-build-build/export_include_directories-config.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-include-directories-install-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-include-directories-install-stderr.txt new file mode 100644 index 0000000..50ad6b9 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-include-directories-install-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-include-directories-install-install/lib/cmake/export_include_directories/export_include_directories-targets.cmake:[0-9]+ \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-include-directories-install-install/lib/cmake/export_include_directories/export_include_directories-config.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-build-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-build-stderr.txt new file mode 100644 index 0000000..10404c6 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-build-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-interface-build-build/export_interfaces-targets.cmake:[0-9]+ \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-interface-build-build/export_interfaces-config.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-install-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-install-stderr.txt new file mode 100644 index 0000000..04124cd --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-install-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-interface-install-install/lib/cmake/export_interfaces/export_interfaces-targets.cmake:[0-9]+ \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-interface-install-install/lib/cmake/export_interfaces/export_interfaces-config.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-build-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-build-stderr.txt new file mode 100644 index 0000000..dcf6498 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-build-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build-build/export_interfaces_no_properties-targets.cmake:[0-9]+ \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build-build/export_interfaces_no_properties-config.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-install-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-install-stderr.txt new file mode 100644 index 0000000..7073b4a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-install-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install-install/lib/cmake/export_interfaces_no_properties/export_interfaces_no_properties-targets.cmake:[0-9]+ \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install-install/lib/cmake/export_interfaces_no_properties/export_interfaces_no_properties-config.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt new file mode 100644 index 0000000..946792c --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_import_interfaces CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +if (NO_PROPERTIES) + set(package_name "export_interfaces_no_properties") +elseif (WITH_BMIS) + set(package_name "export_bmi_and_interfaces") +elseif (INCLUDE_PROPERTIES) + set(package_name "export_include_directories") +else () + set(package_name "export_interfaces") +endif () +set(target_name "CXXModules::${package_name}") + +find_package("${package_name}" REQUIRED) + +add_executable(use_import_interfaces) +target_sources(use_import_interfaces + PRIVATE + use.cxx) +target_compile_features(use_import_interfaces PRIVATE cxx_std_20) +target_link_libraries(use_import_interfaces PRIVATE "${target_name}") + +add_test(NAME use_import_interfaces COMMAND use_import_interfaces) diff --git a/Tests/RunCMake/CXXModules/examples/import-modules/use.cxx b/Tests/RunCMake/CXXModules/examples/import-modules/use.cxx new file mode 100644 index 0000000..2da1913 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules/use.cxx @@ -0,0 +1,12 @@ +#if defined(__has_include) +# if __has_include(<include/include.h>) +# error "include directories leaked from private module requirements" +# endif +#endif + +import importable; + +int main(int argc, char* argv[]) +{ + return from_import(); +} diff --git a/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces-stderr.txt b/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces-stderr.txt index 78bdf2b..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/install-bmi-stderr.txt b/Tests/RunCMake/CXXModules/examples/install-bmi-stderr.txt index 78bdf2b..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/install-bmi-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/install-bmi-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/internal-partitions-stderr.txt b/Tests/RunCMake/CXXModules/examples/internal-partitions-stderr.txt index 79c5637..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/internal-partitions-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/internal-partitions-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:10 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/library-shared-stderr.txt b/Tests/RunCMake/CXXModules/examples/library-shared-stderr.txt index 79c5637..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/library-shared-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/library-shared-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:10 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/library-static-stderr.txt b/Tests/RunCMake/CXXModules/examples/library-static-stderr.txt index 79c5637..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/library-static-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/library-static-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:10 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/object-library-stderr.txt b/Tests/RunCMake/CXXModules/examples/object-library-stderr.txt index 4709399..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/object-library-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/object-library-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:[0-9]* \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/partitions-stderr.txt b/Tests/RunCMake/CXXModules/examples/partitions-stderr.txt index 79c5637..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/partitions-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/partitions-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:10 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/public-req-private-stderr.txt b/Tests/RunCMake/CXXModules/examples/public-req-private-stderr.txt index 78bdf2b..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/public-req-private-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/public-req-private-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/req-private-other-target-stderr.txt b/Tests/RunCMake/CXXModules/examples/req-private-other-target-stderr.txt index 78bdf2b..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/req-private-other-target-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/req-private-other-target-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/same-src-name-stderr.txt b/Tests/RunCMake/CXXModules/examples/same-src-name-stderr.txt index 78bdf2b..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/same-src-name-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/same-src-name-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt b/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt index 34f3f85..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:25 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/simple-stderr.txt b/Tests/RunCMake/CXXModules/examples/simple-stderr.txt index 78bdf2b..be89b8c 100644 --- a/Tests/RunCMake/CXXModules/examples/simple-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/simple-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/try-compile-stderr.txt b/Tests/RunCMake/CXXModules/examples/try-compile-stderr.txt new file mode 100644 index 0000000..a121e86 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/try-compile-stderr.txt @@ -0,0 +1,4 @@ +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(try_compile\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/try-compile/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/try-compile/CMakeLists.txt new file mode 100644 index 0000000..dee61f1 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/try-compile/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_try_compile CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") +try_compile(can_use_modules + SOURCES_TYPE CXX_MODULE + SOURCES + "${CMAKE_CURRENT_LIST_DIR}/importable.cxx" + SOURCES_TYPE NORMAL + SOURCE_FROM_FILE + use_importable.cxx "${CMAKE_CURRENT_LIST_DIR}/use_importable.cxx" + CXX_STANDARD 20) + +if (NOT can_use_modules) + message(FATAL_ERROR + "`try_compile` could not compile sources using modules.") +endif () diff --git a/Tests/RunCMake/CXXModules/examples/try-compile/importable.cxx b/Tests/RunCMake/CXXModules/examples/try-compile/importable.cxx new file mode 100644 index 0000000..607680a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/try-compile/importable.cxx @@ -0,0 +1,6 @@ +export module importable; + +export int from_import() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/try-compile/use_importable.cxx b/Tests/RunCMake/CXXModules/examples/try-compile/use_importable.cxx new file mode 100644 index 0000000..8d6bab2 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/try-compile/use_importable.cxx @@ -0,0 +1,6 @@ +import importable; + +int foo() +{ + return from_import(); +} diff --git a/Tests/RunCMake/CXXModules/examples/try-run-stderr.txt b/Tests/RunCMake/CXXModules/examples/try-run-stderr.txt new file mode 100644 index 0000000..8eea7a6 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/try-run-stderr.txt @@ -0,0 +1,4 @@ +CMake Warning \(dev\) at CMakeLists.txt:[0-9]+ \(try_run\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/try-run/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/try-run/CMakeLists.txt new file mode 100644 index 0000000..fb03571 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/try-run/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_try_run CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +try_run(can_run_modules_result can_compile_modules + SOURCES_TYPE CXX_MODULE + SOURCES + "${CMAKE_CURRENT_LIST_DIR}/importable.cxx" + SOURCES_TYPE NORMAL + SOURCE_FROM_FILE + main.cxx "${CMAKE_CURRENT_LIST_DIR}/main.cxx" + CXX_STANDARD 20) + +if (NOT can_compile_modules) + message(FATAL_ERROR + "`try_run` could not compile sources using modules.") +endif () + +if (can_run_modules_result) + message(FATAL_ERROR + "`try_run` could not run sources using modules.") +endif () diff --git a/Tests/RunCMake/CXXModules/examples/try-run/importable.cxx b/Tests/RunCMake/CXXModules/examples/try-run/importable.cxx new file mode 100644 index 0000000..607680a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/try-run/importable.cxx @@ -0,0 +1,6 @@ +export module importable; + +export int from_import() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/try-run/main.cxx b/Tests/RunCMake/CXXModules/examples/try-run/main.cxx new file mode 100644 index 0000000..5c1bb42 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/try-run/main.cxx @@ -0,0 +1,6 @@ +import importable; + +int main(int argc, char* argv[]) +{ + return from_import() == 1; +} diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-private.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-private.json index 65f0759..45b0396 100644 --- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-private.json +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-private.json @@ -6,9 +6,12 @@ "script-location": "<BINARY_DIR>/CMakeFiles/ninja-bmi-install-private.dir/install-cxx-module-bmi-<CONFIG_FORCE>.cmake" }, "compiler-id": "<IGNORE>", + "compiler-frontend-variant": "<IGNORE>", + "compiler-simulate-id": "<IGNORE>", "config": "<CONFIG>", "cxx-modules": { - "CMakeFiles/ninja-bmi-install-private.dir/sources/module-internal-part.cxx.o": { + "CMakeFiles/ninja-bmi-install-private.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": null, "name": "internal_partitions", "relative-directory": "sources", @@ -16,7 +19,8 @@ "type": "CXX_MODULES", "visibility": "PRIVATE" }, - "CMakeFiles/ninja-bmi-install-private.dir/sources/module-part.cxx.o": { + "CMakeFiles/ninja-bmi-install-private.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": null, "name": "modules", "relative-directory": "", @@ -24,7 +28,8 @@ "type": "CXX_MODULES", "visibility": "PRIVATE" }, - "CMakeFiles/ninja-bmi-install-private.dir/sources/module.cxx.o": { + "CMakeFiles/ninja-bmi-install-private.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": { + "bmi-only": false, "destination": null, "name": "modules", "relative-directory": "", @@ -41,5 +46,5 @@ "include-dirs": [], "language": "CXX", "linked-target-dirs": [], - "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-bmi-install-private.dir" + "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-bmi-install-private.dir<CONFIG_DIR>" } diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-public.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-public.json index 9c8a895..30b55e3 100644 --- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-public.json +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-public.json @@ -3,12 +3,15 @@ "destination": "lib/cxx/modules/<CONFIG>", "message-level": "", "permissions": "", - "script-location": "<BINARY_DIR>/CMakeFiles/ninja-bmi-install-public.dir/install-cxx-module-bmi-noconfig.cmake" + "script-location": "<BINARY_DIR>/CMakeFiles/ninja-bmi-install-public.dir/install-cxx-module-bmi-<CONFIG_FORCE>.cmake" }, "compiler-id": "<IGNORE>", + "compiler-frontend-variant": "<IGNORE>", + "compiler-simulate-id": "<IGNORE>", "config": "<CONFIG>", "cxx-modules": { - "CMakeFiles/ninja-bmi-install-public.dir/sources/module-internal-part.cxx.o": { + "CMakeFiles/ninja-bmi-install-public.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": "lib/cxx/internals", "name": "internal_partitions", "relative-directory": "sources", @@ -16,7 +19,8 @@ "type": "CXX_MODULES", "visibility": "PUBLIC" }, - "CMakeFiles/ninja-bmi-install-public.dir/sources/module-part.cxx.o": { + "CMakeFiles/ninja-bmi-install-public.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": "lib/cxx", "name": "modules", "relative-directory": "", @@ -24,7 +28,8 @@ "type": "CXX_MODULES", "visibility": "PUBLIC" }, - "CMakeFiles/ninja-bmi-install-public.dir/sources/module.cxx.o": { + "CMakeFiles/ninja-bmi-install-public.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": { + "bmi-only": false, "destination": "lib/cxx", "name": "modules", "relative-directory": "", @@ -41,5 +46,5 @@ "include-dirs": [], "language": "CXX", "linked-target-dirs": [], - "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-bmi-install-public.dir" + "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-bmi-install-public.dir<CONFIG_DIR>" } diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json index 0545981..f06a846 100644 --- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json @@ -1,9 +1,12 @@ { "bmi-installation": null, "compiler-id": "<IGNORE>", + "compiler-frontend-variant": "<IGNORE>", + "compiler-simulate-id": "<IGNORE>", "config": "<CONFIG>", "cxx-modules": { - "CMakeFiles/ninja-exports-private.dir/sources/module-internal-part.cxx.o": { + "CMakeFiles/ninja-exports-private.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": null, "name": "internal_partitions", "relative-directory": "sources", @@ -11,7 +14,8 @@ "type": "CXX_MODULES", "visibility": "PRIVATE" }, - "CMakeFiles/ninja-exports-private.dir/sources/module-part.cxx.o": { + "CMakeFiles/ninja-exports-private.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": null, "name": "modules", "relative-directory": "", @@ -19,7 +23,8 @@ "type": "CXX_MODULES", "visibility": "PRIVATE" }, - "CMakeFiles/ninja-exports-private.dir/sources/module.cxx.o": { + "CMakeFiles/ninja-exports-private.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": { + "bmi-only": false, "destination": null, "name": "modules", "relative-directory": "", @@ -69,5 +74,5 @@ "include-dirs": [], "language": "CXX", "linked-target-dirs": [], - "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-exports-private.dir" + "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-exports-private.dir<CONFIG_DIR>" } diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json index adc3ae3..938481c 100644 --- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json @@ -1,9 +1,12 @@ { "bmi-installation": null, "compiler-id": "<IGNORE>", + "compiler-frontend-variant": "<IGNORE>", + "compiler-simulate-id": "<IGNORE>", "config": "<CONFIG>", "cxx-modules": { - "CMakeFiles/ninja-exports-public.dir/sources/module-internal-part.cxx.o": { + "CMakeFiles/ninja-exports-public.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": "lib/cxx/internals", "name": "internal_partitions", "relative-directory": "sources", @@ -11,7 +14,8 @@ "type": "CXX_MODULES", "visibility": "PUBLIC" }, - "CMakeFiles/ninja-exports-public.dir/sources/module-part.cxx.o": { + "CMakeFiles/ninja-exports-public.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": "lib/cxx", "name": "modules", "relative-directory": "", @@ -19,7 +23,8 @@ "type": "CXX_MODULES", "visibility": "PUBLIC" }, - "CMakeFiles/ninja-exports-public.dir/sources/module.cxx.o": { + "CMakeFiles/ninja-exports-public.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": { + "bmi-only": false, "destination": "lib/cxx", "name": "modules", "relative-directory": "", @@ -69,5 +74,5 @@ "include-dirs": [], "language": "CXX", "linked-target-dirs": [], - "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-exports-public.dir" + "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-exports-public.dir<CONFIG_DIR>" } diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json index 9ba6568..3a66a94 100644 --- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json @@ -1,9 +1,12 @@ { "bmi-installation": null, "compiler-id": "<IGNORE>", + "compiler-frontend-variant": "<IGNORE>", + "compiler-simulate-id": "<IGNORE>", "config": "<CONFIG>", "cxx-modules": { - "CMakeFiles/ninja-file-sets-private.dir/sources/module-internal-part.cxx.o": { + "CMakeFiles/ninja-file-sets-private.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": null, "name": "internal_partitions", "relative-directory": "sources", @@ -11,7 +14,8 @@ "type": "CXX_MODULES", "visibility": "PRIVATE" }, - "CMakeFiles/ninja-file-sets-private.dir/sources/module-part.cxx.o": { + "CMakeFiles/ninja-file-sets-private.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": null, "name": "modules", "relative-directory": "", @@ -19,7 +23,8 @@ "type": "CXX_MODULES", "visibility": "PRIVATE" }, - "CMakeFiles/ninja-file-sets-private.dir/sources/module.cxx.o": { + "CMakeFiles/ninja-file-sets-private.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": { + "bmi-only": false, "destination": null, "name": "modules", "relative-directory": "", @@ -36,5 +41,5 @@ "include-dirs": [], "language": "CXX", "linked-target-dirs": [], - "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-file-sets-private.dir" + "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-file-sets-private.dir<CONFIG_DIR>" } diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json index 46e2cbf..ac06c0f 100644 --- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json @@ -1,9 +1,12 @@ { "bmi-installation": null, "compiler-id": "<IGNORE>", + "compiler-frontend-variant": "<IGNORE>", + "compiler-simulate-id": "<IGNORE>", "config": "<CONFIG>", "cxx-modules": { - "CMakeFiles/ninja-file-sets-public.dir/<CONFIG_DIR>sources/module-internal-part.cxx.o": { + "CMakeFiles/ninja-file-sets-public.dir<CONFIG_DIR>/sources/module-internal-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": "lib/cxx/internals", "name": "internal_partitions", "relative-directory": "sources", @@ -11,7 +14,8 @@ "type": "CXX_MODULES", "visibility": "PUBLIC" }, - "CMakeFiles/ninja-file-sets-public.dir/<CONFIG_DIR>sources/module-part.cxx.o": { + "CMakeFiles/ninja-file-sets-public.dir<CONFIG_DIR>/sources/module-part.cxx<OBJEXT>": { + "bmi-only": false, "destination": "lib/cxx", "name": "modules", "relative-directory": "", @@ -19,7 +23,8 @@ "type": "CXX_MODULES", "visibility": "PUBLIC" }, - "CMakeFiles/ninja-file-sets-public.dir/<CONFIG_DIR>sources/module.cxx.o": { + "CMakeFiles/ninja-file-sets-public.dir<CONFIG_DIR>/sources/module.cxx<OBJEXT>": { + "bmi-only": false, "destination": "lib/cxx", "name": "modules", "relative-directory": "", @@ -36,5 +41,5 @@ "include-dirs": [], "language": "CXX", "linked-target-dirs": [], - "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-file-sets-public.dir" + "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-file-sets-public.dir<CONFIG_DIR>" } diff --git a/Tests/RunCMake/CommandLine/C-no-file-stderr.txt b/Tests/RunCMake/CommandLine/C-no-file-stderr.txt index b65a349..5d3d4b3 100644 --- a/Tests/RunCMake/CommandLine/C-no-file-stderr.txt +++ b/Tests/RunCMake/CommandLine/C-no-file-stderr.txt @@ -1,3 +1,3 @@ -^CMake Error: Error processing file: .*/Tests/RunCMake/CommandLine/C-no-file-build/nosuchcachefile.txt +^CMake Error: Not a file: .*/Tests/RunCMake/CommandLine/C-no-file-build/nosuchcachefile.txt CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/C-no-file-build" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.$ diff --git a/Tests/RunCMake/CommandLine/Cno-file-stderr.txt b/Tests/RunCMake/CommandLine/Cno-file-stderr.txt index 416686c..4024499 100644 --- a/Tests/RunCMake/CommandLine/Cno-file-stderr.txt +++ b/Tests/RunCMake/CommandLine/Cno-file-stderr.txt @@ -1,3 +1,3 @@ -^CMake Error: Error processing file: .*/Tests/RunCMake/CommandLine/Cno-file-build/nosuchcachefile.txt +^CMake Error: Not a file: .*/Tests/RunCMake/CommandLine/Cno-file-build/nosuchcachefile.txt CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/Cno-file-build" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.$ diff --git a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON-stderr.txt deleted file mode 100644 index 9080942..0000000 --- a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -^CMake Warning: - The "Visual Studio 11 2012" generator is deprecated and will be removed in - a future version of CMake. - - Add CMAKE_WARN_VS11=OFF to the cache to disable this warning.$ diff --git a/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-OFF.cmake b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-OFF.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-OFF.cmake diff --git a/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-ON-stderr.txt new file mode 100644 index 0000000..b69408e --- /dev/null +++ b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-ON-stderr.txt @@ -0,0 +1,5 @@ +^CMake Warning: + The "Visual Studio 12 2013" generator is deprecated and will be removed in + a future version of CMake. + + Add CMAKE_WARN_VS12=OFF to the cache to disable this warning.$ diff --git a/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-ON.cmake b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-ON.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CommandLine/DeprecateVS12-WARN-ON.cmake diff --git a/Tests/RunCMake/CommandLine/P_directory-stderr.txt b/Tests/RunCMake/CommandLine/P_directory-stderr.txt index b8319a1..ec33aed 100644 --- a/Tests/RunCMake/CommandLine/P_directory-stderr.txt +++ b/Tests/RunCMake/CommandLine/P_directory-stderr.txt @@ -1 +1 @@ -^CMake Error: Error processing file: .*/Tests/RunCMake/CommandLine$ +^CMake Error: Not a file: .*/Tests/RunCMake/CommandLine$ diff --git a/Tests/RunCMake/CommandLine/P_no-file-stderr.txt b/Tests/RunCMake/CommandLine/P_no-file-stderr.txt index 2e12399..a3b4e8e 100644 --- a/Tests/RunCMake/CommandLine/P_no-file-stderr.txt +++ b/Tests/RunCMake/CommandLine/P_no-file-stderr.txt @@ -1 +1,2 @@ -^CMake Error: Error processing file: nosuchscriptfile.cmake$ +^CMake Error: Not a file: nosuchscriptfile.cmake +CMake Error: Error processing file: nosuchscriptfile.cmake$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 45b4c0e..52be1bb 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -1119,9 +1119,11 @@ if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 2008") run_cmake_with_options(DeprecateVS9-WARN-OFF -DCMAKE_WARN_VS9=OFF) endif() -if(RunCMake_GENERATOR MATCHES "^Visual Studio 11 2012") - run_cmake_with_options(DeprecateVS11-WARN-ON -DCMAKE_WARN_VS11=ON) - unset(ENV{CMAKE_WARN_VS11}) - run_cmake(DeprecateVS11-WARN-ON) - run_cmake_with_options(DeprecateVS11-WARN-OFF -DCMAKE_WARN_VS11=OFF) +if(RunCMake_GENERATOR MATCHES "^Visual Studio 12 2013") + run_cmake_with_options(DeprecateVS12-WARN-ON -DCMAKE_WARN_VS12=ON) + unset(ENV{CMAKE_WARN_VS12}) + run_cmake(DeprecateVS12-WARN-ON) + run_cmake_with_options(DeprecateVS12-WARN-OFF -DCMAKE_WARN_VS12=OFF) endif() + +run_cmake_with_options(help-arbitrary "--help" "CMAKE_CXX_IGNORE_EXTENSIONS") diff --git a/Tests/RunCMake/CommandLine/help-arbitrary-stdout.txt b/Tests/RunCMake/CommandLine/help-arbitrary-stdout.txt new file mode 100644 index 0000000..3d07e91 --- /dev/null +++ b/Tests/RunCMake/CommandLine/help-arbitrary-stdout.txt @@ -0,0 +1,7 @@ +CMAKE_<LANG>_IGNORE_EXTENSIONS +------------------------------ + +File extensions that should be ignored by the build. + +This is a list of file extensions that may be part of a project for a +given language but are not compiled. diff --git a/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt b/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt index 320aecc..87999d5 100644 --- a/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt +++ b/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt @@ -1 +1 @@ -^CMake Error: Error processing file: +^CMake Error: Not a file: diff --git a/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator-stdout.txt b/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator-stdout.txt new file mode 100644 index 0000000..9a7d746 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator-stdout.txt @@ -0,0 +1,2 @@ +-- env_emulator='pseudo_emulator(\.exe)?' +-- emulator='pseudo_emulator(\.exe)?' diff --git a/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator.cmake b/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator.cmake new file mode 100644 index 0000000..55fc483 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/EnvCrossCompilingEmulator.cmake @@ -0,0 +1,6 @@ +message(STATUS "ENV{CMAKE_CROSS_COMPILING_EMULATOR}='$ENV{CMAKE_CROSSCOMPILING_EMULATOR}'") +message(STATUS "CMAKE_CROSSCOMPLING_EMULATOR='${CMAKE_CROSSCOMPILING_EMULATOR}'") +get_filename_component(env_emulator "$ENV{CMAKE_CROSSCOMPILING_EMULATOR}" NAME) +message(STATUS "env_emulator='${env_emulator}'") +get_filename_component(emulator "${CMAKE_CROSSCOMPILING_EMULATOR}" NAME) +message(STATUS "emulator='${emulator}'") diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake index 97b7b5a..1ffd91c 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake @@ -26,3 +26,11 @@ set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND_ARG}\;custom_argument") CustomCommandGenerator_run_and_build(AddCustomCommandWithArg) CustomCommandGenerator_run_and_build(AddCustomTargetWithArg) +unset(RunCMake_TEST_OPTIONS) + +function(run_EnvCrossCompilingEmulator) + set(ENV{CMAKE_CROSSCOMPILING_EMULATOR} "${PSEUDO_EMULATOR}") + run_cmake(EnvCrossCompilingEmulator) + unset(ENV{CMAKE_CROSSCOMPILING_EMULATOR}) +endfunction() +run_EnvCrossCompilingEmulator() diff --git a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake index 891e138..f7959dc 100644 --- a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake +++ b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake @@ -1,7 +1,11 @@ include(RunCMake) function(check_files dir) - set(expected ${ARGN}) + set(expected) + foreach(i IN LISTS ARGN) + get_filename_component(real_path ${i} REALPATH) + list(APPEND expected ${real_path}) + endforeach() list(FILTER expected EXCLUDE REGEX "^$") list(REMOVE_DUPLICATES expected) list(SORT expected) @@ -59,3 +63,5 @@ run_optimize_test(OptimizeStatic StaticTop) if(CMAKE_Fortran_COMPILER) run_optimize_test(OptimizeFortran FortranTop) endif() + +run_cmake_build(RuntimeTargets mylib SharedTop) diff --git a/Tests/RunCMake/DependencyGraph/RuntimeTargets.cmake b/Tests/RunCMake/DependencyGraph/RuntimeTargets.cmake new file mode 100644 index 0000000..21531cd --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/RuntimeTargets.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +set(CMAKE_OPTIMIZE_DEPENDENCIES TRUE) +add_library(mylib STATIC mylib.c) +add_library(neverbuild SHARED neverbuild.c) + +# Building mylib should not require building neverbuild +target_link_libraries(mylib PRIVATE neverbuild) +set_target_properties(neverbuild PROPERTIES EXCLUDE_FROM_ALL YES) + +# Building SharedTop should require SharedBottom to be built +add_library(SharedTop SHARED top.c) +add_library(StaticMiddle STATIC middle.c) +add_library(SharedBottom SHARED bottom.c) +target_link_libraries(SharedTop PRIVATE StaticMiddle) +target_link_libraries(StaticMiddle PRIVATE SharedBottom) +set_target_properties(StaticMiddle SharedBottom PROPERTIES EXCLUDE_FROM_ALL YES) +set_target_properties(StaticMiddle PROPERTIES POSITION_INDEPENDENT_CODE YES) diff --git a/Tests/RunCMake/DependencyGraph/bottom.c b/Tests/RunCMake/DependencyGraph/bottom.c new file mode 100644 index 0000000..c8ea481 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/bottom.c @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int bottom(void) +{ + return 23; +} diff --git a/Tests/RunCMake/DependencyGraph/middle.c b/Tests/RunCMake/DependencyGraph/middle.c new file mode 100644 index 0000000..3b1b84c --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/middle.c @@ -0,0 +1,9 @@ +#ifdef _WIN32 +__declspec(dllimport) +#endif + int bottom(void); + +int middle(void) +{ + return bottom() + 19; +} diff --git a/Tests/RunCMake/DependencyGraph/neverbuild.c b/Tests/RunCMake/DependencyGraph/neverbuild.c new file mode 100644 index 0000000..e490510 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/neverbuild.c @@ -0,0 +1 @@ +#error I should not be built diff --git a/Tests/RunCMake/DependencyGraph/top.c b/Tests/RunCMake/DependencyGraph/top.c new file mode 100644 index 0000000..eceb0a5 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/top.c @@ -0,0 +1,9 @@ +int middle(void); + +#ifdef _WIN32 +__declspec(dllexport) +#endif + int top(void) +{ + return middle() + 2; +} diff --git a/Tests/RunCMake/ExternalProject/DetectJobServer.cmake b/Tests/RunCMake/ExternalProject/DetectJobServer.cmake new file mode 100644 index 0000000..c6e1412 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/DetectJobServer.cmake @@ -0,0 +1,16 @@ +include(ExternalProject) +ExternalProject_Add(Foo + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Foo + BUILD_COMMAND ${DETECT_JOBSERVER} "ep.txt" + BUILD_JOB_SERVER_AWARE 1 + INSTALL_COMMAND "" +) + +# Add a second step to test JOB_SERVER_AWARE +ExternalProject_Add_Step(Foo + second_step + COMMAND ${DETECT_JOBSERVER} "ep_second_step.txt" + DEPENDEES build + ALWAYS 1 + JOB_SERVER_AWARE 1 +) diff --git a/Tests/RunCMake/ExternalProject/Foo/CMakeLists.txt b/Tests/RunCMake/ExternalProject/Foo/CMakeLists.txt new file mode 100644 index 0000000..b38b173 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Foo/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.27) +project(Foo NONE) + +add_custom_target(drive ALL COMMAND ${CMAKE_COMMAND} -E true) diff --git a/Tests/RunCMake/ExternalProject/GNUMakeJobServerAware-check.cmake b/Tests/RunCMake/ExternalProject/GNUMakeJobServerAware-check.cmake new file mode 100644 index 0000000..55a9f0d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/GNUMakeJobServerAware-check.cmake @@ -0,0 +1,16 @@ +set(BUILD_DIR "${RunCMake_BINARY_DIR}/GNUMakeJobServerAware-build") + +function(check target regex) + file(STRINGS ${BUILD_DIR}/${target} lines + REGEX ${regex} + ) + + list(LENGTH lines len) + if(len EQUAL 0) + message(FATAL_ERROR "Could not find matching lines '${regex}' in ${BUILD_DIR}/${target}") + endif() +endfunction() + +check("/CMakeFiles/Foo.dir/build.make" [[\+cd (/d )?"?.*"? && "?.*"? --build "?.*"?]]) +check("/CMakeFiles/Foo.dir/build.make" [[\+cd (/d )?"?.*"? && "?.*"? -E touch "?.*"?]]) +check("/CMakeFiles/Foo.dir/build.make" [[\+"?.*"? -E true]]) diff --git a/Tests/RunCMake/ExternalProject/GNUMakeJobServerAware.cmake b/Tests/RunCMake/ExternalProject/GNUMakeJobServerAware.cmake new file mode 100644 index 0000000..3f688ca --- /dev/null +++ b/Tests/RunCMake/ExternalProject/GNUMakeJobServerAware.cmake @@ -0,0 +1,16 @@ +include(ExternalProject) +ExternalProject_Add(Foo + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Foo + BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> + BUILD_JOB_SERVER_AWARE 1 + INSTALL_COMMAND "" +) + +# Add a second step to test JOB_SERVER_AWARE +ExternalProject_Add_Step(Foo + second_step + COMMAND ${CMAKE_COMMAND} -E true + DEPENDEES build + ALWAYS 1 + JOB_SERVER_AWARE 1 +) diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index 4afdef8..ffaa46c 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -144,6 +144,24 @@ function(__ep_test_with_build_with_server testName) run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .) endfunction() +if(RunCMake_GENERATOR MATCHES "(MSYS|MinGW|Unix) Makefiles") + __ep_test_with_build(GNUMakeJobServerAware) +endif() + +function(__ep_test_jobserver) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DetectJobServer-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake_with_options(DetectJobServer -DDETECT_JOBSERVER=${DETECT_JOBSERVER}) + run_cmake_command(DetectJobServer-clean ${CMAKE_COMMAND} --build . --target clean) + run_cmake_command(DetectJobServer-build ${CMAKE_COMMAND} --build . -j4) +endfunction() + +if(RunCMake_GENERATOR MATCHES "(MinGW|Unix) Makefiles") + __ep_test_jobserver() +endif() + __ep_test_with_build(MultiCommand) set(RunCMake_TEST_OUTPUT_MERGE 1) diff --git a/Tests/RunCMake/FetchContent/ExcludeFromAll.cmake b/Tests/RunCMake/FetchContent/ExcludeFromAll.cmake new file mode 100644 index 0000000..376f2eb --- /dev/null +++ b/Tests/RunCMake/FetchContent/ExcludeFromAll.cmake @@ -0,0 +1,11 @@ +enable_language(C) + +include(FetchContent) + +FetchContent_Declare( + ExcludeFromAll + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/ExcludeFromAll + EXCLUDE_FROM_ALL +) + +FetchContent_MakeAvailable(ExcludeFromAll) diff --git a/Tests/RunCMake/FetchContent/ExcludeFromAll/CMakeLists.txt b/Tests/RunCMake/FetchContent/ExcludeFromAll/CMakeLists.txt new file mode 100644 index 0000000..08ffb33 --- /dev/null +++ b/Tests/RunCMake/FetchContent/ExcludeFromAll/CMakeLists.txt @@ -0,0 +1 @@ +add_library(broken STATIC error.c) diff --git a/Tests/RunCMake/FetchContent/ExcludeFromAll/error.c b/Tests/RunCMake/FetchContent/ExcludeFromAll/error.c new file mode 100644 index 0000000..f10e687 --- /dev/null +++ b/Tests/RunCMake/FetchContent/ExcludeFromAll/error.c @@ -0,0 +1 @@ +#error "This should not be compiled" diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake index 3781089..d0790eb 100644 --- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake +++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake @@ -64,3 +64,15 @@ run_cmake_command(ScriptMode -DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM} -P ${CMAKE_CURRENT_LIST_DIR}/ScriptMode.cmake ) + +function(run_FetchContent_ExcludeFromAll) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExcludeFromAll-build) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(ExcludeFromAll) + + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build .) +endfunction() +run_FetchContent_ExcludeFromAll() diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 8911e18..807d92b 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -846,7 +846,7 @@ def gen_check_targets(c, g, inSource): e["compileGroups"] = apple_exe_framework["compileGroups"] e["link"] = apple_exe_framework["link"] - if cxx_compiler_id in ['Clang', 'AppleClang', 'LCC', 'GNU', 'Intel', 'IntelLLVM', 'MSVC', 'Embarcadero', 'IBMClang'] and g["name"] != "Xcode": + if cxx_compiler_id in ['Clang', 'AppleClang', 'LCC', 'GNU', 'Intel', 'IntelLLVM', 'MSVC', 'Embarcadero', 'CrayClang', 'IBMClang'] and g["name"] != "Xcode": for e in expected: if e["name"] == "cxx_exe": if matches(g["name"], "^(Visual Studio |Ninja Multi-Config)"): diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json index c4df2ec..f260037 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json @@ -16,7 +16,7 @@ "type": "target", "destination": "lib", "paths": [ - "^fileset/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_headers_1\\.(a|lib)?$" + "^fileset/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_headers_1\\.(a|lib|l)?$" ], "isExcludeFromAll": null, "isForAllComponents": null, @@ -172,7 +172,7 @@ "type": "target", "destination": "lib", "paths": [ - "^fileset/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_headers_2\\.(a|lib)?$" + "^fileset/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_headers_2\\.(a|lib|l)?$" ], "isExcludeFromAll": null, "isForAllComponents": null, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json index a35d5e2..b57ab45 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json @@ -80,7 +80,7 @@ "type": "target", "destination": "lib", "paths": [ - "^((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_shared_lib\\.(lib|dll\\.a)$" + "^((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_shared_lib\\.(dll\\.a|lib|l)$" ], "isExcludeFromAll": null, "isForAllComponents": null, @@ -173,7 +173,7 @@ "type": "target", "destination": "lib", "paths": [ - "^cxx/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?cxx_shared_lib\\.(lib|dll\\.a)$" + "^cxx/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?cxx_shared_lib\\.(dll\\.a|lib|l)$" ], "isExcludeFromAll": null, "isForAllComponents": null, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/apple_exe_framework.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/apple_exe_framework.json index 6d320f4..a4c13a8 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/apple_exe_framework.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/apple_exe_framework.json @@ -34,7 +34,7 @@ "lto": null, "commandFragments": [ { - "fragment": "-iframework .+/framework(/(Debug|Release|RelWithDebInfo|MinSizeRel))?\"? -iframework /usr/Frameworks$", + "fragment": "-F.+/framework(/(Debug|Release|RelWithDebInfo|MinSizeRel))?\"? -F/usr/Frameworks$", "role": "frameworkPath", "backtrace": null }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_1.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_1.json index f6cfa9c..faf0eaa 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_1.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_1.json @@ -219,10 +219,10 @@ } ], "folder": null, - "nameOnDisk": "^(lib)?c_headers_1\\.(a|lib)$", + "nameOnDisk": "^(lib)?c_headers_1\\.(a|lib|l)$", "artifacts": [ { - "path": "^fileset/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_headers_1\\.(a|lib)$", + "path": "^fileset/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_headers_1\\.(a|lib|l)$", "_dllExtra": false } ], diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_2.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_2.json index 591ba4f..b4f2f9d 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_2.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_2.json @@ -71,10 +71,10 @@ } ], "folder": null, - "nameOnDisk": "^(lib)?c_headers_2\\.(a|lib)$", + "nameOnDisk": "^(lib)?c_headers_2\\.(a|lib|l)$", "artifacts": [ { - "path": "^fileset/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_headers_2\\.(a|lib)$", + "path": "^fileset/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_headers_2\\.(a|lib|l)$", "_dllExtra": false } ], diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_lib.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_lib.json index dc74fdf..5b58dd1 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_lib.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_lib.json @@ -88,10 +88,10 @@ } ], "folder": null, - "nameOnDisk": "^(lib)?c_lib\\.(a|lib)$", + "nameOnDisk": "^(lib)?c_lib\\.(a|lib|l)$", "artifacts": [ { - "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_lib\\.(a|lib)$", + "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_lib\\.(a|lib|l)$", "_dllExtra": false } ], diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json index 85b5108..8d5faf8 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json @@ -100,7 +100,7 @@ "_dllExtra": false }, { - "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_shared_lib\\.(dll\\.a|lib)$", + "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_shared_lib\\.(dll\\.a|lib|l)$", "_dllExtra": true }, { diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_static_lib.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_static_lib.json index 6a51295..2220581 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_static_lib.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_static_lib.json @@ -88,10 +88,10 @@ } ], "folder": null, - "nameOnDisk": "^(lib)?c_static_lib\\.(a|lib)$", + "nameOnDisk": "^(lib)?c_static_lib\\.(a|lib|l)$", "artifacts": [ { - "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_static_lib\\.(a|lib)$", + "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_static_lib\\.(a|lib|l)$", "_dllExtra": false } ], diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_subdir.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_subdir.json index 362caf9..a5bebcd 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_subdir.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_subdir.json @@ -113,10 +113,10 @@ } ], "folder": null, - "nameOnDisk": "^(lib)?c_subdir\\.(a|lib)$", + "nameOnDisk": "^(lib)?c_subdir\\.(a|lib|l)$", "artifacts": [ { - "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_subdir\\.(a|lib)$", + "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_subdir\\.(a|lib|l)$", "_dllExtra": false } ], diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_lib.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_lib.json index 725cad9..2f8d6ed 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_lib.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_lib.json @@ -64,10 +64,10 @@ } ], "folder": null, - "nameOnDisk": "^(lib)?cxx_lib\\.(a|lib)$", + "nameOnDisk": "^(lib)?cxx_lib\\.(a|lib|l)$", "artifacts": [ { - "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?cxx_lib\\.(a|lib)$", + "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?cxx_lib\\.(a|lib|l)$", "_dllExtra": false } ], diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json index c92e573..2274e45 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json @@ -76,7 +76,7 @@ "_dllExtra": false }, { - "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?cxx_shared_lib\\.(dll\\.a|lib)$", + "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?cxx_shared_lib\\.(dll\\.a|lib|l)$", "_dllExtra": true }, { diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_static_lib.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_static_lib.json index 38790dd..2f322b0 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_static_lib.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_static_lib.json @@ -64,10 +64,10 @@ } ], "folder": null, - "nameOnDisk": "^(lib)?cxx_static_lib\\.(a|lib)$", + "nameOnDisk": "^(lib)?cxx_static_lib\\.(a|lib|l)$", "artifacts": [ { - "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?cxx_static_lib\\.(a|lib)$", + "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?cxx_static_lib\\.(a|lib|l)$", "_dllExtra": false } ], diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/interface_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/interface_exe.json index 521e464..5b47814 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/interface_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/interface_exe.json @@ -73,6 +73,47 @@ { "define": "interface_exe_EXPORTS", "backtrace": null + }, + { + "define": "COMPILED_WITH_INTERFACE_LIB", + "backtrace": [ + { + "file": "^include_test\\.cmake$", + "line": 4, + "command": "target_link_libraries", + "hasParent": true + }, + { + "file": "^include_test\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] } ], "compileCommandFragments": null @@ -129,7 +170,7 @@ "_dllExtra": false }, { - "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?my_interface_exe\\.(dll\\.a|lib)$", + "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?my_interface_exe\\.(dll\\.a|lib|l)$", "_dllExtra": true }, { diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/shared_framework.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/shared_framework.json index 41b5605..fab6f66 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/shared_framework.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/shared_framework.json @@ -76,7 +76,7 @@ "_dllExtra": false }, { - "path": "^framework/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?shared_framework\\.(dll\\.a|lib)$", + "path": "^framework/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?shared_framework\\.(dll\\.a|lib|l)$", "_dllExtra": true }, { diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/static_framework.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/static_framework.json index 00dd11e..d6cbded 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/static_framework.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/static_framework.json @@ -64,10 +64,10 @@ } ], "folder": null, - "nameOnDisk": "^(lib)?static_framework\\.(a|lib)$", + "nameOnDisk": "^(lib)?static_framework\\.(a|lib|l)$", "artifacts": [ { - "path": "^framework/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?static_framework\\.(a|lib)$", + "path": "^framework/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?static_framework\\.(a|lib|l)$", "_dllExtra": false } ], diff --git a/Tests/RunCMake/FileAPI/include_test.cmake b/Tests/RunCMake/FileAPI/include_test.cmake index c74d264..c188cb3 100644 --- a/Tests/RunCMake/FileAPI/include_test.cmake +++ b/Tests/RunCMake/FileAPI/include_test.cmake @@ -1,7 +1,7 @@ add_library(interface_lib INTERFACE) target_compile_definitions(interface_lib INTERFACE COMPILED_WITH_INTERFACE_LIB) add_executable(interface_exe empty.c) -target_link_libraries(interface_exe PRIVATE inteface_lib) +target_link_libraries(interface_exe PRIVATE interface_lib) set_property(TARGET interface_exe PROPERTY ENABLE_EXPORTS ON) set_property(TARGET interface_exe PROPERTY RUNTIME_OUTPUT_DIRECTORY bin) set_property(TARGET interface_exe PROPERTY ARCHIVE_OUTPUT_DIRECTORY lib) diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_DEFINE_VARIABLES.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_DEFINE_VARIABLES.cmake new file mode 100644 index 0000000..98f3cd6 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_DEFINE_VARIABLES.cmake @@ -0,0 +1,19 @@ +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) +if(WIN32) + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bletch") +else() + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch") +endif() + +find_package(PkgConfig REQUIRED) +pkg_check_modules(BLETCH QUIET bletch) + +if (NOT BLETCH_FOUND) + message(FATAL_ERROR "Failed to find embedded package bletch via CMAKE_PREFIX_PATH") +endif () + +pkg_get_variable(bletchvar bletch exec_prefix DEFINE_VARIABLES prefix=customprefix) +if (NOT bletchvar STREQUAL "customprefix") + message(FATAL_ERROR "Failed to fetch variable exec_prefix from embedded package bletch with prefix overridden to customprefix") +endif () diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt deleted file mode 100644 index 539e5ef..0000000 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt +++ /dev/null @@ -1,3 +0,0 @@ --- ZOT_LIBRARIES='zot' --- ZOT_LINK_LIBRARIES='[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/root/lib/prefix-zot-suffix' --- ZOT_LDFLAGS='-L[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/root/lib;-lzot' diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_SYSTEM_PATH-stdout.txt b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_SYSTEM_PATH-stdout.txt new file mode 100644 index 0000000..012458d --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_SYSTEM_PATH-stdout.txt @@ -0,0 +1,4 @@ +-- ZOT_LIBRARIES='zot' +-- ZOT_LINK_LIBRARIES='[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_SYSTEM_PATH-build/root/lib/prefix-zot-suffix' +-- ZOT_LDFLAGS='-L[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_SYSTEM_PATH-build/root/lib;-lzot' +-- ZOT_CFLAGS='-I[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_SYSTEM_PATH-build/root/include' diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_SYSTEM_PATH.cmake index 1278c49..e58cefb 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_SYSTEM_PATH.cmake @@ -3,16 +3,19 @@ find_package(PkgConfig REQUIRED) set(ROOT "${CMAKE_CURRENT_BINARY_DIR}/root") string(REPLACE " " "\\ " ESCAPED_ROOT "${ROOT}") set(LIB_DIR "${ROOT}/lib") +set(INCLUDE_DIR "${ROOT}/include") set(PKGCONFIG_DIR "${LIB_DIR}/pkgconfig") file(WRITE "${PKGCONFIG_DIR}/zot.pc" " prefix=${ESCAPED_ROOT} libdir=\${prefix}/lib +includedir=\${prefix}/include Name: Zot Description: Dummy package to test LIBRARY_DIR support Version: 1.0 Libs: -L\${libdir} -lzot +Cflags: -I\${includedir} ") # Create a "library" file to find in libdir. @@ -22,9 +25,13 @@ file(WRITE "${LIB_DIR}/prefix-zot-suffix") # 'pkg-config --libs' drops -L flags in PKG_CONFIG_SYSTEM_LIBRARY_PATH by default. set(ENV{PKG_CONFIG_SYSTEM_LIBRARY_PATH} "${LIB_DIR}") +# 'pkg-config --cflags' drops -I flags in PKG_CONFIG_SYSTEM_INCLUDE_PATH by default. +set(ENV{PKG_CONFIG_SYSTEM_INCLUDE_PATH} "${INCLUDE_DIR}") # 'pkgconf --libs' also drops -L flags in LIBRARY_PATH by default. set(ENV{LIBRARY_PATH} "${LIB_DIR}") +# 'pkgconf --cflags' also drops -I flags in CPATH by default. +set(ENV{CPATH} "${INCLUDE_DIR}") set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_DIR}") pkg_check_modules(ZOT REQUIRED zot) @@ -32,3 +39,4 @@ pkg_check_modules(ZOT REQUIRED zot) message(STATUS "ZOT_LIBRARIES='${ZOT_LIBRARIES}'") message(STATUS "ZOT_LINK_LIBRARIES='${ZOT_LINK_LIBRARIES}'") message(STATUS "ZOT_LDFLAGS='${ZOT_LDFLAGS}'") +message(STATUS "ZOT_CFLAGS='${ZOT_CFLAGS}'") diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index 6b8e884..7af425a 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -51,6 +51,7 @@ Libs: -L\${libdir} endif() endif() run_cmake(FindPkgConfig_GET_VARIABLE) + run_cmake(FindPkgConfig_GET_VARIABLE_DEFINE_VARIABLES) run_cmake(FindPkgConfig_GET_VARIABLE_PREFIX_PATH) run_cmake(FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH) run_cmake(FindPkgConfig_cache_variables) @@ -59,6 +60,6 @@ Libs: -L\${libdir} run_cmake(FindPkgConfig_GET_MATCHING_MODULE_NAME) run_cmake(FindPkgConfig_empty_target) if(NOT PKG_CONFIG_DONT_SUPPORT_SPACES_IN_PATH) - run_cmake(FindPkgConfig_LIBRARY_PATH) + run_cmake(FindPkgConfig_SYSTEM_PATH) endif() endif () diff --git a/Tests/RunCMake/Framework/FrameworkConsumption.cmake b/Tests/RunCMake/Framework/FrameworkConsumption.cmake index 2180cf9..f831a94 100644 --- a/Tests/RunCMake/Framework/FrameworkConsumption.cmake +++ b/Tests/RunCMake/Framework/FrameworkConsumption.cmake @@ -1,5 +1,7 @@ enable_language(C) +set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install") + # Create framework and ensure header is placed in Headers set(input_header "${CMAKE_SOURCE_DIR}/Gui.h") add_library(Gui SHARED Gui.c "${input_header}") @@ -8,6 +10,8 @@ set_target_properties(Gui PROPERTIES FRAMEWORK TRUE ) +install(TARGETS Gui DESTINATION .) + add_executable(app main.c) target_link_libraries(app PRIVATE Gui) diff --git a/Tests/RunCMake/Framework/FrameworkSystemIncludeTest.cmake b/Tests/RunCMake/Framework/FrameworkSystemIncludeTest.cmake index bcf6c29..b50a8ad 100644 --- a/Tests/RunCMake/Framework/FrameworkSystemIncludeTest.cmake +++ b/Tests/RunCMake/Framework/FrameworkSystemIncludeTest.cmake @@ -8,7 +8,7 @@ set_target_properties(Example::Example PROPERTIES ) add_library(testcase FrameworkSystemIncludeTest.c) -target_compile_options(testcase PRIVATE "-Werror=#pragma-messages") +target_compile_options(testcase PRIVATE "$<IF:$<C_COMPILER_ID:GNU>,-Werror,-Werror=#pragma-messages>") target_link_libraries(testcase PRIVATE Example::Example) @@ -20,5 +20,17 @@ set_target_properties(Example::Example2 PROPERTIES ) add_library(testcase2 FrameworkSystemIncludeTest.c) -target_compile_options(testcase2 PRIVATE "-Werror=#pragma-messages") +target_compile_options(testcase2 PRIVATE "$<IF:$<C_COMPILER_ID:GNU>,-Werror,-Werror=#pragma-messages>") target_link_libraries(testcase2 PRIVATE Example::Example2) + + + +add_library(Example::Example3 SHARED IMPORTED) +set_target_properties(Example::Example3 PROPERTIES + FRAMEWORK 1 + IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/subdir/Example.framework" +) + +add_library(testcase3 FrameworkSystemIncludeTest.c) +target_compile_options(testcase3 PRIVATE "$<IF:$<C_COMPILER_ID:GNU>,-Werror,-Werror=#pragma-messages>") +target_link_libraries(testcase3 PRIVATE Example::Example3) diff --git a/Tests/RunCMake/Framework/ImportedFrameworkConsumption.cmake b/Tests/RunCMake/Framework/ImportedFrameworkConsumption.cmake new file mode 100644 index 0000000..c44a1bb --- /dev/null +++ b/Tests/RunCMake/Framework/ImportedFrameworkConsumption.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_library(Gui IMPORTED UNKNOWN) +set_property(TARGET Gui PROPERTY IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/../FrameworkConsumption-build/install/Gui.framework") + +add_executable(app main.c) +target_link_libraries(app PRIVATE Gui) diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake index a767130..2c5b46f 100644 --- a/Tests/RunCMake/Framework/RunCMakeTest.cmake +++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake @@ -15,8 +15,10 @@ function(framework_layout_test Name Toolchain Type) run_cmake_command(${Name} ${CMAKE_COMMAND} --build .) endfunction() -framework_layout_test(iOSFrameworkLayout-build ios SHARED) -framework_layout_test(iOSFrameworkLayout-build ios STATIC) +if (NOT CMAKE_C_COMPILER_ID STREQUAL "GNU") + framework_layout_test(iOSFrameworkLayout-build ios SHARED) + framework_layout_test(iOSFrameworkLayout-build ios STATIC) +endif() framework_layout_test(OSXFrameworkLayout-build osx SHARED) framework_layout_test(OSXFrameworkLayout-build osx STATIC) @@ -36,13 +38,17 @@ function(framework_type_test Toolchain Type UseProperty) run_cmake_command(FrameworkType${Type}-build ${CMAKE_COMMAND} --build .) endfunction() -framework_type_test(ios SHARED NO) -framework_type_test(ios STATIC NO) +if (NOT CMAKE_C_COMPILER_ID STREQUAL "GNU") + framework_type_test(ios SHARED NO) + framework_type_test(ios STATIC NO) +endif() framework_type_test(osx SHARED NO) framework_type_test(osx STATIC NO) -framework_type_test(ios SHARED YES) -framework_type_test(ios STATIC YES) +if (NOT CMAKE_C_COMPILER_ID STREQUAL "GNU") + framework_type_test(ios SHARED YES) + framework_type_test(ios STATIC YES) +endif() framework_type_test(osx SHARED YES) framework_type_test(osx STATIC YES) @@ -113,7 +119,16 @@ function(framework_consumption) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(FrameworkConsumption) - run_cmake_command(FrameworkConsumption-build ${CMAKE_COMMAND} --build .) + run_cmake_command(FrameworkConsumption-build ${CMAKE_COMMAND} --build . --config Release) + run_cmake_command(FrameworkConsumption-install ${CMAKE_COMMAND} --install . --config Release) + + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/ImportedFrameworkConsumption-build") + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(ImportedFrameworkConsumption) + run_cmake_command(ImportedFrameworkConsumption-build ${CMAKE_COMMAND} --build . --config Release) endfunction() framework_consumption() diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake index 3e35aa3..a34708e 100644 --- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake +++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake @@ -98,7 +98,7 @@ if (WIN32 OR CYGWIN) if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") set(_platform Win32-Clang) - elseif(MSVC AND COMPILER_HAS_DEPRECATED) + elseif((MSVC OR CMAKE_C_COMPILER_ID STREQUAL "OrangeC") AND COMPILER_HAS_DEPRECATED) set(_platform Win32) elseif(CYGWIN AND COMPILER_HAS_DEPRECATED) set(_platform Cygwin) diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/BadAND-result.txt b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadAND-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadAND-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/BadAND-stderr.txt b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadAND-stderr.txt new file mode 100644 index 0000000..1267cb3 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadAND-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at BadAND.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<0> + + \$<0> expression requires a parameter. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/BadAND.cmake b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadAND.cmake new file mode 100644 index 0000000..91efaf4 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadAND.cmake @@ -0,0 +1,4 @@ +set(error $<0>) +add_custom_target(check ALL COMMAND check + $<AND:1,${error}> +) diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/BadIF-result.txt b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadIF-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadIF-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/BadIF-stderr.txt b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadIF-stderr.txt new file mode 100644 index 0000000..4e296a5 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadIF-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at BadIF.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<0> + + \$<0> expression requires a parameter. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/BadIF.cmake b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadIF.cmake new file mode 100644 index 0000000..797cc69 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadIF.cmake @@ -0,0 +1,4 @@ +set(error $<0>) +add_custom_target(check ALL COMMAND check + $<IF:0,1,${error}> +) diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/BadOR-result.txt b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadOR-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadOR-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/BadOR-stderr.txt b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadOR-stderr.txt new file mode 100644 index 0000000..7876d7d --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadOR-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at BadOR.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<0> + + \$<0> expression requires a parameter. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/BadOR.cmake b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadOR.cmake new file mode 100644 index 0000000..7477b8f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/BadOR.cmake @@ -0,0 +1,4 @@ +set(error $<0>) +add_custom_target(check ALL COMMAND check + $<OR:0,${error}> +) diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/CMakeLists.txt b/Tests/RunCMake/GeneratorExpressionShortCircuit/CMakeLists.txt new file mode 100644 index 0000000..54a4d62 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.26) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/GoodAND.cmake b/Tests/RunCMake/GeneratorExpressionShortCircuit/GoodAND.cmake new file mode 100644 index 0000000..26bcaba --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/GoodAND.cmake @@ -0,0 +1,4 @@ +set(error $<0>) +add_custom_target(check ALL COMMAND check + $<AND:0,${error}> +) diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/GoodIF.cmake b/Tests/RunCMake/GeneratorExpressionShortCircuit/GoodIF.cmake new file mode 100644 index 0000000..1f9fbe6 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/GoodIF.cmake @@ -0,0 +1,5 @@ +set(error $<0>) +add_custom_target(check ALL + COMMAND check $<IF:1,1,${error}> + COMMAND Check $<IF:0,${error},1> +) diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/GoodOR.cmake b/Tests/RunCMake/GeneratorExpressionShortCircuit/GoodOR.cmake new file mode 100644 index 0000000..b574937 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/GoodOR.cmake @@ -0,0 +1,4 @@ +set(error $<0>) +add_custom_target(check ALL COMMAND check + $<OR:1,${error}> +) diff --git a/Tests/RunCMake/GeneratorExpressionShortCircuit/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpressionShortCircuit/RunCMakeTest.cmake new file mode 100644 index 0000000..b0ad679 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpressionShortCircuit/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCMake) + +run_cmake(GoodIF) +run_cmake(GoodAND) +run_cmake(GoodOR) + +run_cmake(BadIF) +run_cmake(BadAND) +run_cmake(BadOR) diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem1-result.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem1-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem1-stderr.txt new file mode 100644 index 0000000..61188b6 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem1-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Xcode + + toolset specification field + + buildsystem=1 + + is not allowed with Xcode [0-9.]+\.$ diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem1.cmake b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem1.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetXcodeBuildSystem1.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index a742391..71cc2d4 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -89,7 +89,11 @@ elseif("${RunCMake_GENERATOR}" STREQUAL "Xcode") set(RunCMake_GENERATOR_TOOLSET "Test Toolset") run_cmake(TestToolsetXcodeBuildSystemDefault12) set(RunCMake_GENERATOR_TOOLSET "Test Toolset,buildsystem=1") - run_cmake(TestToolsetXcodeBuildSystem1) + if(XCODE_VERSION VERSION_GREATER_EQUAL 14) + run_cmake(BadToolsetXcodeBuildSystem1) + else() + run_cmake(TestToolsetXcodeBuildSystem1) + endif() set(RunCMake_GENERATOR_TOOLSET "Test Toolset,buildsystem=12") run_cmake(TestToolsetXcodeBuildSystem12) else() diff --git a/Tests/RunCMake/GoogleTest/xcode_sign_adhoc.cmake b/Tests/RunCMake/GoogleTest/xcode_sign_adhoc.cmake index d2dc530..571e4aa 100644 --- a/Tests/RunCMake/GoogleTest/xcode_sign_adhoc.cmake +++ b/Tests/RunCMake/GoogleTest/xcode_sign_adhoc.cmake @@ -1,8 +1,14 @@ function(xcode_sign_adhoc target) if(CMAKE_GENERATOR STREQUAL "Xcode" AND - "${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") - # Xcode runs POST_BUILD before signing, so let the linker use ad-hoc signing. - # See CMake Issue 21845. - target_link_options(${target} PRIVATE LINKER:-adhoc_codesign) + "${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") + if(XCODE_VERSION VERSION_GREATER_EQUAL 15) + # Xcode 15+ enforces '-Xlinker -no_adhoc_codesign' after user flags, + # so we cannot convince the linker to add an adhoc signature. + add_custom_command(TARGET ${target} POST_BUILD COMMAND codesign --sign - --force "$<TARGET_FILE:${target}>") + else() + # Xcode runs POST_BUILD before signing, so let the linker use ad-hoc signing. + # See CMake Issue 21845. + target_link_options(${target} PRIVATE LINKER:-adhoc_codesign) + endif() endif() endfunction() diff --git a/Tests/RunCMake/MSVCRuntimeTypeInfo/CMP0117-OLD-stderr.txt b/Tests/RunCMake/MSVCRuntimeTypeInfo/CMP0117-OLD-stderr.txt new file mode 100644 index 0000000..4499d97 --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeTypeInfo/CMP0117-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0117-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0117 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/Make/DetectJobServer-present.cmake b/Tests/RunCMake/Make/DetectJobServer-present.cmake new file mode 100644 index 0000000..cfaf7be --- /dev/null +++ b/Tests/RunCMake/Make/DetectJobServer-present.cmake @@ -0,0 +1,13 @@ +# Verifies that the jobserver is present +add_custom_command(OUTPUT custom_command.txt + JOB_SERVER_AWARE ON + COMMENT "Should detect jobserver support" + COMMAND ${DETECT_JOBSERVER} "custom_command.txt" +) + +# trigger the custom command to run +add_custom_target(dummy ALL + JOB_SERVER_AWARE ON + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/custom_command.txt + COMMAND ${DETECT_JOBSERVER} "custom_target.txt" +) diff --git a/Tests/RunCMake/Make/Foo/CMakeLists.txt b/Tests/RunCMake/Make/Foo/CMakeLists.txt new file mode 100644 index 0000000..baa6634 --- /dev/null +++ b/Tests/RunCMake/Make/Foo/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.26) +project(Foo NONE) + +add_custom_target(drive ALL COMMAND ${CMAKE_COMMAND} -E true) diff --git a/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake b/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake new file mode 100644 index 0000000..dbc1555 --- /dev/null +++ b/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake @@ -0,0 +1,18 @@ +set(BUILD_DIR "${RunCMake_BINARY_DIR}/GNUMakeJobServerAware-build") + +function(check target regex) + file(STRINGS ${BUILD_DIR}/${target} lines + REGEX ${regex} + ) + + list(LENGTH lines len) + if(len EQUAL 0) + message(FATAL_ERROR "Could not find matching lines '${regex}' in ${BUILD_DIR}/${target}") + endif() +endfunction() + +check("CMakeFiles/dummy.dir/build.make" [[\+\$\(CMAKE_COMMAND\) -E true]]) +check("CMakeFiles/dummy2.dir/build.make" [[\+\$\(CMAKE_COMMAND\) -E true]]) + +check("CMakeFiles/dummy3.dir/build.make" [[\+cd (/d )?"?.*"? && \$\(CMAKE_COMMAND\) -E true]]) +check("CMakeFiles/dummy4.dir/build.make" [[\+cd (/d )?"?.*"? && \$\(CMAKE_COMMAND\) -E true]]) diff --git a/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake b/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake new file mode 100644 index 0000000..d92e842 --- /dev/null +++ b/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake @@ -0,0 +1,31 @@ +# Test JOB_SERVER_AWARE with custom commands +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/missing" + JOB_SERVER_AWARE ON + COMMAND $(CMAKE_COMMAND) -E true +) +add_custom_target(dummy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/missing") + +# Test JOB_SERVER_AWARE with custom targets +add_custom_target( + dummy2 ALL + JOB_SERVER_AWARE ON + COMMAND $(CMAKE_COMMAND) -E true +) + +# Test JOB_SERVER_AWARE with custom commands with WORKING_DIRECTORY +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/missing2" + JOB_SERVER_AWARE ON + COMMAND $(CMAKE_COMMAND) -E true + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Foo" +) +add_custom_target(dummy3 ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/missing2") + +# Test JOB_SERVER_AWARE with custom targets with WORKING_DIRECTORY +add_custom_target( + dummy4 ALL + JOB_SERVER_AWARE ON + COMMAND $(CMAKE_COMMAND) -E true + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Foo" +) diff --git a/Tests/RunCMake/Make/RunCMakeTest.cmake b/Tests/RunCMake/Make/RunCMakeTest.cmake index c7717ec..5d1ba48 100644 --- a/Tests/RunCMake/Make/RunCMakeTest.cmake +++ b/Tests/RunCMake/Make/RunCMakeTest.cmake @@ -70,3 +70,22 @@ if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") run_CMP0113(OLD) run_CMP0113(NEW) endif() + +function(detect_jobserver_present) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DetectJobServer-present-build) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OPTIONS "-DDETECT_JOBSERVER=${DETECT_JOBSERVER}") + run_cmake(DetectJobServer-present) + run_cmake_command(DetectJobServer-present-parallel-build ${CMAKE_COMMAND} --build . -j4) +endfunction() + +# Jobservers are currently only supported by GNU makes, except MSYS2 make +if(MAKE_IS_GNU AND NOT RunCMake_GENERATOR MATCHES "MSYS Makefiles") + detect_jobserver_present() +endif() + +if(MAKE_IS_GNU) + # In GNU makes, `JOB_SERVER_AWARE` support is implemented by prefixing + # commands with the '+' operator. + run_cmake(GNUMakeJobServerAware) +endif() diff --git a/Tests/RunCMake/Ninja/QtSubDir3/CMakeLists.txt b/Tests/RunCMake/Ninja/QtSubDir3/CMakeLists.txt deleted file mode 100644 index 70644fa..0000000 --- a/Tests/RunCMake/Ninja/QtSubDir3/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(sub_exe_3 ../app.cpp) -target_link_libraries(sub_exe_3 PRIVATE ${QtX}::Core) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 6eb0b1d..69f2587 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -348,7 +348,11 @@ if("${ninja_version}" VERSION_LESS 1.6) return() endif() -foreach(ninja_output_path_prefix "sub space" "sub") +set(ninja_output_path_prefixes "sub") +if(NOT CMAKE_C_COMPILER_ID STREQUAL "OrangeC") + list(APPEND ninja_output_path_prefixes "sub space") +endif() +foreach(ninja_output_path_prefix IN LISTS ninja_output_path_prefixes) run_sub_cmake(Executable "${ninja_output_path_prefix}") run_sub_cmake(StaticLib "${ninja_output_path_prefix}") run_sub_cmake(SharedLib "${ninja_output_path_prefix}") @@ -380,45 +384,6 @@ function (run_ChangeBuildType) endfunction() run_ChangeBuildType() -function(run_QtAutoMocDeps) - set(QtX Qt${CMake_TEST_Qt_version}) - if(CMake_TEST_${QtX}Core_Version VERSION_GREATER_EQUAL 5.15.0) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/QtAutoMocDeps-build) - run_cmake_with_options(QtAutoMocDeps - "-Dwith_qt_version=${CMake_TEST_Qt_version}" - "-D${QtX}_DIR=${${QtX}_DIR}" - "-D${QtX}Core_DIR=${${QtX}Core_DIR}" - "-D${QtX}Widgets_DIR=${${QtX}Widgets_DIR}" - "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" - ) - # Build the project. - run_ninja("${RunCMake_TEST_BINARY_DIR}") - # Touch just the library source file, which shouldn't cause a rerun of AUTOMOC - # for app_with_qt target. - file(TOUCH "${RunCMake_SOURCE_DIR}/simple_lib.cpp") - # Build and assert that AUTOMOC was not run for app_with_qt. - run_ninja("${RunCMake_TEST_BINARY_DIR}") - if(ninja_stdout MATCHES "Automatic MOC for target app_with_qt") - message(FATAL_ERROR - "AUTOMOC should not have executed for 'app_with_qt' target:\nstdout:\n${ninja_stdout}") - endif() - # Assert that the subdir executables were not rebuilt. - if(ninja_stdout MATCHES "Automatic MOC for target sub_exe_1") - message(FATAL_ERROR - "AUTOMOC should not have executed for 'sub_exe_1' target:\nstdout:\n${ninja_stdout}") - endif() - if(ninja_stdout MATCHES "Automatic MOC for target sub_exe_2") - message(FATAL_ERROR - "AUTOMOC should not have executed for 'sub_exe_2' target:\nstdout:\n${ninja_stdout}") - endif() - # Touch a header file to make sure an automoc dependency cycle is not introduced. - file(TOUCH "${RunCMake_SOURCE_DIR}/MyWindow.h") - run_ninja("${RunCMake_TEST_BINARY_DIR}") - # Need to run a second time to hit the dependency cycle. - run_ninja("${RunCMake_TEST_BINARY_DIR}") - endif() -endfunction() - function(run_QtAutoMocSkipPch) set(QtX Qt${CMake_TEST_Qt_version}) if(CMake_TEST_${QtX}Core_Version VERSION_GREATER_EQUAL 5.15.0) @@ -433,7 +398,7 @@ function(run_QtAutoMocSkipPch) run_ninja("${RunCMake_TEST_BINARY_DIR}") endif() endfunction() + if(CMake_TEST_Qt_version) - run_QtAutoMocDeps() run_QtAutoMocSkipPch() endif() diff --git a/Tests/RunCMake/NinjaMultiConfig/CompileCommands-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CompileCommands-check.cmake index 30b24bf..e65be3b 100644 --- a/Tests/RunCMake/NinjaMultiConfig/CompileCommands-check.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/CompileCommands-check.cmake @@ -8,7 +8,7 @@ set(expected_compile_commands ]*", "file": "[^ ]*(/Tests/RunCMake/NinjaMultiConfig/main\.c|\\\\Tests\\\\RunCMake\\\\NinjaMultiConfig\\\\main\.c)", - "output": "(CMakeFiles/exe\.dir/Debug/main\.c\.o|CMakeFiles\\\\exe\.dir\\\\Debug\\\\main\.c\.obj)" + "output": "(CMakeFiles/exe\.dir/Debug/main\.c\.o|CMakeFiles\\\\exe\.dir\\\\Debug\\\\main\.c\.(obj|o))" }, { "directory": "[^ @@ -18,7 +18,7 @@ set(expected_compile_commands ]*", "file": "[^ ]*(/Tests/RunCMake/NinjaMultiConfig/main\.c|\\\\Tests\\\\RunCMake\\\\NinjaMultiConfig\\\\main\.c)", - "output": "(CMakeFiles/exe\.dir/Release/main\.c\.o|CMakeFiles\\\\exe\.dir\\\\Release\\\\main\.c\.obj)" + "output": "(CMakeFiles/exe\.dir/Release/main\.c\.o|CMakeFiles\\\\exe\.dir\\\\Release\\\\main\.c\.(obj|o))" } ]$]==]) diff --git a/Tests/RunCMake/NinjaMultiConfig/QtX-debug-in-release-graph-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/QtX-debug-in-release-graph-build-check.cmake deleted file mode 100644 index 2d8df13..0000000 --- a/Tests/RunCMake/NinjaMultiConfig/QtX-debug-in-release-graph-build-check.cmake +++ /dev/null @@ -1,7 +0,0 @@ -check_files("${RunCMake_TEST_BINARY_DIR}" - INCLUDE - ${AUTOGEN_FILES} - - ${TARGET_FILE_exe_Debug} - ${TARGET_OBJECT_FILES_exe_Debug} - ) diff --git a/Tests/RunCMake/NinjaMultiConfig/QtX.cmake b/Tests/RunCMake/NinjaMultiConfig/QtX.cmake index 130f883..dded383 100644 --- a/Tests/RunCMake/NinjaMultiConfig/QtX.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/QtX.cmake @@ -19,16 +19,17 @@ if(${QtX}Core_VERSION VERSION_GREATER_EQUAL "5.15.0") set(moc_writes_depfiles 1) endif() -set(autogen_files) -if(moc_writes_depfiles) - list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/deps") - list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/timestamp") -endif() -foreach(c IN LISTS CMAKE_CONFIGURATION_TYPES) - list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/mocs_compilation_${c}.cpp") - list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp") +foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES) + set(autogen_files) if(moc_writes_depfiles) - list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${c}/moc_qt5.cpp.d") + list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/deps_${CONFIG}") + list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/timestamp_${CONFIG}") endif() + list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/mocs_compilation_${CONFIG}.cpp") + list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${CONFIG}/moc_qt5.cpp") + if(moc_writes_depfiles) + list(APPEND autogen_files "${CMAKE_BINARY_DIR}/exe_autogen/include_${CONFIG}/moc_qt5.cpp.d") + endif() + file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "set(AUTOGEN_FILES_${CONFIG} [==[${autogen_files}]==])\n") + unset(autogen_files) endforeach() -file(APPEND "${CMAKE_BINARY_DIR}/target_files.cmake" "set(AUTOGEN_FILES [==[${autogen_files}]==])\n") diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake index 47f5eee..a39606d 100644 --- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -17,7 +17,7 @@ function(check_files dir) list(SORT expected) file(GLOB_RECURSE actual "${dir}/*") - list(FILTER actual EXCLUDE REGEX "/CMakeFiles/|\\.ninja$|/CMakeCache\\.txt$|/target_files[^/]*\\.cmake$|/\\.ninja_[^/]*$|/cmake_install\\.cmake$|\\.ilk$|\\.manifest$|\\.pdb$|\\.exp$|/install_manifest\\.txt$|/\\.qt/QtDeploySupport[^/]*\\.cmake$") + list(FILTER actual EXCLUDE REGEX "/CMakeFiles/|\\.ninja$|/CMakeCache\\.txt$|/target_files[^/]*\\.cmake$|/\\.ninja_[^/]*$|/cmake_install\\.cmake$|\\.ilk$|\\.manifest$|\\.odx$|\\.pdb$|\\.exp$|/install_manifest\\.txt$|/\\.qt/QtDeploySupport[^/]*\\.cmake$") foreach(f IN LISTS _check_files_INCLUDE _check_files_EXCLUDE) if(EXISTS ${f}) list(APPEND actual ${f}) @@ -486,11 +486,35 @@ if(CMake_TEST_Qt_version) "-D${QtX}Core_DIR=${${QtX}Core_DIR}" "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" ) - run_cmake_configure(QtX) - unset(RunCMake_TEST_OPTIONS) - include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) - run_cmake_build(QtX debug-in-release-graph Release exe:Debug) + + foreach(target_config IN ITEMS Debug Release RelWithDebInfo) + foreach(ninja_config IN ITEMS Debug Release RelWithDebInfo) + block() + run_cmake_configure(QtX) + include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) + run_cmake_build(QtX ${target_config}-in-${ninja_config}-graph ${ninja_config} exe:${target_config}) + check_files("${RunCMake_TEST_BINARY_DIR}" + INCLUDE + "${AUTOGEN_FILES_${target_config}}" + "${TARGET_FILE_exe_${target_config}}" + "${TARGET_OBJECT_FILES_exe_${target_config}}" + ) + if (DEFINED RunCMake_TEST_FAILED AND NOT RunCMake_TEST_FAILED STREQUAL "") + message(FATAL_ERROR "RunCMake_TEST_FAILED:${RunCMake_TEST_FAILED}") + endif() + + check_file_contents("${RunCMake_TEST_BINARY_DIR}/exe_autogen/deps_${target_config}" "exe_autogen/timestamp_${target_config}") + if (DEFINED RunCMake_TEST_FAILED AND NOT RunCMake_TEST_FAILED STREQUAL "") + message(FATAL_ERROR "RunCMake_TEST_FAILED:${RunCMake_TEST_FAILED}") + endif() + endblock() + endforeach() + endforeach() if(CMake_TEST_${QtX}Core_Version VERSION_GREATER_EQUAL 5.15.0) - run_ninja(QtX automoc-check build-Debug.ninja -t query exe_autogen/timestamp) + foreach(target_config IN ITEMS Debug Release RelWithDebInfo) + foreach(ninja_config IN ITEMS Debug Release RelWithDebInfo) + run_ninja(QtX automoc-check-${target_config} build-${ninja_config}.ninja -t query exe_autogen/timestamp_${target_config}) + endforeach() + endforeach() endif() endif() diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-target-ninja-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-target-ninja-stderr.txt index 6db4bcc..ace6512 100644 --- a/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-target-ninja-stderr.txt +++ b/Tests/RunCMake/NinjaMultiConfig/SimpleNoCross-all-target-ninja-stderr.txt @@ -1 +1 @@ -^ninja: error: unknown target 'simplestatic:all'$ +^ninja: error: unknown target 'simplestatic:all'(, did you mean 'simplestatic.l'\?)?$ diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-Source-check.cmake new file mode 100644 index 0000000..7658930 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-Source-check.cmake @@ -0,0 +1,3 @@ +if (EXISTS ${RunCMake_TEST_BINARY_DIR}/empty.cpp) + set(RunCMake_TEST_FAILED "Compiled source generated before compilation of consumers.") +endif() diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-check.cmake new file mode 100644 index 0000000..3287a65 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-check.cmake @@ -0,0 +1,3 @@ +if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/empty.cpp) + set(RunCMake_TEST_FAILED "Compiled source did not generate.") +endif() diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-NoFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-NoFileSet-Source-check.cmake new file mode 100644 index 0000000..9e99ed8 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-NoFileSet-Source-check.cmake @@ -0,0 +1,3 @@ +if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/none.cpp) + set(RunCMake_TEST_FAILED "Private source dependency used for target without filesets.") +endif() diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-Source-check.cmake new file mode 100644 index 0000000..dd814c9 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-Source-check.cmake @@ -0,0 +1,3 @@ +if (EXISTS ${RunCMake_TEST_BINARY_DIR}/private.h) + set(RunCMake_TEST_FAILED "Private header generated before compilation.") +endif() diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-check.cmake new file mode 100644 index 0000000..357b8c0 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-check.cmake @@ -0,0 +1,3 @@ +if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/private.h) + set(RunCMake_TEST_FAILED "Private header generated before compilation.") +endif() diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PublicFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PublicFileSet-Source-check.cmake new file mode 100644 index 0000000..cfceb7a --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PublicFileSet-Source-check.cmake @@ -0,0 +1,3 @@ +if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/public.h) + set(RunCMake_TEST_FAILED "Public header did not generate before compilation.") +endif() diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW.cmake new file mode 100644 index 0000000..3330269 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0154 NEW) +include(CMP0154-common.cmake) diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-EmptyFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-EmptyFileSet-Source-check.cmake new file mode 100644 index 0000000..8ee1ad4 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-EmptyFileSet-Source-check.cmake @@ -0,0 +1,3 @@ +if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/empty.cpp) + set(RunCMake_TEST_FAILED "Policy CMP0154 set to OLD but using new behavior compiled sources.") +endif() diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-PrivateFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-PrivateFileSet-Source-check.cmake new file mode 100644 index 0000000..25c23d7 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-PrivateFileSet-Source-check.cmake @@ -0,0 +1,3 @@ +if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/private.h) + set(RunCMake_TEST_FAILED "Policy CMP0154 set to OLD but using new behavior private headers.") +endif() diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD.cmake new file mode 100644 index 0000000..691530c --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0154 OLD) +include(CMP0154-common.cmake) diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-common.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-common.cmake new file mode 100644 index 0000000..a9e6d20 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-common.cmake @@ -0,0 +1,45 @@ +enable_language(CXX) + +function(copy_file file dest) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/${dest} + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_SOURCE_DIR}/${file} ${CMAKE_BINARY_DIR}/${dest} + ) +endfunction() + +copy_file(header.h.in private.h) +copy_file(header.h.in public.h) +copy_file(source.cpp.in empty.cpp) +copy_file(source.cpp.in none.cpp) + +add_library(HelloLib_PrivateFileSet STATIC hello_lib.cpp) +target_sources(HelloLib_PrivateFileSet + PRIVATE FILE_SET HEADERS + BASE_DIRS ${CMAKE_BINARY_DIR} + FILES ${CMAKE_BINARY_DIR}/private.h +) + +add_library(HelloLib_PublicFileSet STATIC hello_lib.cpp) +target_sources(HelloLib_PublicFileSet + PUBLIC FILE_SET HEADERS + BASE_DIRS ${CMAKE_BINARY_DIR} + FILES ${CMAKE_BINARY_DIR}/public.h +) + +add_library(HelloLib_EmptyFileSet STATIC hello_lib.cpp empty.cpp) +target_sources(HelloLib_EmptyFileSet + PUBLIC FILE_SET HEADERS +) + +add_library(HelloLib_NoFileSet STATIC hello_lib.cpp none.cpp) + +function(hello_executable name) + add_executable(Hello_${name} hello.cpp) + target_link_libraries(Hello_${name} PRIVATE HelloLib_${name}) +endfunction() + +hello_executable(PrivateFileSet) +hello_executable(PublicFileSet) +hello_executable(EmptyFileSet) +hello_executable(NoFileSet) diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMakeLists.txt b/Tests/RunCMake/NinjaPrivateDeps/CMakeLists.txt new file mode 100644 index 0000000..54a4d62 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.26) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/NinjaPrivateDeps/RunCMakeTest.cmake b/Tests/RunCMake/NinjaPrivateDeps/RunCMakeTest.cmake new file mode 100644 index 0000000..e821185 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/RunCMakeTest.cmake @@ -0,0 +1,30 @@ +include(RunCMake) + +function(compile_source test target) + if (RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(config "Debug/") + endif() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-Build-${target}-Source ${CMAKE_COMMAND} --build . + --target CMakeFiles/Hello_${target}.dir/${config}hello.cpp${CMAKE_C_OUTPUT_EXTENSION}) +endfunction() + +function(compile_target test target) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-Build-${target} ${CMAKE_COMMAND} --build . + --target Hello_${target}) +endfunction() + +run_cmake(CMP0154-OLD) +compile_source(CMP0154-OLD PrivateFileSet) +compile_source(CMP0154-OLD EmptyFileSet) + +run_cmake(CMP0154-NEW) +compile_source(CMP0154-NEW PrivateFileSet) +compile_target(CMP0154-NEW PrivateFileSet) +compile_source(CMP0154-NEW PublicFileSet) +compile_source(CMP0154-NEW NoFileSet) +compile_source(CMP0154-NEW EmptyFileSet) +compile_target(CMP0154-NEW EmptyFileSet) diff --git a/Tests/RunCMake/NinjaPrivateDeps/header.h.in b/Tests/RunCMake/NinjaPrivateDeps/header.h.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/header.h.in diff --git a/Tests/RunCMake/NinjaPrivateDeps/hello.cpp b/Tests/RunCMake/NinjaPrivateDeps/hello.cpp new file mode 100644 index 0000000..34fabe9 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/hello.cpp @@ -0,0 +1,6 @@ +#include "hello_lib.h" + +int main() +{ + say_hello(); +} diff --git a/Tests/RunCMake/NinjaPrivateDeps/hello_lib.cpp b/Tests/RunCMake/NinjaPrivateDeps/hello_lib.cpp new file mode 100644 index 0000000..d67113f --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/hello_lib.cpp @@ -0,0 +1,8 @@ +#include "hello_lib.h" + +#include <iostream> + +void say_hello() +{ + std::cout << "hello" << std::endl; +} diff --git a/Tests/RunCMake/NinjaPrivateDeps/hello_lib.h b/Tests/RunCMake/NinjaPrivateDeps/hello_lib.h new file mode 100644 index 0000000..3b4775f --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/hello_lib.h @@ -0,0 +1 @@ +void say_hello(); diff --git a/Tests/RunCMake/NinjaPrivateDeps/source.cpp.in b/Tests/RunCMake/NinjaPrivateDeps/source.cpp.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/NinjaPrivateDeps/source.cpp.in diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake index 3d60556..a1fa7b3 100644 --- a/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake +++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake @@ -14,8 +14,14 @@ target_link_libraries(LinkObjLHSShared AnObjLib) # Verify that our dependency on OtherLib generated its versioning symlinks. if(CMAKE_GENERATOR STREQUAL "Xcode" AND "${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") - # Xcode runs POST_BUILD before signing, so let the linker use ad-hoc signing. - # See CMake Issue 21845. - target_link_options(LinkObjLHSShared PRIVATE LINKER:-adhoc_codesign) + if(XCODE_VERSION VERSION_GREATER_EQUAL 15) + # Xcode 15+ enforces '-Xlinker -no_adhoc_codesign' after user flags, + # so we cannot convince the linker to add an adhoc signature. + add_custom_command(TARGET LinkObjLHSShared POST_BUILD COMMAND codesign --sign - --force "$<TARGET_FILE:LinkObjLHSShared>") + else() + # Xcode runs POST_BUILD before signing, so let the linker use ad-hoc signing. + # See CMake Issue 21845. + target_link_options(LinkObjLHSShared PRIVATE LINKER:-adhoc_codesign) + endif() endif() add_custom_command(TARGET LinkObjLHSShared POST_BUILD COMMAND LinkObjLHSShared) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index bc4a330..fcf904e 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -24,6 +24,8 @@ function(run_cmake test) if(EXISTS ${top_src}/${test}-result.txt) file(READ ${top_src}/${test}-result.txt expect_result) string(REGEX REPLACE "\n+$" "" expect_result "${expect_result}") + elseif(DEFINED RunCMake_TEST_EXPECT_RESULT) + set(expect_result "${RunCMake_TEST_EXPECT_RESULT}") else() set(expect_result 0) endif() @@ -53,6 +55,11 @@ function(run_cmake test) unset(expect_${o}) endif() endforeach() + foreach(o IN ITEMS stdout stderr config) + if(DEFINED RunCMake_TEST_NOT_EXPECT_${o}) + string(REGEX REPLACE "\n+$" "" not_expect_${o} "${RunCMake_TEST_NOT_EXPECT_${o}}") + endif() + endforeach() if (NOT expect_stderr) if (NOT RunCMake_DEFAULT_stderr) set(RunCMake_DEFAULT_stderr "^$") @@ -145,7 +152,19 @@ function(run_cmake test) ${maybe_timeout} ${maybe_input_file} )]]) + if(DEFINED ENV{PWD}) + set(old_pwd "$ENV{PWD}") + else() + set(old_pwd) + endif() + # Emulate a shell using this directory. + set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}") cmake_language(EVAL CODE "${_code}") + if(DEFINED old_pwd) + set(ENV{PWD} "${old_pwd}") + else() + set(ENV{PWD}) + endif() set(msg "") if(NOT "${actual_result}" MATCHES "${expect_result}") string(APPEND msg "Result is [${actual_result}], not [${expect_result}].\n") @@ -182,6 +201,8 @@ function(run_cmake test) "|ic(p?c|l): remark #10441: The Intel\\(R\\) C\\+\\+ Compiler Classic \\(ICC\\) is deprecated" "|[^\n]*install_name_tool: warning: changes being made to the file will invalidate the code signature in:" + "|[^\n]*(createItemModels|_NSMainThread|Please file a bug at)" + "|[^\n]*xcodebuild[^\n]*DVTAssertions: Warning" "|[^\n]*xcodebuild[^\n]*DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default" "|[^\n]*xcodebuild[^\n]*DVTPlugInManager" "|[^\n]*xcodebuild[^\n]*DVTSDK: Warning: SDK path collision for path" @@ -216,6 +237,11 @@ function(run_cmake test) string(APPEND msg "${o} does not match that expected.\n") endif() endif() + if(DEFINED not_expect_${o}) + if("${actual_${o}}" MATCHES "${not_expect_${o}}") + string(APPEND msg "${o} matches that not expected.\n") + endif() + endif() endforeach() unset(RunCMake_TEST_FAILED) if(RunCMake-check-file AND EXISTS ${top_src}/${RunCMake-check-file}) diff --git a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake index 58a111a..12f004b 100644 --- a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake +++ b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake @@ -29,8 +29,6 @@ function (run_symlink_test case src bin src_from_bin bin_from_src) # Test running in binary directory. set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - # Emulate a shell using this directory. - set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}") # Pass absolute path to the source tree, plain. set(RunCMake_TEST_VARIANT_DESCRIPTION " $abs/${name}/${src}") @@ -50,8 +48,6 @@ function (run_symlink_test case src bin src_from_bin bin_from_src) # Test running in source directory. set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}") - # Emulate a shell using this directory. - set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}") # Pass absolute path to the binary tree with -B. set(RunCMake_TEST_VARIANT_DESCRIPTION " -B $abs/${name}/${bin}") @@ -63,8 +59,6 @@ function (run_symlink_test case src bin src_from_bin bin_from_src) # Test running in another directory. set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_BINARY_DIR}/${name}") - # Emulate a shell using this directory. - set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}") # Pass absolute paths to the source and binary trees. set(RunCMake_TEST_VARIANT_DESCRIPTION " -S $abs/${name}/${src} -B $abs/${name}/${bin}") diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 0d8e4c9..7e91b76 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -37,6 +37,7 @@ \* CMP0119 \* CMP0131 \* CMP0142 + \* CMP0154 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake index c7a118f..537f67d 100644 --- a/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake +++ b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake @@ -6,7 +6,7 @@ run_cmake(CMP0078-NEW) run_cmake(CMP0086-WARN) -if (CMake_TEST_FindPython) +if (CMake_TEST_FindPython2 OR CMake_TEST_FindPython3) macro(run_cmake_target test subtest target) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/CMP0120-OLD-Direct-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/CMP0120-OLD-Direct-stderr.txt new file mode 100644 index 0000000..53f603e --- /dev/null +++ b/Tests/RunCMake/WriteCompilerDetectionHeader/CMP0120-OLD-Direct-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0120-OLD-Direct\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0120 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/CMP0120-OLD-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/CMP0120-OLD-stderr.txt new file mode 100644 index 0000000..fea708f --- /dev/null +++ b/Tests/RunCMake/WriteCompilerDetectionHeader/CMP0120-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0120-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0120 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/XcFramework/CMakeLists.txt b/Tests/RunCMake/XcFramework/CMakeLists.txt new file mode 100644 index 0000000..54a4d62 --- /dev/null +++ b/Tests/RunCMake/XcFramework/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.26) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/XcFramework/RunCMakeTest.cmake b/Tests/RunCMake/XcFramework/RunCMakeTest.cmake new file mode 100644 index 0000000..9a13892 --- /dev/null +++ b/Tests/RunCMake/XcFramework/RunCMakeTest.cmake @@ -0,0 +1,121 @@ +include(RunCMake) + +function(create_library type platform system_name archs sysroot) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/create-${type}-${platform}-build) + run_cmake_with_options(create-${type}-${platform} -DCMAKE_SYSTEM_NAME=${system_name} -DCMAKE_OSX_ARCHITECTURES=${archs} -DCMAKE_OSX_SYSROOT=${sysroot} -DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install) + + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(create-${type}-${platform}-build ${CMAKE_COMMAND} --build . --config Release) + run_cmake_command(create-${type}-${platform}-install ${CMAKE_COMMAND} --install . --config Release) +endfunction() + +function(create_libraries type) + create_library(${type} macos Darwin "${macos_archs_2}" macosx) + create_library(${type} ios iOS "arm64" iphoneos) + create_library(${type} tvos tvOS "arm64" appletvos) + create_library(${type} watchos watchOS "armv7k\\\\;arm64_32" watchos) + #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. + #if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) + # create_library(${type} visionos visionOS "arm64" xros) + #endif() + create_library(${type} ios-simulator iOS "${macos_archs_2}" iphonesimulator) + create_library(${type} tvos-simulator tvOS "${macos_archs_2}" appletvsimulator) + create_library(${type} watchos-simulator watchOS "${watch_sim_archs_2}" watchsimulator) + #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. + #if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) + # create_library(${type} visionos-simulator visionOS "${macos_archs_2}" xrsimulator) + #endif() +endfunction() + +function(create_xcframework name type platforms) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/create-xcframework-${name}-build) + if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) + # 'xcodebuild -create-xcframework' fails on symlinked paths. + file(REAL_PATH "${RunCMake_SOURCE_DIR}" src_dir) + file(REAL_PATH "${RunCMake_BINARY_DIR}" bld_dir) + else() + set(src_dir "${RunCMake_SOURCE_DIR}") + set(bld_dir "${RunCMake_BINARY_DIR}") + endif() + set(args) + foreach(platform IN LISTS platforms) + set(lib_dir "${bld_dir}/create-${type}-${platform}-build/install/lib") + if(type STREQUAL "framework") + list(APPEND args -framework ${lib_dir}/mylib.framework) + else() + list(APPEND args -library ${lib_dir}/libmylib.a -headers ${src_dir}/mylib/include) + endif() + endforeach() + run_cmake_command(create-xcframework-${name} xcodebuild -create-xcframework ${args} -output ${RunCMake_TEST_BINARY_DIR}/mylib.xcframework) +endfunction() + +function(create_executable name xcfname system_name archs sysroot) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/create-executable-${name}-build) + run_cmake_with_options(create-executable-${name} -DCMAKE_SYSTEM_NAME=${system_name} -DCMAKE_OSX_ARCHITECTURES=${archs} -DCMAKE_OSX_SYSROOT=${sysroot} -DMYLIB_LIBRARY=${RunCMake_BINARY_DIR}/create-xcframework-${xcfname}-build/mylib.xcframework) + + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(create-executable-${name}-build ${CMAKE_COMMAND} --build . --config Release) +endfunction() + +function(create_executables name type) + create_executable(${name}-macos ${type} Darwin "${macos_archs_2}" macosx) + create_executable(${name}-ios ${type} iOS "arm64" iphoneos) + create_executable(${name}-tvos ${type} tvOS "arm64" appletvos) + create_executable(${name}-watchos ${type} watchOS "armv7k\\\\;arm64_32" watchos) + #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. + #if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) + # create_executable(${name}-visionos ${type} visionOS "arm64" xros) + #endif() + create_executable(${name}-ios-simulator ${type} iOS "${macos_archs_2}" iphonesimulator) + create_executable(${name}-tvos-simulator ${type} tvOS "${macos_archs_2}" appletvsimulator) + create_executable(${name}-watchos-simulator ${type} watchOS "${watch_sim_archs_2}" watchsimulator) + #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. + #if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) + # create_executable(${name}-visionos-simulator ${type} visionOS "${macos_archs_2}" xrsimulator) + #endif() +endfunction() + +set(xcframework_platforms macos ios tvos watchos ios-simulator tvos-simulator watchos-simulator) +#FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. +#if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 15) +# list(APPEND xcframework_platforms visionos visionos-simulator) +#endif() +if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 12) + set(macos_archs_1 "x86_64\\;arm64") + set(macos_archs_2 "x86_64\\\\;arm64") + set(watch_sim_archs_2 "x86_64") +else() + set(macos_archs_1 "x86_64") + set(macos_archs_2 "x86_64") + set(watch_sim_archs_2 "i386") +endif() + +create_libraries(library) +create_libraries(framework) +create_xcframework(library library "${xcframework_platforms}") +create_xcframework(framework framework "${xcframework_platforms}") +create_xcframework(incomplete framework "tvos;watchos") +create_executables(library library) +create_executables(framework framework) +run_cmake_with_options(create-executable-incomplete -DCMAKE_SYSTEM_NAME=Darwin "-DCMAKE_OSX_ARCHITECTURES=${macos_archs_1}" -DMYLIB_LIBRARY=${RunCMake_BINARY_DIR}/create-xcframework-incomplete-build/mylib.xcframework) +create_executables(target-library library) +create_executables(target-framework framework) +run_cmake_with_options(create-executable-target-incomplete -DCMAKE_SYSTEM_NAME=Darwin "-DCMAKE_OSX_ARCHITECTURES=${macos_archs_1}" -DMYLIB_LIBRARY=${RunCMake_BINARY_DIR}/create-xcframework-incomplete-build/mylib.xcframework) +if(RunCMake_GENERATOR STREQUAL "Xcode" AND CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 12) + create_executables(library-link-phase library) + create_executables(framework-link-phase framework) + run_cmake_with_options(create-executable-incomplete-link-phase -DCMAKE_SYSTEM_NAME=Darwin "-DCMAKE_OSX_ARCHITECTURES=${macos_archs_1}" -DMYLIB_LIBRARY=${RunCMake_BINARY_DIR}/create-xcframework-incomplete-build/mylib.xcframework) + create_executables(target-library-link-phase library) + create_executables(target-framework-link-phase framework) + run_cmake_with_options(create-executable-target-incomplete-link-phase -DCMAKE_SYSTEM_NAME=Darwin "-DCMAKE_OSX_ARCHITECTURES=${macos_archs_1}" -DMYLIB_LIBRARY=${RunCMake_BINARY_DIR}/create-xcframework-incomplete-build/mylib.xcframework) +endif() + +# Ensure that .xcframework is found before .framework +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/create-xcframework-framework-build) +set(RunCMake_TEST_NO_CLEAN 1) +run_cmake_command(copy-framework ${CMAKE_COMMAND} -E copy_directory ${RunCMake_BINARY_DIR}/create-framework-macos-build/install/lib/mylib.framework ${RunCMake_TEST_BINARY_DIR}/mylib.framework) +unset(RunCMake_TEST_NO_CLEAN) +unset(RunCMake_TEST_BINARY_DIR) + +run_cmake(find-library) +run_cmake_command(find-library-script ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/find-library.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-ios-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-ios-simulator.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-ios-simulator.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-ios.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-ios.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-ios.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-ios-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-ios-simulator.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-ios-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-ios.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-ios.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-ios.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-macos.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-macos.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-macos.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-tvos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-tvos-simulator.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-tvos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-tvos.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-tvos.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-tvos.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-visionos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-visionos-simulator.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-visionos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-visionos.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-visionos.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-visionos.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-watchos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-watchos-simulator.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-watchos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-watchos.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-watchos.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-link-phase-watchos.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-macos.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-macos.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-macos.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-tvos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-tvos-simulator.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-tvos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-tvos.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-tvos.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-tvos.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-visionos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-visionos-simulator.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-visionos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-visionos.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-visionos.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-visionos.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-watchos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-watchos-simulator.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-watchos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-framework-watchos.cmake b/Tests/RunCMake/XcFramework/create-executable-framework-watchos.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-framework-watchos.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-incomplete-link-phase-result.txt b/Tests/RunCMake/XcFramework/create-executable-incomplete-link-phase-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-incomplete-link-phase-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/XcFramework/create-executable-incomplete-link-phase-stderr.txt b/Tests/RunCMake/XcFramework/create-executable-incomplete-link-phase-stderr.txt new file mode 100644 index 0000000..5b43e19 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-incomplete-link-phase-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at create-executable\.cmake:[0-9]+ \(target_link_libraries\): + Unable to find suitable library in: + + [^ +]*/Tests/RunCMake/XcFramework/create-xcframework-incomplete-build/mylib\.xcframework/Info\.plist + + for system name "Darwin" +Call Stack \(most recent call first\): + create-executable-link-phase\.cmake:[0-9]+ \(include\) + create-executable-incomplete-link-phase\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/XcFramework/create-executable-incomplete-link-phase.cmake b/Tests/RunCMake/XcFramework/create-executable-incomplete-link-phase.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-incomplete-link-phase.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-incomplete-result.txt b/Tests/RunCMake/XcFramework/create-executable-incomplete-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-incomplete-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/XcFramework/create-executable-incomplete-stderr.txt b/Tests/RunCMake/XcFramework/create-executable-incomplete-stderr.txt new file mode 100644 index 0000000..66b7d62 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-incomplete-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at create-executable\.cmake:[0-9]+ \(target_link_libraries\): + Unable to find suitable library in: + + [^ +]*/Tests/RunCMake/XcFramework/create-xcframework-incomplete-build/mylib\.xcframework/Info\.plist + + for system name "Darwin" +Call Stack \(most recent call first\): + create-executable-incomplete\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/XcFramework/create-executable-incomplete.cmake b/Tests/RunCMake/XcFramework/create-executable-incomplete.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-incomplete.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-ios-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-library-ios-simulator.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-ios-simulator.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-ios.cmake b/Tests/RunCMake/XcFramework/create-executable-library-ios.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-ios.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-link-phase-ios-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-ios-simulator.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-ios-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-link-phase-ios.cmake b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-ios.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-ios.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-link-phase-macos.cmake b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-macos.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-macos.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-link-phase-tvos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-tvos-simulator.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-tvos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-link-phase-tvos.cmake b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-tvos.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-tvos.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-link-phase-visionos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-visionos-simulator.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-visionos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-link-phase-visionos.cmake b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-visionos.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-visionos.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-link-phase-watchos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-watchos-simulator.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-watchos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-link-phase-watchos.cmake b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-watchos.cmake new file mode 100644 index 0000000..2888c85 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-link-phase-watchos.cmake @@ -0,0 +1 @@ +include(create-executable-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-macos.cmake b/Tests/RunCMake/XcFramework/create-executable-library-macos.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-macos.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-tvos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-library-tvos-simulator.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-tvos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-tvos.cmake b/Tests/RunCMake/XcFramework/create-executable-library-tvos.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-tvos.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-visionos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-library-visionos-simulator.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-visionos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-visionos.cmake b/Tests/RunCMake/XcFramework/create-executable-library-visionos.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-visionos.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-watchos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-library-watchos-simulator.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-watchos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-library-watchos.cmake b/Tests/RunCMake/XcFramework/create-executable-library-watchos.cmake new file mode 100644 index 0000000..760d9d4 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-library-watchos.cmake @@ -0,0 +1 @@ +include(create-executable.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-link-phase.cmake b/Tests/RunCMake/XcFramework/create-executable-link-phase.cmake new file mode 100644 index 0000000..9884781 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-link-phase.cmake @@ -0,0 +1,2 @@ +include(create-executable.cmake) +set_property(TARGET myexe PROPERTY XCODE_LINK_BUILD_PHASE_MODE "KNOWN_LOCATION") diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-ios-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-ios-simulator.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-ios-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-ios.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-ios.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-ios.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-ios-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-ios-simulator.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-ios-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-ios.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-ios.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-ios.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-macos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-macos.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-macos.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-tvos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-tvos-simulator.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-tvos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-tvos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-tvos.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-tvos.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-visionos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-visionos-simulator.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-visionos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-visionos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-visionos.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-visionos.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-watchos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-watchos-simulator.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-watchos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-watchos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-watchos.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-link-phase-watchos.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-macos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-macos.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-macos.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-tvos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-tvos-simulator.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-tvos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-tvos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-tvos.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-tvos.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-visionos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-visionos-simulator.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-visionos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-visionos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-visionos.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-visionos.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-watchos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-watchos-simulator.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-watchos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-framework-watchos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-framework-watchos.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-framework-watchos.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-incomplete-link-phase-result.txt b/Tests/RunCMake/XcFramework/create-executable-target-incomplete-link-phase-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-incomplete-link-phase-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/XcFramework/create-executable-target-incomplete-link-phase-stderr.txt b/Tests/RunCMake/XcFramework/create-executable-target-incomplete-link-phase-stderr.txt new file mode 100644 index 0000000..1308933 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-incomplete-link-phase-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at create-executable-target\.cmake:[0-9]+ \(target_link_libraries\): + Unable to find suitable library in: + + [^ +]*/Tests/RunCMake/XcFramework/create-xcframework-incomplete-build/mylib\.xcframework/Info\.plist + + for system name "Darwin" +Call Stack \(most recent call first\): + create-executable-target-link-phase\.cmake:[0-9]+ \(include\) + create-executable-target-incomplete-link-phase\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-incomplete-link-phase.cmake b/Tests/RunCMake/XcFramework/create-executable-target-incomplete-link-phase.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-incomplete-link-phase.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-incomplete-result.txt b/Tests/RunCMake/XcFramework/create-executable-target-incomplete-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-incomplete-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/XcFramework/create-executable-target-incomplete-stderr.txt b/Tests/RunCMake/XcFramework/create-executable-target-incomplete-stderr.txt new file mode 100644 index 0000000..716b17d --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-incomplete-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at create-executable-target\.cmake:[0-9]+ \(target_link_libraries\): + Unable to find suitable library in: + + [^ +]*/Tests/RunCMake/XcFramework/create-xcframework-incomplete-build/mylib\.xcframework/Info\.plist + + for system name "Darwin" +Call Stack \(most recent call first\): + create-executable-target-incomplete\.cmake:[0-9]+ \(include\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-incomplete.cmake b/Tests/RunCMake/XcFramework/create-executable-target-incomplete.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-incomplete.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-ios-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-ios-simulator.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-ios-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-ios.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-ios.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-ios.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-ios-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-ios-simulator.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-ios-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-ios.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-ios.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-ios.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-macos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-macos.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-macos.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-tvos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-tvos-simulator.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-tvos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-tvos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-tvos.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-tvos.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-visionos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-visionos-simulator.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-visionos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-visionos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-visionos.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-visionos.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-watchos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-watchos-simulator.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-watchos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-watchos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-watchos.cmake new file mode 100644 index 0000000..dfeccb9 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-link-phase-watchos.cmake @@ -0,0 +1 @@ +include(create-executable-target-link-phase.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-macos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-macos.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-macos.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-tvos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-tvos-simulator.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-tvos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-tvos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-tvos.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-tvos.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-visionos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-visionos-simulator.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-visionos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-visionos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-visionos.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-visionos.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-watchos-simulator.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-watchos-simulator.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-watchos-simulator.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-library-watchos.cmake b/Tests/RunCMake/XcFramework/create-executable-target-library-watchos.cmake new file mode 100644 index 0000000..b2e3469 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-library-watchos.cmake @@ -0,0 +1 @@ +include(create-executable-target.cmake) diff --git a/Tests/RunCMake/XcFramework/create-executable-target-link-phase.cmake b/Tests/RunCMake/XcFramework/create-executable-target-link-phase.cmake new file mode 100644 index 0000000..9c0b0d5 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target-link-phase.cmake @@ -0,0 +1,2 @@ +include(create-executable-target.cmake) +set_property(TARGET myexe PROPERTY XCODE_LINK_BUILD_PHASE_MODE "KNOWN_LOCATION") diff --git a/Tests/RunCMake/XcFramework/create-executable-target.cmake b/Tests/RunCMake/XcFramework/create-executable-target.cmake new file mode 100644 index 0000000..0cc356c --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable-target.cmake @@ -0,0 +1,21 @@ +enable_language(C) + +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") +endif() + +add_library(mylib IMPORTED STATIC) +set_property(TARGET mylib PROPERTY IMPORTED_LOCATION ${MYLIB_LIBRARY}) + +add_executable(myexe myexe/myexe.c) +target_link_libraries(myexe PRIVATE mylib) diff --git a/Tests/RunCMake/XcFramework/create-executable.cmake b/Tests/RunCMake/XcFramework/create-executable.cmake new file mode 100644 index 0000000..6706b9f --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-executable.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") +endif() + +add_executable(myexe myexe/myexe.c) +target_link_libraries(myexe PRIVATE ${MYLIB_LIBRARY}) diff --git a/Tests/RunCMake/XcFramework/create-framework-ios-simulator.cmake b/Tests/RunCMake/XcFramework/create-framework-ios-simulator.cmake new file mode 100644 index 0000000..8b7df9b --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-framework-ios-simulator.cmake @@ -0,0 +1 @@ +include(create-framework.cmake) diff --git a/Tests/RunCMake/XcFramework/create-framework-ios.cmake b/Tests/RunCMake/XcFramework/create-framework-ios.cmake new file mode 100644 index 0000000..8b7df9b --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-framework-ios.cmake @@ -0,0 +1 @@ +include(create-framework.cmake) diff --git a/Tests/RunCMake/XcFramework/create-framework-macos.cmake b/Tests/RunCMake/XcFramework/create-framework-macos.cmake new file mode 100644 index 0000000..8b7df9b --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-framework-macos.cmake @@ -0,0 +1 @@ +include(create-framework.cmake) diff --git a/Tests/RunCMake/XcFramework/create-framework-tvos-simulator.cmake b/Tests/RunCMake/XcFramework/create-framework-tvos-simulator.cmake new file mode 100644 index 0000000..8b7df9b --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-framework-tvos-simulator.cmake @@ -0,0 +1 @@ +include(create-framework.cmake) diff --git a/Tests/RunCMake/XcFramework/create-framework-tvos.cmake b/Tests/RunCMake/XcFramework/create-framework-tvos.cmake new file mode 100644 index 0000000..8b7df9b --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-framework-tvos.cmake @@ -0,0 +1 @@ +include(create-framework.cmake) diff --git a/Tests/RunCMake/XcFramework/create-framework-visionos-simulator.cmake b/Tests/RunCMake/XcFramework/create-framework-visionos-simulator.cmake new file mode 100644 index 0000000..8b7df9b --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-framework-visionos-simulator.cmake @@ -0,0 +1 @@ +include(create-framework.cmake) diff --git a/Tests/RunCMake/XcFramework/create-framework-visionos.cmake b/Tests/RunCMake/XcFramework/create-framework-visionos.cmake new file mode 100644 index 0000000..8b7df9b --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-framework-visionos.cmake @@ -0,0 +1 @@ +include(create-framework.cmake) diff --git a/Tests/RunCMake/XcFramework/create-framework-watchos-simulator.cmake b/Tests/RunCMake/XcFramework/create-framework-watchos-simulator.cmake new file mode 100644 index 0000000..8b7df9b --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-framework-watchos-simulator.cmake @@ -0,0 +1 @@ +include(create-framework.cmake) diff --git a/Tests/RunCMake/XcFramework/create-framework-watchos.cmake b/Tests/RunCMake/XcFramework/create-framework-watchos.cmake new file mode 100644 index 0000000..8b7df9b --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-framework-watchos.cmake @@ -0,0 +1 @@ +include(create-framework.cmake) diff --git a/Tests/RunCMake/XcFramework/create-framework.cmake b/Tests/RunCMake/XcFramework/create-framework.cmake new file mode 100644 index 0000000..f4406e6 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-framework.cmake @@ -0,0 +1,3 @@ +set(CMAKE_FRAMEWORK ON) +include(create-library-common.cmake) +install(FILES mylib/include/mylib/mylib.h DESTINATION lib/mylib.framework/Headers) diff --git a/Tests/RunCMake/XcFramework/create-library-common.cmake b/Tests/RunCMake/XcFramework/create-library-common.cmake new file mode 100644 index 0000000..958660d --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-library-common.cmake @@ -0,0 +1,12 @@ +enable_language(C) + +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") +endif() + +add_library(mylib STATIC mylib/mylib.c) +install(TARGETS mylib DESTINATION lib) diff --git a/Tests/RunCMake/XcFramework/create-library-ios-simulator.cmake b/Tests/RunCMake/XcFramework/create-library-ios-simulator.cmake new file mode 100644 index 0000000..a9f5dee --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-library-ios-simulator.cmake @@ -0,0 +1 @@ +include(create-library.cmake) diff --git a/Tests/RunCMake/XcFramework/create-library-ios.cmake b/Tests/RunCMake/XcFramework/create-library-ios.cmake new file mode 100644 index 0000000..a9f5dee --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-library-ios.cmake @@ -0,0 +1 @@ +include(create-library.cmake) diff --git a/Tests/RunCMake/XcFramework/create-library-macos.cmake b/Tests/RunCMake/XcFramework/create-library-macos.cmake new file mode 100644 index 0000000..a9f5dee --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-library-macos.cmake @@ -0,0 +1 @@ +include(create-library.cmake) diff --git a/Tests/RunCMake/XcFramework/create-library-tvos-simulator.cmake b/Tests/RunCMake/XcFramework/create-library-tvos-simulator.cmake new file mode 100644 index 0000000..a9f5dee --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-library-tvos-simulator.cmake @@ -0,0 +1 @@ +include(create-library.cmake) diff --git a/Tests/RunCMake/XcFramework/create-library-tvos.cmake b/Tests/RunCMake/XcFramework/create-library-tvos.cmake new file mode 100644 index 0000000..a9f5dee --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-library-tvos.cmake @@ -0,0 +1 @@ +include(create-library.cmake) diff --git a/Tests/RunCMake/XcFramework/create-library-visionos-simulator.cmake b/Tests/RunCMake/XcFramework/create-library-visionos-simulator.cmake new file mode 100644 index 0000000..a9f5dee --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-library-visionos-simulator.cmake @@ -0,0 +1 @@ +include(create-library.cmake) diff --git a/Tests/RunCMake/XcFramework/create-library-visionos.cmake b/Tests/RunCMake/XcFramework/create-library-visionos.cmake new file mode 100644 index 0000000..a9f5dee --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-library-visionos.cmake @@ -0,0 +1 @@ +include(create-library.cmake) diff --git a/Tests/RunCMake/XcFramework/create-library-watchos-simulator.cmake b/Tests/RunCMake/XcFramework/create-library-watchos-simulator.cmake new file mode 100644 index 0000000..a9f5dee --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-library-watchos-simulator.cmake @@ -0,0 +1 @@ +include(create-library.cmake) diff --git a/Tests/RunCMake/XcFramework/create-library-watchos.cmake b/Tests/RunCMake/XcFramework/create-library-watchos.cmake new file mode 100644 index 0000000..a9f5dee --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-library-watchos.cmake @@ -0,0 +1 @@ +include(create-library.cmake) diff --git a/Tests/RunCMake/XcFramework/create-library.cmake b/Tests/RunCMake/XcFramework/create-library.cmake new file mode 100644 index 0000000..f2a5249 --- /dev/null +++ b/Tests/RunCMake/XcFramework/create-library.cmake @@ -0,0 +1 @@ +include(create-library-common.cmake) diff --git a/Tests/RunCMake/XcFramework/find-library.cmake b/Tests/RunCMake/XcFramework/find-library.cmake new file mode 100644 index 0000000..1bc7672 --- /dev/null +++ b/Tests/RunCMake/XcFramework/find-library.cmake @@ -0,0 +1,6 @@ +find_library(MYLIB_XCFRAMEWORK mylib NO_DEFAULT_PATH PATHS "${CMAKE_BINARY_DIR}/../create-xcframework-framework-build") +get_filename_component(bin_parent "${CMAKE_BINARY_DIR}" PATH) +set(expected_path "${bin_parent}/create-xcframework-framework-build/mylib.xcframework") +if(NOT MYLIB_XCFRAMEWORK STREQUAL expected_path) + message(FATAL_ERROR "Expected value of MYLIB_XCFRAMEWORK:\n ${expected_path}\nActual value:\n ${MYLIB_XCFRAMEWORK}") +endif() diff --git a/Tests/RunCMake/XcFramework/myexe/myexe.c b/Tests/RunCMake/XcFramework/myexe/myexe.c new file mode 100644 index 0000000..d04efbd --- /dev/null +++ b/Tests/RunCMake/XcFramework/myexe/myexe.c @@ -0,0 +1,7 @@ +#include <mylib/mylib.h> + +int main(void) +{ + mylib(); + return 0; +} diff --git a/Tests/RunCMake/XcFramework/mylib/include/mylib/mylib.h b/Tests/RunCMake/XcFramework/mylib/include/mylib/mylib.h new file mode 100644 index 0000000..1de07aa --- /dev/null +++ b/Tests/RunCMake/XcFramework/mylib/include/mylib/mylib.h @@ -0,0 +1,3 @@ +#pragma once + +extern void mylib(void); diff --git a/Tests/RunCMake/XcFramework/mylib/mylib.c b/Tests/RunCMake/XcFramework/mylib/mylib.c new file mode 100644 index 0000000..4489684 --- /dev/null +++ b/Tests/RunCMake/XcFramework/mylib/mylib.c @@ -0,0 +1,3 @@ +void mylib(void) +{ +} diff --git a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c index 5e0f40f..c00fce7 100644 --- a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c +++ b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.c @@ -5,6 +5,10 @@ # if __MAC_OS_X_VERSION_MIN_REQUIRED != __MAC_10_11 # error macOS deployment version mismatch # endif +#elif TARGET_OS_XR +# if __XR_OS_VERSION_MIN_REQUIRED != __XROS_1_0 +# error visionOS deployment version mismatch +# endif #elif TARGET_OS_IOS # if __IPHONE_OS_VERSION_MIN_REQUIRED != __IPHONE_9_1 # error iOS deployment version mismatch diff --git a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake index 234ceef..80e3877 100644 --- a/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake +++ b/Tests/RunCMake/XcodeProject-Device/DeploymentTarget.cmake @@ -7,6 +7,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") +elseif(CMAKE_SYSTEM_NAME STREQUAL "visionOS") + set(CMAKE_OSX_DEPLOYMENT_TARGET "1.0") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") elseif(CMAKE_SYSTEM_NAME STREQUAL "watchOS") set(CMAKE_OSX_DEPLOYMENT_TARGET "2.0") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") diff --git a/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake index e2ed045..e4dbb90 100644 --- a/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject-Device/RunCMakeTest.cmake @@ -93,6 +93,26 @@ if(NOT XCODE_VERSION VERSION_LESS 7.1) unset(RunCMake_TEST_OPTIONS) endif() +#FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. +#if(NOT XCODE_VERSION VERSION_LESS 15) +# set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesVisionOS-build) +# set(RunCMake_TEST_NO_CLEAN 1) +# set(RunCMake_TEST_OPTIONS +# "-DCMAKE_SYSTEM_NAME=visionOS" +# "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install") +# +# file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") +# file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") +# +# run_cmake(XcodeBundles) +# run_cmake_command(XcodeBundles-build-visionOS ${CMAKE_COMMAND} --build .) +# run_cmake_command(XcodeBundles-install-visionOS ${CMAKE_COMMAND} --build . --target install) +# +# unset(RunCMake_TEST_BINARY_DIR) +# unset(RunCMake_TEST_NO_CLEAN) +# unset(RunCMake_TEST_OPTIONS) +#endif() + if(NOT XCODE_VERSION VERSION_LESS 7) set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/osx.cmake") run_cmake(XcodeTbdStub) @@ -242,6 +262,11 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8) deployment_target_test(tvOS appletvsimulator) deployment_target_test(watchOS watchos) deployment_target_test(watchOS watchsimulator) + #FIXME(#25266): Xcode 15.0 does not have visionOS. Improve this condition. + #if(XCODE_VERSION VERSION_GREATER_EQUAL 15) + # deployment_target_test(visionOS xros) + # deployment_target_test(visionOS xrsimulator) + #endif() endif() if(XCODE_VERSION VERSION_GREATER_EQUAL 8) @@ -288,9 +313,11 @@ if (XCODE_VERSION VERSION_GREATER_EQUAL 7.3) endfunction() if(XCODE_VERSION VERSION_GREATER_EQUAL 12) - xctest_add_bundle_test(Darwin macosx "1" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns") xctest_add_bundle_test(Darwin macosx "12" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns") - xctest_add_bundle_test(iOS iphonesimulator "1" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns") + if(XCODE_VERSION VERSION_LESS 14) + xctest_add_bundle_test(Darwin macosx "1" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns") + xctest_add_bundle_test(iOS iphonesimulator "1" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>/PlugIns") + endif() if (XCODE_VERSION VERSION_LESS 12.5) xctest_add_bundle_test(iOS iphonesimulator "12" "$<TARGET_BUNDLE_CONTENT_DIR:TestedApp>") else() diff --git a/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake index a9fafd2..376a7fc 100644 --- a/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake +++ b/Tests/RunCMake/XcodeProject-Device/XcodeBundles.cmake @@ -9,7 +9,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") endif() -if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS") +if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedPlugIns-macOS-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedPlugIns-macOS-check.cmake index 576be11..66db44e 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedPlugIns-macOS-check.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedPlugIns-macOS-check.cmake @@ -1,4 +1,3 @@ include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) -findAttribute(${test} "RemoveHeadersOnCopy" TRUE) findAttribute(${test} "CodeSignOnCopy" FALSE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedPlugIns.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedPlugIns.cmake index 1bd1bd0..f5c9364 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedPlugIns.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedPlugIns.cmake @@ -1,4 +1,4 @@ -add_executable(plug_in MACOS_BUNDLE Empty.txt) +add_executable(plug_in MACOSX_BUNDLE Empty.txt) set_target_properties(plug_in PROPERTIES LINKER_LANGUAGE CXX XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedResources-iOS-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedResources-iOS-check.cmake new file mode 100644 index 0000000..75aaa91 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedResources-iOS-check.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) + +findAttribute(${test} "Embed Resources" TRUE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedResources-iOS.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedResources-iOS.cmake new file mode 100644 index 0000000..54f9fc8 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedResources-iOS.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/EmbedResources.cmake) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedResources-macOS-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedResources-macOS-check.cmake new file mode 100644 index 0000000..75aaa91 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedResources-macOS-check.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) + +findAttribute(${test} "Embed Resources" TRUE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedResources-macOS.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedResources-macOS.cmake new file mode 100644 index 0000000..54f9fc8 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedResources-macOS.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/EmbedResources.cmake) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedResources.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedResources.cmake new file mode 100644 index 0000000..0638037 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedResources.cmake @@ -0,0 +1,18 @@ +add_executable(app MACOSX_BUNDLE main.m) + +set(EMBED_RESOURCES_FOLDER ${CMAKE_BINARY_DIR}/runtime/shaders) + +# ensure embed resources folder exists +if (NOT (IS_DIRECTORY ${EMBED_RESOURCES_FOLDER})) + file(MAKE_DIRECTORY ${EMBED_RESOURCES_FOLDER}) +endif() + +set_target_properties(app PROPERTIES + XCODE_EMBED_RESOURCES_PATH ${EMBED_RESOURCES_FOLDER} +) + +set_target_properties(app PROPERTIES + XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + MACOSX_BUNDLE_GUI_IDENTIFIER "com.example.app" +) diff --git a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake index a7bccee..3798ddc 100644 --- a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake @@ -83,6 +83,25 @@ function(TestExtensionKitExtension platform) ) endfunction() +function(TestEmbedCommon what platform) + set(testName Embed${what}-${platform}) + if(NOT platform STREQUAL "macOS") + set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=${platform}) + endif() + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(${testName}) + run_cmake_command(${testName}-build + ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} + --config Debug + --target app + ) +endfunction() + # Isolate device tests from host architecture selection. unset(ENV{CMAKE_OSX_ARCHITECTURES}) @@ -100,4 +119,7 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 14.1) # defaults, which is to remove headers on copy, but not code sign. TestAppExtension(macOS) TestAppExtension(iOS) + TestEmbedCommon(Resources macOS) + TestEmbedCommon(Resources iOS) + TestEmbedCommon(PlugIns macOS) endif() diff --git a/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Empty-stdout.txt b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Empty-stdout.txt new file mode 100644 index 0000000..d5a0ca8 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Empty-stdout.txt @@ -0,0 +1 @@ +MSYSTEM_PREFIX='' diff --git a/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Empty.cmake b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Empty.cmake new file mode 100644 index 0000000..ac36c8d --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Empty.cmake @@ -0,0 +1,3 @@ +unset(ENV{MSYSTEM}) +cmake_host_system_information(RESULT result QUERY MSYSTEM_PREFIX) +message(STATUS "MSYSTEM_PREFIX='${result}'") diff --git a/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Missing-result.txt b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Missing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Missing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Missing-stderr.txt b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Missing-stderr.txt new file mode 100644 index 0000000..89c4e9b --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Missing-stderr.txt @@ -0,0 +1,3 @@ +^CMake Error at [^ +]*/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Missing.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information does not recognize <key> MSYSTEM_PREFIX$ diff --git a/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Missing.cmake b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Missing.cmake new file mode 100644 index 0000000..dc1def3 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-Missing.cmake @@ -0,0 +1,2 @@ +unset(ENV{MSYSTEM}) +cmake_host_system_information(RESULT result QUERY MSYSTEM_PREFIX) diff --git a/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-stdout.txt b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-stdout.txt new file mode 100644 index 0000000..f6e2549 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX-stdout.txt @@ -0,0 +1,2 @@ +-- MSYSTEM_PREFIX='[^ +]+' diff --git a/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX.cmake b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX.cmake new file mode 100644 index 0000000..d1c996b --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/MSYSTEM_PREFIX.cmake @@ -0,0 +1,7 @@ +cmake_host_system_information(RESULT result QUERY MSYSTEM_PREFIX) +message(STATUS "MSYSTEM_PREFIX='${result}'") +if(CMake_TEST_MSYSTEM_PREFIX) + if(NOT "${result}" STREQUAL "${CMake_TEST_MSYSTEM_PREFIX}") + message(FATAL_ERROR "Actual result:\n ${result}\nis not expected result:\n ${CMake_TEST_MSYSTEM_PREFIX}") + endif() +endif() diff --git a/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake b/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake index 9122470..0b3576d 100644 --- a/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake +++ b/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake @@ -22,6 +22,17 @@ else() run_cmake(VsMSBuildMissing) endif() +if(CMAKE_HOST_WIN32) + run_cmake_script(MSYSTEM_PREFIX-Empty) + if("$ENV{MSYSTEM}" MATCHES "(MSYS|MINGW32|MINGW64|UCRT64)") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-$ENV{MSYSTEM}") + run_cmake_script(MSYSTEM_PREFIX -DCMake_TEST_MSYSTEM_PREFIX=${CMake_TEST_MSYSTEM_PREFIX}) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + endif() +else() + run_cmake_script(MSYSTEM_PREFIX-Missing) +endif() + # WINDOWS_REGISTRY tests run_cmake(Registry_NoArgs) run_cmake(Registry_BadQuery1) diff --git a/Tests/RunCMake/ctest_build/BuildFailure.cxx b/Tests/RunCMake/ctest_build/BuildFailure.cxx new file mode 100644 index 0000000..8102883 --- /dev/null +++ b/Tests/RunCMake/ctest_build/BuildFailure.cxx @@ -0,0 +1,4 @@ +int main() +{ + this code will not compile +} diff --git a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake index 12525f2..af56ead 100644 --- a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake @@ -13,18 +13,18 @@ endfunction() run_ctest_build(BuildQuiet QUIET) run_ctest_build(ParallelLevel PARALLEL_LEVEL 1) -function(run_BuildFailure) - set(CASE_CMAKELISTS_SUFFIX_CODE [[ -add_custom_target(BuildFailure ALL COMMAND command-does-not-exist) -]]) +block() + set(LANG CXX) + configure_file("${RunCMake_SOURCE_DIR}/BuildFailure.cxx" "${RunCMake_BINARY_DIR}/BuildFailure/BuildFailure.cxx" COPYONLY) + set(CASE_CMAKELISTS_SUFFIX_CODE [=[ + add_executable(BuildFailure BuildFailure.cxx) + ]=]) set(CASE_CMAKELISTS_PREFIX_CODE [[ if(NOT CTEST_USE_LAUNCHERS) message(FATAL_ERROR "CTEST_USE_LAUNCHERS not set") endif() ]]) - set(CASE_TEST_PREFIX_CODE [[ -cmake_policy(SET CMP0061 NEW) -]]) + set(CASE_TEST_PREFIX_CODE "") set(CASE_TEST_SUFFIX_CODE [[ if (ctest_build_return_value) message("ctest_build returned non-zero") @@ -35,13 +35,16 @@ endif() run_ctest(BuildFailure) if (RunCMake_GENERATOR MATCHES "Makefiles") + set(LANG NONE) set(CASE_TEST_PREFIX_CODE [[ cmake_policy(VERSION 3.2) ]]) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_custom_target(BuildFailure ALL COMMAND command-does-not-exist) +]]) run_ctest(BuildFailure-CMP0061-OLD) endif() -endfunction() -run_BuildFailure() +endblock() function(run_BuildChangeId) set(CASE_TEST_PREFIX_CODE [[ diff --git a/Tests/RunCMake/ctest_test/NotRun-result.txt b/Tests/RunCMake/ctest_test/NotRun-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_test/NotRun-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_test/NotRun-stderr.txt b/Tests/RunCMake/ctest_test/NotRun-stderr.txt new file mode 100644 index 0000000..85907f3 --- /dev/null +++ b/Tests/RunCMake/ctest_test/NotRun-stderr.txt @@ -0,0 +1,2 @@ +.*Unable to find executable[^ +]*does_not_exist diff --git a/Tests/RunCMake/ctest_test/NotRun-stdout.txt b/Tests/RunCMake/ctest_test/NotRun-stdout.txt new file mode 100644 index 0000000..8d60833 --- /dev/null +++ b/Tests/RunCMake/ctest_test/NotRun-stdout.txt @@ -0,0 +1,7 @@ +.*Could not find executable[^ +]*does_not_exist +.* +50% tests passed, 1 tests failed out of 2 +.* +The following tests FAILED: +.*testNotRun \(Not Run\) diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 242a059..d2f3da3 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -53,6 +53,13 @@ unset(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING}) unset(CASE_CTEST_TEST_LOAD) unset(RunCTest_VERBOSE_FLAG) +block() + set(CASE_CMAKELISTS_SUFFIX_CODE [[ + add_test(NAME testNotRun COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist) + ]]) + run_ctest_test(NotRun) +endblock() + function(run_TestChangeId) set(CASE_TEST_PREFIX_CODE [[ set(CTEST_CHANGE_ID "<>1") @@ -131,8 +138,7 @@ run_TestRepeat(AfterTimeout RETURN_VALUE:0 REPEAT AFTER_TIMEOUT:3) # test repeat and not run tests interact correctly set(CASE_CMAKELISTS_SUFFIX_CODE [[ -add_test(NAME testNotRun - COMMAND ${CMAKE_COMMAND}/doesnt_exist) + add_test(NAME testNotRun COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist) set_property(TEST testNotRun PROPERTY TIMEOUT 5) ]]) run_TestRepeat(NotRun RETURN_VALUE:1 REPEAT UNTIL_PASS:3) diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt index a69932d..85907f3 100644 --- a/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stderr.txt @@ -1 +1,2 @@ -.*Unable to find executable.* +.*Unable to find executable[^ +]*does_not_exist diff --git a/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt index 72c98bc..8d60833 100644 --- a/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt +++ b/Tests/RunCMake/ctest_test/TestRepeatNotRun-stdout.txt @@ -1,5 +1,7 @@ +.*Could not find executable[^ +]*does_not_exist .* 50% tests passed, 1 tests failed out of 2 .* The following tests FAILED: -.*testNotRun.*Not Run.* +.*testNotRun \(Not Run\) diff --git a/Tests/RunCMake/detect_jobserver.c b/Tests/RunCMake/detect_jobserver.c new file mode 100644 index 0000000..8cbfe2e --- /dev/null +++ b/Tests/RunCMake/detect_jobserver.c @@ -0,0 +1,179 @@ +#ifndef _CRT_SECURE_NO_WARNINGS +# define _CRT_SECURE_NO_WARNINGS +#endif + +#if defined(_MSC_VER) && _MSC_VER >= 1928 +# pragma warning(disable : 5105) /* macro expansion warning in windows.h */ +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define MAX_MESSAGE_LENGTH 1023 +#define USAGE "Usage: %s <output_file>\n" + +// Extracts the jobserver details from the MAKEFLAGS environment variable. +// +// Returns a pointer to either a string of the form "R,W" where R and W are fds +// or "fifo:PATH". +// +// Returns NULL if MAKEFLAGS is not set or does not contain recognized +// jobserver flags. +char* jobserver_auth(char* message) +{ + const char* jobserver_flags[3] = { "--jobserver-auth=", "--jobserver-fds=", + "-J" }; + char* start = NULL; + char* end; + char* result; + size_t len; + int i; + + char* makeflags = getenv("MAKEFLAGS"); + if (makeflags == NULL) { + strncpy(message, "MAKEFLAGS not set", MAX_MESSAGE_LENGTH); + return NULL; + } + + fprintf(stdout, "MAKEFLAGS: %s\n", makeflags); + + for (i = 0; i < 3; i++) { + start = strstr(makeflags, jobserver_flags[i]); + if (start != NULL) { + start += strlen(jobserver_flags[i]); + break; + } + } + + if (start == NULL) { + strncpy(message, "No jobserver flags found", MAX_MESSAGE_LENGTH); + return NULL; + } + + // Skip leading white space + while (*start == ' ' || *start == '\t') { + start++; + } + + end = strchr(start, ' '); + if (end == NULL) { + end = start + strlen(start); + } + len = (size_t)(end - start); + result = (char*)malloc(len + 1); + strncpy(result, start, len); + result[len] = '\0'; + + return result; +} + +#if defined(_WIN32) +# include <windows.h> + +int windows_semaphore(const char* semaphore, char* message) +{ + // Open the semaphore + HANDLE hSemaphore = OpenSemaphoreA(SEMAPHORE_ALL_ACCESS, FALSE, semaphore); + + if (hSemaphore == NULL) { +# if defined(_MSC_VER) && _MSC_VER < 1900 + sprintf(message, "Error opening semaphore: %s (%ld)\n", semaphore, + GetLastError()); +# else + snprintf(message, MAX_MESSAGE_LENGTH, + "Error opening semaphore: %s (%ld)\n", semaphore, GetLastError()); +# endif + return 1; + } + + strncpy(message, "Success", MAX_MESSAGE_LENGTH); + return 0; +} +#else +# include <errno.h> +# include <fcntl.h> + +int test_fd(int read_fd, int write_fd, char* message) +{ + // Detect if the file descriptors are valid + int read_good = fcntl(read_fd, F_GETFD) != -1; + int read_error = errno; + + int write_good = fcntl(write_fd, F_GETFD) != -1; + int write_error = errno; + + if (!read_good || !write_good) { + snprintf(message, MAX_MESSAGE_LENGTH, + "Error opening file descriptors: %d (%s), %d (%s)\n", read_fd, + strerror(read_error), write_fd, strerror(write_error)); + return 1; + } + + snprintf(message, MAX_MESSAGE_LENGTH, "Success\n"); + return 0; +} + +int posix(const char* jobserver, char* message) +{ + int read_fd; + int write_fd; + const char* path; + + // First try to parse as "R,W" file descriptors + if (sscanf(jobserver, "%d,%d", &read_fd, &write_fd) == 2) { + return test_fd(read_fd, write_fd, message); + } + + // Then try to parse as "fifo:PATH" + if (strncmp(jobserver, "fifo:", 5) == 0) { + path = jobserver + 5; + read_fd = open(path, O_RDONLY); + write_fd = open(path, O_WRONLY); + return test_fd(read_fd, write_fd, message); + } + + // We don't understand the format + snprintf(message, MAX_MESSAGE_LENGTH, "Unrecognized jobserver format: %s\n", + jobserver); + return 1; +} +#endif + +// Takes 1 argument: an outfile to write results to. +int main(int argc, char** argv) +{ + char message[MAX_MESSAGE_LENGTH + 1]; + char* output_file; + FILE* fp; + char* jobserver; + int result; + + if (argc != 2) { + fprintf(stderr, USAGE, argv[0]); + return 2; + } + + output_file = argv[1]; + fp = fopen(output_file, "w"); + if (fp == NULL) { + fprintf(stderr, "Error opening output file: %s\n", output_file); + return 2; + } + + jobserver = jobserver_auth(message); + if (jobserver == NULL) { + fprintf(stderr, "%s\n", message); + return 1; + } + +#if defined(_WIN32) + result = windows_semaphore(jobserver, message); +#else + result = posix(jobserver, message); +#endif + free(jobserver); + message[MAX_MESSAGE_LENGTH] = '\0'; + + return result; +} diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake index c2f9144..1f89829 100644 --- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake +++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake @@ -34,6 +34,7 @@ run_cmake_command(AnyCommandGood ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/AnyC run_cmake_command(LastCommandError ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/LastCommandError.cmake) run_cmake_command(LastCommandTimeout ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/LastCommandTimeout.cmake) run_cmake_command(LastCommandGood ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/LastCommandGood.cmake) +run_cmake_command(Stdin ${CMAKE_COMMAND} -DPRINT_STDIN_EXE=${PRINT_STDIN_EXE} -P ${RunCMake_SOURCE_DIR}/Stdin.cmake) if(UNIX AND Python_EXECUTABLE) run_cmake_command(AnyCommandAbnormalExit ${CMAKE_COMMAND} -DPython_EXECUTABLE=${Python_EXECUTABLE} -P ${RunCMake_SOURCE_DIR}/AnyCommandAbnormalExit.cmake) diff --git a/Tests/RunCMake/execute_process/Stdin-stdin.txt b/Tests/RunCMake/execute_process/Stdin-stdin.txt new file mode 100644 index 0000000..cd08755 --- /dev/null +++ b/Tests/RunCMake/execute_process/Stdin-stdin.txt @@ -0,0 +1 @@ +Hello world! diff --git a/Tests/RunCMake/execute_process/Stdin-stdout.txt b/Tests/RunCMake/execute_process/Stdin-stdout.txt new file mode 100644 index 0000000..04bd136 --- /dev/null +++ b/Tests/RunCMake/execute_process/Stdin-stdout.txt @@ -0,0 +1 @@ +^Hello world!$ diff --git a/Tests/RunCMake/execute_process/Stdin.cmake b/Tests/RunCMake/execute_process/Stdin.cmake new file mode 100644 index 0000000..e8a2098 --- /dev/null +++ b/Tests/RunCMake/execute_process/Stdin.cmake @@ -0,0 +1 @@ +execute_process(COMMAND ${PRINT_STDIN_EXE}) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-all-check.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-all-check.cmake index 10b7b82..61ab542 100644 --- a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-all-check.cmake +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-all-check.cmake @@ -1,4 +1,4 @@ -if(CMAKE_C_COMPILER_ID STREQUAL "Borland") +if(CMAKE_C_COMPILER_ID MATCHES "^(Borland|OrangeC)$") # Borland upper-cases dll names referenced in import libraries. set(conflict_dll [[CONFLICT\.DLL]]) set(unresolved_dll [[UNRESOLVED\.DLL]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-conflict-all-stderr-OrangeC.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-conflict-all-stderr-OrangeC.txt new file mode 100644 index 0000000..607e4b8 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-conflict-all-stderr-OrangeC.txt @@ -0,0 +1,7 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Multiple conflicting paths found for PATH\.DLL: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-conflict-build/root-all/lib/test1/path\.dll + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-conflict-build/root-all/lib/test2/path\.dll$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-unresolved-all-stderr-OrangeC.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-unresolved-all-stderr-OrangeC.txt new file mode 100644 index 0000000..fea1083 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-unresolved-all-stderr-OrangeC.txt @@ -0,0 +1,4 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Could not resolve runtime dependencies: + + UNRESOLVED\.DLL$ diff --git a/Tests/RunCMake/file/REAL_PATH.cmake b/Tests/RunCMake/file/REAL_PATH.cmake index 9c5d4ea..0485655 100644 --- a/Tests/RunCMake/file/REAL_PATH.cmake +++ b/Tests/RunCMake/file/REAL_PATH.cmake @@ -1,18 +1,57 @@ if (NOT WIN32 OR CYGWIN) + file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}" real_binary_dir) + file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/test.txt") file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test.sym") file(CREATE_LINK "test.txt" "${CMAKE_CURRENT_BINARY_DIR}/test.sym" SYMBOLIC) file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/test.sym" real_path) - if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/test.txt") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/test.txt\"") + if (NOT real_path STREQUAL "${real_binary_dir}/test.txt") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/test.txt\"") endif() file(REAL_PATH "test.sym" real_path BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/test.txt") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/test.txt\"") + if (NOT real_path STREQUAL "${real_binary_dir}/test.txt") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/test.txt\"") + endif() + + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dir/") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dir/nested/") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dir/nested/bin/") + file(CREATE_LINK "${CMAKE_CURRENT_BINARY_DIR}/dir/nested/bin" "${CMAKE_CURRENT_BINARY_DIR}/dir/bin" SYMBOLIC) + + cmake_policy(SET CMP0152 NEW) + file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/dir/bin/../" real_path) + if (NOT real_path STREQUAL "${real_binary_dir}/dir/nested") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir/nested\"") + endif() + + file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/dir/bin/../bin" real_path) + if (NOT real_path STREQUAL "${real_binary_dir}/dir/nested/bin") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir/nested/bin\"") + endif() + + file(REAL_PATH "dir/bin/../bin" real_path BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + if (NOT real_path STREQUAL "${real_binary_dir}/dir/nested/bin") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir/nested/bin\"") + endif() + + file(REAL_PATH "../bin" real_path BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dir/bin/" ) + if (NOT real_path STREQUAL "${real_binary_dir}/dir/nested/bin") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir/nested/bin\"") endif() + + cmake_policy(SET CMP0152 OLD) + file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/dir/bin/../" real_path) + if (NOT real_path STREQUAL "${real_binary_dir}/dir") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir/nested\"") + endif() + file(REAL_PATH "../" real_path BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dir/bin/") + if (NOT real_path STREQUAL "${real_binary_dir}/dir") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir\"") + endif() + endif() @@ -24,12 +63,14 @@ If (WIN32) else() set(HOME_DIR "$ENV{HOME}") endif() +file(REAL_PATH "${HOME_DIR}" HOME_DIR) file(REAL_PATH "~" real_path EXPAND_TILDE) if (NOT real_path STREQUAL "${HOME_DIR}") message(SEND_ERROR "real path is \"${real_path}\", should be \"${HOME_DIR}\"") endif() +file(TOUCH "${HOME_DIR}/test.txt") file(REAL_PATH "~/test.txt" real_path EXPAND_TILDE) if (NOT real_path STREQUAL "${HOME_DIR}/test.txt") message(SEND_ERROR "real path is \"${real_path}\", should be \"${HOME_DIR}/test.txt\"") diff --git a/Tests/RunCMake/find_file/FromPATHEnv-stdout-cygwin.txt b/Tests/RunCMake/find_file/FromPATHEnv-stdout-cygwin.txt deleted file mode 100644 index 6912bdf..0000000 --- a/Tests/RunCMake/find_file/FromPATHEnv-stdout-cygwin.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' diff --git a/Tests/RunCMake/find_file/FromPATHEnv-stdout-msys.txt b/Tests/RunCMake/find_file/FromPATHEnv-stdout-msys.txt deleted file mode 100644 index 6912bdf..0000000 --- a/Tests/RunCMake/find_file/FromPATHEnv-stdout-msys.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' diff --git a/Tests/RunCMake/find_file/FromPATHEnv-stdout-windows.txt b/Tests/RunCMake/find_file/FromPATHEnv-stdout-windows.txt deleted file mode 100644 index 6912bdf..0000000 --- a/Tests/RunCMake/find_file/FromPATHEnv-stdout-windows.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-cygwin.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-cygwin.txt deleted file mode 100644 index 6912bdf..0000000 --- a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-cygwin.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-msys.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-msys.txt deleted file mode 100644 index 6912bdf..0000000 --- a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-msys.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-windows.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-windows.txt deleted file mode 100644 index 6912bdf..0000000 --- a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-windows.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' --- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' diff --git a/Tests/RunCMake/find_file/MSYSTEM_PREFIX-stdout.txt b/Tests/RunCMake/find_file/MSYSTEM_PREFIX-stdout.txt new file mode 100644 index 0000000..ab9b9d5 --- /dev/null +++ b/Tests/RunCMake/find_file/MSYSTEM_PREFIX-stdout.txt @@ -0,0 +1 @@ +-- MSYSTEM_PREFIX_H='[^']*/Tests/RunCMake/find_file/MSYSTEM_PREFIX/include/msystem_prefix.h' diff --git a/Tests/RunCMake/find_file/MSYSTEM_PREFIX.cmake b/Tests/RunCMake/find_file/MSYSTEM_PREFIX.cmake new file mode 100644 index 0000000..08e4127 --- /dev/null +++ b/Tests/RunCMake/find_file/MSYSTEM_PREFIX.cmake @@ -0,0 +1,5 @@ +set(ENV{MSYSTEM} "FAKEMSYS") +set(ENV{MSYSTEM_PREFIX} "${CMAKE_CURRENT_LIST_DIR}/MSYSTEM_PREFIX") +enable_language(C) +find_file(MSYSTEM_PREFIX_H NAMES msystem_prefix.h) +message(STATUS "MSYSTEM_PREFIX_H='${MSYSTEM_PREFIX_H}'") diff --git a/Tests/RunCMake/find_file/MSYSTEM_PREFIX/include/msystem_prefix.h b/Tests/RunCMake/find_file/MSYSTEM_PREFIX/include/msystem_prefix.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_file/MSYSTEM_PREFIX/include/msystem_prefix.h diff --git a/Tests/RunCMake/find_file/PrefixInPATH-stdout-cygwin.txt b/Tests/RunCMake/find_file/PrefixInPATH-stdout-cygwin.txt deleted file mode 100644 index d73bc1d..0000000 --- a/Tests/RunCMake/find_file/PrefixInPATH-stdout-cygwin.txt +++ /dev/null @@ -1,4 +0,0 @@ --- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' diff --git a/Tests/RunCMake/find_file/PrefixInPATH-stdout-msys.txt b/Tests/RunCMake/find_file/PrefixInPATH-stdout-msys.txt deleted file mode 100644 index d73bc1d..0000000 --- a/Tests/RunCMake/find_file/PrefixInPATH-stdout-msys.txt +++ /dev/null @@ -1,4 +0,0 @@ --- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' diff --git a/Tests/RunCMake/find_file/PrefixInPATH-stdout-windows.txt b/Tests/RunCMake/find_file/PrefixInPATH-stdout-windows.txt deleted file mode 100644 index d73bc1d..0000000 --- a/Tests/RunCMake/find_file/PrefixInPATH-stdout-windows.txt +++ /dev/null @@ -1,4 +0,0 @@ --- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake index 296bb71..2d59e38 100644 --- a/Tests/RunCMake/find_file/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_file/RunCMakeTest.cmake @@ -12,6 +12,10 @@ run_cmake(VALIDATOR-undefined-function) run_cmake(VALIDATOR-specify-macro) run_cmake(VALIDATOR) +if(CMAKE_HOST_WIN32 AND MINGW) + run_cmake(MSYSTEM_PREFIX) +endif() + run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PrefixInPATH_File) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") diff --git a/Tests/RunCMake/find_library/FromPATHEnv-stdout-cygwin.txt b/Tests/RunCMake/find_library/FromPATHEnv-stdout-cygwin.txt deleted file mode 100644 index 01e2720..0000000 --- a/Tests/RunCMake/find_library/FromPATHEnv-stdout-cygwin.txt +++ /dev/null @@ -1,6 +0,0 @@ --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnv-build/lib/libcreated.a' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnv-build/lib/libcreated.a' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' diff --git a/Tests/RunCMake/find_library/FromPATHEnv-stdout-msys.txt b/Tests/RunCMake/find_library/FromPATHEnv-stdout-msys.txt deleted file mode 100644 index 01e2720..0000000 --- a/Tests/RunCMake/find_library/FromPATHEnv-stdout-msys.txt +++ /dev/null @@ -1,6 +0,0 @@ --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnv-build/lib/libcreated.a' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnv-build/lib/libcreated.a' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' diff --git a/Tests/RunCMake/find_library/FromPATHEnv-stdout-windows.txt b/Tests/RunCMake/find_library/FromPATHEnv-stdout-windows.txt deleted file mode 100644 index 01e2720..0000000 --- a/Tests/RunCMake/find_library/FromPATHEnv-stdout-windows.txt +++ /dev/null @@ -1,6 +0,0 @@ --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnv-build/lib/libcreated.a' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnv-build/lib/libcreated.a' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-cygwin.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-cygwin.txt deleted file mode 100644 index 48f36cc..0000000 --- a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-cygwin.txt +++ /dev/null @@ -1,6 +0,0 @@ --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-msys.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-msys.txt deleted file mode 100644 index 48f36cc..0000000 --- a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-msys.txt +++ /dev/null @@ -1,6 +0,0 @@ --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-windows.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-windows.txt deleted file mode 100644 index 48f36cc..0000000 --- a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-windows.txt +++ /dev/null @@ -1,6 +0,0 @@ --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' --- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' --- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' diff --git a/Tests/RunCMake/find_library/FromScriptMode-stderr-darwin.txt b/Tests/RunCMake/find_library/FromScriptMode-stderr-darwin.txt index 185720b..b0bf460 100644 --- a/Tests/RunCMake/find_library/FromScriptMode-stderr-darwin.txt +++ b/Tests/RunCMake/find_library/FromScriptMode-stderr-darwin.txt @@ -1,4 +1,4 @@ .*find_library considered the following locations.* -.*\(lib\)library_no_exist\(\\.tbd\|\\.dylib\|\\.so\|\\.a\).* +.*liblibrary_no_exist\(\\.tbd\|\\.dylib\|\\.so\|\\.a\).* .*The item was found at.* .*lib/libcreated.a.* diff --git a/Tests/RunCMake/find_library/FromScriptMode-stderr.txt b/Tests/RunCMake/find_library/FromScriptMode-stderr.txt index 046f680..6f25184 100644 --- a/Tests/RunCMake/find_library/FromScriptMode-stderr.txt +++ b/Tests/RunCMake/find_library/FromScriptMode-stderr.txt @@ -1,4 +1,4 @@ .*find_library considered the following locations.* -.*\(lib\)library_no_exist\(\\.so\|\\.a\).* +.*liblibrary_no_exist\(\\.so\|\\.a\).* .*The item was found at.* .*lib/libcreated.a.* diff --git a/Tests/RunCMake/find_library/MSYSTEM_PREFIX-stdout.txt b/Tests/RunCMake/find_library/MSYSTEM_PREFIX-stdout.txt new file mode 100644 index 0000000..b19bcce --- /dev/null +++ b/Tests/RunCMake/find_library/MSYSTEM_PREFIX-stdout.txt @@ -0,0 +1 @@ +-- MSYSTEM_PREFIX_LIB='[^']*/Tests/RunCMake/find_library/MSYSTEM_PREFIX/lib/libmsystem_prefix.a' diff --git a/Tests/RunCMake/find_library/MSYSTEM_PREFIX.cmake b/Tests/RunCMake/find_library/MSYSTEM_PREFIX.cmake new file mode 100644 index 0000000..ef4ce2f --- /dev/null +++ b/Tests/RunCMake/find_library/MSYSTEM_PREFIX.cmake @@ -0,0 +1,5 @@ +set(ENV{MSYSTEM} "FAKEMSYS") +set(ENV{MSYSTEM_PREFIX} "${CMAKE_CURRENT_LIST_DIR}/MSYSTEM_PREFIX") +enable_language(C) +find_library(MSYSTEM_PREFIX_LIB NAMES msystem_prefix) +message(STATUS "MSYSTEM_PREFIX_LIB='${MSYSTEM_PREFIX_LIB}'") diff --git a/Tests/RunCMake/find_library/MSYSTEM_PREFIX/lib/libmsystem_prefix.a b/Tests/RunCMake/find_library/MSYSTEM_PREFIX/lib/libmsystem_prefix.a new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_library/MSYSTEM_PREFIX/lib/libmsystem_prefix.a diff --git a/Tests/RunCMake/find_library/PrefixInPATH-stdout-cygwin.txt b/Tests/RunCMake/find_library/PrefixInPATH-stdout-cygwin.txt deleted file mode 100644 index 1ab884c..0000000 --- a/Tests/RunCMake/find_library/PrefixInPATH-stdout-cygwin.txt +++ /dev/null @@ -1,4 +0,0 @@ --- PrefixInPATH_LIBRARY='PrefixInPATH_LIBRARY-NOTFOUND' --- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' --- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' --- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' diff --git a/Tests/RunCMake/find_library/PrefixInPATH-stdout-msys.txt b/Tests/RunCMake/find_library/PrefixInPATH-stdout-msys.txt deleted file mode 100644 index 1ab884c..0000000 --- a/Tests/RunCMake/find_library/PrefixInPATH-stdout-msys.txt +++ /dev/null @@ -1,4 +0,0 @@ --- PrefixInPATH_LIBRARY='PrefixInPATH_LIBRARY-NOTFOUND' --- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' --- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' --- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' diff --git a/Tests/RunCMake/find_library/PrefixInPATH-stdout-windows.txt b/Tests/RunCMake/find_library/PrefixInPATH-stdout-windows.txt deleted file mode 100644 index 1ab884c..0000000 --- a/Tests/RunCMake/find_library/PrefixInPATH-stdout-windows.txt +++ /dev/null @@ -1,4 +0,0 @@ --- PrefixInPATH_LIBRARY='PrefixInPATH_LIBRARY-NOTFOUND' --- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' --- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' --- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a' diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake index 8b223b4..0bed252 100644 --- a/Tests/RunCMake/find_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake @@ -20,6 +20,10 @@ run_cmake(VALIDATOR-undefined-function) run_cmake(VALIDATOR-specify-macro) run_cmake(VALIDATOR) +if(CMAKE_HOST_WIN32 AND MINGW) + run_cmake(MSYSTEM_PREFIX) +endif() + run_cmake_script(FromScriptMode "-DTEMP_DIR=${RunCMake_BINARY_DIR}/FromScriptMode-temp") run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=CREATED_LIBRARY) diff --git a/Tests/RunCMake/find_package/MSYSTEM_PREFIX-stdout.txt b/Tests/RunCMake/find_package/MSYSTEM_PREFIX-stdout.txt new file mode 100644 index 0000000..b1c8346 --- /dev/null +++ b/Tests/RunCMake/find_package/MSYSTEM_PREFIX-stdout.txt @@ -0,0 +1 @@ +-- MsysPfx_DIR='[^']*/Tests/RunCMake/find_package/MSYSTEM_PREFIX' diff --git a/Tests/RunCMake/find_package/MSYSTEM_PREFIX.cmake b/Tests/RunCMake/find_package/MSYSTEM_PREFIX.cmake new file mode 100644 index 0000000..2826e53 --- /dev/null +++ b/Tests/RunCMake/find_package/MSYSTEM_PREFIX.cmake @@ -0,0 +1,5 @@ +set(ENV{MSYSTEM} "FAKEMSYS") +set(ENV{MSYSTEM_PREFIX} "${CMAKE_CURRENT_LIST_DIR}/MSYSTEM_PREFIX") +enable_language(C) +find_package(MsysPfx QUIET) +message(STATUS "MsysPfx_DIR='${MsysPfx_DIR}'") diff --git a/Tests/RunCMake/find_package/MSYSTEM_PREFIX/MsysPfxConfig.cmake b/Tests/RunCMake/find_package/MSYSTEM_PREFIX/MsysPfxConfig.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_package/MSYSTEM_PREFIX/MsysPfxConfig.cmake diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 006757a..a93b811 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -72,6 +72,10 @@ run_cmake(REGISTRY_VIEW-no-view) run_cmake(REGISTRY_VIEW-wrong-view) run_cmake(REGISTRY_VIEW-propagated) +if(CMAKE_HOST_WIN32 AND MINGW) + run_cmake(MSYSTEM_PREFIX) +endif() + if(CMAKE_HOST_WIN32) run_cmake(CMP0144-WARN-CaseInsensitive) run_cmake(CMP0144-OLD-CaseInsensitive) diff --git a/Tests/RunCMake/find_path/FromPATHEnv-stdout-cygwin.txt b/Tests/RunCMake/find_path/FromPATHEnv-stdout-cygwin.txt deleted file mode 100644 index 8f3e7ca..0000000 --- a/Tests/RunCMake/find_path/FromPATHEnv-stdout-cygwin.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' diff --git a/Tests/RunCMake/find_path/FromPATHEnv-stdout-msys.txt b/Tests/RunCMake/find_path/FromPATHEnv-stdout-msys.txt deleted file mode 100644 index 8f3e7ca..0000000 --- a/Tests/RunCMake/find_path/FromPATHEnv-stdout-msys.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' diff --git a/Tests/RunCMake/find_path/FromPATHEnv-stdout-windows.txt b/Tests/RunCMake/find_path/FromPATHEnv-stdout-windows.txt deleted file mode 100644 index 8f3e7ca..0000000 --- a/Tests/RunCMake/find_path/FromPATHEnv-stdout-windows.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND' diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-cygwin.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-cygwin.txt deleted file mode 100644 index a502d78..0000000 --- a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-cygwin.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='' --- PATH_IN_ENV_PATH='' --- PATH_IN_ENV_PATH='' diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-msys.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-msys.txt deleted file mode 100644 index a502d78..0000000 --- a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-msys.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='' --- PATH_IN_ENV_PATH='' --- PATH_IN_ENV_PATH='' diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-windows.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-windows.txt deleted file mode 100644 index a502d78..0000000 --- a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-windows.txt +++ /dev/null @@ -1,9 +0,0 @@ --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' --- PATH_IN_ENV_PATH='' --- PATH_IN_ENV_PATH='' --- PATH_IN_ENV_PATH='' diff --git a/Tests/RunCMake/find_path/MSYSTEM_PREFIX-stdout.txt b/Tests/RunCMake/find_path/MSYSTEM_PREFIX-stdout.txt new file mode 100644 index 0000000..87ee490 --- /dev/null +++ b/Tests/RunCMake/find_path/MSYSTEM_PREFIX-stdout.txt @@ -0,0 +1 @@ +-- MSYSTEM_PREFIX_INCLUDE_DIR='[^']*/Tests/RunCMake/find_path/MSYSTEM_PREFIX/include' diff --git a/Tests/RunCMake/find_path/MSYSTEM_PREFIX.cmake b/Tests/RunCMake/find_path/MSYSTEM_PREFIX.cmake new file mode 100644 index 0000000..d17a52f --- /dev/null +++ b/Tests/RunCMake/find_path/MSYSTEM_PREFIX.cmake @@ -0,0 +1,5 @@ +set(ENV{MSYSTEM} "FAKEMSYS") +set(ENV{MSYSTEM_PREFIX} "${CMAKE_CURRENT_LIST_DIR}/MSYSTEM_PREFIX") +enable_language(C) +find_path(MSYSTEM_PREFIX_INCLUDE_DIR NAMES msystem_prefix.h) +message(STATUS "MSYSTEM_PREFIX_INCLUDE_DIR='${MSYSTEM_PREFIX_INCLUDE_DIR}'") diff --git a/Tests/RunCMake/find_path/MSYSTEM_PREFIX/include/msystem_prefix.h b/Tests/RunCMake/find_path/MSYSTEM_PREFIX/include/msystem_prefix.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_path/MSYSTEM_PREFIX/include/msystem_prefix.h diff --git a/Tests/RunCMake/find_path/PrefixInPATH-stdout-cygwin.txt b/Tests/RunCMake/find_path/PrefixInPATH-stdout-cygwin.txt deleted file mode 100644 index bb2ceb7..0000000 --- a/Tests/RunCMake/find_path/PrefixInPATH-stdout-cygwin.txt +++ /dev/null @@ -1,4 +0,0 @@ --- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include' diff --git a/Tests/RunCMake/find_path/PrefixInPATH-stdout-msys.txt b/Tests/RunCMake/find_path/PrefixInPATH-stdout-msys.txt deleted file mode 100644 index bb2ceb7..0000000 --- a/Tests/RunCMake/find_path/PrefixInPATH-stdout-msys.txt +++ /dev/null @@ -1,4 +0,0 @@ --- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include' diff --git a/Tests/RunCMake/find_path/PrefixInPATH-stdout-windows.txt b/Tests/RunCMake/find_path/PrefixInPATH-stdout-windows.txt deleted file mode 100644 index bb2ceb7..0000000 --- a/Tests/RunCMake/find_path/PrefixInPATH-stdout-windows.txt +++ /dev/null @@ -1,4 +0,0 @@ --- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include' --- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include' diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake index 9c76f2e..2ed4d7d 100644 --- a/Tests/RunCMake/find_path/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake @@ -12,6 +12,10 @@ run_cmake(VALIDATOR-undefined-function) run_cmake(VALIDATOR-specify-macro) run_cmake(VALIDATOR) +if(CMAKE_HOST_WIN32 AND MINGW) + run_cmake(MSYSTEM_PREFIX) +endif() + if(APPLE) run_cmake(FrameworksWithSubdirs) endif() diff --git a/Tests/RunCMake/get_property/test_properties-stderr.txt b/Tests/RunCMake/get_property/test_properties-stderr.txt index a447280..9f5a10f 100644 --- a/Tests/RunCMake/get_property/test_properties-stderr.txt +++ b/Tests/RunCMake/get_property/test_properties-stderr.txt @@ -1,6 +1,12 @@ -^get_test_property: --><-- +^get_test_property: -->value<-- +get_property: -->value<-- +get_test_property: --><-- get_property: --><-- get_test_property: -->value<-- get_property: -->value<-- get_test_property: -->NOTFOUND<-- -get_property: --><--$ +get_property: --><-- +get_test_property: -->anotherValue<-- +get_property: -->anotherValue<-- +get_test_property: -->anotherValue<-- +get_property: -->anotherValue<--$ diff --git a/Tests/RunCMake/get_property/test_properties.cmake b/Tests/RunCMake/get_property/test_properties.cmake index 1d0295c..f1cbca4 100644 --- a/Tests/RunCMake/get_property/test_properties.cmake +++ b/Tests/RunCMake/get_property/test_properties.cmake @@ -1,7 +1,11 @@ -function (check_test_property test prop) - get_test_property("${test}" "${prop}" gtp_val) +function (check_test_property test prop dir) + set(dir_args) + if(dir) + set(dir_args DIRECTORY ${dir}) + endif() + get_test_property("${test}" "${prop}" ${dir_args} gtp_val) get_property(gp_val - TEST "${test}" + TEST "${test}" ${dir_args} PROPERTY "${prop}") message("get_test_property: -->${gtp_val}<--") @@ -11,7 +15,10 @@ endfunction () include(CTest) add_test(NAME test COMMAND "${CMAKE_COMMAND}" --help) set_tests_properties(test PROPERTIES empty "" custom value) +add_subdirectory(test_properties) -check_test_property(test empty) -check_test_property(test custom) -check_test_property(test noexist) +check_test_property(test empty "") +check_test_property(test custom "") +check_test_property(test noexist "") +check_test_property(test custom test_properties) +check_test_property(test custom ${CMAKE_BINARY_DIR}/test_properties) diff --git a/Tests/RunCMake/get_property/test_properties/CMakeLists.txt b/Tests/RunCMake/get_property/test_properties/CMakeLists.txt new file mode 100644 index 0000000..ee90344 --- /dev/null +++ b/Tests/RunCMake/get_property/test_properties/CMakeLists.txt @@ -0,0 +1,4 @@ +add_test(NAME test COMMAND "${CMAKE_COMMAND}" --help) +set_tests_properties(test PROPERTIES empty "" custom anotherValue) + +check_test_property(test custom ..) diff --git a/Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake b/Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake index d099469..97b9b5d 100644 --- a/Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake +++ b/Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake @@ -1,7 +1,7 @@ if(WIN32) set(_check_files [[lib3]] - [[lib3/(lib)?lib3\.(dll\.a|lib)]] + [[lib3/(lib)?lib3\.(dll\.a|lib|l)]] [[lib4]] [[lib4/(lib)?lib4\.dll]] [[mybin]] @@ -10,8 +10,8 @@ if(WIN32) [[myinclude]] [[myinclude/obj3\.h]] [[mylib]] - [[mylib/(lib)?lib1\.(dll\.a|lib)]] - [[mylib/(lib)?lib2\.(a|lib)]] + [[mylib/(lib)?lib1\.(dll\.a|lib|l)]] + [[mylib/(lib)?lib2\.(a|lib|l)]] ) elseif(MSYS) set(_check_files diff --git a/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake b/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake index 6e13b84..f357c1e 100644 --- a/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake +++ b/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake @@ -8,10 +8,10 @@ if(WIN32) [[include/obj2\.h]] [[include/obj3\.h]] [[lib]] - [[lib/(lib)?lib1\.(dll\.a|lib)]] - [[lib/(lib)?lib2\.(a|lib)]] + [[lib/(lib)?lib1\.(dll\.a|lib|l)]] + [[lib/(lib)?lib2\.(a|lib|l)]] [[lib3]] - [[lib3/(lib)?lib3\.(dll\.a|lib)]] + [[lib3/(lib)?lib3\.(dll\.a|lib|l)]] [[lib4]] [[lib4/(lib)?lib4\.dll]] ) diff --git a/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake index 91d5ef0..919ccf1 100644 --- a/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake +++ b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake @@ -1,7 +1,7 @@ if(WIN32) set(test123 [[bin/test1out\.exe;bin/test2deb\.exe;bin/test3exc\.exe]]) set(libtest45 [[bin/libtest4\.dll;bin/libtest4\.dll\.a;bin/libtest5ar\.a]]) - set(test45 [[bin/test4\.dll;bin/test4\.lib;bin/test5ar\.lib]]) + set(test45 [[bin/test4\.dll;bin/test4\.(lib|l);bin/test5ar\.(lib|l)]]) check_installed("^bin;(${libtest45};${test123})|(${test123};${test45})\$") elseif(MSYS) diff --git a/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake b/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake index 6245839..8137e92 100644 --- a/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake +++ b/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake @@ -1 +1 @@ -check_installed([[^include;include/obj1\.h;lib;lib/(mylib\.lib|(lib|cyg)mylib\.a)$]]) +check_installed([[^include;include/obj1\.h;lib;lib/(mylib\.(lib|l)|(lib|cyg)mylib\.a)$]]) diff --git a/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCIES-empty-all-check.cmake b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCIES-empty-all-check.cmake index dafc2a4..38635c3 100644 --- a/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCIES-empty-all-check.cmake +++ b/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCIES-empty-all-check.cmake @@ -1 +1 @@ -check_installed([[^static;static/(liblib\.a|lib\.lib)$]]) +check_installed([[^static;static/(liblib\.a|lib\.(lib|l))$]]) diff --git a/Tests/RunCMake/property_init/Always.cmake b/Tests/RunCMake/property_init/Always.cmake new file mode 100644 index 0000000..db23563 --- /dev/null +++ b/Tests/RunCMake/property_init/Always.cmake @@ -0,0 +1,15 @@ +set(properties + # property expected alias + # Test a property which should never be initialized. + "notset" "<UNSET>" "<SAME>" + + # Build graph properties + "VERIFY_INTERFACE_HEADER_SETS" "TRUE" "<SAME>" + + # Metadata + "FOLDER" "folder" "<SAME>" + ) + +prepare_target_types(always ${all_target_types}) + +run_property_tests(always properties) diff --git a/Tests/RunCMake/property_init/CMakeLists.txt b/Tests/RunCMake/property_init/CMakeLists.txt new file mode 100644 index 0000000..51883af --- /dev/null +++ b/Tests/RunCMake/property_init/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.12) +project(${RunCMake_TEST} C) + +set(main_sources main.c) +set(library_sources library.c) + +include(util.cmake) + +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/property_init/CompileSources.cmake b/Tests/RunCMake/property_init/CompileSources.cmake new file mode 100644 index 0000000..e8c5554 --- /dev/null +++ b/Tests/RunCMake/property_init/CompileSources.cmake @@ -0,0 +1,274 @@ +set(dir "${CMAKE_CURRENT_BINARY_DIR}") + +set(properties + # property expected alias + # Compilation properties + "COMPILE_WARNING_AS_ERROR" "ON" "<SAME>" + "INTERPROCEDURAL_OPTIMIZATION" "OFF" "<SAME>" + "NO_SYSTEM_FROM_IMPORTED" "ON" "<SAME>" + "VISIBILITY_INLINES_HIDDEN" "ON" "<SAME>" + ## Features + ### PCH + "DISABLE_PRECOMPILE_HEADERS" "ON" "<SAME>" + "PCH_WARN_INVALID" "OFF" "<SAME>" + "PCH_INSTANTIATE_TEMPLATES" "OFF" "<SAME>" + ## Platforms + ### Android + "ANDROID_API" "9" "<SAME>" + "ANDROID_API_MIN" "9" "<SAME>" + "ANDROID_ARCH" "arm64-v8a" "<SAME>" + "ANDROID_ASSETS_DIRECTORIES" "${dir}" "<SAME>" + "ANDROID_JAVA_SOURCE_DIR" "${dir}" "<SAME>" + "ANDROID_STL_TYPE" "system" "<SAME>" + ### macOS + "OSX_ARCHITECTURES" "arm64" "<SAME>" + ### Windows + "MSVC_DEBUG_INFORMATION_FORMAT" "Embedded" "<SAME>" + "MSVC_RUNTIME_LIBRARY" "MultiThreaded" "<SAME>" + "VS_JUST_MY_CODE_DEBUGGING" "ON" "<SAME>" + ### OpenWatcom + "WATCOM_RUNTIME_LIBRARY" "MultiThreaded" "<SAME>" + ## Language + ### CUDA + "CUDA_SEPARABLE_COMPILATION" "ON" "<SAME>" + "CUDA_ARCHITECTURES" "naive" "<SAME>" + ### Fortran + "Fortran_FORMAT" "FREE" "<SAME>" + "Fortran_MODULE_DIRECTORY" "${dir}" "<SAME>" + "Fortran_COMPILER_LAUNCHER" "ccache" "<SAME>" + "Fortran_PREPROCESS" "ON" "<SAME>" + "Fortran_VISIBILITY_PRESET" "hidden" "<SAME>" + ### HIP + "HIP_ARCHITECTURES" "gfx801" "<SAME>" + ### ISPC + "ISPC_COMPILER_LAUNCHER" "ccache" "<SAME>" + "ISPC_HEADER_DIRECTORY" "${dir}" "<SAME>" + "ISPC_HEADER_SUFFIX" "_i.h" "<SAME>" + "ISPC_INSTRUCTION_SETS" "avx2-i32x4" "<SAME>" + ### Swift + "Swift_LANGUAGE_VERSION" "2.3" "<SAME>" + "Swift_MODULE_DIRECTORY" "${dir}" "<SAME>" + ### moc + "AUTOMOC" "OFF" "<SAME>" + "AUTOMOC_COMPILER_PREDEFINES" "OFF" "<SAME>" + "AUTOMOC_MACRO_NAMES" "MOC_CLASS" "<SAME>" + "AUTOMOC_MOC_OPTIONS" "-v" "<SAME>" + "AUTOMOC_PATH_PREFIX" "moc_" "<SAME>" + "AUTOMOC_EXECUTABLE" "automoc" "<SAME>" + ### uic + "AUTOUIC" "OFF" "<SAME>" + "AUTOUIC_OPTIONS" "-v" "<SAME>" + "AUTOUIC_SEARCH_PATHS" "${dir}" "<SAME>" + "AUTOUIC_EXECUTABLE" "autouic" "<SAME>" + ### rcc + "AUTORCC" "OFF" "<SAME>" + "AUTORCC_OPTIONS" "-v" "<SAME>" + "AUTORCC_EXECUTABLE" "autorcc" "<SAME>" + + # Linking properties + "LINK_SEARCH_START_STATIC" "-Bstatic" "<SAME>" + "LINK_SEARCH_END_STATIC" "-Bdynamic" "<SAME>" + ## Dependent library lookup + "MACOSX_RPATH" "@loader_path/" "<SAME>" + ### Build + "BUILD_RPATH" "../lib" "<SAME>" + "BUILD_RPATH_USE_ORIGIN" "ON" "<SAME>" + "SKIP_BUILD_RPATH" "ON" "<SAME>" + "BUILD_WITH_INSTALL_RPATH" "ON" "<SAME>" + "BUILD_WITH_INSTALL_NAME_DIR" "@rpath/" "<SAME>" + ### Install + "INSTALL_NAME_DIR" "@rpath/" "<SAME>" + "INSTALL_REMOVE_ENVIRONMENT_RPATH" "ON" "<SAME>" + "INSTALL_RPATH" "@rpath/" "<SAME>" + "INSTALL_RPATH_USE_LINK_PATH" "ON" "<SAME>" + ## Platforms + ### Android + "ANDROID_JAR_DIRECTORIES" "${dir}" "<SAME>" + "ANDROID_JAR_DEPENDENCIES" "${dir}/foo.jar" "<SAME>" + "ANDROID_NATIVE_LIB_DIRECTORIES" "${dir}" "<SAME>" + "ANDROID_NATIVE_LIB_DEPENDENCIES" "${dir}/native.a" "<SAME>" + "ANDROID_PROGUARD" "ON" "<SAME>" + "ANDROID_PROGUARD_CONFIG_PATH" "proguard.props" "<SAME>" + "ANDROID_SECURE_PROPS_PATH" "secure.props" "<SAME>" + ### iOS + "IOS_INSTALL_COMBINED" "ON" "<SAME>" + ### Windows + "GNUtoMS" "ON" "<SAME>" + "WIN32_EXECUTABLE" "OFF" "<SAME>" + ## Languages + ### C + "C_LINKER_LAUNCHER" "ccache" "<SAME>" + ### C++ + "CXX_LINKER_LAUNCHER" "ccache" "<SAME>" + ### CUDA + "CUDA_RESOLVE_DEVICE_SYMBOLS" "ON" "<SAME>" + "CUDA_RUNTIME_LIBRARY" "Static" "<SAME>" + ### HIP + "HIP_RUNTIME_LIBRARY" "SHARED" "<SAME>" + ### Objective C + "OBJC_LINKER_LAUNCHER" "ccache" "<SAME>" + ### Objective C++ + "OBJCXX_LINKER_LAUNCHER" "ccache" "<SAME>" + + # Static analysis + ## C + "C_CLANG_TIDY" "clang-tidy" "<SAME>" + "C_CLANG_TIDY_EXPORT_FIXES_DIR" "${dir}" "<SAME>" + "C_CPPLINT" "cpplint" "<SAME>" + "C_CPPCHECK" "cppcheck" "<SAME>" + "C_INCLUDE_WHAT_YOU_USE" "iwyu" "<SAME>" + ## C++ + "CXX_CLANG_TIDY" "clang-tidy" "<SAME>" + "CXX_CLANG_TIDY_EXPORT_FIXES_DIR" "${dir}" "<SAME>" + "CXX_CPPLINT" "cpplint" "<SAME>" + "CXX_CPPCHECK" "cppcheck" "<SAME>" + "CXX_INCLUDE_WHAT_YOU_USE" "iwyu" "<SAME>" + ## Objective C + "OBJC_CLANG_TIDY" "clang-tidy" "<SAME>" + "OBJC_CLANG_TIDY_EXPORT_FIXES_DIR" "${dir}" "<SAME>" + ## Objective C++ + "OBJCXX_CLANG_TIDY" "clang-tidy" "<SAME>" + "OBJCXX_CLANG_TIDY_EXPORT_FIXES_DIR" "${dir}" "<SAME>" + ## Linking + "LINK_WHAT_YOU_USE" "lwyu" "<SAME>" + + # Build graph properties + "LINK_DEPENDS_NO_SHARED" "OFF" "<SAME>" + "UNITY_BUILD" "OFF" "<SAME>" + "UNITY_BUILD_UNIQUE_ID" "unity" "<SAME>" + "UNITY_BUILD_BATCH_SIZE" "10" "<SAME>" + "UNITY_BUILD_MODE" "GROUP" "<SAME>" + "OPTIMIZE_DEPENDENCIES" "ON" "<SAME>" + ## Android + "ANDROID_ANT_ADDITIONAL_OPTIONS" "-v" "<SAME>" + "ANDROID_PROCESS_MAX" "2" "<SAME>" + "ANDROID_SKIP_ANT_STEP" "ON" "<SAME>" + ## Autogen + "AUTOGEN_ORIGIN_DEPENDS" "OFF" "<SAME>" + "AUTOGEN_PARALLEL" "ON" "<SAME>" + "AUTOGEN_USE_SYSTEM_INCLUDE" "ON" "<SAME>" + ## moc + "AUTOMOC_DEPEND_FILTERS" "FIRST<SEMI>SECOND" "<SAME>" + ## C++ + "CXX_SCAN_FOR_MODULES" "ON" "<SAME>" + ## Ninja + "JOB_POOL_COMPILE" "compile_pool" "<SAME>" + "JOB_POOL_LINK" "link_pool" "<SAME>" + "JOB_POOL_PRECOMPILE_HEADER" "pch_pool" "<SAME>" + ## Visual Studio + "VS_NO_COMPILE_BATCHING" "ON" "<SAME>" + "VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION" "10.0.10240.0" "<SAME>" + + # Output location properties + "ARCHIVE_OUTPUT_DIRECTORY" "${dir}" "<SAME>" + "COMPILE_PDB_OUTPUT_DIRECTORY" "${dir}" "<SAME>" + "LIBRARY_OUTPUT_DIRECTORY" "${dir}" "<SAME>" + "PDB_OUTPUT_DIRECTORY" "${dir}" "<SAME>" + "RUNTIME_OUTPUT_DIRECTORY" "${dir}" "<SAME>" + + # macOS bundle properties + "FRAMEWORK" "OFF" "<SAME>" + "FRAMEWORK_MULTI_CONFIG_POSTFIX" ".mcpostfix" "<SAME>" + "MACOSX_BUNDLE" "OFF" "<SAME>" + + # Usage requirement properties + "LINK_INTERFACE_LIBRARIES" "c" "<SAME>" + + # Metadata + "EXPORT_COMPILE_COMMANDS" "OFF" "<SAME>" + ) + +if (CMAKE_HOST_APPLE) # compile-guarded in CMake + if (CMAKE_GENERATOR STREQUAL "Xcode") + list(APPEND properties + # property expected alias + # Xcode properties + "XCODE_SCHEME_ADDRESS_SANITIZER" "ON" "<SAME>" + "XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN" "ON" "<SAME>" + "XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING" "ON" "<SAME>" + "XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE" "ON" "<SAME>" + "XCODE_SCHEME_THREAD_SANITIZER" "ON" "<SAME>" + "XCODE_SCHEME_THREAD_SANITIZER_STOP" "ON" "<SAME>" + "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER" "ON" "<SAME>" + "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP" "ON" "<SAME>" + "XCODE_SCHEME_LAUNCH_CONFIGURATION" "ON" "<SAME>" + "XCODE_SCHEME_ENABLE_GPU_API_VALIDATION" "ON" "<SAME>" + "XCODE_SCHEME_ENABLE_GPU_SHADER_VALIDATION" "ON" "<SAME>" + "XCODE_SCHEME_WORKING_DIRECTORY" "ON" "<SAME>" + "XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER" "ON" "<SAME>" + "XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP" "ON" "<SAME>" + "XCODE_SCHEME_MALLOC_SCRIBBLE" "ON" "<SAME>" + "XCODE_SCHEME_MALLOC_GUARD_EDGES" "ON" "<SAME>" + "XCODE_SCHEME_GUARD_MALLOC" "ON" "<SAME>" + "XCODE_SCHEME_LAUNCH_MODE" "ON" "<SAME>" + "XCODE_SCHEME_ZOMBIE_OBJECTS" "ON" "<SAME>" + "XCODE_SCHEME_MALLOC_STACK" "ON" "<SAME>" + "XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE" "ON" "<SAME>" + "XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS" "ON" "<SAME>" + "XCODE_SCHEME_ENVIRONMENT" "ON" "<SAME>" + "XCODE_LINK_BUILD_PHASE_MODE" "BUILT_ONLY" "<SAME>" + ) + endif () +endif () + +macro (add_language_properties lang std) + list(APPEND properties + # property expected alias + "${lang}_COMPILER_LAUNCHER" "ccache" "<SAME>" + "${lang}_STANDARD" "${std}" "<SAME>" + "${lang}_STANDARD_REQUIRED" "TRUE" "<SAME>" + "${lang}_EXTENSIONS" "FALSE" "<SAME>" + "${lang}_VISIBILITY_PRESET" "hidden" "<SAME>" + ) +endmacro () + +# Mock up knowing the standard flag. This doesn't actually build, so nothing +# should care at this point. +set(CMAKE_Cc_std_11_STANDARD_COMPILE_OPTION "-std=c11") + +add_language_properties(C c_std_11) +add_language_properties(CXX cxx_std_11) +add_language_properties(CUDA cuda_std_11) +add_language_properties(HIP hip_std_11) +add_language_properties(OBJC c_std_99) +add_language_properties(OBJCXX cxx_std_11) + +# Set up pools for properties set above. +if (CMAKE_GENERATOR MATCHES "Ninja") + set_property(GLOBAL APPEND + PROPERTY + JOB_POOLS + compile_pool=1 + link_pool=1 + pch_pool=1) +endif () + +prepare_target_types(can_compile_sources + EXECUTABLE SHARED STATIC MODULE OBJECT) + +run_property_tests(can_compile_sources properties) + +set(properties_with_defaults + # property expected alias + "PCH_WARN_INVALID" "ON" "<SAME>" + "PCH_INSTANTIATE_TEMPLATES" "ON" "<SAME>" + "ISPC_HEADER_SUFFIX" "_ispc.h" "<SAME>" + "SKIP_BUILD_RPATH" "OFF" "<SAME>" + "BUILD_WITH_INSTALL_RPATH" "OFF" "<SAME>" + "INSTALL_RPATH" "" "<SAME>" + "INSTALL_RPATH_USE_LINK_PATH" "OFF" "<SAME>" + "UNITY_BUILD_BATCH_SIZE" "8" "<SAME>" + "UNITY_BUILD_MODE" "BATCH" "<SAME>" + ) + +if (CMAKE_HOST_APPLE) + if (CMAKE_GENERATOR STREQUAL "Xcode") + list(APPEND properties_with_defaults + # property expected alias + "XCODE_LINK_BUILD_PHASE_MODE" "NONE" "<SAME>" + ) + endif () +endif () + +set(with_defaults 1) +run_property_tests(can_compile_sources properties_with_defaults) diff --git a/Tests/RunCMake/property_init/Executable.cmake b/Tests/RunCMake/property_init/Executable.cmake new file mode 100644 index 0000000..ede0e4b --- /dev/null +++ b/Tests/RunCMake/property_init/Executable.cmake @@ -0,0 +1,25 @@ +set(dir "${CMAKE_CURRENT_BINARY_DIR}") + +set(properties + # property expected alias + # Compilation properties + ## Platforms + ### Windows + "VS_DEBUGGER_COMMAND" "vsdbg" "<SAME>" + "VS_DEBUGGER_COMMAND_ARGUMENTS" "/?" "<SAME>" + "VS_DEBUGGER_ENVIRONMENT" "env=val" "<SAME>" + "VS_DEBUGGER_WORKING_DIRECTORY" "${dir}" "<SAME>" + + # Linking properties + ## Platforms + ### Android + "ANDROID_GUI" "OFF" "<SAME>" + + # Metadata + "CROSSCOMPILING_EMULATOR" "emu" "<SAME>" + ) + +prepare_target_types(executable + EXECUTABLE + IMPORTED_EXECUTABLE) +run_property_tests(executable properties) diff --git a/Tests/RunCMake/property_init/ImportedTargets.cmake b/Tests/RunCMake/property_init/ImportedTargets.cmake new file mode 100644 index 0000000..0b51998 --- /dev/null +++ b/Tests/RunCMake/property_init/ImportedTargets.cmake @@ -0,0 +1,9 @@ +set(properties + # property expected alias + "SYSTEM" "ON" "<SAME>" + ) + +prepare_target_types(imported + IMPORTED_EXECUTABLE IMPORTED_INTERFACE IMPORTED_MODULE IMPORTED_OBJECT IMPORTED_SHARED IMPORTED_STATIC) +set(with_defaults 1) +run_property_tests(imported properties) diff --git a/Tests/RunCMake/property_init/LibraryArtifact.cmake b/Tests/RunCMake/property_init/LibraryArtifact.cmake new file mode 100644 index 0000000..942b433 --- /dev/null +++ b/Tests/RunCMake/property_init/LibraryArtifact.cmake @@ -0,0 +1,10 @@ +per_config(properties + # property expected alias + # Linking properties + "_POSTFIX" "test" "<UNSET>" + ) + +prepare_target_types(library_with_artifact + MODULE SHARED STATIC + IMPORTED_MODULE IMPORTED_SHARED IMPORTED_STATIC) +run_property_tests(library_with_artifact properties) diff --git a/Tests/RunCMake/property_init/Linkable.cmake b/Tests/RunCMake/property_init/Linkable.cmake new file mode 100644 index 0000000..e5d75d1 --- /dev/null +++ b/Tests/RunCMake/property_init/Linkable.cmake @@ -0,0 +1,12 @@ +per_config(properties + # property expected alias + # Linking properties + ## Platforms + ### macOS + "FRAMEWORK_MULTI_CONFIG_POSTFIX_" ".fw" "<UNSET>" + ) + +prepare_target_types(linkable + EXECUTABLE SHARED STATIC + IMPORTED_EXECUTABLE IMPORTED_SHARED IMPORTED_STATIC) +run_property_tests(linkable properties) diff --git a/Tests/RunCMake/property_init/NonImportedNormalTarget.cmake b/Tests/RunCMake/property_init/NonImportedNormalTarget.cmake new file mode 100644 index 0000000..cf3b726 --- /dev/null +++ b/Tests/RunCMake/property_init/NonImportedNormalTarget.cmake @@ -0,0 +1,9 @@ +set(properties + # property expected alias + # Linking properties + "LINK_LIBRARIES_ONLY_TARGETS" "OFF" "<SAME>" + ) + +prepare_target_types(normal_non_imported + EXECUTABLE SHARED STATIC MODULE OBJECT INTERFACE) +run_property_tests(normal_non_imported properties) diff --git a/Tests/RunCMake/property_init/NonImportedTarget.cmake b/Tests/RunCMake/property_init/NonImportedTarget.cmake new file mode 100644 index 0000000..7e2e22c --- /dev/null +++ b/Tests/RunCMake/property_init/NonImportedTarget.cmake @@ -0,0 +1,11 @@ +set(properties + # property expected alias + # Compilation properties + ## Language + ### CSharp + "DOTNET_SDK" "Microsoft.NET.Sdk" "<SAME>" + ) + +prepare_target_types(non_imported + EXECUTABLE SHARED STATIC MODULE OBJECT INTERFACE CUSTOM) +run_property_tests(non_imported properties) diff --git a/Tests/RunCMake/property_init/NormalTarget.cmake b/Tests/RunCMake/property_init/NormalTarget.cmake new file mode 100644 index 0000000..99507cf --- /dev/null +++ b/Tests/RunCMake/property_init/NormalTarget.cmake @@ -0,0 +1,10 @@ +per_config(properties + # property expected alias + # Usage requirement properties + "MAP_IMPORTED_CONFIG_" "Release" "<UNSET>" + ) + +prepare_target_types(normal + EXECUTABLE INTERFACE MODULE OBJECT SHARED STATIC + IMPORTED_EXECUTABLE IMPORTED_INTERFACE IMPORTED_MODULE IMPORTED_OBJECT IMPORTED_SHARED IMPORTED_STATIC) +run_property_tests(normal properties) diff --git a/Tests/RunCMake/property_init/PICTargets.cmake b/Tests/RunCMake/property_init/PICTargets.cmake new file mode 100644 index 0000000..6c99505 --- /dev/null +++ b/Tests/RunCMake/property_init/PICTargets.cmake @@ -0,0 +1,21 @@ +set(properties + # property expected alias + # Compilation properties + "POSITION_INDEPENDENT_CODE" "True" "<SAME>" + ) + +prepare_target_types(pic_targets + EXECUTABLE MODULE OBJECT SHARED STATIC + IMPORTED_MODULE IMPORTED_SHARED) +run_property_tests(pic_targets properties) + +set(APPEND properties_with_defaults + # property expected alias + "POSITION_INDEPENDENT_CODE" "True" "<SAME>" + ) + +prepare_target_types(pic_default_targets + MODULE SHARED + IMPORTED_MODULE IMPORTED_SHARED) +set(with_defaults 1) +run_property_tests(pic_default_targets properties_with_defaults) diff --git a/Tests/RunCMake/property_init/RunCMakeTest.cmake b/Tests/RunCMake/property_init/RunCMakeTest.cmake new file mode 100644 index 0000000..310da72 --- /dev/null +++ b/Tests/RunCMake/property_init/RunCMakeTest.cmake @@ -0,0 +1,16 @@ +include(RunCMake) + +run_cmake(Always) +run_cmake(CompileSources) +run_cmake(Executable) +run_cmake(ImportedTargets) +run_cmake(LibraryArtifact) +run_cmake(Linkable) +run_cmake(NonImportedNormalTarget) +run_cmake(NonImportedTarget) +run_cmake(NormalTarget) +run_cmake(PICTargets) +run_cmake(SharedLibrary) +run_cmake(TargetsWithArtifact) +run_cmake(TargetsWithCommands) +run_cmake(TargetsWithExports) diff --git a/Tests/RunCMake/property_init/SharedLibrary.cmake b/Tests/RunCMake/property_init/SharedLibrary.cmake new file mode 100644 index 0000000..49715a4 --- /dev/null +++ b/Tests/RunCMake/property_init/SharedLibrary.cmake @@ -0,0 +1,12 @@ +set(dir "${CMAKE_CURRENT_BINARY_DIR}") + +set(properties + # property expected alias + # Linking properties + "DLL_NAME_WITH_SOVERSION" "OFF" "<SAME>" + ) + +prepare_target_types(shared_library + SHARED + IMPORTED_SHARED) +run_property_tests(shared_library properties) diff --git a/Tests/RunCMake/property_init/TargetsWithArtifact.cmake b/Tests/RunCMake/property_init/TargetsWithArtifact.cmake new file mode 100644 index 0000000..0c19ea3 --- /dev/null +++ b/Tests/RunCMake/property_init/TargetsWithArtifact.cmake @@ -0,0 +1,19 @@ +set(dir "${CMAKE_CURRENT_BINARY_DIR}") + +per_config(properties + # property expected alias + # Compilation properties + "INTERPROCEDURAL_OPTIMIZATION_" "OFF" "<UNSET>" + + # Output location properties + "ARCHIVE_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>" + "COMPILE_PDB_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>" + "LIBRARY_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>" + "PDB_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>" + "RUNTIME_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>" + ) + +prepare_target_types(with_artifact + EXECUTABLE MODULE SHARED STATIC + IMPORTED_EXECUTABLE IMPORTED_MODULE IMPORTED_SHARED IMPORTED_STATIC) +run_property_tests(with_artifact properties) diff --git a/Tests/RunCMake/property_init/TargetsWithCommands.cmake b/Tests/RunCMake/property_init/TargetsWithCommands.cmake new file mode 100644 index 0000000..4db0ca3 --- /dev/null +++ b/Tests/RunCMake/property_init/TargetsWithCommands.cmake @@ -0,0 +1,13 @@ +set(properties + # property expected alias + # Compilation properties + ## Language + ### CSharp + "DOTNET_TARGET_FRAMEWORK" "netcoreapp2.1" "<SAME>" + "DOTNET_TARGET_FRAMEWORK_VERSION" "v4.5" "<SAME>" + ) + +prepare_target_types(with_commands + EXECUTABLE MODULE OBJECT SHARED STATIC CUSTOM + IMPORTED_EXECUTABLE IMPORTED_MODULE IMPORTED_OBJECT IMPORTED_SHARED IMPORTED_STATIC) +run_property_tests(with_commands properties) diff --git a/Tests/RunCMake/property_init/TargetsWithExports.cmake b/Tests/RunCMake/property_init/TargetsWithExports.cmake new file mode 100644 index 0000000..9b2e213 --- /dev/null +++ b/Tests/RunCMake/property_init/TargetsWithExports.cmake @@ -0,0 +1,51 @@ +set(properties + # property expected alias + # Linking properties + ## Platforms + ### AIX + "AIX_EXPORT_ALL_SYMBOLS" "OFF" "<SAME>" + ### Windows + "WINDOWS_EXPORT_ALL_SYMBOLS" "OFF" "<SAME>" + ) + +prepare_target_types(symbol_export_target + EXECUTABLE SHARED + IMPORTED_EXECUTABLE IMPORTED_SHARED) +run_property_tests(symbol_export_target properties) + +# `ENABLE_EXPORTS` has a more complicated initialization. +set(properties + # property expected alias + # Linking properties + "ENABLE_EXPORTS" "OFF" "<SAME>" + ) + +prepare_target_types(executable + EXECUTABLE + IMPORTED_EXECUTABLE) +set(iteration "-ENABLE_EXPORTS") +run_property_tests(executable_target properties) + +set(with_defaults 1) + +set(CMAKE_SHARED_LIBRARY_ENABLE_EXPORTS OFF) +set(properties + # property expected alias + # Linking properties + "ENABLE_EXPORTS" "OFF" "<SAME>" + ) + +set(iteration "-SHARED_LIBRARY_ENABLE_EXPORTS") +run_property_tests(shared_library_target properties) +unset(CMAKE_SHARED_LIBRARY_ENABLE_EXPORTS) + +set(CMAKE_EXECUTABLE_ENABLE_EXPORTS OFF) +set(properties + # property expected alias + # Linking properties + "ENABLE_EXPORTS" "OFF" "<SAME>" + ) + +set(iteration "-EXECUTABLE_ENABLE_EXPORTS") +run_property_tests(executable_target properties) +unset(CMAKE_EXECUTABLE_ENABLE_EXPORTS) diff --git a/Tests/RunCMake/property_init/library.c b/Tests/RunCMake/property_init/library.c new file mode 100644 index 0000000..ad6a649 --- /dev/null +++ b/Tests/RunCMake/property_init/library.c @@ -0,0 +1,4 @@ +int foo(int arg) +{ + return arg; +} diff --git a/Tests/RunCMake/property_init/main.c b/Tests/RunCMake/property_init/main.c new file mode 100644 index 0000000..14917b7 --- /dev/null +++ b/Tests/RunCMake/property_init/main.c @@ -0,0 +1,4 @@ +int main(int argc, char* argv[]) +{ + return argc - 1; +} diff --git a/Tests/RunCMake/property_init/util.cmake b/Tests/RunCMake/property_init/util.cmake new file mode 100644 index 0000000..7edc6f9 --- /dev/null +++ b/Tests/RunCMake/property_init/util.cmake @@ -0,0 +1,191 @@ +set(all_target_types + "EXECUTABLE" + + "IMPORTED_EXECUTABLE" + + "INTERFACE" + "MODULE" + "OBJECT" + "SHARED" + "STATIC" + + "IMPORTED_INTERFACE" + "IMPORTED_MODULE" + "IMPORTED_OBJECT" + "IMPORTED_SHARED" + "IMPORTED_STATIC" + + "CUSTOM") + +function (prepare_target_types name) + set("${name}" "${ARGN}" PARENT_SCOPE) + list(REMOVE_ITEM all_target_types ${ARGN}) + set("not_${name}" "${all_target_types}" PARENT_SCOPE) +endfunction () + +function (per_config variable) + prepare_properties("${property_table}" properties expected_values expected_alias) + + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if (is_multi_config) + set(configs "${CMAKE_CONFIGURATION_TYPES}") + else () + if (NOT CMAKE_BUILD_TYPE STREQUAL "") + set(configs "${CMAKE_BUILD_TYPE}") + endif () + endif () + + foreach (property expected alias IN ZIP_LISTS expected_properties expected_values expected_alias) + if (property MATCHES "^_") + set(prepend 1) + elseif (property MATCHES "_$") + set(prepend 0) + else () + message(SEND_ERROR + "Per-config properties must have a `_` at one end of their name: '${property}'") + endif () + foreach (config IN LISTS configs) + if (prepend) + list(APPEND "${variable}" + "${config}_${property}" "${value}/${config}" "${alias}") + else () + list(APPEND "${variable}" + "${property}_${config}" "${value}/${config}" "${alias}") + endif () + endforeach () + endforeach () + + set("${variable}" "${${variable}}" PARENT_SCOPE) +endfunction () + +function (make_target name type) + if (type STREQUAL "EXECUTABLE") + add_executable("${name}") + target_sources("${name}" PRIVATE ${main_sources}) + elseif (type STREQUAL "IMPORTED_EXECUTABLE") + add_executable("${name}" IMPORTED) + set_property(TARGET "${name}" PROPERTY IMPORTED_LOCATION "${CMAKE_COMMAND}") + elseif (type STREQUAL "CUSTOM") + add_custom_target("${name}" COMMAND "${CMAKE_EXECUTABLE}" -E echo "${name}") + elseif (type MATCHES "IMPORTED_") + string(REPLACE "IMPORTED_" "" type "${type}") + add_library("${name}" IMPORTED ${type}) + if (NOT type STREQUAL "INTERFACE") + set_property(TARGET "${name}" PROPERTY IMPORTED_LOCATION "${default_library_location}") + endif () + else () + add_library("${name}" ${type}) + target_sources("${name}" PRIVATE ${library_sources}) + endif () + + if (type MATCHES "EXECUTABLE") + add_executable("alias::${name}" ALIAS "${name}") + elseif (NOT type STREQUAL "CUSTOM") + add_library("alias::${name}" ALIAS "${name}") + endif () +endfunction () + +function (check_property target property expected) + if (NOT TARGET "${target}") + message(SEND_ERROR + "No such target '${target}'") + return () + endif () + + get_property(is_set TARGET "${target}" PROPERTY "${property}" SET) + if (is_set) + get_property(actual TARGET "${target}" PROPERTY "${property}") + endif () + if (expected STREQUAL "<UNSET>") + if (is_set) + message(SEND_ERROR + "Target '${target}' should not have '${property}' set at all, but is '${actual}'") + endif () + elseif (is_set AND NOT expected STREQUAL actual) + message(SEND_ERROR + "Target '${target}' should have '${property}' set to '${expected}', but is '${actual}'") + elseif (NOT is_set) + message(SEND_ERROR + "Target '${target}' should have '${property}' set to '${expected}', but is not set at all") + endif () +endfunction () + +function (prepare_properties table output_properties output_expected output_alias) + set(_properties) + set(_expected) + set(_alias) + + set(variable "_properties") + foreach (item IN LISTS "${table}") + list(APPEND "${variable}" "${item}") + if (variable STREQUAL "_properties") + set(variable "_expected") + elseif (variable STREQUAL "_expected") + set(variable "_alias") + elseif (variable STREQUAL "_alias") + set(variable "_properties") + else () + message(FATAL_ERROR + "Failed to track property table parsing") + endif () + endforeach () + if (NOT variable STREQUAL "_properties") + message(FATAL_ERROR + "Table does not have a multiple of 3 items") + endif () + + set("${output_properties}" "${_properties}" PARENT_SCOPE) + set("${output_expected}" "${_expected}" PARENT_SCOPE) + set("${output_alias}" "${_alias}" PARENT_SCOPE) +endfunction () + +# Contextual variables: +# iteration: make unique target names +# with_defaults: if set, do not set variables, but instead test internal +# default calculations +function (run_property_tests applied_types property_table) + prepare_properties("${property_table}" expected_properties expected_values expected_alias) + + if (NOT with_defaults) + foreach (property expected IN ZIP_LISTS expected_properties expected_values) + string(REPLACE "<SEMI>" ";" expected "${expected}") + set("CMAKE_${property}" "${expected}") + endforeach () + endif () + + foreach (target_type IN LISTS "${applied_types}") + set(target_name "${RunCMake_TEST}${iteration}-${target_type}") + if (with_defaults) + string(APPEND target_name "-defaults") + endif () + make_target("${target_name}" "${target_type}") + foreach (property expected alias IN ZIP_LISTS expected_properties expected_values expected_alias) + string(REPLACE "<SEMI>" ";" expected "${expected}") + check_property("${target_name}" "${property}" "${expected}") + if (NOT target_type STREQUAL "CUSTOM") + if (alias STREQUAL "<SAME>") + check_property("alias::${target_name}" "${property}" "${expected}") + elseif (alias STREQUAL "<UNSET>") + check_property("alias::${target_name}" "${property}" "<UNSET>") + else () + message(FATAL_ERROR + "Invalid `alias` entry for property '${property}': '${alias}'") + endif () + endif () + endforeach () + endforeach () + + foreach (target_type IN LISTS "not_${applied_types}") + set(target_name "${RunCMake_TEST}${iteration}-${target_type}-unset") + if (with_defaults) + string(APPEND target_name "-defaults") + endif () + make_target("${target_name}" "${target_type}") + foreach (property IN LISTS expected_properties) + check_property("${target_name}" "${property}" "<UNSET>") + if (NOT target_type STREQUAL "CUSTOM") + check_property("alias::${target_name}" "${property}" "<UNSET>") + endif () + endforeach () + endforeach () +endfunction () diff --git a/Tests/RunCMake/set/CacheErrors-result.txt b/Tests/RunCMake/set/CacheErrors-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/set/CacheErrors-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/set/CacheErrors-stderr.txt b/Tests/RunCMake/set/CacheErrors-stderr.txt new file mode 100644 index 0000000..9983160 --- /dev/null +++ b/Tests/RunCMake/set/CacheErrors-stderr.txt @@ -0,0 +1,19 @@ +^CMake Error at CacheErrors\.cmake:1 \(set\): + set given invalid arguments for CACHE mode: missing type and docstring +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at CacheErrors\.cmake:2 \(set\): + set given invalid arguments for CACHE mode: missing type or docstring +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at CacheErrors\.cmake:3 \(set\): + set given invalid arguments for CACHE mode: missing type or docstring +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at CacheErrors\.cmake:4 \(set\): + set given invalid arguments: FORCE specified without CACHE +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/set/CacheErrors.cmake b/Tests/RunCMake/set/CacheErrors.cmake new file mode 100644 index 0000000..d177474 --- /dev/null +++ b/Tests/RunCMake/set/CacheErrors.cmake @@ -0,0 +1,4 @@ +set (var val CACHE) +set (var val CACHE STRING) +set (var val CACHE "") +set (var val CACH3 STRING "" FORCE) diff --git a/Tests/RunCMake/set/RunCMakeTest.cmake b/Tests/RunCMake/set/RunCMakeTest.cmake index b3bd0a4..c785450 100644 --- a/Tests/RunCMake/set/RunCMakeTest.cmake +++ b/Tests/RunCMake/set/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) +run_cmake(CacheErrors) run_cmake(ParentScope) run_cmake(ParentPulling) run_cmake(ParentPullingRecursive) diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake index 692c6b9..1a5498d 100644 --- a/Tests/RunCMake/set_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake @@ -10,6 +10,12 @@ run_cmake(LINK_DIRECTORIES) run_cmake(LINK_LIBRARIES) run_cmake(SOURCES) run_cmake(SOURCE_FILE) +run_cmake(TEST-invalid) run_cmake(TYPE) run_cmake(USER_PROP) run_cmake(USER_PROP_INHERITED) + +set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/TEST-build") +run_cmake(TEST) +set(RunCMake_TEST_NO_CLEAN 1) +run_cmake_command(TEST-test ${CMAKE_CTEST_COMMAND} -C Debug) diff --git a/Tests/RunCMake/set_property/TEST-invalid-result.txt b/Tests/RunCMake/set_property/TEST-invalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/set_property/TEST-invalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/set_property/TEST-invalid-stderr.txt b/Tests/RunCMake/set_property/TEST-invalid-stderr.txt new file mode 100644 index 0000000..c0a40d6 --- /dev/null +++ b/Tests/RunCMake/set_property/TEST-invalid-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at TEST-invalid\.cmake:[0-9]+ \(set_property\): + set_property called with incorrect number of arguments no value provided to + the DIRECTORY option +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) + + +CMake Error at TEST-invalid\.cmake:[0-9]+ \(set_property\): + set_property given non-existent DIRECTORY nonexistent +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/set_property/TEST-invalid.cmake b/Tests/RunCMake/set_property/TEST-invalid.cmake new file mode 100644 index 0000000..6828c96 --- /dev/null +++ b/Tests/RunCMake/set_property/TEST-invalid.cmake @@ -0,0 +1,4 @@ +enable_testing() + +set_property(TEST t DIRECTORY PROPERTY PASS_REGULAR_EXPRESSION "Invalid") +set_property(TEST t DIRECTORY nonexistent PROPERTY PASS_REGULAR_EXPRESSION "Invalid") diff --git a/Tests/RunCMake/set_property/TEST-subdir1/CMakeLists.txt b/Tests/RunCMake/set_property/TEST-subdir1/CMakeLists.txt new file mode 100644 index 0000000..b1fad66 --- /dev/null +++ b/Tests/RunCMake/set_property/TEST-subdir1/CMakeLists.txt @@ -0,0 +1,3 @@ +add_test(NAME t COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory") +add_test(NAME t2 COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory") +add_test(NAME t3 COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory") diff --git a/Tests/RunCMake/set_property/TEST-subdir2/CMakeLists.txt b/Tests/RunCMake/set_property/TEST-subdir2/CMakeLists.txt new file mode 100644 index 0000000..8621b00 --- /dev/null +++ b/Tests/RunCMake/set_property/TEST-subdir2/CMakeLists.txt @@ -0,0 +1 @@ +set_property(TEST t3 DIRECTORY ../TEST-subdir1 PROPERTY PASS_REGULAR_EXPRESSION "Subdirectory") diff --git a/Tests/RunCMake/set_property/TEST.cmake b/Tests/RunCMake/set_property/TEST.cmake new file mode 100644 index 0000000..7ef5aa3 --- /dev/null +++ b/Tests/RunCMake/set_property/TEST.cmake @@ -0,0 +1,9 @@ +enable_testing() + +add_test(NAME t COMMAND ${CMAKE_COMMAND} -E echo "Top directory") +add_subdirectory(TEST-subdir1) +add_subdirectory(TEST-subdir2) + +set_property(TEST t PROPERTY PASS_REGULAR_EXPRESSION "Top directory") +set_property(TEST t DIRECTORY TEST-subdir1 PROPERTY PASS_REGULAR_EXPRESSION "Subdirectory") +set_property(TEST t2 DIRECTORY "${CMAKE_BINARY_DIR}/TEST-subdir1" PROPERTY PASS_REGULAR_EXPRESSION "Subdirectory") diff --git a/Tests/RunCMake/set_tests_properties/CMakeLists.txt b/Tests/RunCMake/set_tests_properties/CMakeLists.txt new file mode 100644 index 0000000..922aad6 --- /dev/null +++ b/Tests/RunCMake/set_tests_properties/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.27) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-result.txt b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-stderr.txt b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-stderr.txt new file mode 100644 index 0000000..e219399 --- /dev/null +++ b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid-stderr.txt @@ -0,0 +1,13 @@ +^CMake Error at DIRECTORY-invalid\.cmake:[0-9]+ \(set_tests_properties\): + Error after keyword "DIRECTORY": + + missing required value + +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) + + +CMake Error at DIRECTORY-invalid\.cmake:[0-9]+ \(set_tests_properties\): + set_tests_properties given non-existent DIRECTORY nonexistent +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid.cmake b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid.cmake new file mode 100644 index 0000000..4d87df1 --- /dev/null +++ b/Tests/RunCMake/set_tests_properties/DIRECTORY-invalid.cmake @@ -0,0 +1,4 @@ +enable_testing() + +set_tests_properties(t DIRECTORY PROPERTIES PASS_REGULAR_EXPRESSION "Top directory") +set_tests_properties(t DIRECTORY nonexistent PROPERTIES PASS_REGULAR_EXPRESSION "Top directory") diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir1/CMakeLists.txt b/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir1/CMakeLists.txt new file mode 100644 index 0000000..b1fad66 --- /dev/null +++ b/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir1/CMakeLists.txt @@ -0,0 +1,3 @@ +add_test(NAME t COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory") +add_test(NAME t2 COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory") +add_test(NAME t3 COMMAND ${CMAKE_COMMAND} -E echo "Subdirectory") diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir2/CMakeLists.txt b/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir2/CMakeLists.txt new file mode 100644 index 0000000..8859597 --- /dev/null +++ b/Tests/RunCMake/set_tests_properties/DIRECTORY-subdir2/CMakeLists.txt @@ -0,0 +1 @@ +set_tests_properties(t3 DIRECTORY ../DIRECTORY-subdir1 PROPERTIES PASS_REGULAR_EXPRESSION "Subdirectory") diff --git a/Tests/RunCMake/set_tests_properties/DIRECTORY.cmake b/Tests/RunCMake/set_tests_properties/DIRECTORY.cmake new file mode 100644 index 0000000..87d13e3 --- /dev/null +++ b/Tests/RunCMake/set_tests_properties/DIRECTORY.cmake @@ -0,0 +1,9 @@ +enable_testing() + +add_test(NAME t COMMAND ${CMAKE_COMMAND} -E echo "Top directory") +add_subdirectory(DIRECTORY-subdir1) +add_subdirectory(DIRECTORY-subdir2) + +set_tests_properties(t PROPERTIES PASS_REGULAR_EXPRESSION "Top directory") +set_tests_properties(t DIRECTORY DIRECTORY-subdir1 PROPERTIES PASS_REGULAR_EXPRESSION "Subdirectory") +set_tests_properties(t2 DIRECTORY "${CMAKE_BINARY_DIR}/DIRECTORY-subdir1" PROPERTIES PASS_REGULAR_EXPRESSION "Subdirectory") diff --git a/Tests/RunCMake/set_tests_properties/RunCMakeTest.cmake b/Tests/RunCMake/set_tests_properties/RunCMakeTest.cmake new file mode 100644 index 0000000..b49158f --- /dev/null +++ b/Tests/RunCMake/set_tests_properties/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +run_cmake(DIRECTORY-invalid) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DIRECTORY-build) +run_cmake(DIRECTORY) +set(RunCMake_TEST_NO_CLEAN 1) +run_cmake_command(DIRECTORY-test ${CMAKE_CTEST_COMMAND} -C Debug) diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake b/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake index 4a0f068..65c708c 100644 --- a/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake +++ b/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake @@ -14,8 +14,14 @@ set_property(TARGET import-local PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMA set_property(TARGET import-local PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_IMPORT_LIBRARY_SUFFIX}") add_library(alias::local ALIAS import-local) +if(NOT DEFINED CMAKE_IMPORT_LIBRARY_SUFFIX) + add_library(import-local-stub SHARED IMPORTED) + set_property(TARGET import-local-stub PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_SHARED_LIBRARY_SUFFIX}") + add_library(alias::local-stub ALIAS import-local-stub) +endif() + add_library (lib-local SHARED lib.c) -target_link_libraries (lib-local PRIVATE alias::local) +target_link_libraries (lib-local PRIVATE alias::local $<TARGET_NAME_IF_EXISTS:alias::local-stub>) add_executable (main-local main.c) target_link_libraries (main-local PRIVATE alias::local) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake index 9b6581c..0f3a6b7 100644 --- a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake @@ -31,7 +31,7 @@ if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode" set(LINK_SHARED_LIBRARY_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) set(LINK_SHARED_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() - if (MINGW OR MSYS OR CYGWIN) + if (MINGW OR MSYS OR CYGWIN OR CMAKE_C_COMPILER_ID STREQUAL "OrangeC") set(LINK_EXTERN_LIBRARY_SUFFIX "") else() set(LINK_EXTERN_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}") @@ -126,7 +126,7 @@ if ((CMAKE_SYSTEM_NAME STREQUAL "Windows" AND ((DEFINED MSVC_VERSION AND MSVC_VERSION GREATER "1900") OR (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND NOT CMAKE_C_SIMULATE_ID STREQUAL "MSVC"))) OR (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND (NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro" OR CMAKE_C_COMPILER_VERSION GREATER "5.9")) - OR CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS|Linux|BSD|MSYS|CYGWIN") + OR CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|visionOS|watchOS|Linux|BSD|MSYS|CYGWIN") run_cmake(feature-WHOLE_ARCHIVE) run_cmake_target(feature-WHOLE_ARCHIVE link-exe main) endif() diff --git a/Tests/RunCMake/target_link_libraries/ImportedTargetStub.cmake b/Tests/RunCMake/target_link_libraries/ImportedTargetStub.cmake new file mode 100644 index 0000000..04f9cfb --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/ImportedTargetStub.cmake @@ -0,0 +1,2 @@ +add_library(SharedStubImportedGlobal SHARED IMPORTED GLOBAL) +set_target_properties(SharedStubImportedGlobal PROPERTIES IMPORTED_IMPLIB z) diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index 7c5d77d..0e3877a 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -23,6 +23,7 @@ run_cmake(CMP0079-link-NEW-bogus) run_cmake(CMP0108-OLD-self-link) run_cmake(CMP0108-NEW-self-link) run_cmake(ImportedTarget) +run_cmake(ImportedTargetStub) run_cmake(ImportedTargetFailure) run_cmake(MixedSignature) run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses) diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-check.cmake new file mode 100644 index 0000000..0f897fe --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_\\$dollar") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_$dollar'.") +endif() diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-dollar-option-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake index bb04841..879151b 100644 --- a/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake @@ -53,3 +53,7 @@ target_link_options(LinkOptions_mod PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RE # executable with generator expression add_executable(LinkOptions_exe LinkOptionsExe.c) target_link_options(LinkOptions_exe PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>) + +# executable with dollar character +add_executable(LinkOptions_dollar_exe LinkOptionsExe.c) +target_link_options(LinkOptions_dollar_exe PRIVATE "${pre}BADFLAG_$dollar${obj}") diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake index 1a29ecf..ff0c5a8 100644 --- a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake @@ -30,7 +30,7 @@ if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") run_cmake_target(LINK_OPTIONS shared LinkOptions_shared --config Release) run_cmake_target(LINK_OPTIONS mod LinkOptions_mod --config Release) run_cmake_target(LINK_OPTIONS exe LinkOptions_exe --config Release) - + run_cmake_target(LINK_OPTIONS dollar-option LinkOptions_dollar_exe --config Release) run_cmake(genex_LINK_LANGUAGE) diff --git a/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirExport.cmake b/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirExport.cmake new file mode 100644 index 0000000..f049d91 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirExport.cmake @@ -0,0 +1,16 @@ +enable_language(C) + +# According to https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html#module:GNUInstallDirs +# relative CMAKE_INSTALL_<dir> are encouraged, but absolute path's are also allowed. +# Construct an absolute CMAKE_INSTALL_INCLUDEDIR. +set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include") + +add_library(lib1) +target_sources(lib1 + PRIVATE lib1.c + PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h) +# Expect install(TARGETS) to respect absolute CMAKE_INSTALL_INCLUDEDIR +# when installing the HEADERS. +# Must not prepend the CMAKE_INSTALL_PREFIX in the <pkg>-config.cmake. +install(TARGETS lib1 EXPORT lib1-config FILE_SET HEADERS) +install(EXPORT lib1-config NAMESPACE lib1:: DESTINATION share/lib1) diff --git a/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirImport.cmake b/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirImport.cmake new file mode 100644 index 0000000..123d6ae --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirImport.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) + +get_filename_component(CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}" DIRECTORY) +string(APPEND CMAKE_PREFIX_PATH "/FileSetAbsoluteInstallIncludeDirExport-build/install") + +find_package(lib1 REQUIRED) + +add_executable(exe main.cpp) +target_link_libraries(exe PRIVATE lib1::lib1) diff --git a/Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake b/Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake index 44f1626..9a8429d 100644 --- a/Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake +++ b/Tests/RunCMake/target_sources/FileSetDefaultWrongTypeExperimental.cmake @@ -1,6 +1,6 @@ enable_language(C) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") add_library(lib1 STATIC empty.c) target_sources(lib1 PRIVATE FILE_SET UNKNOWN) diff --git a/Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake b/Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake index adf1185..f63308c 100644 --- a/Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake +++ b/Tests/RunCMake/target_sources/FileSetWrongTypeExperimental.cmake @@ -1,6 +1,6 @@ enable_language(C) -set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "ac01f462-0f5f-432a-86aa-acef252918a6") add_library(lib1 STATIC empty.c) target_sources(lib1 PRIVATE FILE_SET a TYPE UNKNOWN) diff --git a/Tests/RunCMake/target_sources/RunCMakeTest.cmake b/Tests/RunCMake/target_sources/RunCMakeTest.cmake index 90915cd..8505f71 100644 --- a/Tests/RunCMake/target_sources/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_sources/RunCMakeTest.cmake @@ -99,3 +99,4 @@ function(run_export_import name) endfunction() run_export_import(FileSet) +run_export_import(FileSetAbsoluteInstallIncludeDir) |