diff options
Diffstat (limited to 'Tests')
206 files changed, 2056 insertions, 193 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 341aba6..da6b670 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -39,6 +39,13 @@ set(ENV{HOME} \"${TEST_HOME}\") ") endif() +# Suppress generator deprecation warnings in test suite. +if(CMAKE_GENERATOR MATCHES "^Visual Studio 10 2010") + set(TEST_WARN_VS10_CODE "set(ENV{CMAKE_WARN_VS10} OFF)") +else() + set(TEST_WARN_VS10_CODE "") +endif() + # 3.9 or later provides a definitive answer to whether we are multi-config # through a global property. Prior to 3.9, CMAKE_CONFIGURATION_TYPES being set # is assumed to mean multi-config, but developers might modify it so it is @@ -1442,6 +1449,7 @@ if(BUILD_TESTING) GIF Git GLEW + GLUT GnuTLS GSL GTK2 @@ -1543,6 +1551,8 @@ if(BUILD_TESTING) ADD_TEST_MACRO(FindMatlab.failure_reports ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) set(FindMatlab.r2018a_check_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.r2018a_check ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set(FindMatlab.targets_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) + ADD_TEST_MACRO(FindMatlab.targets_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) endif() add_test(ExternalProject ${CMAKE_CTEST_COMMAND} @@ -1640,6 +1650,55 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate DEPENDS ExternalProjectUpdateSetup ) + execute_process( + COMMAND ${CMAKE_COMMAND} + "-E" create_symlink + "${CMake_SOURCE_DIR}/Tests/CMakeLists.txt" # random source file that exists + "${CMake_BINARY_DIR}/Tests/try_to_create_symlink" # random target file in existing directory + RESULT_VARIABLE _symlink_result + OUTPUT_VARIABLE _symlink_stdout + ERROR_VARIABLE _symlink_stderr + ) + if(_symlink_result EQUAL 0) + file(REMOVE "${CMake_BINARY_DIR}/Tests/try_to_create_symlink") + function(add_installmode_test _mode) + set(ENV{CMAKE_INSTALL_MODE} _mode) + set(_maybe_InstallMode_CTEST_OPTIONS) + set(_maybe_BUILD_OPTIONS) + if(_isMultiConfig) + set(_maybe_CTEST_OPTIONS -C $<CONFIGURATION>) + else() + set(_maybe_BUILD_OPTIONS "-DCMAKE_BUILD_TYPE=$<CONFIGURATION>") + endif() + add_test( + NAME "InstallMode-${_mode}" + COMMAND + ${CMAKE_CTEST_COMMAND} -V ${_maybe_CTEST_OPTIONS} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/InstallMode" + "${CMake_BINARY_DIR}/Tests/InstallMode-${_mode}" + ${build_generator_args} + --build-project superpro + --build-exe-dir "${CMake_BINARY_DIR}/Tests/InstallMode-${_mode}" + --force-new-ctest-process + --build-options + ${_maybe_BUILD_OPTIONS} + "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/InstallMode-${_mode}/install" + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InstallMode-${_mode}") + unset(ENV{CMAKE_INSTALL_MODE}) + endfunction() + + add_installmode_test(COPY) + add_installmode_test(REL_SYMLINK) + add_installmode_test(REL_SYMLINK_OR_COPY) + add_installmode_test(ABS_SYMLINK) + add_installmode_test(ABS_SYMLINK_OR_COPY) + add_installmode_test(SYMLINK) + add_installmode_test(SYMLINK_OR_COPY) + endif() + + # do each of the tutorial steps function(add_tutorial_test step_name use_mymath tutorial_arg pass_regex) set(tutorial_test_name Tutorial${step_name}) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 52959e6..9e0b891 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -31,7 +31,6 @@ AddCMakeTest(CompilerIdVendor "") AddCMakeTest(ProcessorCount "-DKWSYS_TEST_EXE=$<TARGET_FILE:cmsysTestsCxx>") AddCMakeTest(PushCheckState "") AddCMakeTest(While "") -AddCMakeTest(CMakeHostSystemInformation "") AddCMakeTest(FileDownload "") set_tests_properties(CMake.FileDownload PROPERTIES diff --git a/Tests/CPackNSISGenerator/CMakeLists.txt b/Tests/CPackNSISGenerator/CMakeLists.txt index 64a8ef6..5d6320b 100644 --- a/Tests/CPackNSISGenerator/CMakeLists.txt +++ b/Tests/CPackNSISGenerator/CMakeLists.txt @@ -19,5 +19,6 @@ set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) set(CPACK_NSIS_MANIFEST_DPI_AWARE ON) set(CPACK_NSIS_BRANDING_TEXT "CMake branding text") set(CPACK_NSIS_BRANDING_TEXT_TRIM_POSITION "RIGHT") +set(CPACK_NSIS_IGNORE_LICENSE_PAGE ON) include(CPack) diff --git a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake index 8bfcf26..31a2560 100644 --- a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake +++ b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake @@ -60,3 +60,12 @@ if("${output_index}" EQUAL "-1") else() message(STATUS "Found BrandingText") endif() + +# license page should not be present +file(STRINGS "${project_file}" line REGEX "!insertmacro MUI_PAGE_LICENSE") +string(FIND "${line}" "MUI_PAGE_LICENSE" output_index) +if("${output_index}" EQUAL "-1") + message(STATUS "License not found in the project") +else() + message(FATAL_ERROR "License found in the project") +endif() diff --git a/Tests/CTestTestSerialInDepends/test.ctest b/Tests/CTestTestSerialInDepends/test.ctest index 28ee094..cf0d314 100644 --- a/Tests/CTestTestSerialInDepends/test.ctest +++ b/Tests/CTestTestSerialInDepends/test.ctest @@ -2,6 +2,9 @@ set(CTEST_RUN_CURRENT_SCRIPT 0) set(LOCK_FILE "${TEST_NAME}.lock") +# Delete the old lock file in case it's lingering from a previous failed test run +file(REMOVE "${LOCK_FILE}") + if("${TEST_NAME}" STREQUAL "i_want_to_be_alone") file(GLOB LOCK_FILES *.lock) if(LOCK_FILES) diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index be5ccac..669c412 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -4,7 +4,6 @@ macro (add_cuda_test_macro name) PROPERTY LABELS "CUDA") endmacro () -add_cuda_test_macro(Cuda.ConsumeCompileFeatures CudaConsumeCompileFeatures) add_cuda_test_macro(Cuda.CXXStandardSetTwice CXXStandardSetTwice) add_cuda_test_macro(Cuda.ObjectLibrary CudaObjectLibrary) add_cuda_test_macro(Cuda.MixedStandardLevels1 MixedStandardLevels1) diff --git a/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt b/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt deleted file mode 100644 index b01b9d7..0000000 --- a/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.18) -project(ConsumeCompileFeatures CXX CUDA) -#Goal for this example: - -#build a c++11 library that express a c++11 public compile feature -#link a cuda library and verify it builds with c++11 enabled - -#build a standalone c++/cuda mixed executable where we express a c++11 -#compile feature. - - -add_library(CudaConsumeLib STATIC static.cpp static.cu) -target_compile_features(CudaConsumeLib PUBLIC cxx_nullptr) - -add_executable(CudaConsumeCompileFeatures main.cu) -target_link_libraries(CudaConsumeCompileFeatures PRIVATE CudaConsumeLib) diff --git a/Tests/Cuda/ConsumeCompileFeatures/main.cu b/Tests/Cuda/ConsumeCompileFeatures/main.cu deleted file mode 100644 index bc32450..0000000 --- a/Tests/Cuda/ConsumeCompileFeatures/main.cu +++ /dev/null @@ -1,20 +0,0 @@ - -#include <iostream> - -int static_cxx11_func(int); - -void test_functions() -{ - auto x = static_cxx11_func(int(42)); - std::cout << x << std::endl; -} - -int main(int argc, char** argv) -{ - test_functions(); - std::cout - << "this executable doesn't use cuda code, just call methods defined" - << std::endl; - std::cout << "in libraries that have cuda code" << std::endl; - return 0; -} diff --git a/Tests/Cuda/ConsumeCompileFeatures/static.cpp b/Tests/Cuda/ConsumeCompileFeatures/static.cpp deleted file mode 100644 index 565d52e..0000000 --- a/Tests/Cuda/ConsumeCompileFeatures/static.cpp +++ /dev/null @@ -1,10 +0,0 @@ - - -#include <type_traits> - -int static_cuda11_func(int); - -int static_cxx11_func(int x) -{ - return static_cuda11_func(x) + std::integral_constant<int, 32>::value; -} diff --git a/Tests/Cuda/ConsumeCompileFeatures/static.cu b/Tests/Cuda/ConsumeCompileFeatures/static.cu deleted file mode 100644 index 73e43a8..0000000 --- a/Tests/Cuda/ConsumeCompileFeatures/static.cu +++ /dev/null @@ -1,9 +0,0 @@ - -#include <type_traits> - -using tt = std::true_type; -using ft = std::false_type; -int __host__ static_cuda11_func(int x) -{ - return x * x + std::integral_constant<int, 17>::value; -} diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in index 7781ded..7c6f76a 100644 --- a/Tests/EnforceConfig.cmake.in +++ b/Tests/EnforceConfig.cmake.in @@ -36,3 +36,4 @@ unset(ENV{CMAKE_GENERATOR_TOOLSET}) unset(ENV{CMAKE_EXPORT_COMPILE_COMMANDS}) @TEST_HOME_ENV_CODE@ +@TEST_WARN_VS10_CODE@ diff --git a/Tests/Environment/CMakeLists.txt b/Tests/Environment/CMakeLists.txt index 2b18d24..17009bd 100644 --- a/Tests/Environment/CMakeLists.txt +++ b/Tests/Environment/CMakeLists.txt @@ -9,6 +9,7 @@ add_test(Environment1 Environment) add_test(Environment2 Environment) add_test(EchoEnvironment1 ${CMAKE_COMMAND} -E environment) add_test(EchoEnvironment2 ${CMAKE_COMMAND} -E environment) +add_test(EchoEnvironment3 ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/check_mod.cmake") # Make sure "CMAKE_ENV.*Happy Thanksgiving" is in the output of # the "1" tests: @@ -24,3 +25,37 @@ set_tests_properties(Environment1 EchoEnvironment1 PROPERTIES set_tests_properties(Environment2 EchoEnvironment2 PROPERTIES FAIL_REGULAR_EXPRESSION "CMAKE_ENV.*Happy Thanksgiving" ) + +set_property(TEST EchoEnvironment3 + PROPERTY ENVIRONMENT_MODIFICATION + # Variables expected to be unset. + "UNSET_EXPLICIT=set:value" + "UNSET_EXPLICIT=unset:" + "UNSET_VIA_RESET=set:value" + "UNSET_VIA_RESET=reset:" + + # Direct settings. + "DIRECT=set:old" + "DIRECT=set:new" + + # String manipulation. + "STRING_MANIP=set:-core-" + "STRING_MANIP=string_append:post-" + "STRING_MANIP=string_prepend:-pre" + "STRING_MANIP=string_append:suffix" + "STRING_MANIP=string_prepend:prefix" + + # Path manipulation. + "PATH_MANIP=set:core" + "PATH_MANIP=path_list_append:post" + "PATH_MANIP=path_list_prepend:pre" + "PATH_MANIP=path_list_append:suffix" + "PATH_MANIP=path_list_prepend:prefix" + + # CMake list manipulation. + "CMAKE_LIST_MANIP=set:core" + "CMAKE_LIST_MANIP=cmake_list_append:post" + "CMAKE_LIST_MANIP=cmake_list_prepend:pre" + "CMAKE_LIST_MANIP=cmake_list_append:suffix" + "CMAKE_LIST_MANIP=cmake_list_prepend:prefix" +) diff --git a/Tests/Environment/check_mod.cmake b/Tests/Environment/check_mod.cmake new file mode 100644 index 0000000..16d02f2 --- /dev/null +++ b/Tests/Environment/check_mod.cmake @@ -0,0 +1,55 @@ +execute_process( + COMMAND ${CMAKE_COMMAND} -E environment + OUTPUT_VARIABLE out + ERROR_VARIABLE err + RESULT_VARIABLE res) + +if (res) + message(FATAL_ERROR "Failed with exit code ${res}: ${err}") +endif () + +if (CMAKE_HOST_WIN32) + set(path_sep ";") +else () + set(path_sep ":") +endif () + +set(unexpect_UNSET_EXPLICIT "") +set(unexpect_UNSET_VIA_RESET "") +set(expect_DIRECT "new") +set(expect_STRING_MANIP "prefix-pre-core-post-suffix") +set(expect_PATH_MANIP "prefix${path_sep}pre${path_sep}core${path_sep}post${path_sep}suffix") +set(expect_CMAKE_LIST_MANIP "prefix;pre;core;post;suffix") + +set(expected_vars + DIRECT + STRING_MANIP + PATH_MANIP + CMAKE_LIST_MANIP) + +while (out) + string(FIND "${out}" "\n" nl_pos) + string(SUBSTRING "${out}" 0 "${nl_pos}" line) + math(EXPR line_next "${nl_pos} + 1") + string(SUBSTRING "${out}" "${line_next}" -1 out) + + string(FIND "${line}" "=" eq_pos) + string(SUBSTRING "${line}" 0 "${eq_pos}" name) + math(EXPR value_start "${eq_pos} + 1") + string(SUBSTRING "${line}" "${value_start}" -1 value) + + if (DEFINED "unexpect_${name}") + message(SEND_ERROR "Found `${name}=${value}` when it should have been unset") + elseif (DEFINED "expect_${name}") + list(REMOVE_ITEM expected_vars "${name}") + if (expect_${name} STREQUAL value) + message(STATUS "Found `${name}=${value}` as expected") + else () + message(SEND_ERROR "Found `${name}=${value}` when it should have been ${expect_${name}}") + endif () + endif () +endwhile () + +if (expected_vars) + message(SEND_ERROR "Did not test expected variables: ${expected_vars}") +endif () diff --git a/Tests/FindGLUT/CMakeLists.txt b/Tests/FindGLUT/CMakeLists.txt new file mode 100644 index 0000000..e75ec40 --- /dev/null +++ b/Tests/FindGLUT/CMakeLists.txt @@ -0,0 +1,9 @@ +add_test(NAME FindGLUT.Test COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindGLUT/Test" + "${CMake_BINARY_DIR}/Tests/FindGLUT/Test" + ${build_generator_args} + --build-project TestFindGLUT + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V + ) diff --git a/Tests/FindGLUT/Test/CMakeLists.txt b/Tests/FindGLUT/Test/CMakeLists.txt new file mode 100644 index 0000000..0f4e536 --- /dev/null +++ b/Tests/FindGLUT/Test/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.21) +project(TestFindGLUT C) +include(CTest) + +find_package(GLUT REQUIRED) + +add_executable(testglut_tgt main.c) +target_link_libraries(testglut_tgt GLUT::GLUT) +add_test(NAME testglut_tgt COMMAND testglut_tgt) + +add_executable(testglut_var main.c) +target_include_directories(testglut_var PRIVATE ${GLUT_INCLUDE_DIRS}) +target_link_libraries(testglut_var PRIVATE ${GLUT_LIBRARIES}) +add_test(NAME testglut_var COMMAND testglut_var) + +set_tests_properties(testglut_tgt testglut_var + PROPERTIES WILL_FAIL true) diff --git a/Tests/FindGLUT/Test/main.c b/Tests/FindGLUT/Test/main.c new file mode 100644 index 0000000..1c8569c --- /dev/null +++ b/Tests/FindGLUT/Test/main.c @@ -0,0 +1,11 @@ +#include <GL/glut.h> +#include <stdio.h> + +int main() +{ + /* The following should call exit(1) and print + freeglut ERROR: Function <glutCreateWindow> called + without first calling 'glutInit'. + to stderr */ + glutCreateWindow("gluttest"); +} diff --git a/Tests/FindMatlab/targets_checks/CMakeLists.txt b/Tests/FindMatlab/targets_checks/CMakeLists.txt new file mode 100644 index 0000000..4af7cc3 --- /dev/null +++ b/Tests/FindMatlab/targets_checks/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required (VERSION 2.8.12) +enable_testing() +project(targets_checks) + +set(MATLAB_FIND_DEBUG TRUE) + +if(NOT "${MCR_ROOT}" STREQUAL "") + set(Matlab_ROOT_DIR "${MCR_ROOT}") + if(NOT EXISTS "${MCR_ROOT}") + message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}") + endif() +endif() + +# the success of the following command is dependent on the current configuration: +# - on 32bits builds (cmake is building with 32 bits), it looks for 32 bits Matlab +# - on 64bits builds (cmake is building with 64 bits), it looks for 64 bits Matlab +find_package(Matlab REQUIRED COMPONENTS ENG_LIBRARY MAT_LIBRARY + OPTIONAL_COMPONENTS MAIN_PROGRAM) + +if(NOT TARGET Matlab::mx) + message(FATAL_ERROR "Matlab::mx target does not exist") +endif() + +if(NOT TARGET Matlab::mex) + message(FATAL_ERROR "Matlab::mex target does not exist") +endif() + +if(NOT TARGET Matlab::eng) + message(FATAL_ERROR "Matlab::eng target does not exist") +endif() + +if(NOT TARGET Matlab::mat) + message(FATAL_ERROR "Matlab::mat target does not exist") +endif() + +matlab_add_mex( + # target name + NAME cmake_matlab_test_wrapper1 + # output name + OUTPUT_NAME cmake_matlab_mex1 + SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp + DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt + LINK_TO Matlab::mex + ) diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index d4c19c7..4c488e6 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -2,17 +2,25 @@ cmake_minimum_required (VERSION 2.6) project(IncludeDirectories) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) - OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) + OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + OR CMAKE_C_COMPILER_ID STREQUAL AppleClang + OR ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC" AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "19.29.30036.3" AND + NOT CMAKE_GENERATOR MATCHES "Visual Studio")) # No support for VS generators yet. AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja" OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0))) - include(CheckCXXCompilerFlag) - check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) - if(run_sys_includes_test) - # The Bullseye wrapper appears to break the -isystem effect. - execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE out ERROR_VARIABLE out) - if("x${out}" MATCHES "Bullseye") - set(run_sys_includes_test 0) + if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC") + set(run_sys_includes_test 1) + else () + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) + if(run_sys_includes_test) + # The Bullseye wrapper appears to break the -isystem effect. + execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE out ERROR_VARIABLE out) + if("x${out}" MATCHES "Bullseye") + set(run_sys_includes_test 0) + endif() endif() endif() if (run_sys_includes_test) diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index dee39c8..a746a68 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -6,9 +6,17 @@ project(SystemIncludeDirectories) add_library(systemlib systemlib.cpp) target_include_directories(systemlib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/systemlib") +function (apply_error_flags target) + if (MSVC) + target_compile_options(${target} PRIVATE /we4101) + else () + target_compile_options(${target} PRIVATE -Werror=unused-variable) + endif () +endfunction () + add_library(upstream upstream.cpp) target_link_libraries(upstream LINK_PUBLIC systemlib) -target_compile_options(upstream PRIVATE -Werror=unused-variable) +apply_error_flags(upstream) target_include_directories(upstream SYSTEM PUBLIC $<TARGET_PROPERTY:systemlib,INTERFACE_INCLUDE_DIRECTORIES> @@ -29,7 +37,7 @@ endif() add_library(consumer consumer.cpp) target_link_libraries(consumer upstream config_specific) -target_compile_options(consumer PRIVATE -Werror=unused-variable) +apply_error_flags(consumer) add_library(iface IMPORTED INTERFACE) set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES @@ -38,21 +46,21 @@ set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES add_library(imported_consumer imported_consumer.cpp) target_link_libraries(imported_consumer iface) -target_compile_options(imported_consumer PRIVATE -Werror=unused-variable) +apply_error_flags(imported_consumer) add_library(imported_consumer2 imported_consumer.cpp) target_link_libraries(imported_consumer2 imported_consumer) -target_compile_options(imported_consumer2 PRIVATE -Werror=unused-variable) +apply_error_flags(imported_consumer2) # add a target which has a relative system include add_library(somelib imported_consumer.cpp) target_include_directories(somelib SYSTEM PUBLIC "systemlib_header_only") -target_compile_options(somelib PRIVATE -Werror=unused-variable) +apply_error_flags(somelib) # add a target which consumes a relative system include add_library(otherlib upstream.cpp) target_link_libraries(otherlib PUBLIC somelib) -target_compile_options(somelib PRIVATE -Werror=unused-variable) +apply_error_flags(otherlib) macro(do_try_compile error_option) set(TC_ARGS @@ -61,7 +69,11 @@ macro(do_try_compile error_option) LINK_LIBRARIES iface ) if (${error_option} STREQUAL WITH_ERROR) - list(APPEND TC_ARGS COMPILE_DEFINITIONS -Werror=unused-variable) + if (MSVC) + list(APPEND TC_ARGS COMPILE_DEFINITIONS /we4101) + else () + list(APPEND TC_ARGS COMPILE_DEFINITIONS -Werror=unused-variable) + endif () endif() try_compile(${TC_ARGS}) endmacro() diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp index a13f08f..3da308d 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp @@ -1,5 +1,6 @@ -#include "config_iface.h" +#include <config_iface.h> + #include "upstream.h" int consumer() diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/imported_consumer.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/imported_consumer.cpp index 1dbe819..53759b1 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/imported_consumer.cpp +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/imported_consumer.cpp @@ -1,5 +1,5 @@ -#include "systemlib.h" +#include <systemlib.h> int main() { diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h index a670c2a..3daf69e 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h @@ -2,7 +2,7 @@ #ifndef UPSTREAM_H #define UPSTREAM_H -#include "systemlib.h" +#include <systemlib.h> #ifdef _WIN32 __declspec(dllexport) diff --git a/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/CMakeLists.txt index 70dfa01..5d58633 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/CMakeLists.txt @@ -7,14 +7,14 @@ set_target_properties(c_interface PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}>" INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}>" ) -target_compile_options(c_interface INTERFACE "$<$<COMPILE_LANG_AND_ID:C,GNU,Clang>:-Werror=unused-variable>") +target_compile_options(c_interface INTERFACE "$<$<COMPILE_LANG_AND_ID:C,GNU,Clang>:-Werror=unused-variable>;$<$<COMPILE_LANG_AND_ID:C,MSVC>:/we4101>") add_library(cxx_interface INTERFACE) set_target_properties(cxx_interface PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_system_include>" INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_system_include>" ) -target_compile_options(cxx_interface INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Werror=unused-variable>") +target_compile_options(cxx_interface INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Werror=unused-variable>;$<$<COMPILE_LANG_AND_ID:C,MSVC>:/we4101>") # The C header must come before the C++ header for this test to smoke out the # failure. The order of sources is how CMake determines the include cache diff --git a/Tests/InstallMode/CMakeLists.txt b/Tests/InstallMode/CMakeLists.txt new file mode 100644 index 0000000..96c83a0 --- /dev/null +++ b/Tests/InstallMode/CMakeLists.txt @@ -0,0 +1,124 @@ +cmake_minimum_required(VERSION 3.20.0) + +project(superpro LANGUAGES NONE) + +add_subdirectory(superpro) + +include(Subproject.cmake) +add_subproject(static_lib DIR subpro_a_static_lib) +add_subproject(shared_lib DIR subpro_b_shared_lib) +add_subproject(nested_lib DIR subpro_c_nested_lib NO_INSTALL) +add_subproject(executable DIR subpro_d_executable + DEPENDS + static_lib + shared_lib + nested_lib +) + +include(CTest) +if(BUILD_TESTING) + enable_language(CXX) # required by GNUInstallDirs + include(GNUInstallDirs) + + macro(testme _name _path _symlink) + add_test( + NAME "${_name}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + COMMAND + "${CMAKE_COMMAND}" + "-DFILE_PATH=${CMAKE_INSTALL_PREFIX}/${_path}" + "-DEXPECT_SYMLINK:BOOL=${_symlink}" + "-DEXPECT_ABSOLUTE:BOOL=${ARGN}" + "-P" "${CMAKE_SOURCE_DIR}/Test.cmake" + ) + endmacro() + + set(_mode $ENV{CMAKE_INSTALL_MODE}) + if(NOT "${_mode}" OR "${_mode}" STREQUAL "COPY") + set(expect_symlink NO) + elseif("${_mode}" MATCHES "(REL_)?SYMLINK(_OR_COPY)?") + set(expect_symlink YES) + set(expect_absolute NO) + elseif("${_mode}" MATCHES "ABS_SYMLINK(_OR_COPY)?") + set(expect_symlink YES) + set(expect_absolute YES) + endif() + + # toplevel project should respect CMAKE_INSTALL_MODE + + testme(superproj_file_copy + "file_copy.txt" NO) + testme(superproj_file_copy_file + "file_copy_file.txt" NO) + testme(superproj_file_install + "file_install.txt" + ${expect_symlink} + ${expect_absolute}) + testme(superproj_file_create_link_symbolic + "file_create_link_symbolic.txt" YES YES) + + # subprojects should receive and respect CMAKE_INSTALL_MODE too + + testme(subpro_a_static_lib_header + "${CMAKE_INSTALL_INCLUDEDIR}/static_lib.h" + ${expect_symlink} + ${expect_absolute} + ) + testme(subpro_a_static_lib_libfile + "${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}the_static_lib${CMAKE_STATIC_LIBRARY_SUFFIX}" + ${expect_symlink} + ${expect_absolute} + ) + + testme(subpro_b_shared_lib_header + "${CMAKE_INSTALL_INCLUDEDIR}/shared_lib.h" + ${expect_symlink} + ${expect_absolute} + ) + + if(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG AND + "${CMAKE_CXX_CREATE_SHARED_MODULE}" MATCHES "SONAME_FLAG") + # due to semver, this is always a link + testme(subpro_b_shared_lib_libfile + "${CMAKE_INSTALL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}the_shared_lib${CMAKE_SHARED_LIBRARY_SUFFIX}" + YES + ${expect_absolute} + ) + # this is the actual shared lib, so should follow CMAKE_INSTALL_MODE rules + testme(subpro_b_shared_lib_libfile_versuffix + "${CMAKE_INSTALL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}the_shared_lib${CMAKE_SHARED_LIBRARY_SUFFIX}.2.3.4" + ${expect_symlink} + ${expect_absolute} + ) + endif() + + testme(subpro_d_executable_exefile + "${CMAKE_INSTALL_BINDIR}/the_executable${CMAKE_EXECUTABLE_SUFFIX}" + ${expect_symlink} + ${expect_absolute} + ) + + # nested subprojects should receive and respect CMAKE_INSTALL_MODE too + + testme(subsubpro_c1_header + "${CMAKE_INSTALL_INCLUDEDIR}/c1_lib.h" + ${expect_symlink} + ${expect_absolute} + ) + testme(subsubpro_c1_libfile + "${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}the_c1_lib${CMAKE_STATIC_LIBRARY_SUFFIX}" + ${expect_symlink} + ${expect_absolute} + ) + + testme(subsubpro_c2_header + "${CMAKE_INSTALL_INCLUDEDIR}/c2_lib.h" + ${expect_symlink} + ${expect_absolute} + ) + testme(subsubpro_c2_libfile + "${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}the_c2_lib${CMAKE_STATIC_LIBRARY_SUFFIX}" + ${expect_symlink} + ${expect_absolute} + ) +endif() diff --git a/Tests/InstallMode/README.txt b/Tests/InstallMode/README.txt new file mode 100644 index 0000000..a4316eb --- /dev/null +++ b/Tests/InstallMode/README.txt @@ -0,0 +1,43 @@ +This is an example superbuild project to demonstrate the use of the +CMAKE_INSTALL_MODE environment variable on. + +The project hierarchy is like (B = Builds / D = Link Dependency): + ++---------------------------------------------------------------------+ +| Superbuild (Top) | ++---------------------------------------------------------------------+ + | | | | + | | | | + (B) (B) (B) (B) + | | | | + v v v v ++---------------+ +---------------+ +---------------+ +---------------+ +| A: Static Lib | | B: Shared Lib | | C: Nested | | D: Executable | +| Project | | Project | | Superbuild | | Project | ++---------------+ +---------------+ +---------------+ +---------------+ + ^ ^ | | | | | + | | (B) (B) | | | + | | | | | | | + | | v | | | | + | | +----------------+ | | | | + | | | C1: Static Lib | | | | | + | | | Project | | (D) (D) (D) + | | +----------------+ | | | | + | | ^ | | | | + | | | v | | | + | | (D) +----------------+ | | | + | | | | C2: Static Lib |<---+ | | + | | +--| Project | | | + | | +----------------+ | | + | | | | + | +------------------------------------+ | + | | + +--------------------------------------------------------+ + +The superbuild system is built on top of ExternalProject_Add(). + +NOTE that the subprojects will configure, build and install +during the build phase ('make') of the top-level project. +There is no install target in the top-level project! +The CMAKE_INSTALL_PREFIX is therefore populated during the build +phase already. diff --git a/Tests/InstallMode/Subproject.cmake b/Tests/InstallMode/Subproject.cmake new file mode 100644 index 0000000..826e61e --- /dev/null +++ b/Tests/InstallMode/Subproject.cmake @@ -0,0 +1,73 @@ +include(ExternalProject) + +# add_subproject(<name> [NO_INSTALL] [DIR <dirname>] [DEPENDS [subpro_dep ...]]) +function(add_subproject _name) + cmake_parse_arguments(_arg "NO_INSTALL" "DIR" "DEPENDS" ${ARGN}) + + if(_arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "There are unparsed arguments") + endif() + + set(_maybe_NO_INSTALL) + if(_arg_NO_INSTALL) + set(_maybe_NO_INSTALL INSTALL_COMMAND "") + endif() + + if(CMAKE_GENERATOR MATCHES "Ninja Multi-Config") + # Replace list separator before passing on to ExternalProject_Add + string(REPLACE ";" "|" _CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}") + string(REPLACE ";" "|" _CROSS_CONFIGS "${CMAKE_CROSS_CONFIGS}") + string(REPLACE ";" "|" _DEFAULT_CONFIGS "${CMAKE_DEFAULT_CONFIGS}") + + set(_maybe_NINJA_MULTICONFIG_ARGS + "-DCMAKE_CONFIGURATION_TYPES:STRINGS=${_CONFIGURATION_TYPES}" + "-DCMAKE_CROSS_CONFIGS:STRINGS=${_CROSS_CONFIGS}" + "-DCMAKE_DEFAULT_BUILD_TYPE:STRING=${CMAKE_DEFAULT_BUILD_TYPE}" + "-DCMAKE_DEFAULT_CONFIGS:STRINGS=${_DEFAULT_CONFIGS}" + ) + endif() + + ExternalProject_Add("${_name}" + DOWNLOAD_COMMAND "" + UPDATE_COMMAND "" + UPDATE_DISCONNECTED ON + + "${_maybe_NO_INSTALL}" + + BUILD_ALWAYS ON + + LOG_DOWNLOAD OFF + LOG_UPDATE OFF + LOG_PATCH OFF + LOG_CONFIGURE OFF + LOG_BUILD OFF + LOG_INSTALL OFF + + SOURCE_DIR "${PROJECT_SOURCE_DIR}/${_arg_DIR}" + + # Private build directory per subproject + BINARY_DIR "${PROJECT_BINARY_DIR}/subproject/${_arg_DIR}" + + # Common install directory, populated immediately + # during build (during build - not install - of superproject) + INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" + + DEPENDS + ${_arg_DEPENDS} + + LIST_SEPARATOR "|" + CMAKE_ARGS + "-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>" + + # We can rely on ExternalProject to pick the right + # generator (and architecture/toolset where applicable), + # however, we need to explicitly inherit other parent + # project's build settings. + "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" + "${_maybe_NINJA_MULTICONFIG_ARGS}" + + # Subproject progress reports clutter up the output, disable + "-DCMAKE_TARGET_MESSAGES:BOOL=OFF" + "-DCMAKE_RULE_MESSAGES:BOOL=OFF" + ) +endfunction() diff --git a/Tests/InstallMode/Test.cmake b/Tests/InstallMode/Test.cmake new file mode 100644 index 0000000..46c8fa1 --- /dev/null +++ b/Tests/InstallMode/Test.cmake @@ -0,0 +1,38 @@ +message("Testing...") +message("FILE_PATH = ${FILE_PATH}") +message("EXPECT_SYMLINK = ${EXPECT_SYMLINK}") +message("EXPECT_ABSOLUTE = ${EXPECT_ABSOLUTE}") + +if(NOT DEFINED FILE_PATH) + message(FATAL_ERROR "FILE_PATH variable must be defined") +endif() + +if(NOT EXISTS "${FILE_PATH}") + message(FATAL_ERROR "File ${FILE_PATH} does not exist") +endif() + +if(NOT DEFINED EXPECT_SYMLINK) + message(FATAL_ERROR "EXPECT_SYMLINK must be defined") +endif() + +if(EXPECT_SYMLINK) + if(NOT DEFINED EXPECT_ABSOLUTE) + message(FATAL_ERROR "EXPECT_ABSOLUTE variable must be defined") + endif() + + if(NOT IS_SYMLINK "${FILE_PATH}") + message(FATAL_ERROR "${FILE_PATH} must be a symlink") + endif() + + file(READ_SYMLINK "${FILE_PATH}" TARGET_PATH) + + if(EXPECT_ABSOLUTE AND NOT IS_ABSOLUTE "${TARGET_PATH}") + message(FATAL_ERROR "${FILE_PATH} must be an absolute symlink") + elseif(NOT EXPECT_ABSOLUTE AND IS_ABSOLUTE "${TARGET_PATH}") + message(FATAL_ERROR "${FILE_PATH} must be a relative symlink") + endif() +else() + if(IS_SYMLINK "${FILE_PATH}") + message(FATAL_ERROR "${FILE_PATH} must NOT be a symlink") + endif() +endif() diff --git a/Tests/InstallMode/subpro_a_static_lib/CMakeLists.txt b/Tests/InstallMode/subpro_a_static_lib/CMakeLists.txt new file mode 100644 index 0000000..7cd32cc --- /dev/null +++ b/Tests/InstallMode/subpro_a_static_lib/CMakeLists.txt @@ -0,0 +1,60 @@ +# This CMakeLists.txt is part of the subproject A (ExternalProject_Add). + +cmake_minimum_required(VERSION 3.20) +project(static_lib_project VERSION 1.2.3 LANGUAGES CXX) + +include(GNUInstallDirs) + +add_library(the_static_lib STATIC + "include/static_lib.h" + "src/static_lib.cpp" +) + +target_include_directories(the_static_lib PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> +) + +install( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +install( + TARGETS + the_static_lib + EXPORT main + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") + +include(CMakePackageConfigHelpers) + +configure_package_config_file( + "cmake/PackageConfig.cmake.in" + "${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION "${INSTALL_CMAKE_DIR}" + PATH_VARS + CMAKE_INSTALL_INCLUDEDIR + CMAKE_INSTALL_LIBDIR +) + +write_basic_package_version_file("${PROJECT_NAME}Version.cmake" + VERSION "${PROJECT_VERSION}" + COMPATIBILITY SameMajorVersion +) + +install( + EXPORT main + FILE "${PROJECT_NAME}Targets.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" +) + +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Version.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" +) diff --git a/Tests/InstallMode/subpro_a_static_lib/cmake/PackageConfig.cmake.in b/Tests/InstallMode/subpro_a_static_lib/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000..0fe72c9 --- /dev/null +++ b/Tests/InstallMode/subpro_a_static_lib/cmake/PackageConfig.cmake.in @@ -0,0 +1,8 @@ +set(@PROJECT_NAME@_VERSION @PROJECT_VERSION@) + +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") + +set_and_check(@PROJECT_NAME@_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +set_and_check(@PROJECT_NAME@_LIB_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") diff --git a/Tests/InstallMode/subpro_a_static_lib/include/static_lib.h b/Tests/InstallMode/subpro_a_static_lib/include/static_lib.h new file mode 100644 index 0000000..bd82d2e --- /dev/null +++ b/Tests/InstallMode/subpro_a_static_lib/include/static_lib.h @@ -0,0 +1,3 @@ +#pragma once + +void static_hello(); diff --git a/Tests/InstallMode/subpro_a_static_lib/src/static_lib.cpp b/Tests/InstallMode/subpro_a_static_lib/src/static_lib.cpp new file mode 100644 index 0000000..fe1cd85 --- /dev/null +++ b/Tests/InstallMode/subpro_a_static_lib/src/static_lib.cpp @@ -0,0 +1,10 @@ +#include <iostream> + +#include <static_lib.h> + +using namespace std; + +void static_hello() +{ + cout << "Hello from static_lib" << endl; +} diff --git a/Tests/InstallMode/subpro_b_shared_lib/CMakeLists.txt b/Tests/InstallMode/subpro_b_shared_lib/CMakeLists.txt new file mode 100644 index 0000000..b3d9cb2 --- /dev/null +++ b/Tests/InstallMode/subpro_b_shared_lib/CMakeLists.txt @@ -0,0 +1,75 @@ +# This CMakeLists.txt is part of the subproject B (ExternalProject_Add). + +cmake_minimum_required(VERSION 3.20) +project(shared_lib_project VERSION 2.3.4 LANGUAGES CXX) + +include(GNUInstallDirs) +include(GenerateExportHeader) + +add_library(the_shared_lib SHARED + "include/shared_lib.h" + "src/shared_lib.cpp" +) + +generate_export_header(the_shared_lib + BASE_NAME shared_lib + EXPORT_FILE_NAME include/shared_lib_export.h +) + +set_target_properties(the_shared_lib + PROPERTIES + VERSION "${PROJECT_VERSION}" + SOVERSION "${PROJECT_VERSION}" +) + +target_include_directories(the_shared_lib PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> +) + +install( + DIRECTORY + "${CMAKE_CURRENT_SOURCE_DIR}/include/" + "${CMAKE_CURRENT_BINARY_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +install( + TARGETS + the_shared_lib + EXPORT main + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") + +include(CMakePackageConfigHelpers) + +configure_package_config_file( + "cmake/PackageConfig.cmake.in" + "${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION "${INSTALL_CMAKE_DIR}" + PATH_VARS + CMAKE_INSTALL_INCLUDEDIR + CMAKE_INSTALL_LIBDIR +) + +write_basic_package_version_file("${PROJECT_NAME}Version.cmake" + VERSION "${PROJECT_VERSION}" + COMPATIBILITY SameMajorVersion +) + +install( + EXPORT main + FILE "${PROJECT_NAME}Targets.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" +) + +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Version.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" +) diff --git a/Tests/InstallMode/subpro_b_shared_lib/cmake/PackageConfig.cmake.in b/Tests/InstallMode/subpro_b_shared_lib/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000..0fe72c9 --- /dev/null +++ b/Tests/InstallMode/subpro_b_shared_lib/cmake/PackageConfig.cmake.in @@ -0,0 +1,8 @@ +set(@PROJECT_NAME@_VERSION @PROJECT_VERSION@) + +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") + +set_and_check(@PROJECT_NAME@_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +set_and_check(@PROJECT_NAME@_LIB_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") diff --git a/Tests/InstallMode/subpro_b_shared_lib/include/shared_lib.h b/Tests/InstallMode/subpro_b_shared_lib/include/shared_lib.h new file mode 100644 index 0000000..550b2b4 --- /dev/null +++ b/Tests/InstallMode/subpro_b_shared_lib/include/shared_lib.h @@ -0,0 +1,5 @@ +#pragma once + +#include <shared_lib_export.h> + +void SHARED_LIB_EXPORT shared_hello(); diff --git a/Tests/InstallMode/subpro_b_shared_lib/src/shared_lib.cpp b/Tests/InstallMode/subpro_b_shared_lib/src/shared_lib.cpp new file mode 100644 index 0000000..2820d5d --- /dev/null +++ b/Tests/InstallMode/subpro_b_shared_lib/src/shared_lib.cpp @@ -0,0 +1,10 @@ +#include <iostream> + +#include <shared_lib.h> + +using namespace std; + +void shared_hello() +{ + cout << "Hello from shared_lib" << endl; +} diff --git a/Tests/InstallMode/subpro_c_nested_lib/CMakeLists.txt b/Tests/InstallMode/subpro_c_nested_lib/CMakeLists.txt new file mode 100644 index 0000000..e397c02 --- /dev/null +++ b/Tests/InstallMode/subpro_c_nested_lib/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.20.0) + +project(subpro_c_nested_lib LANGUAGES NONE) + +include(../Subproject.cmake) +add_subproject(c1_lib DIR subsubpro_c1_lib) +add_subproject(c2_lib DIR subsubpro_c2_lib + DEPENDS + c1_lib +) diff --git a/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/CMakeLists.txt b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/CMakeLists.txt new file mode 100644 index 0000000..89f3755 --- /dev/null +++ b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/CMakeLists.txt @@ -0,0 +1,61 @@ +# This CMakeLists.txt is a nested subproject of the +# subproject C (ExternalProject_Add). + +cmake_minimum_required(VERSION 3.20) +project(c1_lib_project VERSION 1.2.3 LANGUAGES CXX) + +include(GNUInstallDirs) + +add_library(the_c1_lib STATIC + "include/c1_lib.h" + "src/c1_lib.cpp" +) + +target_include_directories(the_c1_lib PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> +) + +install( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +install( + TARGETS + the_c1_lib + EXPORT main + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") + +include(CMakePackageConfigHelpers) + +configure_package_config_file( + "cmake/PackageConfig.cmake.in" + "${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION "${INSTALL_CMAKE_DIR}" + PATH_VARS + CMAKE_INSTALL_INCLUDEDIR + CMAKE_INSTALL_LIBDIR +) + +write_basic_package_version_file("${PROJECT_NAME}Version.cmake" + VERSION "${PROJECT_VERSION}" + COMPATIBILITY SameMajorVersion +) + +install( + EXPORT main + FILE "${PROJECT_NAME}Targets.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" +) + +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Version.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" +) diff --git a/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/cmake/PackageConfig.cmake.in b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000..0fe72c9 --- /dev/null +++ b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/cmake/PackageConfig.cmake.in @@ -0,0 +1,8 @@ +set(@PROJECT_NAME@_VERSION @PROJECT_VERSION@) + +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") + +set_and_check(@PROJECT_NAME@_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +set_and_check(@PROJECT_NAME@_LIB_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") diff --git a/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/include/c1_lib.h b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/include/c1_lib.h new file mode 100644 index 0000000..245f9d4 --- /dev/null +++ b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/include/c1_lib.h @@ -0,0 +1,3 @@ +#pragma once + +void c1_hello(); diff --git a/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/src/c1_lib.cpp b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/src/c1_lib.cpp new file mode 100644 index 0000000..c405056 --- /dev/null +++ b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c1_lib/src/c1_lib.cpp @@ -0,0 +1,10 @@ +#include <iostream> + +#include <c1_lib.h> + +using namespace std; + +void c1_hello() +{ + cout << "Hello from c1_lib" << endl; +} diff --git a/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/CMakeLists.txt b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/CMakeLists.txt new file mode 100644 index 0000000..7580c77 --- /dev/null +++ b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/CMakeLists.txt @@ -0,0 +1,71 @@ +# This CMakeLists.txt is a nested subproject of the +# subproject C (ExternalProject_Add). + +cmake_minimum_required(VERSION 3.20) +project(c2_lib_project VERSION 1.2.3 LANGUAGES CXX) + +find_package(c1_lib_project REQUIRED) + +include(GNUInstallDirs) + +add_library(the_c2_lib STATIC + "include/c2_lib.h" + "src/c2_lib.cpp" +) + +target_link_libraries(the_c2_lib + PUBLIC + the_c1_lib +) + +# This is to fix an issue on AIX/GCC (see commit 4fc47424) +set_property(TARGET the_c2_lib PROPERTY NO_SYSTEM_FROM_IMPORTED 1) + +target_include_directories(the_c2_lib PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> +) + +install( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +install( + TARGETS + the_c2_lib + EXPORT main + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") + +include(CMakePackageConfigHelpers) + +configure_package_config_file( + "cmake/PackageConfig.cmake.in" + "${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION "${INSTALL_CMAKE_DIR}" + PATH_VARS + CMAKE_INSTALL_INCLUDEDIR + CMAKE_INSTALL_LIBDIR +) + +write_basic_package_version_file("${PROJECT_NAME}Version.cmake" + VERSION "${PROJECT_VERSION}" + COMPATIBILITY SameMajorVersion +) + +install( + EXPORT main + FILE "${PROJECT_NAME}Targets.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" +) + +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Version.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" +) diff --git a/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/cmake/PackageConfig.cmake.in b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000..45a177a --- /dev/null +++ b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/cmake/PackageConfig.cmake.in @@ -0,0 +1,11 @@ +set(@PROJECT_NAME@_VERSION @PROJECT_VERSION@) + +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") + +set_and_check(@PROJECT_NAME@_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +set_and_check(@PROJECT_NAME@_LIB_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") + +include(CMakeFindDependencyMacro) +find_dependency(c1_lib_project REQUIRED) diff --git a/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/include/c2_lib.h b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/include/c2_lib.h new file mode 100644 index 0000000..5056814 --- /dev/null +++ b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/include/c2_lib.h @@ -0,0 +1,3 @@ +#pragma once + +void c2_hello(); diff --git a/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/src/c2_lib.cpp b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/src/c2_lib.cpp new file mode 100644 index 0000000..cd2c932 --- /dev/null +++ b/Tests/InstallMode/subpro_c_nested_lib/subsubpro_c2_lib/src/c2_lib.cpp @@ -0,0 +1,12 @@ +#include <iostream> + +#include <c1_lib.h> +#include <c2_lib.h> + +using namespace std; + +void c2_hello() +{ + cout << "Hello from c2_lib and also..." << endl; + c1_hello(); +} diff --git a/Tests/InstallMode/subpro_d_executable/CMakeLists.txt b/Tests/InstallMode/subpro_d_executable/CMakeLists.txt new file mode 100644 index 0000000..60189e2 --- /dev/null +++ b/Tests/InstallMode/subpro_d_executable/CMakeLists.txt @@ -0,0 +1,27 @@ +# This CMakeLists.txt is part of the subproject B (ExternalProject_Add). + +cmake_minimum_required(VERSION 3.20) +project(subpro_d_executable LANGUAGES CXX) + +find_package(static_lib_project REQUIRED) +find_package(shared_lib_project REQUIRED) +find_package(c2_lib_project REQUIRED) + +add_executable(the_executable + "src/main.cpp" +) + +target_link_libraries(the_executable PRIVATE + the_static_lib + the_shared_lib + the_c2_lib +) + +# This is to fix an issue on AIX/GCC (see commit 4fc47424) +set_property(TARGET the_executable PROPERTY NO_SYSTEM_FROM_IMPORTED 1) + +install( + TARGETS + the_executable + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" +) diff --git a/Tests/InstallMode/subpro_d_executable/src/main.cpp b/Tests/InstallMode/subpro_d_executable/src/main.cpp new file mode 100644 index 0000000..ec12004 --- /dev/null +++ b/Tests/InstallMode/subpro_d_executable/src/main.cpp @@ -0,0 +1,13 @@ +#include <cstdlib> + +#include <c2_lib.h> +#include <shared_lib.h> +#include <static_lib.h> + +int main() +{ + static_hello(); + shared_hello(); + c2_hello(); + return EXIT_SUCCESS; +} diff --git a/Tests/InstallMode/superpro/CMakeLists.txt b/Tests/InstallMode/superpro/CMakeLists.txt new file mode 100644 index 0000000..ae4d25c --- /dev/null +++ b/Tests/InstallMode/superpro/CMakeLists.txt @@ -0,0 +1,29 @@ +# This CMakeLists.txt is part of the superproject (add_subdirectory). + +# Below file transfers are executed at configuration time! + +file( + COPY + "file_copy.txt" + DESTINATION + "${CMAKE_INSTALL_PREFIX}" +) + +file(COPY_FILE + "${CMAKE_CURRENT_SOURCE_DIR}/file_copy_file.txt" + "${CMAKE_INSTALL_PREFIX}/file_copy_file.txt" +) + +file( + INSTALL + "file_install.txt" + DESTINATION + "${CMAKE_INSTALL_PREFIX}" +) + +file( + CREATE_LINK + "${CMAKE_CURRENT_SOURCE_DIR}/file_create_link_symbolic.txt" + "${CMAKE_INSTALL_PREFIX}/file_create_link_symbolic.txt" + SYMBOLIC +) diff --git a/Tests/InstallMode/superpro/file_copy.txt b/Tests/InstallMode/superpro/file_copy.txt new file mode 100644 index 0000000..aacbb96 --- /dev/null +++ b/Tests/InstallMode/superpro/file_copy.txt @@ -0,0 +1 @@ +This file should always be copied into CMAKE_INSTALL_PREFIX. diff --git a/Tests/InstallMode/superpro/file_copy_file.txt b/Tests/InstallMode/superpro/file_copy_file.txt new file mode 100644 index 0000000..aacbb96 --- /dev/null +++ b/Tests/InstallMode/superpro/file_copy_file.txt @@ -0,0 +1 @@ +This file should always be copied into CMAKE_INSTALL_PREFIX. diff --git a/Tests/InstallMode/superpro/file_create_link_symbolic.txt b/Tests/InstallMode/superpro/file_create_link_symbolic.txt new file mode 100644 index 0000000..16a481b --- /dev/null +++ b/Tests/InstallMode/superpro/file_create_link_symbolic.txt @@ -0,0 +1,2 @@ +This file should always be installed into CMAKE_INSTALL_PREFIX +as a symbolic link to the original file. diff --git a/Tests/InstallMode/superpro/file_install.txt b/Tests/InstallMode/superpro/file_install.txt new file mode 100644 index 0000000..eac9782 --- /dev/null +++ b/Tests/InstallMode/superpro/file_install.txt @@ -0,0 +1,6 @@ +This file should be placed in CMAKE_INSTALL_PREFIX +as a copy if the CMAKE_INSTALL_MODE environment variable +is unset or equals "COPY". +If the variable's value is "SYMLINK" or "SYMLINK_OR_COPY", +the CMAKE_INSTALL_PREFIX should rather receive a symbolic +link to this file. diff --git a/Tests/MSManifest/Subdir/CMakeLists.txt b/Tests/MSManifest/Subdir/CMakeLists.txt index 8664572..3b4fccc 100644 --- a/Tests/MSManifest/Subdir/CMakeLists.txt +++ b/Tests/MSManifest/Subdir/CMakeLists.txt @@ -7,4 +7,8 @@ if(MSVC AND NOT MSVC_VERSION LESS 1400) -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake) add_executable(MSManifestNone main.c) set_property(TARGET MSManifestNone PROPERTY LINK_FLAGS "/MANIFEST:NO") +elseif(WIN32 AND CMAKE_C_COMPILER_ID MATCHES "Clang") + add_test(NAME MSManifest.Single COMMAND + ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:MSManifest> + -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake) endif() diff --git a/Tests/MSManifest/Subdir2/CMakeLists.txt b/Tests/MSManifest/Subdir2/CMakeLists.txt index 19d8de7..0d960ad 100644 --- a/Tests/MSManifest/Subdir2/CMakeLists.txt +++ b/Tests/MSManifest/Subdir2/CMakeLists.txt @@ -6,7 +6,7 @@ add_executable(MSMultipleManifest main.c ${CMAKE_CURRENT_BINARY_DIR}/test_manifest2.manifest ${CMAKE_CURRENT_BINARY_DIR}/test_manifest3.manifest) -if(MSVC AND NOT MSVC_VERSION LESS 1400) +if((MSVC AND NOT MSVC_VERSION LESS 1400) OR (WIN32 AND CMAKE_C_COMPILER_ID MATCHES "Clang") ) add_test(NAME MSManifest.Multiple COMMAND ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:MSMultipleManifest> -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake) diff --git a/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CMakeLists.txt b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CMakeLists.txt new file mode 100644 index 0000000..bbc08e6 --- /dev/null +++ b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.21) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar-build-stdout.txt b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar-build-stdout.txt new file mode 100644 index 0000000..f0f2efc --- /dev/null +++ b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar-build-stdout.txt @@ -0,0 +1 @@ +This message is printed by echo_message.bat diff --git a/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar.cmake b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar.cmake new file mode 100644 index 0000000..63d6068 --- /dev/null +++ b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/CheckEnvironmentVar.cmake @@ -0,0 +1,2 @@ +set(CMAKE_MSVCIDE_RUN_PATH "${CMAKE_SOURCE_DIR}") +add_custom_target(main COMMAND echo_message) diff --git a/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/RunCMakeTest.cmake b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/RunCMakeTest.cmake new file mode 100644 index 0000000..a424ff2 --- /dev/null +++ b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CheckEnvironmentVar-build) +run_cmake(CheckEnvironmentVar) +set(RunCMake_TEST_NO_CLEAN 1) +run_cmake_command(CheckEnvironmentVar-build ${CMAKE_COMMAND} --build . --config Debug --target main) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_NO_CLEAN) diff --git a/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/echo_message.bat b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/echo_message.bat new file mode 100755 index 0000000..9037d02 --- /dev/null +++ b/Tests/RunCMake/CMAKE_MSVCIDE_RUN_PATH/echo_message.bat @@ -0,0 +1 @@ +echo This message is printed by echo_message.bat diff --git a/Tests/RunCMake/CMakeDependentOption/Regex-stdout.txt b/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-NEW-stdout.txt index 15b56a1..15b56a1 100644 --- a/Tests/RunCMake/CMakeDependentOption/Regex-stdout.txt +++ b/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-NEW-stdout.txt diff --git a/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-NEW.cmake b/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-NEW.cmake new file mode 100644 index 0000000..5a2b018 --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-NEW.cmake @@ -0,0 +1,9 @@ +include(CMakeDependentOption) + +cmake_policy(SET CMP0127 NEW) + +set(A 1) +set(B 1) +set(C 0) +cmake_dependent_option(USE_FOO "Use Foo" ON "A AND (B OR C)" OFF) +message(STATUS "USE_FOO='${USE_FOO}'") diff --git a/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-WARN-stderr.txt b/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-WARN-stderr.txt new file mode 100644 index 0000000..b16e84b --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-WARN-stderr.txt @@ -0,0 +1,9 @@ +^CMake Warning \(dev\) at [^ +]*/Modules/CMakeDependentOption.cmake:[0-9]+ \(message\): + Policy CMP0127 is not set: cmake_dependent_option\(\) supports full Condition + Syntax. Run "cmake --help-policy CMP0127" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. +Call Stack \(most recent call first\): + [^ +]*/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-WARN.cmake:[0-9]+ \(cmake_dependent_option\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-WARN-stdout.txt b/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-WARN-stdout.txt new file mode 100644 index 0000000..d89dbd3 --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-WARN-stdout.txt @@ -0,0 +1,2 @@ +-- USE_FOO='OFF' +-- USE_BAR='ON' diff --git a/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-WARN.cmake b/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-WARN.cmake new file mode 100644 index 0000000..00d440d --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/Parentheses-CMP0127-WARN.cmake @@ -0,0 +1,9 @@ +include(CMakeDependentOption) + +set(A 1) +set(B 1) +set(C 0) +cmake_dependent_option(USE_FOO "Use Foo" ON "A AND (B OR C)" OFF) +message(STATUS "USE_FOO='${USE_FOO}'") +cmake_dependent_option(USE_BAR "Use Bar" ON "A;B" OFF) +message(STATUS "USE_BAR='${USE_BAR}'") diff --git a/Tests/RunCMake/CMakeDependentOption/Regex-CMP0127-NEW-stdout.txt b/Tests/RunCMake/CMakeDependentOption/Regex-CMP0127-NEW-stdout.txt new file mode 100644 index 0000000..15b56a1 --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/Regex-CMP0127-NEW-stdout.txt @@ -0,0 +1 @@ +-- USE_FOO='ON' diff --git a/Tests/RunCMake/CMakeDependentOption/Regex-CMP0127-NEW.cmake b/Tests/RunCMake/CMakeDependentOption/Regex-CMP0127-NEW.cmake new file mode 100644 index 0000000..e92c1e6 --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/Regex-CMP0127-NEW.cmake @@ -0,0 +1,7 @@ +include(CMakeDependentOption) + +cmake_policy(SET CMP0127 NEW) + +set(FOO "lower") +cmake_dependent_option(USE_FOO "Use Foo" ON "FOO MATCHES \"(UPPER|lower)\"" OFF) +message(STATUS "USE_FOO='${USE_FOO}'") diff --git a/Tests/RunCMake/CMakeDependentOption/Regex-CMP0127-OLD-stdout.txt b/Tests/RunCMake/CMakeDependentOption/Regex-CMP0127-OLD-stdout.txt new file mode 100644 index 0000000..15b56a1 --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/Regex-CMP0127-OLD-stdout.txt @@ -0,0 +1 @@ +-- USE_FOO='ON' diff --git a/Tests/RunCMake/CMakeDependentOption/Regex.cmake b/Tests/RunCMake/CMakeDependentOption/Regex-CMP0127-OLD.cmake index 8342a01..81df003 100644 --- a/Tests/RunCMake/CMakeDependentOption/Regex.cmake +++ b/Tests/RunCMake/CMakeDependentOption/Regex-CMP0127-OLD.cmake @@ -1,5 +1,7 @@ include(CMakeDependentOption) +cmake_policy(SET CMP0127 OLD) + set(FOO "lower") cmake_dependent_option(USE_FOO "Use Foo" ON "FOO MATCHES (UPPER|lower)" OFF) message(STATUS "USE_FOO='${USE_FOO}'") diff --git a/Tests/RunCMake/CMakeDependentOption/RunCMakeTest.cmake b/Tests/RunCMake/CMakeDependentOption/RunCMakeTest.cmake index e1045f2..61e046f 100644 --- a/Tests/RunCMake/CMakeDependentOption/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakeDependentOption/RunCMakeTest.cmake @@ -1,3 +1,6 @@ include(RunCMake) -run_cmake_script(Regex) +run_cmake_script(Regex-CMP0127-NEW) +run_cmake_script(Regex-CMP0127-OLD) +run_cmake_script(Parentheses-CMP0127-NEW) +run_cmake_script(Parentheses-CMP0127-WARN) diff --git a/Tests/RunCMake/CMakeDependentOption/Simple-CMP0127-OLD-stdout.txt b/Tests/RunCMake/CMakeDependentOption/Simple-CMP0127-OLD-stdout.txt new file mode 100644 index 0000000..15b56a1 --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/Simple-CMP0127-OLD-stdout.txt @@ -0,0 +1 @@ +-- USE_FOO='ON' diff --git a/Tests/RunCMake/CMakeDependentOption/Simple-CMP0127-OLD.cmake b/Tests/RunCMake/CMakeDependentOption/Simple-CMP0127-OLD.cmake new file mode 100644 index 0000000..6db2128 --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/Simple-CMP0127-OLD.cmake @@ -0,0 +1,6 @@ +include(CMakeDependentOption) + +set(A1 1) +set(bb 1) +cmake_dependent_option(USE_FOO "Use Foo" ON "A1;bb" OFF) +message(STATUS "USE_FOO='${USE_FOO}'") diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 86cb849..eb2c2d9 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -349,6 +349,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) endif() add_RunCMake_test(execute_process) add_RunCMake_test(export) +add_RunCMake_test(cmake_host_system_information) add_RunCMake_test(cmake_language) add_RunCMake_test(cmake_minimum_required) add_RunCMake_test(cmake_parse_arguments) @@ -374,12 +375,11 @@ add_RunCMake_test(ctest_disabled_test) add_RunCMake_test(ctest_skipped_test) add_RunCMake_test(ctest_update) add_RunCMake_test(ctest_upload) +add_RunCMake_test(ctest_environment) add_RunCMake_test(ctest_fixtures) add_RunCMake_test(file -DMSYS=${MSYS}) add_RunCMake_test(file-CHMOD -DMSYS=${MSYS}) -if(HAVE_ELF_H OR CMAKE_SYSTEM_NAME STREQUAL "AIX") - add_RunCMake_test(file-RPATH -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DHAVE_ELF_H=${HAVE_ELF_H}) -endif() +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}) @@ -557,6 +557,7 @@ if(CMake_TEST_FindGTK2) endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + add_RunCMake_test(CMAKE_MSVCIDE_RUN_PATH) add_RunCMake_test(include_external_msproject -DVS_PLATFORM_NAME=${CMAKE_VS_PLATFORM_NAME}) if("${CMAKE_GENERATOR}" MATCHES "Visual Studio (9|10)" AND NOT CMAKE_VS_DEVENV_COMMAND) set(NO_USE_FOLDERS 1) diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 746ff8b..7997c78 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -7,6 +7,7 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM.CUSTOM_BINARY_SPEC_FILE" false "MONOLITHIC;COMPONENT") run_cpack_test(CUSTOM_NAMES "RPM.CUSTOM_NAMES;DEB.CUSTOM_NAMES;TGZ;DragNDrop" true "COMPONENT") run_cpack_test(DEBUGINFO "RPM.DEBUGINFO;DEB.DEBUGINFO" true "COMPONENT") +run_cpack_test(DEBUGINFO "DEB.DEBUGINFO" true "MONOLITHIC") run_cpack_test_subtests(DEFAULT_PERMISSIONS "CMAKE_var_set;CPACK_var_set;both_set;invalid_CMAKE_var;invalid_CPACK_var" "RPM.DEFAULT_PERMISSIONS;DEB.DEFAULT_PERMISSIONS" false "MONOLITHIC;COMPONENT") run_cpack_test(DEPENDENCIES "RPM.DEPENDENCIES;DEB.DEPENDENCIES" true "COMPONENT") run_cpack_test(DIST "RPM.DIST" false "MONOLITHIC") diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake index cf4aa51..b3e6485 100644 --- a/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake @@ -1,8 +1,5 @@ set(whitespaces_ "[\t\n\r ]*") -set(EXPECTED_FILES_COUNT "6") -set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) - if(GENERATOR_TYPE STREQUAL "RPM") set(NAME "Debuginfo") set(DEBUG_SUFFIX "debuginfo") @@ -15,30 +12,49 @@ elseif(GENERATOR_TYPE STREQUAL "DEB") set(DEBUG_PKG "ddeb") endif() -set(EXPECTED_FILE_1_NAME "${NAME}") -set(EXPECTED_FILE_1_COMPONENT "applications") -set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) -set(EXPECTED_FILE_2 "TestDinfo-pkg*-headers.${PKG}") -set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt") +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(EXPECTED_FILES_COUNT "6") -set(EXPECTED_FILE_3 "TestDinfo-pkg*-libs.${PKG}") -set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so") + set(EXPECTED_FILE_1_NAME "${NAME}") + set(EXPECTED_FILE_1_COMPONENT "applications") + set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog") -set(EXPECTED_FILE_4 "${NAME}-applications-${DEBUG_SUFFIX}*.${DEBUG_PKG}") -if(GENERATOR_TYPE STREQUAL "RPM") - set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*\.debug.*") -elseif(GENERATOR_TYPE STREQUAL "DEB") - set(EXPECTED_FILE_CONTENT_4 ".*/usr/lib/debug/.build-id/.*\.debug.*") -endif() + set(EXPECTED_FILE_2 "TestDinfo-pkg*-headers.${PKG}") + set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt") -if(GENERATOR_TYPE STREQUAL "RPM") - set(EXPECTED_FILE_5 "libs-DebugInfoPackage.rpm") - set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*\.debug.*") -elseif(GENERATOR_TYPE STREQUAL "DEB") - set(EXPECTED_FILE_5 "TestDinfo-pkg-libs-dbgsym.ddeb") - set(EXPECTED_FILE_CONTENT_5 ".*/usr/lib/debug/.build-id/.*\.debug.*") -endif() + set(EXPECTED_FILE_3 "TestDinfo-pkg*-libs.${PKG}") + set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so") + + set(EXPECTED_FILE_4 "${NAME}-applications-${DEBUG_SUFFIX}*.${DEBUG_PKG}") + if(GENERATOR_TYPE STREQUAL "RPM") + set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*\.debug.*") + elseif(GENERATOR_TYPE STREQUAL "DEB") + set(EXPECTED_FILE_CONTENT_4 ".*/usr/lib/debug/.build-id/.*\.debug.*") + endif() + + if(GENERATOR_TYPE STREQUAL "RPM") + set(EXPECTED_FILE_5 "libs-DebugInfoPackage.rpm") + set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*\.debug.*") + elseif(GENERATOR_TYPE STREQUAL "DEB") + set(EXPECTED_FILE_5 "TestDinfo-pkg-libs-dbgsym.ddeb") + set(EXPECTED_FILE_CONTENT_5 ".*/usr/lib/debug/.build-id/.*\.debug.*") + endif() + + set(EXPECTED_FILE_6 "TestDinfo-pkg*-appheaders.${PKG}") + set(EXPECTED_FILE_CONTENT_6_LIST "/include;/include/test_lib.hpp") -set(EXPECTED_FILE_6 "TestDinfo-pkg*-appheaders.${PKG}") -set(EXPECTED_FILE_CONTENT_6_LIST "/include;/include/test_lib.hpp") +elseif(PACKAGING_TYPE STREQUAL "MONOLITHIC" AND GENERATOR_TYPE STREQUAL "DEB") + set(EXPECTED_FILES_COUNT "2") + + set(EXPECTED_FILE_1 "TestDinfo-pkg.deb") + set( + EXPECTED_FILE_CONTENT_1_LIST + "/bar;/bar/CMakeLists.txt;/bas;/bas/libtest_lib.so;/foo;/foo/test_prog;/include;/include/test_lib.hpp" + ) + + set(EXPECTED_FILE_2 "TestDinfo-pkg-dbgsym.ddeb") + set(EXPECTED_FILE_CONTENT_2 ".*/usr/lib/debug/.build-id/.*\.debug.*") + +endif() diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake index 9ff1f8a..e9cebbf 100644 --- a/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake @@ -28,6 +28,8 @@ install(TARGETS test_prog DESTINATION foo COMPONENT applications) install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) install(TARGETS test_lib DESTINATION bas COMPONENT libs) +set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_APPLICATIONS_DEBUGINFO_PACKAGE ON) set(CPACK_DEBIAN_APPLICATIONS_FILE_NAME "DEB-DEFAULT") diff --git a/Tests/RunCMake/CPack/tests/EXTRA/DEB-stderr.txt b/Tests/RunCMake/CPack/tests/EXTRA/DEB-stderr.txt index 37360e8..8b6ca94 100644 --- a/Tests/RunCMake/CPack/tests/EXTRA/DEB-stderr.txt +++ b/Tests/RunCMake/CPack/tests/EXTRA/DEB-stderr.txt @@ -1,6 +1,6 @@ CPack Warning: Adding file to tar: -#top level directory: .*/Tests/RunCMake/DEB.EXTRA/CPack/EXTRA-build/_CPack_Packages/Linux/DEB/extra-0.1.1-Linux/bas +#top level directory: .*/Tests/RunCMake/DEB.EXTRA/CPack/EXTRA-build/_CPack_Packages/[^/]+/DEB/extra-0.1.1-[^/]+/bas #missing file: .*/Tests/RunCMake/DEB.EXTRA/CPack/EXTRA-build/conffiles CPack Warning: Adding file to tar: -#top level directory: .*/Tests/RunCMake/DEB.EXTRA/CPack/EXTRA-build/_CPack_Packages/Linux/DEB/extra-0.1.1-Linux/foo +#top level directory: .*/Tests/RunCMake/DEB.EXTRA/CPack/EXTRA-build/_CPack_Packages/[^/]+/DEB/extra-0.1.1-[^/]+/foo #missing file: .*/Tests/RunCMake/DEB.EXTRA/CPack/EXTRA-build/conffiles diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake index d1a3a5f..f859215 100644 --- a/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake @@ -1,2 +1,2 @@ set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/bar;/bar/CMakeLists.txt;/baz;/baz/CMakeLists.txt;/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake index fbdda9c..13af097 100644 --- a/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake @@ -1,3 +1,4 @@ set(whitespaces_ "[\t\n\r ]*") -set(md5sums_md5sums "^.* usr/foo/CMakeLists\.txt${whitespaces_}$") +set(hashsyms_ "[a-f0-9]+") +set(md5sums_md5sums "^${hashsyms_} usr/bar/CMakeLists\.txt${whitespaces_}${hashsyms_} usr/baz/CMakeLists\.txt${whitespaces_}${hashsyms_} usr/foo/CMakeLists\.txt${whitespaces_}$") verifyDebControl("${FOUND_FILE_1}" "md5sums" "md5sums") diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake index 15c5892..3c922d2 100644 --- a/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake @@ -1,4 +1,6 @@ install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) +install(FILES CMakeLists.txt DESTINATION bar COMPONENT test) +install(FILES CMakeLists.txt DESTINATION baz COMPONENT test) if(PACKAGING_TYPE STREQUAL "COMPONENT") set(CPACK_COMPONENTS_ALL test) diff --git a/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-OFF.cmake b/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-OFF.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-OFF.cmake diff --git a/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-ON-stderr.txt new file mode 100644 index 0000000..202ef80 --- /dev/null +++ b/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-ON-stderr.txt @@ -0,0 +1,5 @@ +^CMake Warning: + The "Visual Studio 10 2010" generator is deprecated and will be removed in + a future version of CMake. + + Add CMAKE_WARN_VS10=OFF to the cache to disable this warning.$ diff --git a/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-ON.cmake b/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-ON.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-ON.cmake diff --git a/Tests/RunCMake/CommandLine/EnvBuildType-stdout.txt b/Tests/RunCMake/CommandLine/EnvBuildType-stdout.txt new file mode 100644 index 0000000..03b92a7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvBuildType-stdout.txt @@ -0,0 +1,2 @@ +-- ENV{CMAKE_BUILD_TYPE}='BuildTypeEnv' +-- CMAKE_BUILD_TYPE='BuildTypeEnv' diff --git a/Tests/RunCMake/CommandLine/EnvBuildType.cmake b/Tests/RunCMake/CommandLine/EnvBuildType.cmake new file mode 100644 index 0000000..e5e6d04 --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvBuildType.cmake @@ -0,0 +1,2 @@ +message(STATUS "ENV{CMAKE_BUILD_TYPE}='$ENV{CMAKE_BUILD_TYPE}'") +message(STATUS "CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}'") diff --git a/Tests/RunCMake/CommandLine/EnvBuildTypeIgnore-stdout.txt b/Tests/RunCMake/CommandLine/EnvBuildTypeIgnore-stdout.txt new file mode 100644 index 0000000..4a26732 --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvBuildTypeIgnore-stdout.txt @@ -0,0 +1,2 @@ +-- ENV{CMAKE_BUILD_TYPE}='BuildTypeEnv' +-- CMAKE_BUILD_TYPE='BuildTypeOpt' diff --git a/Tests/RunCMake/CommandLine/EnvBuildTypeIgnore.cmake b/Tests/RunCMake/CommandLine/EnvBuildTypeIgnore.cmake new file mode 100644 index 0000000..f21666f --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvBuildTypeIgnore.cmake @@ -0,0 +1 @@ +include(EnvBuildType.cmake) diff --git a/Tests/RunCMake/CommandLine/EnvConfigTypes-stdout.txt b/Tests/RunCMake/CommandLine/EnvConfigTypes-stdout.txt new file mode 100644 index 0000000..bfec18f --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvConfigTypes-stdout.txt @@ -0,0 +1,2 @@ +-- ENV{CMAKE_CONFIGURATION_TYPES}='ConfigTypesEnv' +-- CMAKE_CONFIGURATION_TYPES='ConfigTypesEnv' diff --git a/Tests/RunCMake/CommandLine/EnvConfigTypes.cmake b/Tests/RunCMake/CommandLine/EnvConfigTypes.cmake new file mode 100644 index 0000000..8c9b63a --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvConfigTypes.cmake @@ -0,0 +1,2 @@ +message(STATUS "ENV{CMAKE_CONFIGURATION_TYPES}='$ENV{CMAKE_CONFIGURATION_TYPES}'") +message(STATUS "CMAKE_CONFIGURATION_TYPES='${CMAKE_CONFIGURATION_TYPES}'") diff --git a/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore-stdout.txt b/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore-stdout.txt new file mode 100644 index 0000000..7800a4f --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore-stdout.txt @@ -0,0 +1,2 @@ +-- ENV{CMAKE_CONFIGURATION_TYPES}='ConfigTypesEnv' +-- CMAKE_CONFIGURATION_TYPES='ConfigTypesOpt' diff --git a/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore.cmake b/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore.cmake new file mode 100644 index 0000000..fcbbaea --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvConfigTypesIgnore.cmake @@ -0,0 +1 @@ +include(EnvConfigTypes.cmake) diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index c58b1d0..dc066f1 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -344,6 +344,26 @@ if(RunCMake_GENERATOR MATCHES "Unix Makefiles" OR RunCMake_GENERATOR MATCHES "Ni run_EnvironmentExportCompileCommands() endif() +function(run_EnvironmentBuildType) + set(ENV{CMAKE_BUILD_TYPE} "BuildTypeEnv") + run_cmake(EnvBuildType) + run_cmake_with_options(EnvBuildTypeIgnore -DCMAKE_BUILD_TYPE=BuildTypeOpt) + unset(ENV{CMAKE_BUILD_TYPE}) +endfunction() + +function(run_EnvironmentConfigTypes) + set(ENV{CMAKE_CONFIGURATION_TYPES} "ConfigTypesEnv") + run_cmake(EnvConfigTypes) + run_cmake_with_options(EnvConfigTypesIgnore -DCMAKE_CONFIGURATION_TYPES=ConfigTypesOpt) + unset(ENV{CMAKE_CONFIGURATION_TYPES}) +endfunction() + +if(RunCMake_GENERATOR MATCHES "Make|^Ninja$") + run_EnvironmentBuildType() +elseif(RunCMake_GENERATOR MATCHES "Ninja Multi-Config|Visual Studio|Xcode") + run_EnvironmentConfigTypes() +endif() + function(run_EnvironmentToolchain) set(ENV{CMAKE_TOOLCHAIN_FILE} "${RunCMake_SOURCE_DIR}/EnvToolchain-toolchain.cmake") run_cmake(EnvToolchainAbsolute) @@ -627,9 +647,10 @@ run_cmake_command(E_cat_directory file(WRITE "${out}/first_file.txt" "first file to append\n") file(WRITE "${out}/second_file.txt" "second file to append\n") +file(WRITE "${out}/empty_file.txt" "") file(WRITE "${out}/unicode_file.txt" "à éùç - í•œêµì–´") # Korean in Korean run_cmake_command(E_cat_good_cat - ${CMAKE_COMMAND} -E cat "${out}/first_file.txt" "${out}/second_file.txt" "${out}/unicode_file.txt") + ${CMAKE_COMMAND} -E cat "${out}/first_file.txt" "${out}/second_file.txt" "${out}/empty_file.txt" "${out}/unicode_file.txt") unset(out) run_cmake_command(E_cat_good_binary_cat @@ -898,3 +919,10 @@ set(ProfilingTestOutput ${RunCMake_TEST_BINARY_DIR}/output.json) set(RunCMake_TEST_OPTIONS --profiling-format=google-trace --profiling-output=${ProfilingTestOutput}) run_cmake(ProfilingTest) unset(RunCMake_TEST_OPTIONS) + +if(RunCMake_GENERATOR MATCHES "^Visual Studio 10 2010") + run_cmake_with_options(DeprecateVS10-WARN-ON -DCMAKE_WARN_VS10=ON) + unset(ENV{CMAKE_WARN_VS10}) + run_cmake(DeprecateVS10-WARN-ON) + run_cmake_with_options(DeprecateVS10-WARN-OFF -DCMAKE_WARN_VS10=OFF) +endif() diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_ARGN.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_ARGN.cmake new file mode 100644 index 0000000..e49ff22 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_ARGN.cmake @@ -0,0 +1,17 @@ +if(WIN32) + set(ENV{PKG_CONFIG} "\"${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat\" --static --print-errors") +else() + set(ENV{PKG_CONFIG} "\"${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh\" --static --print-errors") +endif() + +find_package(PkgConfig REQUIRED) + +if(NOT PKG_CONFIG_ARGN STREQUAL "--static;--print-errors") + message(SEND_ERROR "PKG_CONFIG_ARGN has wrong value '${PKG_CONFIG_ARGN}'") +endif() + +_pkgconfig_invoke("none" "prefix" "output" "") + +if(NOT prefix_output STREQUAL "Received;--static;Received;--print-errors") + message(SEND_ERROR "prefix_output has wrong value '${prefix_output}'") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt new file mode 100644 index 0000000..6615d80 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt @@ -0,0 +1,3 @@ +-- ZOT_LIBRARIES='zot' +-- ZOT_LINK_LIBRARIES='[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/zot/lib/prefix-zot-suffix' +-- ZOT_LDFLAGS='-L[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/zot/lib;-lzot' diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake new file mode 100644 index 0000000..9f654b5 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake @@ -0,0 +1,29 @@ +find_package(PkgConfig REQUIRED) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/zot/lib/pkgconfig/zot.pc" " +prefix=${CMAKE_CURRENT_BINARY_DIR}/zot +libdir=\${prefix}/lib + +Name: Zot +Description: Dummy packaget to test LIBRARY_DIR support +Version: 1.0 +Libs: -L\${libdir} -lzot +") + +# Create a "library" file to find in libdir. +set(CMAKE_FIND_LIBRARY_PREFIXES "prefix-") +set(CMAKE_FIND_LIBRARY_SUFFIXES "-suffix") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/zot/lib/prefix-zot-suffix") + +# 'pkg-config --libs' drops -L flags in PKG_CONFIG_SYSTEM_LIBRARY_PATH by default. +set(ENV{PKG_CONFIG_SYSTEM_LIBRARY_PATH} "${CMAKE_CURRENT_BINARY_DIR}/zot/lib") + +# 'pkgconf --libs' also drops -L flags in LIBRARY_PATH by default. +set(ENV{LIBRARY_PATH} "${CMAKE_CURRENT_BINARY_DIR}/zot/lib") + +set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_BINARY_DIR}/zot/lib/pkgconfig") +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}'") diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index 78ccd96..f36d1eb 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -13,6 +13,7 @@ run_cmake(FindPkgConfig_PKGCONFIG_PATH) run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH) run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH) run_cmake(FindPkgConfig_extract_frameworks) +run_cmake(FindPkgConfig_GET_MATCHING_ARGN) if(APPLE) run_cmake(FindPkgConfig_extract_frameworks_target) @@ -31,4 +32,8 @@ if (PKG_CONFIG_FOUND) run_cmake(FindPkgConfig_VERSION_OPERATORS) run_cmake(FindPkgConfig_GET_MATCHING_MODULE_NAME) run_cmake(FindPkgConfig_empty_target) + + if(NOT RunCMake_BINARY_DIR MATCHES " ") + run_cmake(FindPkgConfig_LIBRARY_PATH) + endif() endif () diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat index b038370..c91713b 100755 --- a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat @@ -1,5 +1,10 @@ @ECHO OFF +rem variables to get around `--static --version` printing the received +rem message and then version +set static=false +set print_errors=false + :LOOP IF "%1"=="" ( @@ -21,7 +26,19 @@ IF "%1"=="--exists" ( EXIT /B 0 ) ) +IF "%1"=="--static" ( + set static=true +) +IF "%1"=="--print-errors" ( + set print_errors=true +) SHIFT IF NOT "%~1"=="" GOTO LOOP +IF "%static%"=="true" ECHO Received --static +IF "%print_errors%"=="true" ECHO Received --print-errors + +IF "%static%"=="true" GOTO :EOF +IF "%print_errors%"=="true" GOTO :EOF + EXIT /B 255 diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh index 56bba30..4021bf7 100755 --- a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh @@ -4,6 +4,11 @@ # to the --exists argument with the PKG_CONFIG_PATH environment variable # and returns 1 if they are different. +# variables to get around `--static --version` printing the received +# message and then version +static=false +print_errors=false + while [ $# -gt 0 ]; do case $1 in --version) @@ -17,7 +22,21 @@ while [ $# -gt 0 ]; do echo "Found: ${PKG_CONFIG_PATH}" [ "${last}" = "${PKG_CONFIG_PATH}" ] && exit 0 || exit 1 ;; + --static) + static=true + ;; + --print-errors) + print_errors=true + ;; esac shift done + +$static && echo "Received --static" +$print_errors && echo "Received --print-errors" + +if $static || $print_errors; then + exit 0 +fi + exit 255 diff --git a/Tests/RunCMake/GeneratorExpression/CMP0085-OLD-stderr.txt b/Tests/RunCMake/GeneratorExpression/CMP0085-OLD-stderr.txt new file mode 100644 index 0000000..cae3679 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CMP0085-OLD-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_minimum_required\): + The OLD behavior for policy CMP0085 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/GoogleTest/GoogleTest-test3-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test3-stdout.txt new file mode 100644 index 0000000..cf08267 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test3-stdout.txt @@ -0,0 +1,16 @@ +Test project .* + Start 27: TEST:basic\.case_foo!3 +1/4 Test #27: TEST:basic\.case_foo!3 \.+ +Passed +[0-9.]+ sec + Start 28: TEST:basic\.case_bar!3 +2/4 Test #28: TEST:basic\.case_bar!3 \.+ +Passed +[0-9.]+ sec + Start 29: TEST:basic\.disabled_case!3 +3/4 Test #29: TEST:basic\.disabled_case!3 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec + Start 30: TEST:basic\.DISABLEDnot_really_case!3 +4/4 Test #30: TEST:basic\.DISABLEDnot_really_case!3 \.+ +Passed +[0-9.]+ sec + +100% tests passed, 0 tests failed out of 3 + +Total Test time \(real\) = +[0-9.]+ sec + +The following tests did not run: +.*29 - TEST:basic.disabled_case!3 \(Disabled\) diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt new file mode 100644 index 0000000..4a9d75b --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test4-stdout.txt @@ -0,0 +1,9 @@ +Test project .* + Start 31: TEST:typed/short\.case!4 +1/2 Test #31: TEST:typed/short\.case!4 \.+ +Passed +[0-9.]+ sec + Start 32: TEST:typed/float\.case!4 +2/2 Test #32: TEST:typed/float\.case!4 \.+ +Passed +[0-9.]+ sec + +100% tests passed, 0 tests failed out of 2 + +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/GoogleTest/GoogleTest.cmake b/Tests/RunCMake/GoogleTest/GoogleTest.cmake index 8efd117..221d6ad 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest.cmake +++ b/Tests/RunCMake/GoogleTest/GoogleTest.cmake @@ -24,6 +24,24 @@ gtest_discover_tests( PROPERTIES LABELS TEST2 ) +gtest_discover_tests( + fake_gtest + TEST_PREFIX TEST: + TEST_SUFFIX !3 + TEST_FILTER basic* + EXTRA_ARGS how now "\"brown\" cow" + PROPERTIES LABELS TEST3 +) + +gtest_discover_tests( + fake_gtest + TEST_PREFIX TEST: + TEST_SUFFIX !4 + TEST_FILTER typed* + EXTRA_ARGS how now "\"brown\" cow" + PROPERTIES LABELS TEST4 +) + add_executable(no_tests_defined no_tests_defined.cpp) xcode_sign_adhoc(no_tests_defined) diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake index 530c8ab..c5c5925 100644 --- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake @@ -40,6 +40,20 @@ function(run_GoogleTest DISCOVERY_MODE) --no-label-summary ) + run_cmake_command(GoogleTest-test3 + ${CMAKE_CTEST_COMMAND} + -C Debug + -L TEST3 + --no-label-summary + ) + + run_cmake_command(GoogleTest-test4 + ${CMAKE_CTEST_COMMAND} + -C Debug + -L TEST4 + --no-label-summary + ) + run_cmake_command(GoogleTest-test-missing ${CMAKE_CTEST_COMMAND} -C Debug diff --git a/Tests/RunCMake/GoogleTest/fake_gtest.cpp b/Tests/RunCMake/GoogleTest/fake_gtest.cpp index 1956c37..b2a5cb4 100644 --- a/Tests/RunCMake/GoogleTest/fake_gtest.cpp +++ b/Tests/RunCMake/GoogleTest/fake_gtest.cpp @@ -7,27 +7,42 @@ int main(int argc, char** argv) // it only requires that we produces output in the expected format when // invoked with --gtest_list_tests. Thus, we fake that here. This allows us // to test the module without actually needing Google Test. + bool is_filtered = + argc > 2 && std::string(argv[2]).find("--gtest_filter=") == 0; + bool is_basic_only = + is_filtered && std::string(argv[2]).find("basic*") != std::string::npos; + bool is_typed_only = + is_filtered && std::string(argv[2]).find("typed*") != std::string::npos; + if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") { - std::cout << "basic." << std::endl; - std::cout << " case_foo" << std::endl; - std::cout << " case_bar" << std::endl; - std::cout << " DISABLED_disabled_case" << std::endl; - std::cout << " DISABLEDnot_really_case" << std::endl; - std::cout << "DISABLED_disabled." << std::endl; - std::cout << " case" << std::endl; - std::cout << "DISABLEDnotreally." << std::endl; - std::cout << " case" << std::endl; - std::cout << "typed/0. # TypeParam = short" << std::endl; - std::cout << " case" << std::endl; - std::cout << "typed/1. # TypeParam = float" << std::endl; - std::cout << " case" << std::endl; - std::cout << "value/test." << std::endl; - std::cout << " case/0 # GetParam() = 1" << std::endl; - std::cout << " case/1 # GetParam() = \"foo\"" << std::endl; - std::cout << "param/special." << std::endl; - std::cout << " case/0 # GetParam() = \"semicolon;\"" << std::endl; - std::cout << " case/1 # GetParam() = \"backslash\\\"" << std::endl; - std::cout << " case/2 # GetParam() = \"${var}\"" << std::endl; + if (!is_typed_only) { + std::cout << "basic." << std::endl; + std::cout << " case_foo" << std::endl; + std::cout << " case_bar" << std::endl; + std::cout << " DISABLED_disabled_case" << std::endl; + std::cout << " DISABLEDnot_really_case" << std::endl; + } + if (!is_basic_only && !is_typed_only) { + std::cout << "DISABLED_disabled." << std::endl; + std::cout << " case" << std::endl; + std::cout << "DISABLEDnotreally." << std::endl; + std::cout << " case" << std::endl; + } + if (!is_basic_only) { + std::cout << "typed/0. # TypeParam = short" << std::endl; + std::cout << " case" << std::endl; + std::cout << "typed/1. # TypeParam = float" << std::endl; + std::cout << " case" << std::endl; + } + if (!is_basic_only && !is_typed_only) { + std::cout << "value/test." << std::endl; + std::cout << " case/0 # GetParam() = 1" << std::endl; + std::cout << " case/1 # GetParam() = \"foo\"" << std::endl; + std::cout << "param/special." << std::endl; + std::cout << " case/0 # GetParam() = \"semicolon;\"" << std::endl; + std::cout << " case/1 # GetParam() = \"backslash\\\"" << std::endl; + std::cout << " case/2 # GetParam() = \"${var}\"" << std::endl; + } return 0; } diff --git a/Tests/RunCMake/PrecompileHeaders/PchIncludedAllLanguages.cmake b/Tests/RunCMake/PrecompileHeaders/PchIncludedAllLanguages.cmake new file mode 100644 index 0000000..a455410 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchIncludedAllLanguages.cmake @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.15) +project(PchIncludedAllLanguages C CXX) + +if(CMAKE_CXX_COMPILE_OPTIONS_USE_PCH) + add_definitions(-DHAVE_PCH_SUPPORT) +endif() + +add_executable(main + main.cpp + pch-included.c + pch-included.cpp +) +target_precompile_headers(main PRIVATE pch.h) + +enable_testing() +add_test(NAME main COMMAND main) diff --git a/Tests/RunCMake/PrecompileHeaders/PchLibObjLibExe.cmake b/Tests/RunCMake/PrecompileHeaders/PchLibObjLibExe.cmake new file mode 100644 index 0000000..b4fdb71 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchLibObjLibExe.cmake @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.16) +project(PchLibObjLibExe CXX) + +foreach(i 1 2 3) + file(WRITE ${CMAKE_BINARY_DIR}/empty${i}.cpp "void nothing${i}() {}\n") +endforeach() + +add_library(base_lib_static STATIC ${CMAKE_BINARY_DIR}/empty1.cpp) +target_precompile_headers(base_lib_static PRIVATE <vector>) + +add_library(object_lib OBJECT ${CMAKE_BINARY_DIR}/empty2.cpp) +target_precompile_headers(object_lib REUSE_FROM base_lib_static) + +add_library(mid_lib_static STATIC ${CMAKE_BINARY_DIR}/empty3.cpp) +target_link_libraries(mid_lib_static PRIVATE object_lib) + +add_executable(exec main.cpp) +target_link_libraries(exec PRIVATE mid_lib_static) +set_target_properties(exec PROPERTIES MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>) + +target_precompile_headers(exec PRIVATE <string>) + +enable_testing() +add_test(NAME exec COMMAND exec) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index 8cc59d2..ca5b52e 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -28,3 +28,5 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja") endif() endif() run_test(PchReuseFromObjLib) +run_test(PchIncludedAllLanguages) +run_test(PchLibObjLibExe) diff --git a/Tests/RunCMake/PrecompileHeaders/pch-included.c b/Tests/RunCMake/PrecompileHeaders/pch-included.c new file mode 100644 index 0000000..96fce69 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/pch-included.c @@ -0,0 +1,8 @@ +#ifndef HAVE_PCH_SUPPORT +# include "pch.h" +#endif + +int testC(void) +{ + return PCH_INCLUDED; +} diff --git a/Tests/RunCMake/PrecompileHeaders/pch-included.cpp b/Tests/RunCMake/PrecompileHeaders/pch-included.cpp new file mode 100644 index 0000000..bf4d95d --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/pch-included.cpp @@ -0,0 +1,8 @@ +#ifndef HAVE_PCH_SUPPORT +# include "pch.h" +#endif + +int testCpp() +{ + return PCH_INCLUDED; +} diff --git a/Tests/RunCMake/PrecompileHeaders/pch.h b/Tests/RunCMake/PrecompileHeaders/pch.h index 81b6d9e..20672d1 100644 --- a/Tests/RunCMake/PrecompileHeaders/pch.h +++ b/Tests/RunCMake/PrecompileHeaders/pch.h @@ -1,3 +1,5 @@ #pragma once #define PCH_INCLUDED 1 + +int testC(void); diff --git a/Tests/RunCMake/UseSWIG/CMP0086-OLD-stderr.txt b/Tests/RunCMake/UseSWIG/CMP0086-OLD-stderr.txt new file mode 100644 index 0000000..fca7a73 --- /dev/null +++ b/Tests/RunCMake/UseSWIG/CMP0086-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0086-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0086 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/VS10Project/VsDpiAwareBadParam-stderr.txt b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-stderr.txt index 95fc5ca..39415af 100644 --- a/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-stderr.txt +++ b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-stderr.txt @@ -1,3 +1,3 @@ -CMake Error: Bad parameter for VS_DPI_AWARE: Bar CMake Error: Bad parameter for VS_DPI_AWARE: Foo +CMake Error: Bad parameter for VS_DPI_AWARE: Bar CMake Generate step failed. Build files cannot be regenerated correctly. diff --git a/Tests/RunCMake/VS10Project/VsSettings-check.cmake b/Tests/RunCMake/VS10Project/VsSettings-check.cmake index 0f8b26c..13cc8e2 100644 --- a/Tests/RunCMake/VS10Project/VsSettings-check.cmake +++ b/Tests/RunCMake/VS10Project/VsSettings-check.cmake @@ -4,20 +4,29 @@ macro(ensure_props_set projectFile) return() endif() - set(SettingFound FALSE) + set(Setting1Found FALSE) + set(Setting2Found FALSE) file(STRINGS "${projectFile}" lines) foreach(line IN LISTS lines) if(line MATCHES "<SourceProperty1.*Debug.*>SourceProperty1Value</SourceProperty1>") message("SourceProperty1 setting found") - set(SettingFound TRUE) + set(Setting1Found TRUE) + endif() + if(line MATCHES "<SourceProperty2.*Debug.*>SourceProperty2Value</SourceProperty2>") + message("SourceProperty2 setting found") + set(Setting2Found TRUE) endif() endforeach() - if (NOT SettingFound) + if (NOT Setting1Found) set(RunCMake_TEST_FAILED "SourceProperty1 setting was not found") return() endif() + if (NOT Setting2Found) + set(RunCMake_TEST_FAILED "SourceProperty2 setting was not found") + return() + endif() endmacro() ensure_props_set("${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") diff --git a/Tests/RunCMake/VS10Project/VsSettings.cmake b/Tests/RunCMake/VS10Project/VsSettings.cmake index a4b321b..3a046f1 100644 --- a/Tests/RunCMake/VS10Project/VsSettings.cmake +++ b/Tests/RunCMake/VS10Project/VsSettings.cmake @@ -3,3 +3,5 @@ enable_language(CXX) add_library(foo foo.cpp shader.hlsl) set_property(SOURCE shader.hlsl PROPERTY VS_SETTINGS "$<$<CONFIG:DEBUG>:SourceProperty1=SourceProperty1Value>") +set_property(SOURCE foo.cpp PROPERTY VS_SETTINGS + "$<$<CONFIG:DEBUG>:SourceProperty2=SourceProperty2Value>") diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff.cmake index f4fe07f..54375d5 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff.cmake @@ -1,7 +1,7 @@ add_executable(app MACOSX_BUNDLE main.m) set_target_properties(app PROPERTIES - XCODE_EMBED_FRAMEWORKS "${EXTERNAL_FWK}" + XCODE_EMBED_FRAMEWORKS "${EXTERNAL_DEPENDENCY}" XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY OFF XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY OFF ) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-build-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-build-check.cmake index e4ea55d..23fd49d 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-build-check.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-build-check.cmake @@ -1,3 +1,3 @@ -if(NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/Debug/app.app/Contents/Frameworks/sharedFrameworkExt.framework) - set(RunCMake_TEST_FAILED "Framework was not embedded at the expected location") +if(NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/Debug/app.app/Contents/Frameworks/${EXTERNAL_DEPENDENCY_NAME}) + set(RunCMake_TEST_FAILED "${EXTERNAL_DEPENDENCY_NAME} was not embedded at the expected location") endif() diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir.cmake index 79d8d77..c76226f 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir.cmake @@ -1,7 +1,7 @@ add_executable(app MACOSX_BUNDLE main.m) set_target_properties(app PROPERTIES - XCODE_EMBED_FRAMEWORKS "${EXTERNAL_FWK}" + XCODE_EMBED_FRAMEWORKS "${EXTERNAL_DEPENDENCY}" XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY ON XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY ON ) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-build-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-build-check.cmake index 57c79ea..732f04c 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-build-check.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-build-check.cmake @@ -1,3 +1,3 @@ -if(NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/Debug/app.app/Contents/Frameworks/subdir/sharedFrameworkExt.framework) - set(RunCMake_TEST_FAILED "Framework was not embedded at the expected location") +if(NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/Debug/app.app/Contents/Frameworks/subdir/${EXTERNAL_DEPENDENCY_NAME}) + set(RunCMake_TEST_FAILED "${EXTERNAL_DEPENDENCY_NAME} was not embedded at the expected location") endif() diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir.cmake index 4c78199..f83b1bf 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir.cmake @@ -1,7 +1,7 @@ add_executable(app MACOSX_BUNDLE main.m) set_target_properties(app PROPERTIES - XCODE_EMBED_FRAMEWORKS "${EXTERNAL_FWK}" + XCODE_EMBED_FRAMEWORKS "${EXTERNAL_DEPENDENCY}" XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY ON XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY ON XCODE_EMBED_FRAMEWORKS_PATH "subdir" diff --git a/Tests/RunCMake/XcodeProject-Embed/ExternalFramework.cmake b/Tests/RunCMake/XcodeProject-Embed/ExternalDependencies.cmake index 64e2f95..8c7b06a 100644 --- a/Tests/RunCMake/XcodeProject-Embed/ExternalFramework.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/ExternalDependencies.cmake @@ -1,2 +1,4 @@ add_library(sharedFrameworkExt SHARED func.m) set_target_properties(sharedFrameworkExt PROPERTIES FRAMEWORK TRUE) + +add_library(sharedDylibExt SHARED func.m) diff --git a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake index e94d084..f3a6918 100644 --- a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake @@ -1,47 +1,49 @@ include(RunCMake) -# Build a framework that the other tests will use and treat as external. +# Build dependencies that the other tests will use and treat as external. # Always build in the Debug configuration so that the path to the framework # is predictable. -function(ExternalFramework) +function(ExternalDependencies) set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExternalFramework-build) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExternalDependencies-build) set(externalFramework ${RunCMake_TEST_BINARY_DIR}/Debug/sharedFrameworkExt.framework PARENT_SCOPE) + set(externalDylib ${RunCMake_TEST_BINARY_DIR}/Debug/libsharedDylibExt.dylib PARENT_SCOPE) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - run_cmake(ExternalFramework) - run_cmake_command(ExternalFramework-build + run_cmake(ExternalDependencies) + run_cmake_command(ExternalDependencies-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --config Debug - --target sharedFrameworkExt + --target sharedFrameworkExt sharedDylibExt ) endfunction() -ExternalFramework() +ExternalDependencies() -set(RunCMake_TEST_OPTIONS -DEXTERNAL_FWK=${externalFramework}) - -run_cmake(EmbedFrameworksFlagsOff) - -function(TestFlagsOn testName) +function(TestFlagsOn testName dependencyName) set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-${dependencyName}-build) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(${testName}) - run_cmake_command(${testName}-build + run_cmake_command(${testName}-${dependencyName}-build ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --config Debug --target app ) endfunction() -TestFlagsOn(EmbedFrameworksFlagsOnNoSubdir) -TestFlagsOn(EmbedFrameworksFlagsOnWithSubdir) - +foreach(dependency ${externalFramework} ${externalDylib}) + cmake_path(GET dependency FILENAME dependencyName) + set(RunCMake_TEST_OPTIONS -DEXTERNAL_DEPENDENCY=${dependency} -DEXTERNAL_DEPENDENCY_NAME=${dependencyName}) + run_cmake(EmbedFrameworksFlagsOff) + TestFlagsOn(EmbedFrameworksFlagsOnNoSubdir ${dependencyName}) + TestFlagsOn(EmbedFrameworksFlagsOnWithSubdir ${dependencyName}) +endforeach() +unset(RunCMake_TEST_OPTIONS) function(TestAppExtension platform) set(testName EmbedAppExtensions-${platform}) diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-OLD-stderr.txt b/Tests/RunCMake/add_subdirectory/CMP0082-OLD-stderr.txt new file mode 100644 index 0000000..50838c3 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/CMP0082-OLD-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at CMakeLists.txt:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0082 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/cmake_host_system_information/000-FirstFallbackScript.cmake b/Tests/RunCMake/cmake_host_system_information/000-FirstFallbackScript.cmake new file mode 100644 index 0000000..ad873eb --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/000-FirstFallbackScript.cmake @@ -0,0 +1 @@ +message(WARNING "The warning text to match just to make sure the script get executed") diff --git a/Tests/RunCMake/cmake_host_system_information/999-LastFallbackScript.cmake b/Tests/RunCMake/cmake_host_system_information/999-LastFallbackScript.cmake new file mode 100644 index 0000000..08d8da8 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/999-LastFallbackScript.cmake @@ -0,0 +1,21 @@ +if(DEFINED CMAKE_GET_OS_RELEASE_FALLBACK_RESULT) + message(FATAL_ERROR "The `CMAKE_GET_OS_RELEASE_FALLBACK_RESULT` expected to be unset at this moment") +endif() + +set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME UnitTest) +set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME "Just a Unit Test") +set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID unittest) +set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID_LIKE nothing) +set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION 0.0.1) +set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID 0.0.1) + +list( + APPEND CMAKE_GET_OS_RELEASE_FALLBACK_RESULT + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME + IGNORED_VARIABLE_NAME_WHICH_IS_NOT_STARTED_WITH_EXPECTED_PREFIX + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID_LIKE + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION + CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID + ) diff --git a/Tests/RunCMake/cmake_host_system_information/BadArg1-result.txt b/Tests/RunCMake/cmake_host_system_information/BadArg1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/BadArg1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/BadArg1-stderr.txt b/Tests/RunCMake/cmake_host_system_information/BadArg1-stderr.txt new file mode 100644 index 0000000..ed995e6 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/BadArg1-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at BadArg1\.cmake:1 \(cmake_host_system_information\): + cmake_host_system_information missing RESULT specification. +Call Stack \(most recent call first\): + CMakeLists\.txt:7 \(include\) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg1.cmake b/Tests/RunCMake/cmake_host_system_information/BadArg1.cmake index 1655eb4..1655eb4 100644 --- a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg1.cmake +++ b/Tests/RunCMake/cmake_host_system_information/BadArg1.cmake diff --git a/Tests/RunCMake/cmake_host_system_information/BadArg2-result.txt b/Tests/RunCMake/cmake_host_system_information/BadArg2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/BadArg2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/BadArg2-stderr.txt b/Tests/RunCMake/cmake_host_system_information/BadArg2-stderr.txt new file mode 100644 index 0000000..b78c927 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/BadArg2-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at BadArg2\.cmake:1 \(cmake_host_system_information\): + cmake_host_system_information missing QUERY specification +Call Stack \(most recent call first\): + CMakeLists\.txt:7 \(include\) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg2.cmake b/Tests/RunCMake/cmake_host_system_information/BadArg2.cmake index 1f056d5..1f056d5 100644 --- a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg2.cmake +++ b/Tests/RunCMake/cmake_host_system_information/BadArg2.cmake diff --git a/Tests/RunCMake/cmake_host_system_information/BadArg3-result.txt b/Tests/RunCMake/cmake_host_system_information/BadArg3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/BadArg3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/BadArg3-stderr.txt b/Tests/RunCMake/cmake_host_system_information/BadArg3-stderr.txt new file mode 100644 index 0000000..c3f1314 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/BadArg3-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at BadArg3\.cmake:1 \(cmake_host_system_information\): + cmake_host_system_information does not recognize <key> FOOBAR +Call Stack \(most recent call first\): + CMakeLists\.txt:7 \(include\) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg3.cmake b/Tests/RunCMake/cmake_host_system_information/BadArg3.cmake index 9c5a558..9c5a558 100644 --- a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg3.cmake +++ b/Tests/RunCMake/cmake_host_system_information/BadArg3.cmake diff --git a/Tests/RunCMake/cmake_host_system_information/CMakeLists.txt b/Tests/RunCMake/cmake_host_system_information/CMakeLists.txt new file mode 100644 index 0000000..0198f9b --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.21) + +project(${RunCMake_TEST} NONE) + +set(CMAKE_SYSROOT ${PROJECT_SOURCE_DIR}/${RunCMake_TEST}) + +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/cmake_host_system_information/CentOS6-stdout.txt b/Tests/RunCMake/cmake_host_system_information/CentOS6-stdout.txt new file mode 100644 index 0000000..50dbb08 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/CentOS6-stdout.txt @@ -0,0 +1,7 @@ +-- CENTOS6_ID=`centos` +-- CENTOS6_ID_LIKE=`rhel` +-- CENTOS6_NAME=`CentOS` +-- CENTOS6_PRETTY_NAME=`CentOS release 6\.10 \(Final\)` +-- CENTOS6_USED_FALLBACK_SCRIPT=`.*/Modules/Internal/OSRelease/010-TryOldCentOS.cmake` +-- CENTOS6_VERSION=`6\.10` +-- CENTOS6_VERSION_ID=`6\.10` diff --git a/Tests/RunCMake/cmake_host_system_information/CentOS6.cmake b/Tests/RunCMake/cmake_host_system_information/CentOS6.cmake new file mode 100644 index 0000000..3bc632b --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/CentOS6.cmake @@ -0,0 +1,5 @@ +cmake_host_system_information(RESULT CENTOS6 QUERY DISTRIB_INFO) + +foreach(VAR IN LISTS CENTOS6) + message(STATUS "${VAR}=`${${VAR}}`") +endforeach() diff --git a/Tests/RunCMake/cmake_host_system_information/CentOS6/etc/centos-release b/Tests/RunCMake/cmake_host_system_information/CentOS6/etc/centos-release new file mode 100644 index 0000000..294ccc9 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/CentOS6/etc/centos-release @@ -0,0 +1 @@ +CentOS release 6.10 (Final) diff --git a/Tests/RunCMake/cmake_host_system_information/Debian6-stdout.txt b/Tests/RunCMake/cmake_host_system_information/Debian6-stdout.txt new file mode 100644 index 0000000..4193d6f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Debian6-stdout.txt @@ -0,0 +1,5 @@ +-- DEBIAN6_ID=`debian` +-- DEBIAN6_NAME=`Debian` +-- DEBIAN6_USED_FALLBACK_SCRIPT=`.*/Modules/Internal/OSRelease/020-TryDebianVersion.cmake` +-- DEBIAN6_VERSION=`6\.0\.10` +-- DEBIAN6_VERSION_ID=`6\.0\.10` diff --git a/Tests/RunCMake/cmake_host_system_information/Debian6.cmake b/Tests/RunCMake/cmake_host_system_information/Debian6.cmake new file mode 100644 index 0000000..cbf83a9 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Debian6.cmake @@ -0,0 +1,5 @@ +cmake_host_system_information(RESULT DEBIAN6 QUERY DISTRIB_INFO) + +foreach(VAR IN LISTS DEBIAN6) + message(STATUS "${VAR}=`${${VAR}}`") +endforeach() diff --git a/Tests/RunCMake/cmake_host_system_information/Debian6/etc/debian_version b/Tests/RunCMake/cmake_host_system_information/Debian6/etc/debian_version new file mode 100644 index 0000000..c7d48f0 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Debian6/etc/debian_version @@ -0,0 +1 @@ +6.0.10 diff --git a/Tests/RunCMake/cmake_host_system_information/Exherbo-stdout.txt b/Tests/RunCMake/cmake_host_system_information/Exherbo-stdout.txt new file mode 100644 index 0000000..11ae71f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Exherbo-stdout.txt @@ -0,0 +1,9 @@ +-- TEST1_ANSI_COLOR=`0;32` +-- TEST1_BUG_REPORT_URL=`https://bugs.exherbo.org/` +-- TEST1_HOME_URL=`https://www.exherbo.org/` +-- TEST1_ID=`exherbo` +-- TEST1_NAME=`Exherbo` +-- TEST1_PRETTY_NAME=`Exherbo Linux` +-- TEST1_SUPPORT_URL=`irc://irc.freenode.net/#exherbo` +-- TEST2_ID=`exherbo` +-- TEST2_VERSION=`` diff --git a/Tests/RunCMake/cmake_host_system_information/Exherbo.cmake b/Tests/RunCMake/cmake_host_system_information/Exherbo.cmake new file mode 100644 index 0000000..7fc26d8 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Exherbo.cmake @@ -0,0 +1,11 @@ +cmake_host_system_information(RESULT TEST1 QUERY DISTRIB_INFO) + +foreach(VAR IN LISTS TEST1) + message(STATUS "${VAR}=`${${VAR}}`") +endforeach() + +# Query individual variables +cmake_host_system_information(RESULT TEST2 QUERY DISTRIB_ID DISTRIB_VERSION) +list(POP_FRONT TEST2 TEST2_ID TEST2_VERSION) +message(STATUS "TEST2_ID=`${TEST2_ID}`") +message(STATUS "TEST2_VERSION=`${TEST2_VERSION}`") diff --git a/Tests/RunCMake/cmake_host_system_information/Exherbo/etc/os-release b/Tests/RunCMake/cmake_host_system_information/Exherbo/etc/os-release new file mode 100644 index 0000000..944c9b4 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Exherbo/etc/os-release @@ -0,0 +1,7 @@ +NAME="Exherbo" +PRETTY_NAME="Exherbo Linux" +ID="exherbo" +ANSI_COLOR="0;32" +HOME_URL="https://www.exherbo.org/" +SUPPORT_URL="irc://irc.freenode.net/#exherbo" +BUG_REPORT_URL="https://bugs.exherbo.org/" diff --git a/Tests/RunCMake/cmake_host_system_information/QueryKeys-stdout.txt b/Tests/RunCMake/cmake_host_system_information/QueryKeys-stdout.txt new file mode 100644 index 0000000..f583deb --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/QueryKeys-stdout.txt @@ -0,0 +1,27 @@ +-- NUMBER_OF_LOGICAL_CORES=`[0-9]+` +-- NUMBER_OF_PHYSICAL_CORES=`[0-9]+` +-- HOSTNAME=`.*` +-- FQDN=`.*` +-- TOTAL_VIRTUAL_MEMORY=`[0-9]+` +-- AVAILABLE_VIRTUAL_MEMORY=`[0-9]+` +-- TOTAL_PHYSICAL_MEMORY=`[0-9]+` +-- AVAILABLE_PHYSICAL_MEMORY=`[0-9]+` +-- IS_64BIT=`[01]` +-- HAS_FPU=`[01]` +-- HAS_MMX=`[01]` +-- HAS_MMX_PLUS=`[01]` +-- HAS_SSE=`[01]` +-- HAS_SSE2=`[01]` +-- HAS_SSE_FP=`[01]` +-- HAS_SSE_MMX=`[01]` +-- HAS_AMD_3DNOW=`[01]` +-- HAS_AMD_3DNOW_PLUS=`[01]` +-- HAS_IA64=`[01]` +-- HAS_SERIAL_NUMBER=`[01]` +-- PROCESSOR_SERIAL_NUMBER=`.*` +-- PROCESSOR_NAME=`.*` +-- PROCESSOR_DESCRIPTION=`.*` +-- OS_NAME=`.*` +-- OS_RELEASE=`.*` +-- OS_VERSION=`.*` +-- OS_PLATFORM=`.*` diff --git a/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in b/Tests/RunCMake/cmake_host_system_information/QueryKeys.cmake index a3c2b05..f22a0ae 100644 --- a/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in +++ b/Tests/RunCMake/cmake_host_system_information/QueryKeys.cmake @@ -1,19 +1,8 @@ -set(BadArg1-RESULT 1) -set(BadArg1-STDERR "missing RESULT specification") -set(BadArg2-RESULT 1) -set(BadArg2-STDERR "missing QUERY specification") -set(BadArg3-RESULT 1) -set(BadArg3-STDERR "does not recognize <key> FOOBAR") -set(QueryList-RESULT 0) -set(QueryList-STDERR "\\[[0-9]+;[0-9]+\\]") - function(try_and_print key) - cmake_host_system_information(RESULT RESULT QUERY ${key}) - message(STATUS "[${key}] [${RESULT}]") + cmake_host_system_information(RESULT RESULT QUERY ${key}) + message(STATUS "${key}=`${RESULT}`") endfunction() -message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") - try_and_print(NUMBER_OF_LOGICAL_CORES) try_and_print(NUMBER_OF_PHYSICAL_CORES) try_and_print(HOSTNAME) @@ -41,12 +30,3 @@ try_and_print(OS_NAME) try_and_print(OS_RELEASE) try_and_print(OS_VERSION) try_and_print(OS_PLATFORM) - -include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") - -check_cmake_test(CMakeHostSystemInformation - BadArg1 - BadArg2 - BadArg3 - QueryList -) diff --git a/Tests/RunCMake/cmake_host_system_information/QueryList-stdout.txt b/Tests/RunCMake/cmake_host_system_information/QueryList-stdout.txt new file mode 100644 index 0000000..eebe0d4 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/QueryList-stdout.txt @@ -0,0 +1 @@ +-- \[[0-9]+;[0-9]+\] diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-QueryList.cmake b/Tests/RunCMake/cmake_host_system_information/QueryList.cmake index 1c3156d..f24aa2b 100644 --- a/Tests/CMakeTests/CMakeHostSystemInformation-QueryList.cmake +++ b/Tests/RunCMake/cmake_host_system_information/QueryList.cmake @@ -2,4 +2,4 @@ cmake_host_system_information(RESULT RESULT QUERY NUMBER_OF_LOGICAL_CORES NUMBER_OF_PHYSICAL_CORES ) -message("[${RESULT}]") +message(STATUS "[${RESULT}]") diff --git a/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake b/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake new file mode 100644 index 0000000..189013f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake @@ -0,0 +1,17 @@ +include(RunCMake) + +run_cmake(BadArg1) +run_cmake(BadArg2) +run_cmake(BadArg3) + +run_cmake(QueryList) +run_cmake(QueryKeys) + +run_cmake(UnitTest) +run_cmake(Exherbo) +run_cmake(Ubuntu) + +run_cmake(CentOS6) +run_cmake(Debian6) + +run_cmake(UserFallbackScript) diff --git a/Tests/RunCMake/cmake_host_system_information/Ubuntu-stdout.txt b/Tests/RunCMake/cmake_host_system_information/Ubuntu-stdout.txt new file mode 100644 index 0000000..d1a18da --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Ubuntu-stdout.txt @@ -0,0 +1,14 @@ +-- TEST1_BUG_REPORT_URL=`https://bugs\.launchpad\.net/ubuntu/` +-- TEST1_HOME_URL=`https://www\.ubuntu\.com/` +-- TEST1_ID=`ubuntu` +-- TEST1_ID_LIKE=`debian` +-- TEST1_NAME=`Ubuntu` +-- TEST1_PRETTY_NAME=`Ubuntu 20\.04\.2 LTS` +-- TEST1_PRIVACY_POLICY_URL=`https://www\.ubuntu\.com/legal/terms-and-policies/privacy-policy` +-- TEST1_SUPPORT_URL=`https://help\.ubuntu\.com/` +-- TEST1_UBUNTU_CODENAME=`focal` +-- TEST1_VERSION=`20\.04\.2 LTS \(Focal Fossa\)` +-- TEST1_VERSION_CODENAME=`focal` +-- TEST1_VERSION_ID=`20\.04` +-- TEST2_ID=`ubuntu` +-- TEST2_VERSION=`20\.04\.2 LTS \(Focal Fossa\)` diff --git a/Tests/RunCMake/cmake_host_system_information/Ubuntu.cmake b/Tests/RunCMake/cmake_host_system_information/Ubuntu.cmake new file mode 100644 index 0000000..7fc26d8 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Ubuntu.cmake @@ -0,0 +1,11 @@ +cmake_host_system_information(RESULT TEST1 QUERY DISTRIB_INFO) + +foreach(VAR IN LISTS TEST1) + message(STATUS "${VAR}=`${${VAR}}`") +endforeach() + +# Query individual variables +cmake_host_system_information(RESULT TEST2 QUERY DISTRIB_ID DISTRIB_VERSION) +list(POP_FRONT TEST2 TEST2_ID TEST2_VERSION) +message(STATUS "TEST2_ID=`${TEST2_ID}`") +message(STATUS "TEST2_VERSION=`${TEST2_VERSION}`") diff --git a/Tests/RunCMake/cmake_host_system_information/Ubuntu/etc/os-release b/Tests/RunCMake/cmake_host_system_information/Ubuntu/etc/os-release new file mode 100644 index 0000000..f228f22 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Ubuntu/etc/os-release @@ -0,0 +1,12 @@ +NAME="Ubuntu" +VERSION="20.04.2 LTS (Focal Fossa)" +ID=ubuntu +ID_LIKE=debian +PRETTY_NAME="Ubuntu 20.04.2 LTS" +VERSION_ID="20.04" +HOME_URL="https://www.ubuntu.com/" +SUPPORT_URL="https://help.ubuntu.com/" +BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" +PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" +VERSION_CODENAME=focal +UBUNTU_CODENAME=focal diff --git a/Tests/RunCMake/cmake_host_system_information/UnitTest-stdout.txt b/Tests/RunCMake/cmake_host_system_information/UnitTest-stdout.txt new file mode 100644 index 0000000..db6f487 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/UnitTest-stdout.txt @@ -0,0 +1,7 @@ +-- UNIT_TEST_A_LIST_LIKE_VARIABLE=`satu;dua;tiga` +-- UNIT_TEST_DBL_QUOTED_VALUE=`"The" value in double "quotes"` +-- UNIT_TEST_DBL_QUOTED_VALUE_STIPPED_COMMENT=`Blah blah blah` +-- UNIT_TEST_NON_SPACE_VALUE=`Blah-blah-blah` +-- UNIT_TEST_QUOTED_VALUE=`'The' value in single 'quotes'` +-- UNIT_TEST_QUOTED_VALUE_STIPPED_COMMENT=`The value in single quotes` +-- UNIT_TEST_THE_URL_WITH_ANCHOR_TEST=`https://blah.blah/resource#anchor` diff --git a/Tests/RunCMake/cmake_host_system_information/UnitTest.cmake b/Tests/RunCMake/cmake_host_system_information/UnitTest.cmake new file mode 100644 index 0000000..d9a0aca --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/UnitTest.cmake @@ -0,0 +1,5 @@ +cmake_host_system_information(RESULT UNIT_TEST QUERY DISTRIB_INFO) + +foreach(VAR IN LISTS UNIT_TEST) + message(STATUS "${VAR}=`${${VAR}}`") +endforeach() diff --git a/Tests/RunCMake/cmake_host_system_information/UnitTest/etc/os-release b/Tests/RunCMake/cmake_host_system_information/UnitTest/etc/os-release new file mode 100644 index 0000000..66c33b5 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/UnitTest/etc/os-release @@ -0,0 +1,9 @@ +# Comment string gonna be ignored +NON_SPACE_VALUE=Blah-blah-blah +QUOTED_VALUE='\'The\' value in single \'quotes\'' +QUOTED_VALUE_STIPPED_COMMENT='The value in single quotes'# The comment right after `'` +DBL_QUOTED_VALUE="\"The\" value in double \"quotes\"" +DBL_QUOTED_VALUE_STIPPED_COMMENT="Blah blah blah"# The comment right after `'` +THE_URL_WITH_ANCHOR_TEST="https://blah.blah/resource#anchor" # And a comment after +A_LIST_LIKE_VARIABLE='satu;dua;tiga' +INCORRECT_ESCAPE_IGNORED=\'This line gonna be ignored' diff --git a/Tests/RunCMake/cmake_host_system_information/UserFallbackScript-stderr.txt b/Tests/RunCMake/cmake_host_system_information/UserFallbackScript-stderr.txt new file mode 100644 index 0000000..78acea2 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/UserFallbackScript-stderr.txt @@ -0,0 +1,5 @@ +CMake Warning at 000-FirstFallbackScript\.cmake:[0-9]+ \(message\): + The warning text to match just to make sure the script get executed +Call Stack \(most recent call first\): + UserFallbackScript\.cmake:[0-9]+ \(cmake_host_system_information\) + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/UserFallbackScript-stdout.txt b/Tests/RunCMake/cmake_host_system_information/UserFallbackScript-stdout.txt new file mode 100644 index 0000000..acaf47e --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/UserFallbackScript-stdout.txt @@ -0,0 +1,7 @@ +-- UFS_ID=`unittest` +-- UFS_ID_LIKE=`nothing` +-- UFS_NAME=`UnitTest` +-- UFS_PRETTY_NAME=`Just a Unit Test` +-- UFS_USED_FALLBACK_SCRIPT=`.*/999-LastFallbackScript\.cmake` +-- UFS_VERSION=`0\.0\.1` +-- UFS_VERSION_ID=`0\.0\.1` diff --git a/Tests/RunCMake/cmake_host_system_information/UserFallbackScript.cmake b/Tests/RunCMake/cmake_host_system_information/UserFallbackScript.cmake new file mode 100644 index 0000000..660aa1c --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/UserFallbackScript.cmake @@ -0,0 +1,12 @@ +list( + APPEND CMAKE_GET_OS_RELEASE_FALLBACK_SCRIPTS + ${CMAKE_CURRENT_SOURCE_DIR}/000-FirstFallbackScript.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/Ignored-Script.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/999-LastFallbackScript.cmake + ) + +cmake_host_system_information(RESULT UFS QUERY DISTRIB_INFO) + +foreach(VAR IN LISTS UFS) + message(STATUS "${VAR}=`${${VAR}}`") +endforeach() diff --git a/Tests/RunCMake/ctest_environment/CMakeLists.txt.in b/Tests/RunCMake/ctest_environment/CMakeLists.txt.in new file mode 100644 index 0000000..c9c4a64 --- /dev/null +++ b/Tests/RunCMake/ctest_environment/CMakeLists.txt.in @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.21.0) +project("@CASE_NAME@" NONE) +include("@CASE_SOURCE_DIR@/@CASE_NAME@.cmake") diff --git a/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-invalid-op-result.txt b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-invalid-op-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-invalid-op-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-invalid-op-stderr.txt b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-invalid-op-stderr.txt new file mode 100644 index 0000000..5b56d6f --- /dev/null +++ b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-invalid-op-stderr.txt @@ -0,0 +1 @@ +Error: Unrecognized environment manipulation argument: unknown diff --git a/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-invalid-op.cmake b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-invalid-op.cmake new file mode 100644 index 0000000..d6ca4b2 --- /dev/null +++ b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-invalid-op.cmake @@ -0,0 +1,6 @@ +include(CTest) +add_test(NAME cmake_version COMMAND "${CMAKE_COMMAND}" --version) + +set_property(TEST cmake_version + PROPERTY ENVIRONMENT_MODIFICATION + INVALID_OP=unknown:) diff --git a/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-colon-result.txt b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-colon-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-colon-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-colon-stderr.txt b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-colon-stderr.txt new file mode 100644 index 0000000..3ba6ba7 --- /dev/null +++ b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-colon-stderr.txt @@ -0,0 +1 @@ +Error: Missing `:` after the operation in: MISSING_COLON=unset diff --git a/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-colon.cmake b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-colon.cmake new file mode 100644 index 0000000..601dd8b --- /dev/null +++ b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-colon.cmake @@ -0,0 +1,6 @@ +include(CTest) + +add_test(NAME cmake_version COMMAND "${CMAKE_COMMAND}" --version) +set_property(TEST cmake_version + PROPERTY ENVIRONMENT_MODIFICATION + MISSING_COLON=unset) diff --git a/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-equals-result.txt b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-equals-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-equals-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-equals-stderr.txt b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-equals-stderr.txt new file mode 100644 index 0000000..20bc9a5 --- /dev/null +++ b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-equals-stderr.txt @@ -0,0 +1 @@ +Error: Missing `=` after the variable name in: MISSING_EQUAL diff --git a/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-equals.cmake b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-equals.cmake new file mode 100644 index 0000000..18448cf --- /dev/null +++ b/Tests/RunCMake/ctest_environment/ENVIRONMENT_MODIFICATION-no-equals.cmake @@ -0,0 +1,6 @@ +include(CTest) + +add_test(NAME cmake_version COMMAND "${CMAKE_COMMAND}" --version) +set_property(TEST cmake_version + PROPERTY ENVIRONMENT_MODIFICATION + MISSING_EQUAL) diff --git a/Tests/RunCMake/ctest_environment/RunCMakeTest.cmake b/Tests/RunCMake/ctest_environment/RunCMakeTest.cmake new file mode 100644 index 0000000..3447779 --- /dev/null +++ b/Tests/RunCMake/ctest_environment/RunCMakeTest.cmake @@ -0,0 +1,12 @@ +include(RunCTest) + +# Isolate our ctest runs from external environment. +unset(ENV{CTEST_PARALLEL_LEVEL}) +unset(ENV{CTEST_OUTPUT_ON_FAILURE}) + +set(CASE_SOURCE_DIR "${RunCMake_SOURCE_DIR}") +set(RunCTest_VERBOSE_FLAG "-VV") + +run_ctest(ENVIRONMENT_MODIFICATION-invalid-op) +run_ctest(ENVIRONMENT_MODIFICATION-no-colon) +run_ctest(ENVIRONMENT_MODIFICATION-no-equals) diff --git a/Tests/RunCMake/ctest_environment/test.cmake.in b/Tests/RunCMake/ctest_environment/test.cmake.in new file mode 100644 index 0000000..ca23c83 --- /dev/null +++ b/Tests/RunCMake/ctest_environment/test.cmake.in @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.7) + +set(CTEST_SITE "test-site") +set(CTEST_BUILD_NAME "test-build-name") +set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build") +set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + +set(ctest_test_args "@CASE_CTEST_TEST_ARGS@") +ctest_start(Experimental) +ctest_configure() +ctest_build() +ctest_test(${ctest_test_args}) diff --git a/Tests/RunCMake/ctest_memcheck/ExpectedOutputs-check.cmake b/Tests/RunCMake/ctest_memcheck/ExpectedOutputs-check.cmake new file mode 100644 index 0000000..9d2a059 --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/ExpectedOutputs-check.cmake @@ -0,0 +1,10 @@ +function (find_xml_file name) + file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/${name}.xml") + if (NOT test_xml_file) + message(FATAL_ERROR + "${name}.xml not created.") + endif () +endfunction () + +find_xml_file(DynamicAnalysis) +find_xml_file(DynamicAnalysis-Test) diff --git a/Tests/RunCMake/ctest_memcheck/ExpectedOutputs-stderr.txt b/Tests/RunCMake/ctest_memcheck/ExpectedOutputs-stderr.txt new file mode 100644 index 0000000..e1fc77a --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/ExpectedOutputs-stderr.txt @@ -0,0 +1 @@ +Cannot find memory tester output file: .*/Tests/RunCMake/ctest_memcheck/ExpectedOutputs-build/Testing/Temporary/MemoryChecker.1.log\.\* diff --git a/Tests/RunCMake/ctest_memcheck/ExpectedOutputs-stdout.txt b/Tests/RunCMake/ctest_memcheck/ExpectedOutputs-stdout.txt new file mode 100644 index 0000000..b3473bf --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/ExpectedOutputs-stdout.txt @@ -0,0 +1,2 @@ +Memory checking results: +left shift of negative value -256 - 1 diff --git a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake index 6e0a91c..cb8f696 100644 --- a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake @@ -95,6 +95,19 @@ unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- +# add output test +set(CTEST_EXTRA_CODE +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1\") +") +set(CMAKELISTS_EXTRA_CODE +"add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\" +-P \"${RunCMake_SOURCE_DIR}/testUndefinedBehaviorSanitizer.cmake\") +") +run_mc_test(ExpectedOutputs "" -DMEMCHECK_TYPE=UndefinedBehaviorSanitizer) +unset(CMAKELISTS_EXTRA_CODE) +unset(CTEST_EXTRA_CODE) + +#----------------------------------------------------------------------------- set(CTEST_EXTRA_CODE "string(REPLACE \" \" \"\\\\ \" PRE_POST_COMMAND \"\${CTEST_MEMORYCHECK_COMMAND}\") set(CTEST_CUSTOM_PRE_MEMCHECK \"\${PRE_POST_COMMAND} pre command\") diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 5f9b32d..de81049 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -158,13 +158,25 @@ add_test( COMMAND ${CMAKE_COMMAND} -E echo <DartMeasurement type="numeric/double" name="my_custom_value">1.4847</DartMeasurement>) add_test( + NAME double_measurement2 + COMMAND ${CMAKE_COMMAND} -E + echo <CTestMeasurement type="numeric/double" name="another_custom_value">1.8474</CTestMeasurement>) +add_test( NAME img_measurement COMMAND ${CMAKE_COMMAND} -E echo <DartMeasurementFile name="TestImage" type="image/png">]] ${IMAGE_DIR}/cmake-logo-16.png [[</DartMeasurementFile>) add_test( + NAME img_measurement2 + COMMAND ${CMAKE_COMMAND} -E + echo <CTestMeasurementFile name="TestImage2" type="image/png">]] ${IMAGE_DIR}/cmake-logo-16.png [[</CTestMeasurementFile>) +add_test( NAME file_measurement COMMAND ${CMAKE_COMMAND} -E echo <DartMeasurementFile name="my_test_input_data" type="file">]] ${IMAGE_DIR}/cmake-logo-16.png [[</DartMeasurementFile>) +add_test( + NAME file_measurement2 + COMMAND ${CMAKE_COMMAND} -E + echo <CTestMeasurementFile name="another_test_input_data" type="file">]] ${IMAGE_DIR}/cmake-logo-16.png [[</CTestMeasurementFile>) ]]) run_ctest(TestMeasurements) endfunction() @@ -194,3 +206,16 @@ set_property(TEST b PROPERTY LABELS b) run_ctest(TestChangingLabels) endfunction() run_changing_labels() + +# Verify that test output can add additional labels +function(run_extra_labels) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_test( + NAME custom_labels + COMMAND ${CMAKE_COMMAND} -E + echo before\n<CTestLabel>label2</CTestLabel>\n<CTestLabel>label1</CTestLabel>\n<CTestLabel>label3</CTestLabel>\n<CTestLabel>label2</CTestLabel>\nafter) +set_tests_properties(custom_labels PROPERTIES LABELS "label1") + ]]) + run_ctest(TestExtraLabels) +endfunction() +run_extra_labels() diff --git a/Tests/RunCMake/ctest_test/TestExtraLabels-check.cmake b/Tests/RunCMake/ctest_test/TestExtraLabels-check.cmake new file mode 100644 index 0000000..eaa50d1 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestExtraLabels-check.cmake @@ -0,0 +1,25 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/Testing/TAG" _tag) +string(REGEX REPLACE "^([^\n]*)\n.*$" "\\1" _date "${_tag}") +file(READ "${RunCMake_TEST_BINARY_DIR}/Testing/${_date}/Test.xml" _test_contents) + +# Check labels. +STRING(REGEX MATCHALL [[<Label>label1</Label>]] matches "${_test_contents}") +list(LENGTH matches n_matches) +if(NOT n_matches EQUAL 1) + string(APPEND RunCMake_TEST_FAILED "expected 1 match for label1, found ${n_matches}") +endif() +STRING(REGEX MATCHALL [[<Label>label2</Label>]] matches "${_test_contents}") +list(LENGTH matches n_matches) +if(NOT n_matches EQUAL 1) + string(APPEND RunCMake_TEST_FAILED "expected 1 match for label2, found ${n_matches}") +endif() +STRING(REGEX MATCHALL [[<Label>label3</Label>]] matches "${_test_contents}") +list(LENGTH matches n_matches) +if(NOT n_matches EQUAL 1) + string(APPEND RunCMake_TEST_FAILED "expected 1 match for label3, found ${n_matches}") +endif() + +# Check test output. +if(NOT _test_contents MATCHES "<Value>before\nafter\n</Value>") + string(APPEND RunCMake_TEST_FAILED "Could not find expected output in Test.xml") +endif() diff --git a/Tests/RunCMake/ctest_test/TestMeasurements-check.cmake b/Tests/RunCMake/ctest_test/TestMeasurements-check.cmake index 0095db0..7e0928d 100644 --- a/Tests/RunCMake/ctest_test/TestMeasurements-check.cmake +++ b/Tests/RunCMake/ctest_test/TestMeasurements-check.cmake @@ -10,13 +10,31 @@ endif() if(NOT _test_contents MATCHES "<Value>1.4847</Value>") string(APPEND RunCMake_TEST_FAILED "Could not find expected measurement value in Test.xml") endif() +# Check the other double measurement. +if(NOT _test_contents MATCHES [[NamedMeasurement type="numeric/double" name="another_custom_value"]]) + string(APPEND RunCMake_TEST_FAILED + "Could not find expected <NamedMeasurement> tag(2) for type='numeric/double' in Test.xml") +endif() +if(NOT _test_contents MATCHES "<Value>1.8474</Value>") + string(APPEND RunCMake_TEST_FAILED "Could not find expected measurement value(2) in Test.xml") +endif() # Check img measurement. if(NOT _test_contents MATCHES [[NamedMeasurement name="TestImage" type="image/png" encoding="base64"]]) string(APPEND RunCMake_TEST_FAILED "Could not find expected <NamedMeasurement> tag for type='image/png' in Test.xml") endif() +# Check img measurement 2. +if(NOT _test_contents MATCHES [[NamedMeasurement name="TestImage2" type="image/png" encoding="base64"]]) + string(APPEND RunCMake_TEST_FAILED + "Could not find expected <NamedMeasurement> tag(2) for type='image/png' in Test.xml") +endif() # Check file measurement. if(NOT _test_contents MATCHES [[NamedMeasurement name="my_test_input_data" encoding="base64" compression="tar/gzip" filename="cmake-logo-16.png" type="file"]]) string(APPEND RunCMake_TEST_FAILED "Could not find expected <NamedMeasurement> tag for type='file' in Test.xml") endif() +# Check file measurement 2. +if(NOT _test_contents MATCHES [[NamedMeasurement name="another_test_input_data" encoding="base64" compression="tar/gzip" filename="cmake-logo-16.png" type="file"]]) + string(APPEND RunCMake_TEST_FAILED + "Could not find expected <NamedMeasurement> tag(2) for type='file' in Test.xml") +endif() diff --git a/Tests/RunCMake/file-RPATH/RunCMakeTest.cmake b/Tests/RunCMake/file-RPATH/RunCMakeTest.cmake index eb7b497..1ca2e75 100644 --- a/Tests/RunCMake/file-RPATH/RunCMakeTest.cmake +++ b/Tests/RunCMake/file-RPATH/RunCMakeTest.cmake @@ -1,8 +1,6 @@ include(RunCMake) -if(HAVE_ELF_H) - run_cmake_command(ELF ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/ELF.cmake) -endif() +run_cmake_command(ELF ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/ELF.cmake) if(CMAKE_SYSTEM_NAME STREQUAL "AIX") run_cmake_command(XCOFF ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/XCOFF.cmake) diff --git a/Tests/RunCMake/find_library/FromScriptMode-stderr-darwin.txt b/Tests/RunCMake/find_library/FromScriptMode-stderr-darwin.txt new file mode 100644 index 0000000..185720b --- /dev/null +++ b/Tests/RunCMake/find_library/FromScriptMode-stderr-darwin.txt @@ -0,0 +1,4 @@ +.*find_library considered the following locations.* +.*\(lib\)library_no_exist\(\\.tbd\|\\.dylib\|\\.so\|\\.a\).* +.*The item was found at.* +.*lib/libcreated.a.* diff --git a/Tests/RunCMake/find_library/FromScriptMode-stderr-windows.txt b/Tests/RunCMake/find_library/FromScriptMode-stderr-windows.txt new file mode 100644 index 0000000..501ec0f --- /dev/null +++ b/Tests/RunCMake/find_library/FromScriptMode-stderr-windows.txt @@ -0,0 +1,4 @@ +.*find_library considered the following locations.* +.*\(\|lib\)library_no_exist\(\\.lib\|\\.dll\\.a\|\\.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 new file mode 100644 index 0000000..046f680 --- /dev/null +++ b/Tests/RunCMake/find_library/FromScriptMode-stderr.txt @@ -0,0 +1,4 @@ +.*find_library considered the following locations.* +.*\(lib\)library_no_exist\(\\.so\|\\.a\).* +.*The item was found at.* +.*lib/libcreated.a.* diff --git a/Tests/RunCMake/find_library/FromScriptMode.cmake b/Tests/RunCMake/find_library/FromScriptMode.cmake new file mode 100644 index 0000000..4d3c699 --- /dev/null +++ b/Tests/RunCMake/find_library/FromScriptMode.cmake @@ -0,0 +1,15 @@ + +if(TEMP_DIR) + file(REMOVE_RECURSE "${TEMP_DIR}") + file(MAKE_DIRECTORY "${TEMP_DIR}") + file(MAKE_DIRECTORY "${TEMP_DIR}/lib") + file(WRITE "${TEMP_DIR}/lib/libcreated.a" "created") +endif() + +set(CMAKE_FIND_DEBUG_MODE 1) +find_library(CREATED_LIBRARY NAMES library_no_exist) + +set(CMAKE_PREFIX_PATH "${TEMP_DIR}") +find_library(CREATED_LIBRARY NAMES created) +message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'") +set(CMAKE_FIND_DEBUG_MODE 0) diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake index e297173..ad02c82 100644 --- a/Tests/RunCMake/find_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake @@ -10,3 +10,5 @@ endif() run_cmake(PrefixInPATH) run_cmake(Required) run_cmake(NO_CACHE) + +run_cmake_script(FromScriptMode "-DTEMP_DIR=${RunCMake_BINARY_DIR}/FromScriptMode-temp") diff --git a/Tests/RunCMake/find_package/CMP0084-OLD-stderr.txt b/Tests/RunCMake/find_package/CMP0084-OLD-stderr.txt new file mode 100644 index 0000000..0db83aa --- /dev/null +++ b/Tests/RunCMake/find_package/CMP0084-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0084-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0084 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/find_package/MissingNormalForceRequired-result.txt b/Tests/RunCMake/find_package/MissingNormalForceRequired-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalForceRequired-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/MissingNormalForceRequired-stderr.txt b/Tests/RunCMake/find_package/MissingNormalForceRequired-stderr.txt new file mode 100644 index 0000000..f6c0b44 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalForceRequired-stderr.txt @@ -0,0 +1,20 @@ +CMake Error at MissingNormalForceRequired.cmake:2 \(find_package\): + No "FindNotHere.cmake" found in CMAKE_MODULE_PATH\. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Warning \(dev\) at MissingNormalForceRequired.cmake:2 \(find_package\): + FindNotHere.cmake must either be part of this project itself, in this case + adjust CMAKE_MODULE_PATH so that it points to the correct location inside + its source tree\. + + Or it must be installed by a package which has already been found via + find_package\(\)\. In this case make sure that package has indeed been found + and adjust CMAKE_MODULE_PATH to contain the location where that package has + installed FindNotHere\.cmake\. This must be a location provided by that + package. This error in general means that the buildsystem of this project + is relying on a Find-module without ensuring that it is actually available\. + +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/find_package/MissingNormalForceRequired.cmake b/Tests/RunCMake/find_package/MissingNormalForceRequired.cmake new file mode 100644 index 0000000..5935316 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalForceRequired.cmake @@ -0,0 +1,3 @@ +set(CMAKE_REQUIRE_FIND_PACKAGE_NotHere ON) +find_package(NotHere MODULE) +message(FATAL_ERROR "This error must not be reachable.") diff --git a/Tests/RunCMake/find_package/RequiredOptionValuesClash-result.txt b/Tests/RunCMake/find_package/RequiredOptionValuesClash-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_package/RequiredOptionValuesClash-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/RequiredOptionValuesClash-stderr.txt b/Tests/RunCMake/find_package/RequiredOptionValuesClash-stderr.txt new file mode 100644 index 0000000..b4fdd98 --- /dev/null +++ b/Tests/RunCMake/find_package/RequiredOptionValuesClash-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at RequiredOptionValuesClash.cmake:4 \(find_package\): + find_package for module Foo was made REQUIRED with + CMAKE_REQUIRE_FIND_PACKAGE_Foo but CMAKE_DISABLE_FIND_PACKAGE_Foo is + enabled. A REQUIRED package cannot be disabled. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at RequiredOptionValuesClash.cmake:5 \(message\): + This error must not be reachable\. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/RequiredOptionValuesClash.cmake b/Tests/RunCMake/find_package/RequiredOptionValuesClash.cmake new file mode 100644 index 0000000..04fece7 --- /dev/null +++ b/Tests/RunCMake/find_package/RequiredOptionValuesClash.cmake @@ -0,0 +1,5 @@ +set(CMAKE_DISABLE_FIND_PACKAGE_Foo ON) +set(CMAKE_REQUIRE_FIND_PACKAGE_Foo ON) + +find_package(Foo) +message(FATAL_ERROR "This error must not be reachable.") diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 3ba04c8..b20a889 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -6,6 +6,7 @@ run_cmake(ComponentRequiredAndOptional) run_cmake(FromPATHEnv) run_cmake(FromPrefixPath) run_cmake(MissingNormal) +run_cmake(MissingNormalForceRequired) run_cmake(MissingNormalRequired) run_cmake(MissingNormalVersion) run_cmake(MissingNormalWarnNoModuleOld) @@ -23,6 +24,7 @@ run_cmake(PackageRootNestedConfig) run_cmake(PackageRootNestedModule) run_cmake(PolicyPush) run_cmake(PolicyPop) +run_cmake(RequiredOptionValuesClash) run_cmake(SetFoundFALSE) run_cmake(WrongVersion) run_cmake(WrongVersionConfig) diff --git a/Tests/RunCMake/if/IncompleteMatches-stdout.txt b/Tests/RunCMake/if/IncompleteMatches-stdout.txt new file mode 100644 index 0000000..634d988 --- /dev/null +++ b/Tests/RunCMake/if/IncompleteMatches-stdout.txt @@ -0,0 +1,6 @@ +-- Test #1 passed +-- Test #2 passed +-- Test #3 passed +-- Test #4 passed +-- Test #5 passed +-- Test #6 passed diff --git a/Tests/RunCMake/if/IncompleteMatches.cmake b/Tests/RunCMake/if/IncompleteMatches.cmake new file mode 100644 index 0000000..7142cfc --- /dev/null +++ b/Tests/RunCMake/if/IncompleteMatches.cmake @@ -0,0 +1,36 @@ +if(MATCHES) + message(SEND_ERROR "Test #1 failed") +else() + message(STATUS "Test #1 passed") +endif() + +if("" MATCHES "") + message(STATUS "Test #2 passed") +else() + message(SEND_ERROR "Test #2 failed") +endif() + +if(MATCHES RHS) + message(SEND_ERROR "Test #3 failed") +else() + message(STATUS "Test #3 passed") +endif() + +set(RHS "") +if(MATCHES RHS) + message(SEND_ERROR "Test #4 failed") +else() + message(STATUS "Test #4 passed") +endif() + +if(MATCHES "^$") + message(SEND_ERROR "Test #5 failed") +else() + message(STATUS "Test #5 passed") +endif() + +if("" MATCHES "^$") + message(STATUS "Test #6 passed") +else() + message(SEND_ERROR "Test #6 failed") +endif() diff --git a/Tests/RunCMake/if/IncompleteMatchesFail-result.txt b/Tests/RunCMake/if/IncompleteMatchesFail-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/if/IncompleteMatchesFail-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/if/IncompleteMatchesFail-stderr.txt b/Tests/RunCMake/if/IncompleteMatchesFail-stderr.txt new file mode 100644 index 0000000..6e8ac80 --- /dev/null +++ b/Tests/RunCMake/if/IncompleteMatchesFail-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at IncompleteMatchesFail\.cmake:1 \(if\): + if given arguments: + + "LHS" "MATCHES" + + Unknown arguments specified diff --git a/Tests/RunCMake/if/IncompleteMatchesFail.cmake b/Tests/RunCMake/if/IncompleteMatchesFail.cmake new file mode 100644 index 0000000..a3ef2b8 --- /dev/null +++ b/Tests/RunCMake/if/IncompleteMatchesFail.cmake @@ -0,0 +1,2 @@ +if(LHS MATCHES) +endif() diff --git a/Tests/RunCMake/if/RunCMakeTest.cmake b/Tests/RunCMake/if/RunCMakeTest.cmake index f54edf7..6baa840 100644 --- a/Tests/RunCMake/if/RunCMakeTest.cmake +++ b/Tests/RunCMake/if/RunCMakeTest.cmake @@ -9,7 +9,11 @@ run_cmake(duplicate-else-after-elseif) run_cmake(elseif-message) run_cmake(misplaced-elseif) +run_cmake(unbalanced-parenthesis) + run_cmake(MatchesSelf) +run_cmake(IncompleteMatches) +run_cmake(IncompleteMatchesFail) run_cmake(TestNameThatExists) run_cmake(TestNameThatDoesNotExist) diff --git a/Tests/RunCMake/if/unbalanced-parenthesis-result.txt b/Tests/RunCMake/if/unbalanced-parenthesis-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/if/unbalanced-parenthesis-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/if/unbalanced-parenthesis-stderr.txt b/Tests/RunCMake/if/unbalanced-parenthesis-stderr.txt new file mode 100644 index 0000000..770ccb8 --- /dev/null +++ b/Tests/RunCMake/if/unbalanced-parenthesis-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at unbalanced-parenthesis\.cmake:[0-9]+ \(if\): + if given arguments: + + "NOT" "\(" "IN_LIST" "some_list" + + mismatched parenthesis in condition +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/if/unbalanced-parenthesis.cmake b/Tests/RunCMake/if/unbalanced-parenthesis.cmake new file mode 100644 index 0000000..c51c755 --- /dev/null +++ b/Tests/RunCMake/if/unbalanced-parenthesis.cmake @@ -0,0 +1,8 @@ +set(var_with_paren "(") +set(some_list "") + +if(NOT ${var_with_paren} IN_LIST some_list) + message(STATUS "Never prints") +else() + message(STATUS "Never prints") +endif() diff --git a/Tests/RunCMake/install/CMP0087-OLD-stderr.txt b/Tests/RunCMake/install/CMP0087-OLD-stderr.txt new file mode 100644 index 0000000..5233ebc --- /dev/null +++ b/Tests/RunCMake/install/CMP0087-OLD-stderr.txt @@ -0,0 +1,8 @@ +^CMake Deprecation Warning at CMP0087-OLD/CMakeLists.txt:5 \(cmake_policy\): + The OLD behavior for policy CMP0087 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/string/Timestamp-stderr.txt b/Tests/RunCMake/string/Timestamp-stderr.txt index cd4dcb3..d54777b 100644 --- a/Tests/RunCMake/string/Timestamp-stderr.txt +++ b/Tests/RunCMake/string/Timestamp-stderr.txt @@ -1 +1 @@ -RESULT=2005-08-07 23:19:49 Sunday=Sun August=Aug 05 day=219 wd=0 week=32 %I=11 epoch=1123456789 +RESULT=2005-08-07 23:19:49 Sunday=Sun August=Aug 05 day=219 wd=0 week=32 w_iso=31 %I=11 epoch=1123456789 diff --git a/Tests/RunCMake/string/Timestamp.cmake b/Tests/RunCMake/string/Timestamp.cmake index cba258d..7fd6d72 100644 --- a/Tests/RunCMake/string/Timestamp.cmake +++ b/Tests/RunCMake/string/Timestamp.cmake @@ -1,3 +1,3 @@ set(ENV{SOURCE_DATE_EPOCH} "1123456789") -string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %A=%a %B=%b %y day=%j wd=%w week=%U %%I=%I epoch=%s" UTC) +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %A=%a %B=%b %y day=%j wd=%w week=%U w_iso=%V %%I=%I epoch=%s" UTC) message("RESULT=${RESULT}") diff --git a/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt b/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt index 5b4761c..cf4c540 100644 --- a/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt +++ b/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt @@ -1,4 +1,2 @@ -^CMake Error at cxx_not_enabled.cmake:[0-9]+ \(target_compile_features\): - target_compile_features cannot use features from non-enabled language CXX -Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ +^CMake Error:.*CMake can not determine linker language for target: main.* +CMake Generate step failed. Build files cannot be regenerated correctly.$ diff --git a/Tests/RunCMake/while/RunCMakeTest.cmake b/Tests/RunCMake/while/RunCMakeTest.cmake index 7da80ac..bb9b991 100644 --- a/Tests/RunCMake/while/RunCMakeTest.cmake +++ b/Tests/RunCMake/while/RunCMakeTest.cmake @@ -5,3 +5,5 @@ run_cmake(EndMissing) run_cmake(EndMismatch) run_cmake(EndAlone) run_cmake(EndAloneArgs) + +run_cmake(unbalanced-parenthesis) diff --git a/Tests/RunCMake/while/unbalanced-parenthesis-result.txt b/Tests/RunCMake/while/unbalanced-parenthesis-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/while/unbalanced-parenthesis-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/while/unbalanced-parenthesis-stderr.txt b/Tests/RunCMake/while/unbalanced-parenthesis-stderr.txt new file mode 100644 index 0000000..9d4132c --- /dev/null +++ b/Tests/RunCMake/while/unbalanced-parenthesis-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at unbalanced-parenthesis.cmake:[0-9]+ \(while\): + had incorrect arguments: + + "NOT" "\(" "IN_LIST" "some_list" + + mismatched parenthesis in condition +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/while/unbalanced-parenthesis.cmake b/Tests/RunCMake/while/unbalanced-parenthesis.cmake new file mode 100644 index 0000000..7a12701 --- /dev/null +++ b/Tests/RunCMake/while/unbalanced-parenthesis.cmake @@ -0,0 +1,8 @@ +set(var_with_paren "(") +set(some_list "") + +while(NOT ${var_with_paren} IN_LIST some_list) + message(STATUS "Never prints") +endwhile() + +message(STATUS "Never prints") diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index f1b2f32..c3f9e03 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -67,7 +67,7 @@ add_test(NAME UseSWIG.BasicPerl COMMAND --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) if(SWIG_FOUND AND NOT SWIG_VERSION VERSION_LESS "4.0.2" - AND CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode") + AND CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode|Visual Studio (1[1-9]|[2-9][0-9])") add_test(NAME UseSWIG.Depfile.BasicPython COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test |