diff options
Diffstat (limited to 'Tests')
315 files changed, 2134 insertions, 1293 deletions
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 3b4ff60..39a5131 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -345,6 +345,17 @@ is not newer than dependency ${TEST_LINK_DEPENDS} ") endif() + + set(linkdep2 ${BuildDepends_BINARY_DIR}/Project/linkdep2${CMAKE_EXECUTABLE_SUFFIX}) + if(${linkdep2} IS_NEWER_THAN ${TEST_LINK_DEPENDS}) + message("INTERFACE_LINK_DEPENDS worked") + else() + message(SEND_ERROR "INTERFACE_LINK_DEPENDS failed. Executable + ${linkdep2} +is not newer than dependency + ${TEST_LINK_DEPENDS} +") + endif() endif() if(EXISTS "${link_depends_no_shared_check_txt}") diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 127b365..3f41b26 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -106,7 +106,12 @@ set_property( if(TEST_LINK_DEPENDS) add_executable(linkdep linkdep.cxx) - set_property(TARGET linkdep PROPERTY LINK_DEPENDS ${TEST_LINK_DEPENDS}) + set_property(TARGET linkdep PROPERTY LINK_DEPENDS $<1:${TEST_LINK_DEPENDS}>) + + add_library(foo_interface INTERFACE) + set_property(TARGET foo_interface PROPERTY INTERFACE_LINK_DEPENDS $<1:${TEST_LINK_DEPENDS}>) + add_executable(linkdep2 linkdep.cxx) + target_link_libraries(linkdep2 PRIVATE foo_interface) endif() add_library(link_depends_no_shared_lib SHARED link_depends_no_shared_lib.c diff --git a/Tests/CMakeCommands/add_link_options/CMakeLists.txt b/Tests/CMakeCommands/add_link_options/CMakeLists.txt new file mode 100644 index 0000000..bb7dcbb --- /dev/null +++ b/Tests/CMakeCommands/add_link_options/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.11) + +project(add_link_options LANGUAGES C) + + +add_link_options(-LINK_FLAG) + +add_executable(add_link_options EXCLUDE_FROM_ALL LinkOptionsExe.c) + +get_target_property(result add_link_options LINK_OPTIONS) +if (NOT result MATCHES "-LINK_FLAG") + message(SEND_ERROR "add_link_options not populated the LINK_OPTIONS target property") +endif() + + +add_library(imp UNKNOWN IMPORTED) +get_target_property(result imp LINK_OPTIONS) +if (result) + message(FATAL_ERROR "add_link_options populated the LINK_OPTIONS target property") +endif() diff --git a/Tests/CMakeCommands/add_link_options/LinkOptionsExe.c b/Tests/CMakeCommands/add_link_options/LinkOptionsExe.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/CMakeCommands/add_link_options/LinkOptionsExe.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/CMakeCommands/target_link_options/CMakeLists.txt b/Tests/CMakeCommands/target_link_options/CMakeLists.txt new file mode 100644 index 0000000..c66cd37 --- /dev/null +++ b/Tests/CMakeCommands/target_link_options/CMakeLists.txt @@ -0,0 +1,19 @@ + +cmake_minimum_required(VERSION 3.11) + +project(target_link_options LANGUAGES C) + +add_library(target_link_options SHARED LinkOptionsLib.c) +# Test no items +target_link_options(target_link_options PRIVATE) + +add_library(target_link_options_2 SHARED EXCLUDE_FROM_ALL LinkOptionsLib.c) +target_link_options(target_link_options_2 PRIVATE -PRIVATE_FLAG INTERFACE -INTERFACE_FLAG) +get_target_property(result target_link_options_2 LINK_OPTIONS) +if (NOT result MATCHES "-PRIVATE_FLAG") + message(SEND_ERROR "target_link_options not populated the LINK_OPTIONS target property") +endif() +get_target_property(result target_link_options_2 INTERFACE_LINK_OPTIONS) +if (NOT result MATCHES "-INTERFACE_FLAG") + message(SEND_ERROR "target_link_options not populated the INTERFACE_LINK_OPTIONS target property") +endif() diff --git a/Tests/CMakeCommands/target_link_options/LinkOptionsLib.c b/Tests/CMakeCommands/target_link_options/LinkOptionsLib.c new file mode 100644 index 0000000..9bbd24c --- /dev/null +++ b/Tests/CMakeCommands/target_link_options/LinkOptionsLib.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) +__declspec(dllexport) +#endif + int flags_lib(void) +{ + return 0; +} diff --git a/Tests/CMakeCommands/target_sources/CMakeLists.txt b/Tests/CMakeCommands/target_sources/CMakeLists.txt new file mode 100644 index 0000000..ab14855 --- /dev/null +++ b/Tests/CMakeCommands/target_sources/CMakeLists.txt @@ -0,0 +1,36 @@ + +cmake_minimum_required(VERSION 3.12) +cmake_policy(SET CMP0076 NEW) + +project(target_sources) + +add_library(target_sources_lib) +target_compile_definitions(target_sources_lib PRIVATE "-DIS_LIB") +add_subdirectory(subdir) + +set(subdir_fullpath "${CMAKE_CURRENT_LIST_DIR}/subdir") + +get_property(target_sources_lib_property TARGET target_sources_lib PROPERTY SOURCES) +if (NOT "$<1:${subdir_fullpath}/subdir_empty_1.cpp>" IN_LIST target_sources_lib_property) + message(SEND_ERROR "target_sources_lib: Generator expression to absolute sub directory file not found") +endif() +if (NOT "$<1:${subdir_fullpath}/../empty_1.cpp>" IN_LIST target_sources_lib_property) + message(SEND_ERROR "target_sources_lib: Generator expression to absolute main directory file not found") +endif() +if (NOT "${subdir_fullpath}/subdir_empty_2.cpp" IN_LIST target_sources_lib_property) + message(SEND_ERROR "target_sources_lib: Relative sub directory file not converted to absolute") +endif() +if (NOT "$<1:empty_2.cpp>" IN_LIST target_sources_lib_property) + message(SEND_ERROR "target_sources_lib: Generator expression to relative main directory file not found") +endif() +if (NOT "${subdir_fullpath}/../empty_3.cpp" IN_LIST target_sources_lib_property) + message(SEND_ERROR "target_sources_lib: Relative main directory file not converted to absolute") +endif() + +add_executable(target_sources main.cpp) +target_link_libraries(target_sources target_sources_lib) + +get_property(target_sources_property TARGET target_sources PROPERTY SOURCES) +if (NOT "main.cpp" IN_LIST target_sources_property) + message(SEND_ERROR "target_sources: Relative main directory file converted to absolute") +endif() diff --git a/Tests/CMakeCommands/target_sources/empty_1.cpp b/Tests/CMakeCommands/target_sources/empty_1.cpp new file mode 100644 index 0000000..01e5b07 --- /dev/null +++ b/Tests/CMakeCommands/target_sources/empty_1.cpp @@ -0,0 +1,21 @@ +#ifdef IS_LIB + +# ifdef _WIN32 +__declspec(dllexport) +# endif + int internal_empty_1() +{ + return 0; +} + +#else + +# ifdef _WIN32 +__declspec(dllexport) +# endif + int empty_1() +{ + return 0; +} + +#endif diff --git a/Tests/CMakeCommands/target_sources/empty_2.cpp b/Tests/CMakeCommands/target_sources/empty_2.cpp new file mode 100644 index 0000000..48ae8bb --- /dev/null +++ b/Tests/CMakeCommands/target_sources/empty_2.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty_2() +{ + return 0; +} diff --git a/Tests/CMakeCommands/target_sources/empty_3.cpp b/Tests/CMakeCommands/target_sources/empty_3.cpp new file mode 100644 index 0000000..bd3a6d1 --- /dev/null +++ b/Tests/CMakeCommands/target_sources/empty_3.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty_3() +{ + return 0; +} diff --git a/Tests/CMakeCommands/target_sources/main.cpp b/Tests/CMakeCommands/target_sources/main.cpp new file mode 100644 index 0000000..622771c --- /dev/null +++ b/Tests/CMakeCommands/target_sources/main.cpp @@ -0,0 +1,16 @@ +#include <iostream> + +int empty_1(); +int subdir_empty_1(); +int subdir_empty_2(); + +int main() +{ + int e1 = empty_1(); + int se1 = subdir_empty_1(); + int se2 = subdir_empty_2(); + + std::cout << e1 << " " << se1 << " " << se2 << std::endl; + + return 0; +} diff --git a/Tests/CMakeCommands/target_sources/subdir/CMakeLists.txt b/Tests/CMakeCommands/target_sources/subdir/CMakeLists.txt new file mode 100644 index 0000000..f749f1d --- /dev/null +++ b/Tests/CMakeCommands/target_sources/subdir/CMakeLists.txt @@ -0,0 +1,6 @@ + +target_sources(target_sources_lib PUBLIC $<1:${CMAKE_CURRENT_LIST_DIR}/subdir_empty_1.cpp> + $<1:${CMAKE_CURRENT_LIST_DIR}/../empty_1.cpp> + subdir_empty_2.cpp + PRIVATE $<1:empty_2.cpp> + ../empty_3.cpp) diff --git a/Tests/CMakeCommands/target_sources/subdir/subdir_empty_1.cpp b/Tests/CMakeCommands/target_sources/subdir/subdir_empty_1.cpp new file mode 100644 index 0000000..3c61321 --- /dev/null +++ b/Tests/CMakeCommands/target_sources/subdir/subdir_empty_1.cpp @@ -0,0 +1,21 @@ +#ifdef IS_LIB + +# ifdef _WIN32 +__declspec(dllexport) +# endif + int internal_subdir_empty_1() +{ + return 0; +} + +#else + +# ifdef _WIN32 +__declspec(dllexport) +# endif + int subdir_empty_1() +{ + return 0; +} + +#endif diff --git a/Tests/CMakeCommands/target_sources/subdir/subdir_empty_2.cpp b/Tests/CMakeCommands/target_sources/subdir/subdir_empty_2.cpp new file mode 100644 index 0000000..47fa736 --- /dev/null +++ b/Tests/CMakeCommands/target_sources/subdir/subdir_empty_2.cpp @@ -0,0 +1,21 @@ +#ifdef IS_LIB + +# ifdef _WIN32 +__declspec(dllexport) +# endif + int internal_subdir_empty_2() +{ + return 0; +} + +#else + +# ifdef _WIN32 +__declspec(dllexport) +# endif + int subdir_empty_2() +{ + return 0; +} + +#endif diff --git a/Tests/CMakeLib/testRST.expect b/Tests/CMakeLib/testRST.expect index 1ffd6b9..d7b91d1 100644 --- a/Tests/CMakeLib/testRST.expect +++ b/Tests/CMakeLib/testRST.expect @@ -19,6 +19,7 @@ Variable ``VARIABLE_<PLACEHOLDER>`` with trailing placeholder and target. Environment variable ``SOME_ENV_VAR``. Environment variable ``some env var`` with space and target. Generator ``Some Generator`` with space. +Generator ``Some Generator`` with space. Inline literal ``~!@#$%^&*( )_+-=\\[]{}'":;,<>.?/``. Inline link Link Text. Inline link Link Text <With \-escaped Brackets>. diff --git a/Tests/CMakeLib/testRST.rst b/Tests/CMakeLib/testRST.rst index c8587c0..633219f 100644 --- a/Tests/CMakeLib/testRST.rst +++ b/Tests/CMakeLib/testRST.rst @@ -26,6 +26,7 @@ Variable :variable:`VARIABLE_<PLACEHOLDER> <target>` with trailing placeholder a Environment variable :envvar:`SOME_ENV_VAR`. Environment variable :envvar:`some env var <SOME_ENV_VAR>` with space and target. Generator :generator:`Some Generator` with space. +Generator :cpack_gen:`Some Generator` with space. Inline literal ``~!@#$%^&*( )_+-=\\[]{}'":;,<>.?/``. Inline link `Link Text <ExternalDest>`_. Inline link `Link Text \<With \\-escaped Brackets\> <ExternalDest>`_. diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index b8b724e..971d7ff 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -869,33 +869,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BuildDepends") - set(SimpleInstallInstallDir - "${CMake_BINARY_DIR}/Tests/SimpleInstall/InstallDirectory") - add_test(SimpleInstall ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/SimpleInstall" - "${CMake_BINARY_DIR}/Tests/SimpleInstall" - ${build_generator_args} - --build-project TestSimpleInstall - --build-two-config - --build-options ${build_options} - "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" - "-DCTEST_TEST_CPACK:BOOL=${CTEST_TEST_CPACK}" - --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExe) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstall") - add_test(SimpleInstall-Stage2 ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/SimpleInstallS2" - "${CMake_BINARY_DIR}/Tests/SimpleInstallS2" - ${build_generator_args} - --build-project TestSimpleInstall - --build-two-config - --build-options ${build_options} - "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" - "-DSTAGE2:BOOL=1" - --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstallS2") - set(MissingInstallInstallDir "${CMake_BINARY_DIR}/Tests/MissingInstall/InstallDirectory") add_test(MissingInstall ${CMAKE_CTEST_COMMAND} @@ -1821,7 +1794,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release set_tests_properties ( testdriver2 PROPERTIES DEPENDS testdriver1) set_tests_properties ( testdriver3 PROPERTIES DEPENDS testdriver2) set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1) - set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall) # Test static linking on toolchains known to support it. if(CMAKE_C_COMPILER_ID STREQUAL "GNU" @@ -1940,6 +1912,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release message(STATUS ".vcproj file association indicates VCExpress, avoiding MFC test") set(CTEST_RUN_MFC OFF) + elseif( NOT ov ) + message(STATUS + ".vcproj has no file association, avoiding MFC test") + set(CTEST_RUN_MFC OFF) endif() endif() @@ -2256,7 +2232,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-generator "Green Hills MULTI" --build-project ReturnNum --build-config $<CONFIGURATION> - --build-options -DGHS_PRIMARY_TARGET="arm_integrity.tgt" + --build-options -DGHS_PRIMARY_TARGET=arm_integrity.tgt -DGHS_BSP_NAME="simarm" ) endif () @@ -2843,6 +2819,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories) ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions) ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options) + ADD_TEST_MACRO(CMakeCommands.target_sources target_sources) + + ADD_TEST_MACRO(CMakeCommands.add_link_options) + ADD_TEST_MACRO(CMakeCommands.target_link_options) # The cmake server-mode test requires python for a simple client. find_package(PythonInterp QUIET) @@ -3437,10 +3417,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) endif() - add_test(NAME CMakeWizardTest COMMAND cmake -i) - set_property(TEST CMakeWizardTest PROPERTY PASS_REGULAR_EXPRESSION - "The \"cmake -i\" wizard mode is no longer supported.") - # Define a set of "contract" tests, each activated by a cache entry # named "CMake_TEST_CONTRACT_<project>". For each Contract test, # the project should provide a directory with a CMakeLists.txt file diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in index 76f5e4f..f517e64 100644 --- a/Tests/CMakeTests/ListTest.cmake.in +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -53,6 +53,10 @@ set(result andy brad) list(INSERT result -1 bill ken) TEST("INSERT result -1 bill ken" "andy;bill;ken;brad") +set(result andy brad) +list(INSERT result 2 bill ken) +TEST("INSERT result 2 bill ken" "andy;brad;bill;ken") + set(result andy bill brad ken bob) list(REMOVE_ITEM result bob) TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken") diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index 59f3e84..5b7c0e6 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -1,4 +1,5 @@ +ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine) ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard) ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX) ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) diff --git a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt new file mode 100644 index 0000000..c978e51 --- /dev/null +++ b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.7) +project (CudaOnlyCircularLinkLine CUDA) + +#Goal for this example: +# Verify that we de-duplicate the device link line +# Verify that a de-duplicated link line still works with circular static libraries + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30]") +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CUDA_STANDARD 11) + +add_library(CUDACircularDeviceLinking1 STATIC file1.cu) +add_library(CUDACircularDeviceLinking2 STATIC file2.cu) +add_library(CUDACircularDeviceLinking3 STATIC file3.cu) +add_executable(CudaOnlyCircularLinkLine main.cu) + +target_link_libraries(CUDACircularDeviceLinking1 PUBLIC CUDACircularDeviceLinking2) +target_link_libraries(CUDACircularDeviceLinking2 PUBLIC CUDACircularDeviceLinking3) +target_link_libraries(CUDACircularDeviceLinking3 PUBLIC CUDACircularDeviceLinking1) + +target_link_libraries(CudaOnlyCircularLinkLine PRIVATE CUDACircularDeviceLinking3) + + +set_target_properties(CUDACircularDeviceLinking1 + PROPERTIES + CUDA_SEPARABLE_COMPILATION ON) + +set_target_properties(CUDACircularDeviceLinking2 + PROPERTIES + CUDA_SEPARABLE_COMPILATION ON) + +set_target_properties(CUDACircularDeviceLinking3 + PROPERTIES + CUDA_SEPARABLE_COMPILATION ON) diff --git a/Tests/CudaOnly/CircularLinkLine/file1.cu b/Tests/CudaOnly/CircularLinkLine/file1.cu new file mode 100644 index 0000000..88ac4e3 --- /dev/null +++ b/Tests/CudaOnly/CircularLinkLine/file1.cu @@ -0,0 +1,6 @@ + +extern __device__ int file2_func(int); +int __device__ file1_func(int x) +{ + return file2_func(x); +} diff --git a/Tests/CudaOnly/CircularLinkLine/file2.cu b/Tests/CudaOnly/CircularLinkLine/file2.cu new file mode 100644 index 0000000..b32dbff --- /dev/null +++ b/Tests/CudaOnly/CircularLinkLine/file2.cu @@ -0,0 +1,6 @@ + +extern __device__ int file3_func(int); +int __device__ file2_func(int x) +{ + return x + file3_func(x); +} diff --git a/Tests/CudaOnly/CircularLinkLine/file3.cu b/Tests/CudaOnly/CircularLinkLine/file3.cu new file mode 100644 index 0000000..7f67187 --- /dev/null +++ b/Tests/CudaOnly/CircularLinkLine/file3.cu @@ -0,0 +1,8 @@ + +extern __device__ int file1_func(int); +int __device__ file3_func(int x) +{ + if (x > 0) + return file1_func(-x); + return x; +} diff --git a/Tests/CudaOnly/CircularLinkLine/main.cu b/Tests/CudaOnly/CircularLinkLine/main.cu new file mode 100644 index 0000000..1c19e8d --- /dev/null +++ b/Tests/CudaOnly/CircularLinkLine/main.cu @@ -0,0 +1,5 @@ + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 0f1a556..fdb2fa1 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -510,9 +510,9 @@ install( cmp0022NEW cmp0022OLD systemlib EXPORT exp - RUNTIME DESTINATION $<1:bin> - LIBRARY DESTINATION $<1:lib> NAMELINK_SKIP - ARCHIVE DESTINATION $<1:lib> + RUNTIME DESTINATION $<1:bin>$<0:/wrong> + LIBRARY DESTINATION $<1:lib>$<0:/wrong> NAMELINK_SKIP + ARCHIVE DESTINATION $<1:lib>$<0:/wrong> ${maybe_OBJECTS_DESTINATION} FRAMEWORK DESTINATION Frameworks BUNDLE DESTINATION Applications @@ -597,3 +597,27 @@ install( ) install(DIRECTORY $<1:include/abs>$<0:/wrong> DESTINATION $<1:include>$<0:/wrong>) install(EXPORT expAbs NAMESPACE expAbs_ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/expAbs) + + +#------------------------------------------------------------------------------ +# test export of INTERFACE_LINK_OPTIONS +add_library(testLinkOptions INTERFACE) +target_link_options(testLinkOptions INTERFACE INTERFACE_FLAG) + +install(TARGETS testLinkOptions + EXPORT RequiredExp DESTINATION lib) +export(TARGETS testLinkOptions NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake) + + +#------------------------------------------------------------------------------ +# test export of INTERFACE_LINK_DEPENDS +if(CMAKE_GENERATOR MATCHES "Make|Ninja") + add_library(testLinkDepends INTERFACE) + set_property(TARGET testLinkDepends PROPERTY INTERFACE_LINK_DEPENDS + $<BUILD_INTERFACE:BUILD_LINK_DEPENDS> + $<INSTALL_INTERFACE:INSTALL_LINK_DEPENDS>) + + install(TARGETS testLinkDepends + EXPORT RequiredExp DESTINATION lib) + export(TARGETS testLinkDepends NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake) +endif() diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 39a89dc..7510d7e 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -472,3 +472,15 @@ if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREA endif() endif() endif() + +#--------------------------------------------------------------------------------- +# check that imported libraries have the expected INTERFACE_LINK_OPTIONS property +checkForProperty(bld_testLinkOptions "INTERFACE_LINK_OPTIONS" "INTERFACE_FLAG") +checkForProperty(Req::testLinkOptions "INTERFACE_LINK_OPTIONS" "INTERFACE_FLAG") + +#--------------------------------------------------------------------------------- +# check that imported libraries have the expected INTERFACE_LINK_DEPENDS property +if(CMAKE_GENERATOR MATCHES "Make|Ninja") + checkForProperty(bld_testLinkDepends "INTERFACE_LINK_DEPENDS" "BUILD_LINK_DEPENDS") + checkForProperty(Req::testLinkDepends "INTERFACE_LINK_DEPENDS" "${CMAKE_INSTALL_PREFIX}/INSTALL_LINK_DEPENDS") +endif() diff --git a/Tests/ExportImport/Import/A/imp_testLinkOptions.cpp b/Tests/ExportImport/Import/A/imp_testLinkOptions.cpp new file mode 100644 index 0000000..2b18b2e --- /dev/null +++ b/Tests/ExportImport/Import/A/imp_testLinkOptions.cpp @@ -0,0 +1,8 @@ + +#include "testSharedLibRequired.h" + +int foo() +{ + TestSharedLibRequired req; + return req.foo(); +} diff --git a/Tests/MathTest/CMakeLists.txt b/Tests/MathTest/CMakeLists.txt index f764b3a..5403d29 100644 --- a/Tests/MathTest/CMakeLists.txt +++ b/Tests/MathTest/CMakeLists.txt @@ -13,14 +13,35 @@ set(expressions "-1 + +1" "+1 - -1" "+1 - - + + -(-3 + - - +1)" + "1000 -12*5" + "1000 +12*-5" + "1000 -12*-5" ) -set(FILE_EXPRESSIONS "") -foreach(expression - ${expressions}) - math(EXPR expr "${expression}") - string(APPEND FILE_EXPRESSIONS "TEST_EXPRESSION(${expression}, ${expr})\n") -endforeach() +set(FILE_EXPRESSIONS "extern void test_expression(int x, int y, const char * text);\n") + + +macro(add_math_test expression) + math(EXPR result ${expression} ${ARGV1} ${ARGV2}) + set(CODE "test_expression(${expression}, ${result}, \"${expression}\");") + string(APPEND FILE_EXPRESSIONS "${CODE}\n") +endmacro() + +macro(add_math_tests) + foreach (expression ${expressions}) + add_math_test(${expression} ${ARGV0} ${ARGV1}) + endforeach () +endmacro() + +add_math_tests() +add_math_tests("OUTPUT_FORMAT" "DECIMAL") +add_math_tests("OUTPUT_FORMAT" "HEXADECIMAL") + +# Avoid the test with negative result and hexadecimal formatting +# therefore more tests with a negative result +add_math_test("-12*5") +add_math_test("12*-5") + configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/MathTestTests.h.in" diff --git a/Tests/MathTest/MathTestExec.cxx b/Tests/MathTest/MathTestExec.cxx index 124eba4..fbcddc4 100644 --- a/Tests/MathTest/MathTestExec.cxx +++ b/Tests/MathTest/MathTestExec.cxx @@ -1,21 +1,43 @@ #include <stdio.h> +#include <stdlib.h> +#include <string.h> -#define TEST_EXPRESSION(x, y) \ - if ((x) != (y)) { \ - printf("Problem with EXPR: Expression: \"%s\" in C returns %d while in " \ - "CMake returns: %d\n", \ - #x, (x), (y)); \ - res++; \ +int res = 0; +bool print = false; + +void test_expression(int x, int y, const char* text) +{ + bool fail = (x) != (y); + if (fail) { + res++; + printf("Problem with EXPR:"); + } + if (fail || print) { + printf("Expression: \"%s\" in CMake returns %d", text, (y)); + if (fail) { + printf(" while in C returns: %d", (x)); + } + printf("\n"); } +} int main(int argc, char* argv[]) { - if (argc > 1) { - printf("Usage: %s\n", argv[0]); + if (argc > 2) { + printf("Usage: %s [print]\n", argv[0]); return 1; } - int res = 0; + + if (argc > 1) { + if (strcmp(argv[1], "print") != 0) { + printf("Usage: %s [print]\n", argv[0]); + return 1; + } + print = true; + } + #include "MathTestTests.h" + if (res != 0) { printf("%s: %d math tests failed\n", argv[0], res); return 1; diff --git a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt index 0bb0339..6fad80c 100644 --- a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt @@ -16,6 +16,7 @@ try_compile(MOC_RERUN "${mocBasicSrcDir}" MocBasic CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" OUTPUT_VARIABLE output ) diff --git a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt index 8a89b38..b5287c1 100644 --- a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt @@ -19,6 +19,7 @@ try_compile(MOC_PLUGIN "${mocPlugSrcDir}" MocPlugin CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" OUTPUT_VARIABLE output ) diff --git a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt index f09865d..4dc24fe 100644 --- a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt @@ -19,6 +19,7 @@ try_compile(RCC_DEPENDS "${rccDepSD}" RccConfigChange CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" OUTPUT_VARIABLE output ) diff --git a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt index 52e2488..4268de2 100644 --- a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt @@ -21,6 +21,7 @@ try_compile(RCC_DEPENDS "${rccDepSD}" RccDepends CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" OUTPUT_VARIABLE output ) diff --git a/Tests/QtAutogen/TestMacros.cmake b/Tests/QtAutogen/TestMacros.cmake index bc7c7e2..8e4bea2 100644 --- a/Tests/QtAutogen/TestMacros.cmake +++ b/Tests/QtAutogen/TestMacros.cmake @@ -4,6 +4,7 @@ if(NOT _isMultiConfig) # Set in Tests/CMakeLists.txt list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_BUILD_TYPE=$<CONFIGURATION>") endif() list(APPEND Autogen_BUILD_OPTIONS + "-DCMAKE_AUTOGEN_VERBOSE=1" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" ) diff --git a/Tests/RunCMake/AndroidMK/AndroidMK.cmake b/Tests/RunCMake/AndroidMK/AndroidMK.cmake index 3fbb2cf..9137f2b 100644 --- a/Tests/RunCMake/AndroidMK/AndroidMK.cmake +++ b/Tests/RunCMake/AndroidMK/AndroidMK.cmake @@ -5,7 +5,9 @@ add_library(car foo.cxx) add_library(bar bar.c) add_library(dog foo.cxx) target_link_libraries(foo PRIVATE car bar dog debug -lm) -export(TARGETS bar dog car foo ANDROID_MK +add_library(foo2 foo.cxx) +target_link_options(foo2 INTERFACE -lm) +export(TARGETS bar dog car foo foo2 ANDROID_MK ${build_BINARY_DIR}/Android.mk) -install(TARGETS bar dog car foo DESTINATION lib EXPORT myexp) +install(TARGETS bar dog car foo foo2 DESTINATION lib EXPORT myexp) install(EXPORT_ANDROID_MK myexp DESTINATION share/ndk-modules) diff --git a/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt index bbf67a5..a0e5044 100644 --- a/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt +++ b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt @@ -24,3 +24,11 @@ LOCAL_STATIC_LIBRARIES.*car bar dog LOCAL_EXPORT_LDLIBS := -lm LOCAL_HAS_CPP := true include.*PREBUILT_STATIC_LIBRARY.* +.* +include.*CLEAR_VARS.* +LOCAL_MODULE.*foo2 +LOCAL_SRC_FILES.*.*foo2.* +LOCAL_CPP_FEATURES.*rtti exceptions +LOCAL_EXPORT_LDFLAGS := -lm +LOCAL_HAS_CPP := true +include.*PREBUILT_STATIC_LIBRARY.* diff --git a/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt index 3515fb9..28b1c21 100644 --- a/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt +++ b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt @@ -26,3 +26,11 @@ LOCAL_STATIC_LIBRARIES.*car bar dog LOCAL_EXPORT_LDLIBS := -lm LOCAL_HAS_CPP := true include.*PREBUILT_STATIC_LIBRARY.* + +include.*CLEAR_VARS.* +LOCAL_MODULE.*foo2 +LOCAL_SRC_FILES.*_IMPORT_PREFIX\)/lib.*foo2.* +LOCAL_CPP_FEATURES.*rtti exceptions +LOCAL_EXPORT_LDFLAGS := -lm +LOCAL_HAS_CPP := true +include.*PREBUILT_STATIC_LIBRARY.* diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 637c5c2..c030cda 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -238,7 +238,9 @@ add_RunCMake_test(include) add_RunCMake_test(include_directories) add_RunCMake_test(include_guard) add_RunCMake_test(list) +add_RunCMake_test(math) add_RunCMake_test(message) +add_RunCMake_test(option) add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES}) add_RunCMake_test(project_injected) add_RunCMake_test(return) @@ -333,6 +335,8 @@ endif() add_RunCMake_test(File_Generate) add_RunCMake_test(ExportWithoutLanguage) add_RunCMake_test(target_link_libraries) +add_RunCMake_test(add_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) +add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) add_RunCMake_test(target_compile_features) add_RunCMake_test(CheckModules) @@ -421,7 +425,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") add_RunCMake_test(ctest_labels_for_subprojects) endif() -add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ") +add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;Ext") # add a test to make sure symbols are exported from a shared library # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used add_RunCMake_test(AutoExportDll) diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake index 447b08b..8c9f4b4 100644 --- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake +++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake @@ -1,10 +1,14 @@ cmake_policy(SET CMP0057 NEW) -function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACKAGING_TYPE) +function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACKAGING_TYPE package_target) if(TEST_TYPE IN_LIST types) set(RunCMake_TEST_NO_CLEAN TRUE) - set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build") - set(full_test_name_ "${TEST_NAME}") + if(package_target) + set(full_test_name_ "${TEST_NAME}-package-target") + else() + set(full_test_name_ "${TEST_NAME}") + endif() + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${full_test_name_}-build") if(SUBTEST_SUFFIX) set(RunCMake_TEST_BINARY_DIR "${RunCMake_TEST_BINARY_DIR}-${SUBTEST_SUFFIX}-subtest") @@ -67,9 +71,15 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACK unset(pack_params_) endif() + if(package_target) + set(cpack_command_ ${CMAKE_COMMAND} --build "${RunCMake_TEST_BINARY_DIR}" --target package) + else() + set(cpack_command_ ${CMAKE_CPACK_COMMAND} ${pack_params_}) + endif() + # execute cpack execute_process( - COMMAND ${CMAKE_CPACK_COMMAND} ${pack_params_} + COMMAND ${cpack_command_} WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" RESULT_VARIABLE "result_" OUTPUT_FILE "${RunCMake_TEST_BINARY_DIR}/test_output.txt" @@ -113,18 +123,24 @@ endfunction() function(run_cpack_test TEST_NAME types build PACKAGING_TYPES) foreach(packaging_type_ IN LISTS PACKAGING_TYPES) - run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false "${packaging_type_}") + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false "${packaging_type_}" false) + endforeach() +endfunction() + +function(run_cpack_test_package_target TEST_NAME types build PACKAGING_TYPES) + foreach(packaging_type_ IN LISTS PACKAGING_TYPES) + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false "${packaging_type_}" true) endforeach() endfunction() function(run_cpack_test_subtests TEST_NAME SUBTEST_SUFFIXES types build PACKAGING_TYPES) foreach(suffix_ IN LISTS SUBTEST_SUFFIXES) foreach(packaging_type_ IN LISTS PACKAGING_TYPES) - run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false "${packaging_type_}") + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false "${packaging_type_}" false) endforeach() endforeach() endfunction() function(run_cpack_source_test TEST_NAME types) - run_cpack_test_common_("${TEST_NAME}" "${types}" false "" true "") + run_cpack_test_common_("${TEST_NAME}" "${types}" false "" true "" false) endfunction() diff --git a/Tests/RunCMake/CPack/Ext/Helpers.cmake b/Tests/RunCMake/CPack/Ext/Helpers.cmake new file mode 100644 index 0000000..2c67e06 --- /dev/null +++ b/Tests/RunCMake/CPack/Ext/Helpers.cmake @@ -0,0 +1,31 @@ +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + set(${RESULT_VAR} "${NAME}-${VERSION}-*.json" PARENT_SCOPE) +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + set("${RESULT_VAR}" "" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + set("${CONTENT_VAR}" "" PARENT_SCOPE) +endfunction() + +set(ALL_FILES_GLOB "*.json") + +function(check_ext_json EXPECTED_FILE ACTUAL_FILE) + file(READ "${EXPECTED_FILE}" _expected_regex) + file(READ "${ACTUAL_FILE}" _actual_contents) + + string(REGEX REPLACE "\n+$" "" _expected_regex "${_expected_regex}") + string(REGEX REPLACE "\n+$" "" _actual_contents "${_actual_contents}") + + if(NOT "${_actual_contents}" MATCHES "${_expected_regex}") + message(FATAL_ERROR + "Output JSON does not match expected regex.\n" + "Expected regex:\n" + "${_expected_regex}\n" + "Actual output:\n" + "${_actual_contents}\n" + ) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/Ext/Prerequirements.cmake b/Tests/RunCMake/CPack/Ext/Prerequirements.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CPack/Ext/Prerequirements.cmake diff --git a/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt b/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt index 4a0e4e6..f02f9d6 100644 --- a/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt +++ b/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt @@ -1 +1 @@ -^(CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM/CPack/[^-]*-build((-[^-]*-subtest/)|/)_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec(\n|$))*$ +^(CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM/CPack/[^-]*(-package-target)?-build((-[^-]*-subtest/)|/)_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec(\n|$))*$ diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 4b7f146..33ffa14 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -18,7 +18,8 @@ run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT") run_cpack_test(INSTALL_SCRIPTS "RPM" false "COMPONENT") run_cpack_test(LONG_FILENAMES "DEB" false "MONOLITHIC") run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false "COMPONENT") -run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ" false "MONOLITHIC;COMPONENT") +run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;Ext" false "MONOLITHIC;COMPONENT") +run_cpack_test_package_target(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;Ext" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC") run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT") run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT") @@ -31,3 +32,4 @@ run_cpack_test(USER_FILELIST "RPM" false "MONOLITHIC") run_cpack_test(MD5SUMS "DEB" false "MONOLITHIC;COMPONENT") run_cpack_test(CPACK_INSTALL_SCRIPT "ZIP" false "MONOLITHIC") run_cpack_test(DEB_PACKAGE_VERSION_BACK_COMPATIBILITY "DEB" false "MONOLITHIC;COMPONENT") +run_cpack_test_subtests(EXT "none;good;good_multi;bad_major;bad_minor;invalid_good;invalid_bad" "Ext" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index 1f5ab87..af12d37 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -56,8 +56,12 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0) set(EXPECTED_FILE_CONTENT_${file_no_} "${EXPECTED_FILE_CONTENT_${file_no_}_LIST}") toExpectedContentList("${file_no_}" "EXPECTED_FILE_CONTENT_${file_no_}") - list(SORT PACKAGE_CONTENT) - list(SORT EXPECTED_FILE_CONTENT_${file_no_}) + if(NOT PACKAGE_CONTENT STREQUAL "") + list(SORT PACKAGE_CONTENT) + endif() + if(NOT EXPECTED_FILE_CONTENT_${file_no_} STREQUAL "") + list(SORT EXPECTED_FILE_CONTENT_${file_no_}) + endif() if(PACKAGE_CONTENT STREQUAL EXPECTED_FILE_CONTENT_${file_no_}) set(expected_content_list TRUE) diff --git a/Tests/RunCMake/CPack/tests/EXT/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EXT/ExpectedFiles.cmake new file mode 100644 index 0000000..2634111 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXT/ExpectedFiles.cmake @@ -0,0 +1,6 @@ +if(RunCMake_SUBTEST_SUFFIX MATCHES "^(none|good(_multi)?|invalid_good)$") + set(EXPECTED_FILES_COUNT "1") + set(EXPECTED_FILE_CONTENT_1_LIST "/share;/share/cpack-test;/share/cpack-test/f1.txt;/share/cpack-test/f2.txt;/share/cpack-test/f3.txt;/share/cpack-test/f4.txt") +else() + set(EXPECTED_FILES_COUNT "0") +endif() diff --git a/Tests/RunCMake/CPack/tests/EXT/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/EXT/VerifyResult.cmake new file mode 100644 index 0000000..97b74f7 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXT/VerifyResult.cmake @@ -0,0 +1,3 @@ +if(RunCMake_SUBTEST_SUFFIX MATCHES "^(none|good(_multi)?|invalid_good)") + check_ext_json("${src_dir}/tests/EXT/expected-json-1.0.txt" "${FOUND_FILE_1}") +endif() diff --git a/Tests/RunCMake/CPack/tests/EXT/bad_major-stderr.txt b/Tests/RunCMake/CPack/tests/EXT/bad_major-stderr.txt new file mode 100644 index 0000000..372c5e4 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXT/bad_major-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/Internal/CPack/CPackExt\.cmake:[0-9]+ \(message\): + Could not find a suitable version in CPACK_EXT_REQUESTED_VERSIONS + + +CPack Error: Error while executing CPackExt\.cmake +CPack Error: Cannot initialize the generator Ext diff --git a/Tests/RunCMake/CPack/tests/EXT/bad_minor-stderr.txt b/Tests/RunCMake/CPack/tests/EXT/bad_minor-stderr.txt new file mode 100644 index 0000000..372c5e4 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXT/bad_minor-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/Internal/CPack/CPackExt\.cmake:[0-9]+ \(message\): + Could not find a suitable version in CPACK_EXT_REQUESTED_VERSIONS + + +CPack Error: Error while executing CPackExt\.cmake +CPack Error: Cannot initialize the generator Ext diff --git a/Tests/RunCMake/CPack/tests/EXT/expected-json-1.0.txt b/Tests/RunCMake/CPack/tests/EXT/expected-json-1.0.txt new file mode 100644 index 0000000..b96cf0b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXT/expected-json-1.0.txt @@ -0,0 +1,176 @@ +^\{ + "componentGroups" :[ ] + \{ + "f12" :[ ] + \{ + "components" :[ ] + \[ + "f1", + "f2" + \], + "description" : "Component group for files 1 and 2", + "displayName" : "Files 1 and 2", + "isBold" : false, + "isExpandedByDefault" : false, + "name" : "f12", + "parentGroup" : "f1234", + "subgroups" : \[\] + \}, + "f1234" :[ ] + \{ + "components" : \[\], + "description" : "Component group for all files", + "displayName" : "Files 1-4", + "isBold" : false, + "isExpandedByDefault" : false, + "name" : "f1234", + "subgroups" :[ ] + \[ + "f12", + "f34" + \] + \}, + "f34" :[ ] + \{ + "components" :[ ] + \[ + "f3", + "f4" + \], + "description" : "Component group for files 3 and 4", + "displayName" : "Files 3 and 4", + "isBold" : false, + "isExpandedByDefault" : false, + "name" : "f34", + "parentGroup" : "f1234", + "subgroups" : \[\] + \} + \}, + "components" :[ ] + \{ + "f1" :[ ] + \{ + "archiveFile" : "", + "dependencies" : \[\], + "description" : "Component for file 1", + "displayName" : "File 1", + "group" : "f12", + "installationTypes" :[ ] + \[ + "full", + "f12" + \], + "isDisabledByDefault" : false, + "isDownloaded" : false, + "isHidden" : false, + "isRequired" : false, + "name" : "f1" + \}, + "f2" :[ ] + \{ + "archiveFile" : "", + "dependencies" :[ ] + \[ + "f1" + \], + "description" : "Component for file 2", + "displayName" : "File 2", + "group" : "f12", + "installationTypes" :[ ] + \[ + "full", + "f12" + \], + "isDisabledByDefault" : false, + "isDownloaded" : false, + "isHidden" : false, + "isRequired" : false, + "name" : "f2" + \}, + "f3" :[ ] + \{ + "archiveFile" : "", + "dependencies" :[ ] + \[ + "f1", + "f2" + \], + "description" : "Component for file 3", + "displayName" : "File 3", + "group" : "f34", + "installationTypes" :[ ] + \[ + "full" + \], + "isDisabledByDefault" : false, + "isDownloaded" : false, + "isHidden" : false, + "isRequired" : false, + "name" : "f3" + \}, + "f4" :[ ] + \{ + "archiveFile" : "", + "dependencies" :[ ] + \[ + "f2", + "f3", + "f1" + \], + "description" : "Component for file 4", + "displayName" : "File 4", + "group" : "f34", + "installationTypes" :[ ] + \[ + "full" + \], + "isDisabledByDefault" : false, + "isDownloaded" : false, + "isHidden" : false, + "isRequired" : false, + "name" : "f4" + \} + \}, + "errorOnAbsoluteInstallDestination" : false, + "formatVersionMajor" : 1, + "formatVersionMinor" : 0, + "installationTypes" :[ ] + \{ + "f12" :[ ] + \{ + "displayName" : "Only files 1 and 2", + "index" : 2, + "name" : "f12" + \}, + "full" :[ ] + \{ + "displayName" : "Full installation", + "index" : 1, + "name" : "full" + \} + \}, + "packageDescriptionFile" : ".*/Templates/CPack\.GenericDescription\.txt", + "packageDescriptionSummary" : "EXT-(none|good(_multi)?|invalid_good)-subtest-(MONOLITHIC|COMPONENT)-type built using CMake", + "packageName" : "ext", + "packageVersion" : "0\.1\.1", + "projects" :[ ] + \[ + \{ + "component" : "ALL", + "components" :[ ] + \[ + "f1", + "f2", + "f3", + "f4" + \], + "directory" : ".*/Tests/RunCMake/Ext/CPack/EXT-build-(none|good(_multi)?|invalid_good)-subtest", + "installationTypes" : \[\], + "projectName" : "EXT-(none|good(_multi)?|invalid_good)-subtest-(MONOLITHIC|COMPONENT)-type", + "subDirectory" : "/" + \} + \], + "setDestdir" : false, + "stripFiles" : false, + "warnOnAbsoluteInstallDestination" : false +\}$ diff --git a/Tests/RunCMake/CPack/tests/EXT/invalid_bad-stderr.txt b/Tests/RunCMake/CPack/tests/EXT/invalid_bad-stderr.txt new file mode 100644 index 0000000..372c5e4 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXT/invalid_bad-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/Internal/CPack/CPackExt\.cmake:[0-9]+ \(message\): + Could not find a suitable version in CPACK_EXT_REQUESTED_VERSIONS + + +CPack Error: Error while executing CPackExt\.cmake +CPack Error: Cannot initialize the generator Ext diff --git a/Tests/RunCMake/CPack/tests/EXT/test.cmake b/Tests/RunCMake/CPack/tests/EXT/test.cmake new file mode 100644 index 0000000..6bd3cb8 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXT/test.cmake @@ -0,0 +1,83 @@ +include(CPackComponent) + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "none") + unset(CPACK_EXT_REQUESTED_VERSIONS) +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "good") + set(CPACK_EXT_REQUESTED_VERSIONS "1.0") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "good_multi") + set(CPACK_EXT_REQUESTED_VERSIONS "1.0;2.0") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "bad_major") + set(CPACK_EXT_REQUESTED_VERSIONS "2.0") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "bad_minor") + set(CPACK_EXT_REQUESTED_VERSIONS "1.1") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid_good") + set(CPACK_EXT_REQUESTED_VERSIONS "1;1.0") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid_bad") + set(CPACK_EXT_REQUESTED_VERSIONS "1") +endif() + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f1.txt" test1) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f2.txt" test2) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f3.txt" test3) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f4.txt" test4) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f1.txt" DESTINATION share/cpack-test COMPONENT f1) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f2.txt" DESTINATION share/cpack-test COMPONENT f2) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f3.txt" DESTINATION share/cpack-test COMPONENT f3) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f4.txt" DESTINATION share/cpack-test COMPONENT f4) + +cpack_add_component(f1 + DISPLAY_NAME "File 1" + DESCRIPTION "Component for file 1" + GROUP f12 + INSTALL_TYPES full f12 +) + +cpack_add_component(f2 + DISPLAY_NAME "File 2" + DESCRIPTION "Component for file 2" + GROUP f12 + DEPENDS f1 + INSTALL_TYPES full f12 +) + +cpack_add_component(f3 + DISPLAY_NAME "File 3" + DESCRIPTION "Component for file 3" + GROUP f34 + DEPENDS f1 f2 + INSTALL_TYPES full +) + +cpack_add_component(f4 + DISPLAY_NAME "File 4" + DESCRIPTION "Component for file 4" + GROUP f34 + DEPENDS f2 f3 f1 + INSTALL_TYPES full +) + +cpack_add_component_group(f12 + DISPLAY_NAME "Files 1 and 2" + DESCRIPTION "Component group for files 1 and 2" + PARENT_GROUP f1234 +) + +cpack_add_component_group(f34 + DISPLAY_NAME "Files 3 and 4" + DESCRIPTION "Component group for files 3 and 4" + PARENT_GROUP f1234 +) + +cpack_add_component_group(f1234 + DISPLAY_NAME "Files 1-4" + DESCRIPTION "Component group for all files" +) + +cpack_add_install_type(full + DISPLAY_NAME "Full installation" +) + +cpack_add_install_type(f12 + DISPLAY_NAME "Only files 1 and 2" +) diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 3bb2a89..cef2b9b 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.1) include(RunCMake) run_cmake_command(NoArgs ${CMAKE_COMMAND}) +run_cmake_command(Wizard ${CMAKE_COMMAND} -i) run_cmake_command(C-no-arg ${CMAKE_COMMAND} -C) run_cmake_command(C-no-file ${CMAKE_COMMAND} -C nosuchcachefile.txt) run_cmake_command(cache-no-file ${CMAKE_COMMAND} nosuchsubdir/CMakeCache.txt) diff --git a/Tests/RunCMake/list/SORT-TooManyArguments-result.txt b/Tests/RunCMake/CommandLine/Wizard-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/list/SORT-TooManyArguments-result.txt +++ b/Tests/RunCMake/CommandLine/Wizard-result.txt diff --git a/Tests/RunCMake/CommandLine/Wizard-stderr.txt b/Tests/RunCMake/CommandLine/Wizard-stderr.txt new file mode 100644 index 0000000..f757aff --- /dev/null +++ b/Tests/RunCMake/CommandLine/Wizard-stderr.txt @@ -0,0 +1 @@ +^The "cmake -i" wizard mode is no longer supported\. diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake index 1150568..24e7202 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -1,10 +1,12 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(FindPkgConfig_IMPORTED_TARGET C) find_package(PkgConfig REQUIRED) pkg_check_modules(NCURSES IMPORTED_TARGET QUIET ncurses) +message(STATUS "source: ${CMAKE_CURRENT_SOURCE_DIR} bin ${CMAKE_CURRENT_BINARY_DIR}") + if (NCURSES_FOUND) set(tgt PkgConfig::NCURSES) if (NOT TARGET ${tgt}) @@ -66,6 +68,16 @@ if (NOT TARGET PkgConfig::FakePackage1) message(FATAL_ERROR "No import target for fake package 1 with prefix path") endif() +# find targets in subdir and check their visibility +add_subdirectory(target_subdir) +if (TARGET PkgConfig::FakePackage1_dir) + message(FATAL_ERROR "imported target PkgConfig::FakePackage1_dir is visible outside it's directory") +endif() + +if (NOT TARGET PkgConfig::FakePackage1_global) + message(FATAL_ERROR "imported target PkgConfig::FakePackage1_global is not visible outside it's directory") +endif() + # And now do the same for the NO_CMAKE_ENVIRONMENT_PATH - ENV{CMAKE_PREFIX_PATH} # combination unset(CMAKE_PREFIX_PATH) diff --git a/Tests/RunCMake/FindPkgConfig/target_subdir/CMakeLists.txt b/Tests/RunCMake/FindPkgConfig/target_subdir/CMakeLists.txt new file mode 100644 index 0000000..2171ef6 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/target_subdir/CMakeLists.txt @@ -0,0 +1,5 @@ +# a target with visibility only in this directory +pkg_check_modules(FakePackage1_dir REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage1) + +# the same with global visibility +pkg_check_modules(FakePackage1_global REQUIRED QUIET IMPORTED_TARGET GLOBAL cmakeinternalfakepackage1) diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 5af6fcd..6c861fa 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -24,6 +24,7 @@ \* CMP0068 \* CMP0069 \* CMP0073 + \* CMP0076 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface-result.txt b/Tests/RunCMake/TargetSources/CMP0076-OLD-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/TargetSources/RelativePathInInterface-result.txt +++ b/Tests/RunCMake/TargetSources/CMP0076-OLD-result.txt diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface-stderr.txt b/Tests/RunCMake/TargetSources/CMP0076-OLD-stderr.txt index d47dd4d..d47dd4d 100644 --- a/Tests/RunCMake/TargetSources/RelativePathInInterface-stderr.txt +++ b/Tests/RunCMake/TargetSources/CMP0076-OLD-stderr.txt diff --git a/Tests/RunCMake/TargetSources/CMP0076-OLD.cmake b/Tests/RunCMake/TargetSources/CMP0076-OLD.cmake new file mode 100644 index 0000000..4d8c268 --- /dev/null +++ b/Tests/RunCMake/TargetSources/CMP0076-OLD.cmake @@ -0,0 +1,10 @@ +cmake_policy(SET CMP0076 OLD) + +add_library(iface INTERFACE) +target_sources(iface INTERFACE empty_1.cpp) + +get_property(iface_sources TARGET iface PROPERTY INTERFACE_SOURCES) +message(STATUS "iface: ${iface_sources}") + +add_executable(main main.cpp) +target_link_libraries(main iface) diff --git a/Tests/RunCMake/TargetSources/CMP0076-WARN-result.txt b/Tests/RunCMake/TargetSources/CMP0076-WARN-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetSources/CMP0076-WARN-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetSources/CMP0076-WARN-stderr.txt b/Tests/RunCMake/TargetSources/CMP0076-WARN-stderr.txt new file mode 100644 index 0000000..217c762 --- /dev/null +++ b/Tests/RunCMake/TargetSources/CMP0076-WARN-stderr.txt @@ -0,0 +1,21 @@ +CMake Warning \(dev\) at CMP0076-WARN/CMakeLists.txt:2 \(target_sources\): + Policy CMP0076 is not set: target_sources\(\) command converts relative paths + to absolute. Run "cmake --help-policy CMP0076" for policy details. Use + the cmake_policy command to set the policy and suppress this warning. + + An interface source of target "publiclib" has a relative path. +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning \(dev\) at CMP0076-WARN/CMakeLists.txt:2 \(target_sources\): + Policy CMP0076 is not set: target_sources\(\) command converts relative paths + to absolute. Run "cmake --help-policy CMP0076" for policy details. Use + the cmake_policy command to set the policy and suppress this warning. + + A private source from a directory other than that of target "publiclib" has + a relative path. +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Error in CMakeLists.txt: + Target "publiclib" contains relative path in its INTERFACE_SOURCES: + + "CMP0076-WARN/subdir_empty_1.cpp" diff --git a/Tests/RunCMake/TargetSources/CMP0076-WARN.cmake b/Tests/RunCMake/TargetSources/CMP0076-WARN.cmake new file mode 100644 index 0000000..2e07331 --- /dev/null +++ b/Tests/RunCMake/TargetSources/CMP0076-WARN.cmake @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.12) + +add_library(publiclib) + +add_subdirectory(CMP0076-WARN) + +add_executable(main main.cpp) +target_link_libraries(main publiclib) diff --git a/Tests/RunCMake/TargetSources/CMP0076-WARN/CMakeLists.txt b/Tests/RunCMake/TargetSources/CMP0076-WARN/CMakeLists.txt new file mode 100644 index 0000000..f9c7d6d --- /dev/null +++ b/Tests/RunCMake/TargetSources/CMP0076-WARN/CMakeLists.txt @@ -0,0 +1,3 @@ + +target_sources(publiclib INTERFACE CMP0076-WARN/subdir_empty_1.cpp + PRIVATE empty_1.cpp) diff --git a/Tests/RunCMake/TargetSources/CMP0076-WARN/subdir_empty_1.cpp b/Tests/RunCMake/TargetSources/CMP0076-WARN/subdir_empty_1.cpp new file mode 100644 index 0000000..11ec041 --- /dev/null +++ b/Tests/RunCMake/TargetSources/CMP0076-WARN/subdir_empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface-stdout.txt b/Tests/RunCMake/TargetSources/RelativePathInInterface-stdout.txt new file mode 100644 index 0000000..4581d8a --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInInterface-stdout.txt @@ -0,0 +1 @@ +-- iface: .*Tests/RunCMake/TargetSources/empty_1.cpp diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake b/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake index 8bb6149..0d3e9a4 100644 --- a/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake +++ b/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake @@ -1,6 +1,10 @@ +cmake_policy(SET CMP0076 NEW) add_library(iface INTERFACE) target_sources(iface INTERFACE empty_1.cpp) +get_property(iface_sources TARGET iface PROPERTY INTERFACE_SOURCES) +message(STATUS "iface: ${iface_sources}") + add_executable(main main.cpp) target_link_libraries(main iface) diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx-stdout.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx-stdout.txt new file mode 100644 index 0000000..7f48082 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx-stdout.txt @@ -0,0 +1 @@ +-- genexlib: \$<1:.*Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/subdir_empty_1.cpp>;\$<1:.*Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/../empty_1.cpp>;\$<1:empty_2.cpp> diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx.cmake b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx.cmake new file mode 100644 index 0000000..1cdc2a7 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx.cmake @@ -0,0 +1,10 @@ +cmake_policy(SET CMP0076 NEW) + +add_library(genexlib) +add_subdirectory(RelativePathInSubdirGenEx) + +get_property(genexlib_sources TARGET genexlib PROPERTY SOURCES) +message(STATUS "genexlib: ${genexlib_sources}") + +add_executable(genexmain main.cpp) +target_link_libraries(genexmain genexlib) diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/CMakeLists.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/CMakeLists.txt new file mode 100644 index 0000000..3bcf454 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/CMakeLists.txt @@ -0,0 +1,4 @@ + +target_sources(genexlib PUBLIC $<1:${CMAKE_CURRENT_LIST_DIR}/subdir_empty_1.cpp> + $<1:${CMAKE_CURRENT_LIST_DIR}/../empty_1.cpp> + PRIVATE $<1:empty_2.cpp>) diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/subdir_empty_1.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/subdir_empty_1.cpp new file mode 100644 index 0000000..11ec041 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/subdir_empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude-stdout.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude-stdout.txt new file mode 100644 index 0000000..aa4851f --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude-stdout.txt @@ -0,0 +1 @@ +-- privatelib: .*Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/subdir_empty_1.cpp;empty_1.cpp diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude.cmake b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude.cmake new file mode 100644 index 0000000..4acbeca --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude.cmake @@ -0,0 +1,8 @@ +cmake_policy(SET CMP0076 NEW) + +add_library(privatelib) + +include("RelativePathInSubdirInclude/CMakeLists.txt") + +get_property(privatelib_sources TARGET privatelib PROPERTY SOURCES) +message(STATUS "privatelib: ${privatelib_sources}") diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/CMakeLists.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/CMakeLists.txt new file mode 100644 index 0000000..3dcb135 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/CMakeLists.txt @@ -0,0 +1,3 @@ + +target_sources(privatelib PRIVATE "${CMAKE_CURRENT_LIST_DIR}/subdir_empty_1.cpp" + empty_1.cpp) diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/subdir_empty_1.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/subdir_empty_1.cpp new file mode 100644 index 0000000..11ec041 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/subdir_empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface-stdout.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface-stdout.txt new file mode 100644 index 0000000..5990a05 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface-stdout.txt @@ -0,0 +1 @@ +-- iface: .*Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_1.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_2.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/../empty_1.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/../empty_2.cpp diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface.cmake b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface.cmake new file mode 100644 index 0000000..3652b4f --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface.cmake @@ -0,0 +1,11 @@ +cmake_policy(SET CMP0076 NEW) + +add_library(iface INTERFACE) + +add_subdirectory(RelativePathInSubdirInterface) + +get_property(iface_sources TARGET iface PROPERTY INTERFACE_SOURCES) +message(STATUS "iface: ${iface_sources}") + +add_executable(main main.cpp) +target_link_libraries(main iface) diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/CMakeLists.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/CMakeLists.txt new file mode 100644 index 0000000..02e6966 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/CMakeLists.txt @@ -0,0 +1,5 @@ + +target_sources(iface INTERFACE subdir_empty_1.cpp + "${CMAKE_CURRENT_LIST_DIR}/subdir_empty_2.cpp" + ../empty_1.cpp + "${CMAKE_CURRENT_LIST_DIR}/../empty_2.cpp") diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_1.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_1.cpp new file mode 100644 index 0000000..11ec041 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_2.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_2.cpp new file mode 100644 index 0000000..11ec041 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_2.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate-stdout.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate-stdout.txt new file mode 100644 index 0000000..fa5bcbf --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate-stdout.txt @@ -0,0 +1 @@ +-- privatelib: .*Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_1.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_2.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/../empty_1.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/../empty_2.cpp diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate.cmake b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate.cmake new file mode 100644 index 0000000..d0d3dc4 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate.cmake @@ -0,0 +1,8 @@ +cmake_policy(SET CMP0076 NEW) + +add_library(privatelib) + +add_subdirectory(RelativePathInSubdirPrivate) + +get_property(privatelib_sources TARGET privatelib PROPERTY SOURCES) +message(STATUS "privatelib: ${privatelib_sources}") diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/CMakeLists.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/CMakeLists.txt new file mode 100644 index 0000000..56ee853 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/CMakeLists.txt @@ -0,0 +1,5 @@ + +target_sources(privatelib PRIVATE subdir_empty_1.cpp + "${CMAKE_CURRENT_LIST_DIR}/subdir_empty_2.cpp" + ../empty_1.cpp + "${CMAKE_CURRENT_LIST_DIR}/../empty_2.cpp") diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_1.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_1.cpp new file mode 100644 index 0000000..11ec041 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_2.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_2.cpp new file mode 100644 index 0000000..11ec041 --- /dev/null +++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_2.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake index 36d01de..bee8c4e 100644 --- a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake @@ -6,5 +6,11 @@ endif() run_cmake(OriginDebug) run_cmake(CMP0026-LOCATION) +run_cmake(CMP0076-OLD) +run_cmake(CMP0076-WARN) run_cmake(RelativePathInInterface) +run_cmake(RelativePathInSubdirGenEx) +run_cmake(RelativePathInSubdirInterface) +run_cmake(RelativePathInSubdirPrivate) +run_cmake(RelativePathInSubdirInclude) run_cmake(ExportBuild) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 0d178ce..d50de3d 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -7,6 +7,8 @@ run_cmake(VsTargetsFileReferences) run_cmake(VsCustomProps) run_cmake(VsDebuggerWorkingDir) run_cmake(VsDebuggerCommand) +run_cmake(VsDebuggerCommandArguments) +run_cmake(VsDebuggerEnvironment) run_cmake(VsCSharpCustomTags) run_cmake(VsCSharpReferenceProps) run_cmake(VsCSharpWithoutSources) diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake index 0ded780..440f9f2 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake @@ -9,7 +9,7 @@ set(debuggerCommandSet FALSE) file(STRINGS "${vcProjectFile}" lines) foreach(line IN LISTS lines) if(line MATCHES "^ *<LocalDebuggerCommand[^>]*>([^<>]+)</LocalDebuggerCommand>$") - if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command foo") message(STATUS "foo.vcxproj has debugger command set") set(debuggerCommandSet TRUE) endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake index e29adc4..5dcb6d1 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake @@ -2,4 +2,4 @@ enable_language(CXX) add_library(foo foo.cpp) set_target_properties(foo PROPERTIES - VS_DEBUGGER_COMMAND "my-debugger-command") + VS_DEBUGGER_COMMAND "my-debugger-command $<TARGET_PROPERTY:foo,NAME>") diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake new file mode 100644 index 0000000..b2e0a43 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake @@ -0,0 +1,22 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(debuggerCommandArgumentsSet FALSE) + +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<LocalDebuggerCommandArguments[^>]*>([^<>]+)</LocalDebuggerCommandArguments>$") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command-arguments foo") + message(STATUS "foo.vcxproj has debugger command arguments set") + set(debuggerCommandArgumentsSet TRUE) + endif() + endif() +endforeach() + +if(NOT debuggerCommandArgumentsSet) + set(RunCMake_TEST_FAILED "LocalDebuggerCommandArguments not found or not set correctly.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake new file mode 100644 index 0000000..aa87cdc --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(foo foo.cpp) + +set_target_properties(foo PROPERTIES + VS_DEBUGGER_COMMAND_ARGUMENTS "my-debugger-command-arguments $<TARGET_PROPERTY:foo,NAME>") diff --git a/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake new file mode 100644 index 0000000..2427ad4 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake @@ -0,0 +1,22 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(debuggerEnvironmentSet FALSE) + +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<LocalDebuggerEnvironment[^>]*>([^<>]+)</LocalDebuggerEnvironment>$") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-environment foo") + message(STATUS "foo.vcxproj has debugger environment set") + set(debuggerEnvironmentSet TRUE) + endif() + endif() +endforeach() + +if(NOT debuggerEnvironmentSet) + set(RunCMake_TEST_FAILED "LocalDebuggerEnvironment not found or not set correctly.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake new file mode 100644 index 0000000..d5bec4c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) +add_library(foo foo.cpp) + +set_target_properties(foo PROPERTIES + VS_DEBUGGER_ENVIRONMENT "my-debugger-environment $<TARGET_PROPERTY:foo,NAME>") diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake index 637c68c..6a142f8 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake @@ -9,7 +9,7 @@ set(debuggerWorkDirSet FALSE) file(STRINGS "${vcProjectFile}" lines) foreach(line IN LISTS lines) if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$") - if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory") + if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory foo") message(STATUS "foo.vcxproj has debugger working dir set") set(debuggerWorkDirSet TRUE) endif() diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake index a277c65..36daed0 100644 --- a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake +++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake @@ -2,4 +2,4 @@ enable_language(CXX) add_library(foo foo.cpp) set_target_properties(foo PROPERTIES - VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory") + VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory $<TARGET_PROPERTY:foo,NAME>") diff --git a/Tests/RunCMake/add_link_options/CMakeLists.txt b/Tests/RunCMake/add_link_options/CMakeLists.txt new file mode 100644 index 0000000..14ef56e --- /dev/null +++ b/Tests/RunCMake/add_link_options/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.11) + +project(${RunCMake_TEST} LANGUAGES NONE) + +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion-build-check.cmake b/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion-build-check.cmake new file mode 100644 index 0000000..d0ef8de --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion-build-check.cmake @@ -0,0 +1,2 @@ + +include ("${CMAKE_CURRENT_LIST_DIR}/LINKER_expansion-validation.cmake") diff --git a/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion.cmake b/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion.cmake new file mode 100644 index 0000000..7316ef5 --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion.cmake @@ -0,0 +1,4 @@ + +set (LINKER_OPTION "LINKER:SHELL:-foo bar") + +include ("LINKER_expansion-list.cmake") diff --git a/Tests/RunCMake/add_link_options/LINKER_expansion-build-check.cmake b/Tests/RunCMake/add_link_options/LINKER_expansion-build-check.cmake new file mode 100644 index 0000000..d0ef8de --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINKER_expansion-build-check.cmake @@ -0,0 +1,2 @@ + +include ("${CMAKE_CURRENT_LIST_DIR}/LINKER_expansion-validation.cmake") diff --git a/Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake b/Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake new file mode 100644 index 0000000..34dcc67 --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake @@ -0,0 +1,36 @@ + +enable_language(C) + +add_executable(dump dump.c) + +add_link_options("${LINKER_OPTION}") + +# ensure no temp file will be used +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}") + +add_library(example SHARED LinkOptionsLib.c) +# use LAUNCH facility to dump linker command +set_property(TARGET example PROPERTY RULE_LAUNCH_LINK "\"${CMAKE_CURRENT_BINARY_DIR}/dump${CMAKE_EXECUTABLE_SUFFIX}\"") + +add_dependencies (example dump) + +# generate reference for LINKER flag +if (CMAKE_C_LINKER_WRAPPER_FLAG) + set(linker_flag ${CMAKE_C_LINKER_WRAPPER_FLAG}) + list(GET linker_flag -1 linker_space) + if (linker_space STREQUAL " ") + list(REMOVE_AT linker_flag -1) + else() + set(linker_space) + endif() + list (JOIN linker_flag " " linker_flag) + if (CMAKE_C_LINKER_WRAPPER_FLAG_SEP) + string (APPEND linker_flag "${linker_space}" "-foo${CMAKE_C_LINKER_WRAPPER_FLAG_SEP}bar") + else() + set (linker_flag "${linker_flag}${linker_space}-foo ${linker_flag}${linker_space}bar") + endif() +else() + set(linker_flag "-foo bar") +endif() +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LINKER.txt" "${linker_flag}") diff --git a/Tests/RunCMake/add_link_options/LINKER_expansion-validation.cmake b/Tests/RunCMake/add_link_options/LINKER_expansion-validation.cmake new file mode 100644 index 0000000..bebd6c7 --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINKER_expansion-validation.cmake @@ -0,0 +1,15 @@ + +if (actual_stdout MATCHES "(LINKER|SHELL):") + set (RunCMake_TEST_FAILED "LINKER: prefix was not expanded.") + return() +endif() + +if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/LINKER.txt") + set (RunCMake_TEST_FAILED "${RunCMake_TEST_BINARY_DIR}/LINKER.txt: Reference file not found.") + return() +endif() +file(READ "${RunCMake_TEST_BINARY_DIR}/LINKER.txt" linker_flag) + +if (NOT actual_stdout MATCHES "${linker_flag}") + set (RunCMake_TEST_FAILED "LINKER: was not expanded correctly.") +endif() diff --git a/Tests/RunCMake/add_link_options/LINKER_expansion.cmake b/Tests/RunCMake/add_link_options/LINKER_expansion.cmake new file mode 100644 index 0000000..42b286d --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINKER_expansion.cmake @@ -0,0 +1,4 @@ + +set (LINKER_OPTION "LINKER:-foo,bar") + +include ("LINKER_expansion-list.cmake") diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-check.cmake b/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-check.cmake new file mode 100644 index 0000000..4a22d7e --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-check.cmake @@ -0,0 +1,7 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_EXECUTABLE_RELEASE") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_EXECUTABLE_RELEASE'.") +endif() +if (actual_stdout MATCHES "BADFLAG_(SHARED|MODULE)_RELEASE") + set (RunCMake_TEST_FAILED "Found unexpected 'BADFLAG_(SHARED|MODULE)_RELEASE'.") +endif() diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-result.txt b/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-check.cmake b/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-check.cmake new file mode 100644 index 0000000..d695761 --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-check.cmake @@ -0,0 +1,7 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_MODULE_RELEASE") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_MODULE_RELEASE'.") +endif() +if (actual_stdout MATCHES "BADFLAG_(SHARED|EXECUTABLE)_RELEASE") + set (RunCMake_TEST_FAILED "Found unexpected 'BADFLAG_(SHARED|EXECUTABLE)_RELEASE'.") +endif() diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-result.txt b/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-check.cmake b/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-check.cmake new file mode 100644 index 0000000..eaac8e3 --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-check.cmake @@ -0,0 +1,7 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_SHARED_RELEASE") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_SHARED_RELEASE'.") +endif() +if (actual_stdout MATCHES "BADFLAG_(MODULE|EXECUTABLE)_RELEASE") + set (RunCMake_TEST_FAILED "Found unexpected 'BADFLAG_(MODULE|EXECUTABLE)_RELEASE'.") +endif() diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-result.txt b/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS.cmake b/Tests/RunCMake/add_link_options/LINK_OPTIONS.cmake new file mode 100644 index 0000000..802ff4f --- /dev/null +++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS.cmake @@ -0,0 +1,17 @@ + +enable_language(C) + +set(obj "${CMAKE_C_OUTPUT_EXTENSION}") +if(BORLAND) + set(pre -) +endif() + +add_link_options($<$<AND:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>,$<CONFIG:Release>>:${pre}BADFLAG_SHARED_RELEASE${obj}>) +add_link_options($<$<AND:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>,$<CONFIG:Release>>:${pre}BADFLAG_MODULE_RELEASE${obj}>) +add_link_options($<$<AND:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>,$<CONFIG:Release>>:${pre}BADFLAG_EXECUTABLE_RELEASE${obj}>) + +add_library(LinkOptions_shared SHARED LinkOptionsLib.c) + +add_library(LinkOptions_mod MODULE LinkOptionsLib.c) + +add_executable(LinkOptions_exe LinkOptionsExe.c) diff --git a/Tests/RunCMake/add_link_options/LinkOptionsExe.c b/Tests/RunCMake/add_link_options/LinkOptionsExe.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/add_link_options/LinkOptionsExe.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/add_link_options/LinkOptionsLib.c b/Tests/RunCMake/add_link_options/LinkOptionsLib.c new file mode 100644 index 0000000..9bbd24c --- /dev/null +++ b/Tests/RunCMake/add_link_options/LinkOptionsLib.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) +__declspec(dllexport) +#endif + int flags_lib(void) +{ + return 0; +} diff --git a/Tests/RunCMake/add_link_options/RunCMakeTest.cmake b/Tests/RunCMake/add_link_options/RunCMakeTest.cmake new file mode 100644 index 0000000..4f5df72 --- /dev/null +++ b/Tests/RunCMake/add_link_options/RunCMakeTest.cmake @@ -0,0 +1,38 @@ + +include(RunCMake) + +macro(run_cmake_target test subtest target) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN}) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endmacro() + +if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") + # Intel compiler does not reject bad flags or objects! + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + + run_cmake(LINK_OPTIONS) + + run_cmake_target(LINK_OPTIONS shared LinkOptions_shared --config Release) + run_cmake_target(LINK_OPTIONS mod LinkOptions_mod --config Release) + run_cmake_target(LINK_OPTIONS exe LinkOptions_exe --config Release) + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) +endif() + +run_cmake(bad_SHELL_usage) + +if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)") + run_cmake(LINKER_expansion) + run_cmake_target(LINKER_expansion build all) + + run_cmake(LINKER_SHELL_expansion) + run_cmake_target(LINKER_SHELL_expansion build all) +endif() diff --git a/Tests/RunCMake/add_link_options/bad_SHELL_usage-result.txt b/Tests/RunCMake/add_link_options/bad_SHELL_usage-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_link_options/bad_SHELL_usage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_link_options/bad_SHELL_usage-stderr.txt b/Tests/RunCMake/add_link_options/bad_SHELL_usage-stderr.txt new file mode 100644 index 0000000..02d09f3 --- /dev/null +++ b/Tests/RunCMake/add_link_options/bad_SHELL_usage-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at bad_SHELL_usage.cmake:6 \(add_library\): + 'SHELL:' prefix is not supported as part of 'LINKER:' arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:5 \(include\) diff --git a/Tests/RunCMake/add_link_options/bad_SHELL_usage.cmake b/Tests/RunCMake/add_link_options/bad_SHELL_usage.cmake new file mode 100644 index 0000000..324893d --- /dev/null +++ b/Tests/RunCMake/add_link_options/bad_SHELL_usage.cmake @@ -0,0 +1,6 @@ + +enable_language(C) + +add_link_options("LINKER:-foo,SHELL:-bar") + +add_library(example SHARED LinkOptionsLib.c) diff --git a/Tests/RunCMake/add_link_options/dump.c b/Tests/RunCMake/add_link_options/dump.c new file mode 100644 index 0000000..8baa313 --- /dev/null +++ b/Tests/RunCMake/add_link_options/dump.c @@ -0,0 +1,13 @@ + +#include "stdio.h" + +int main(int argc, char* argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + printf("%s ", argv[i]); + printf("\n"); + + return 0; +} diff --git a/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt b/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt index 27fbb86..fc08163 100644 --- a/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt +++ b/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt @@ -3,7 +3,7 @@ Foo_ROOT :<base>/foo/cmake_root ENV{Foo_ROOT} :<base>/foo/env_root + CMake Warning \(dev\) at CMP0074-common.cmake:[0-9]+ \(find_package\): - Policy CMP0074 is not set: find_package uses PackageName_ROOT variables. + Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables. Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy command to set the policy and suppress this warning. diff --git a/Tests/RunCMake/find_program/RelAndAbsPath-stdout.txt b/Tests/RunCMake/find_program/RelAndAbsPath-stdout.txt new file mode 100644 index 0000000..cb3c99f --- /dev/null +++ b/Tests/RunCMake/find_program/RelAndAbsPath-stdout.txt @@ -0,0 +1,6 @@ +-- PROG_ABS='PROG_ABS-NOTFOUND' +-- PROG_ABS_NPD='PROG_ABS_NPD-NOTFOUND' +-- PROG_CWD='PROG_CWD-NOTFOUND' +-- PROG_CWD_NPD='PROG_CWD_NPD-NOTFOUND' +-- PROG_CWD_DOT='[^']*/Tests/RunCMake/find_program/testCWD' +-- PROG_CWD_DOT_NPD='[^']*/Tests/RunCMake/find_program/testCWD' diff --git a/Tests/RunCMake/find_program/RelAndAbsPath.cmake b/Tests/RunCMake/find_program/RelAndAbsPath.cmake new file mode 100644 index 0000000..9a42c5e --- /dev/null +++ b/Tests/RunCMake/find_program/RelAndAbsPath.cmake @@ -0,0 +1,63 @@ +# testNoSuchFile should only be found if the file absolute path is +# incorrectly prepended with the search path. + +function(strip_windows_path_prefix p outvar) + if(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + string(REGEX REPLACE "^.:" "" p "${p}") + endif() + set(${outvar} "${p}" PARENT_SCOPE) +endfunction() + +strip_windows_path_prefix("${CMAKE_CURRENT_SOURCE_DIR}" srcdir) + +file(MAKE_DIRECTORY "tmp${srcdir}") +configure_file(testCWD "tmp${srcdir}/testNoSuchFile" COPYONLY) + +find_program(PROG_ABS + NAMES "${srcdir}/testNoSuchFile" + PATHS "${CMAKE_CURRENT_BINARY_DIR}/tmp" + NO_DEFAULT_PATH + ) +message(STATUS "PROG_ABS='${PROG_ABS}'") + +find_program(PROG_ABS_NPD + NAMES "${srcdir}/testNoSuchFile" + PATHS "${CMAKE_CURRENT_BINARY_DIR}/tmp" + NAMES_PER_DIR + NO_DEFAULT_PATH + ) +message(STATUS "PROG_ABS_NPD='${PROG_ABS_NPD}'") + +# ./testCWD should not be found without '.' being in the path list. + +configure_file(testCWD testCWD COPYONLY) + +find_program(PROG_CWD + NAMES testCWD + NO_DEFAULT_PATH + ) +message(STATUS "PROG_CWD='${PROG_CWD}'") + +find_program(PROG_CWD_NPD + NAMES testCWD + NAMES_PER_DIR + NO_DEFAULT_PATH + ) +message(STATUS "PROG_CWD_NPD='${PROG_CWD_NPD}'") + +# Confirm that adding '.' to path does locate ./testCWD. + +find_program(PROG_CWD_DOT + NAMES testCWD + PATHS . + NO_DEFAULT_PATH + ) +message(STATUS "PROG_CWD_DOT='${PROG_CWD_DOT}'") + +find_program(PROG_CWD_DOT_NPD + NAMES testCWD + PATHS . + NAMES_PER_DIR + NO_DEFAULT_PATH + ) +message(STATUS "PROG_CWD_DOT_NPD='${PROG_CWD_DOT_NPD}'") diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake index 89307c1..6903f05 100644 --- a/Tests/RunCMake/find_program/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(EnvAndHints) run_cmake(DirsPerName) run_cmake(NamesPerDir) +run_cmake(RelAndAbsPath) if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN)$") run_cmake(WindowsCom) diff --git a/Tests/RunCMake/find_program/testCWD b/Tests/RunCMake/find_program/testCWD new file mode 100755 index 0000000..1a24852 --- /dev/null +++ b/Tests/RunCMake/find_program/testCWD @@ -0,0 +1 @@ +#!/bin/sh diff --git a/Tests/RunCMake/install/CODE-genex-bad-result.txt b/Tests/RunCMake/install/CODE-genex-bad-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/install/CODE-genex-bad-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/install/CODE-genex-bad-stderr.txt b/Tests/RunCMake/install/CODE-genex-bad-stderr.txt new file mode 100644 index 0000000..9844158 --- /dev/null +++ b/Tests/RunCMake/install/CODE-genex-bad-stderr.txt @@ -0,0 +1,6 @@ +CMake Error: + Error evaluating generator expression: + + \$<NOTAGENEX> + + Expression did not evaluate to a known generator expression diff --git a/Tests/RunCMake/install/CODE-genex-bad.cmake b/Tests/RunCMake/install/CODE-genex-bad.cmake new file mode 100644 index 0000000..1663b39 --- /dev/null +++ b/Tests/RunCMake/install/CODE-genex-bad.cmake @@ -0,0 +1 @@ +install(CODE "message(\"$<NOTAGENEX>\")") diff --git a/Tests/RunCMake/install/CODE-genex-check.cmake b/Tests/RunCMake/install/CODE-genex-check.cmake new file mode 100644 index 0000000..422c532 --- /dev/null +++ b/Tests/RunCMake/install/CODE-genex-check.cmake @@ -0,0 +1,7 @@ +execute_process(COMMAND ${CMAKE_COMMAND} -P ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake + OUTPUT_VARIABLE out ERROR_VARIABLE err) +if(NOT out MATCHES "-- Install configuration: .*-- codegenexlib") + string(REGEX REPLACE "\n" "\n " out " ${out}") + string(APPEND RunCMake_TEST_FAILED + "\"-- codegenexlib\" was not found:\n${out}") +endif() diff --git a/Tests/RunCMake/install/CODE-genex.cmake b/Tests/RunCMake/install/CODE-genex.cmake new file mode 100644 index 0000000..3b8513d --- /dev/null +++ b/Tests/RunCMake/install/CODE-genex.cmake @@ -0,0 +1,2 @@ +add_library( codegenexlib INTERFACE ) +install(CODE "message( STATUS \"$<TARGET_PROPERTY:codegenexlib,NAME>\")") diff --git a/Tests/RunCMake/install/DIRECTORY-OPTIONAL-all-check.cmake b/Tests/RunCMake/install/DIRECTORY-OPTIONAL-all-check.cmake new file mode 100644 index 0000000..c14998e --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-OPTIONAL-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^dir;dir/empty.txt$]]) diff --git a/Tests/RunCMake/install/DIRECTORY-OPTIONAL.cmake b/Tests/RunCMake/install/DIRECTORY-OPTIONAL.cmake new file mode 100644 index 0000000..e57aab0 --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-OPTIONAL.cmake @@ -0,0 +1 @@ +install(DIRECTORY dir/ noexist/ DESTINATION dir OPTIONAL) diff --git a/Tests/RunCMake/install/DIRECTORY-PATTERN-all-check.cmake b/Tests/RunCMake/install/DIRECTORY-PATTERN-all-check.cmake new file mode 100644 index 0000000..7a20edc --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-PATTERN-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^dir1;dir1/empty\.c;dir1/empty\.h;dir2;dir2/pattern;dir2/pattern/empty\.txt;dir3;dir3/empty\.c;dir3/empty\.h;dir3/empty\.txt;dir4;dir4/empty\.c;dir4/empty\.h;dir4/empty\.txt;empty$]]) diff --git a/Tests/RunCMake/install/DIRECTORY-PATTERN.cmake b/Tests/RunCMake/install/DIRECTORY-PATTERN.cmake new file mode 100644 index 0000000..74d8043 --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-PATTERN.cmake @@ -0,0 +1,36 @@ +install( + DIRECTORY pattern/ + DESTINATION dir1 + FILES_MATCHING + PATTERN "*.h" + REGEX "\\.c$" + ) + +# FIXME: If/when CMake gains a good way to read file permissions, we should +# check that these permissions were set correctly. +install( + DIRECTORY pattern + DESTINATION dir2 + FILE_PERMISSIONS OWNER_READ OWNER_WRITE + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + PATTERN "*.h" EXCLUDE + REGEX "\\.c$" EXCLUDE + ) + +install( + DIRECTORY pattern/ + DESTINATION dir3 + PATTERN "*.h" + PERMISSIONS OWNER_READ OWNER_WRITE + ) + +install( + DIRECTORY pattern/ + DESTINATION dir4 + USE_SOURCE_PERMISSIONS + ) + +install( + DIRECTORY + DESTINATION empty + ) diff --git a/Tests/RunCMake/install/Deprecated-all-check.cmake b/Tests/RunCMake/install/Deprecated-all-check.cmake new file mode 100644 index 0000000..9ea33a6 --- /dev/null +++ b/Tests/RunCMake/install/Deprecated-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin;bin/myexe(\.exe)?;scripts1;scripts1/script;scripts1/script\.bat;scripts2;scripts2/script;scripts2/script\.bat;scripts3;scripts3/script;scripts3/script\.bat;src;src/empty\.c;src/obj1\.c;src/obj\2.c$]]) diff --git a/Tests/RunCMake/install/Deprecated.cmake b/Tests/RunCMake/install/Deprecated.cmake new file mode 100644 index 0000000..c435cb5 --- /dev/null +++ b/Tests/RunCMake/install/Deprecated.cmake @@ -0,0 +1,13 @@ +enable_language(C) + +add_executable(myexe main.c) + +install_files(/src FILES empty.c) +install_files(/src .c obj1) +install_files(/src "^obj2.c$") + +install_targets(/bin myexe) + +install_programs(/scripts1 FILES script script.bat) +install_programs(/scripts2 script script.bat) +install_programs(/scripts3 "^script(\.bat)?$") diff --git a/Tests/RunCMake/install/FILES-OPTIONAL-all-check.cmake b/Tests/RunCMake/install/FILES-OPTIONAL-all-check.cmake new file mode 100644 index 0000000..2997a8d --- /dev/null +++ b/Tests/RunCMake/install/FILES-OPTIONAL-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^src;src/main.c$]]) diff --git a/Tests/RunCMake/install/FILES-OPTIONAL.cmake b/Tests/RunCMake/install/FILES-OPTIONAL.cmake new file mode 100644 index 0000000..812bf4f --- /dev/null +++ b/Tests/RunCMake/install/FILES-OPTIONAL.cmake @@ -0,0 +1 @@ +install(FILES main.c noexist.c DESTINATION src OPTIONAL) diff --git a/Tests/RunCMake/install/FILES-PERMISSIONS-all-check.cmake b/Tests/RunCMake/install/FILES-PERMISSIONS-all-check.cmake new file mode 100644 index 0000000..b8ba6d0 --- /dev/null +++ b/Tests/RunCMake/install/FILES-PERMISSIONS-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^src;src/empty.c]]) diff --git a/Tests/RunCMake/install/FILES-PERMISSIONS.cmake b/Tests/RunCMake/install/FILES-PERMISSIONS.cmake new file mode 100644 index 0000000..999c271 --- /dev/null +++ b/Tests/RunCMake/install/FILES-PERMISSIONS.cmake @@ -0,0 +1,5 @@ +install( + FILES empty.c + DESTINATION src + PERMISSIONS OWNER_READ OWNER_WRITE + ) diff --git a/Tests/RunCMake/install/InstallRequiredSystemLibraries-stderr.txt b/Tests/RunCMake/install/InstallRequiredSystemLibraries-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/install/InstallRequiredSystemLibraries-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/install/InstallRequiredSystemLibraries.cmake b/Tests/RunCMake/install/InstallRequiredSystemLibraries.cmake new file mode 100644 index 0000000..27ff683 --- /dev/null +++ b/Tests/RunCMake/install/InstallRequiredSystemLibraries.cmake @@ -0,0 +1,10 @@ +enable_language(C) +set(CMAKE_INSTALL_MFC_LIBRARIES 1) +set(CMAKE_INSTALL_DEBUG_LIBRARIES 1) +set(CMAKE_INSTALL_UCRT_LIBRARIES 1) +set(CMAKE_INSTALL_OPENMP_LIBRARIES 1) +include(InstallRequiredSystemLibraries) + +# FIXME: This test emits warnings because InstallRequiredSystemLibraries +# doesn't currently work properly. The warnings have been suppressed in +# InstallRequiredSystemLibraries-stderr.txt. This needs to be fixed. diff --git a/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT-all-check.cmake b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT-all-check.cmake new file mode 100644 index 0000000..16ff1e1 --- /dev/null +++ b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin;bin/myexe(\.exe)?;postinstall;preinstall]]) diff --git a/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT.cmake b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT.cmake new file mode 100644 index 0000000..357c688 --- /dev/null +++ b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_executable(myexe main.c) +set_property(TARGET myexe PROPERTY PRE_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/preinstall.cmake") +set_property(TARGET myexe PROPERTY POST_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/postinstall.cmake") + +install(TARGETS myexe DESTINATION bin) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index f004ce9..91524a6 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -65,12 +65,34 @@ run_cmake(CMP0062-NEW) run_cmake(CMP0062-WARN) run_cmake(TARGETS-NAMELINK_COMPONENT-bad-all) run_cmake(TARGETS-NAMELINK_COMPONENT-bad-exc) +run_cmake(CODE-genex) +run_cmake(CODE-genex-bad) if(NOT RunCMake_GENERATOR STREQUAL "Xcode" OR NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]") run_install_test(FILES-TARGET_OBJECTS) endif() +run_install_test(TARGETS-InstallFromSubDir) +run_install_test(TARGETS-OPTIONAL) +run_install_test(FILES-OPTIONAL) +run_install_test(DIRECTORY-OPTIONAL) + +set(RunCMake_TEST_OPTIONS "-DCMAKE_BUILD_TYPE:STRING=Debug") +run_install_test(TARGETS-OUTPUT_NAME) +unset(RunCMake_TEST_OPTIONS) + +run_install_test(Deprecated) +run_install_test(PRE_POST_INSTALL_SCRIPT) +run_install_test(SCRIPT) +run_install_test(TARGETS-CONFIGURATIONS) +run_install_test(DIRECTORY-PATTERN) +run_install_test(TARGETS-Parts) +run_install_test(FILES-PERMISSIONS) +run_install_test(TARGETS-RPATH) +run_install_test(InstallRequiredSystemLibraries) + set(run_install_test_components 1) run_install_test(FILES-EXCLUDE_FROM_ALL) run_install_test(TARGETS-EXCLUDE_FROM_ALL) run_install_test(TARGETS-NAMELINK_COMPONENT) +run_install_test(SCRIPT-COMPONENT) diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT-all-check.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT-all-check.cmake new file mode 100644 index 0000000..48d8e1a --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT-COMPONENT-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^empty1.txt;empty2.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT-dev-check.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT-dev-check.cmake new file mode 100644 index 0000000..48d8e1a --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT-COMPONENT-dev-check.cmake @@ -0,0 +1 @@ +check_installed([[^empty1.txt;empty2.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT-uns-check.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT-uns-check.cmake new file mode 100644 index 0000000..e09a102 --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT-COMPONENT-uns-check.cmake @@ -0,0 +1 @@ +check_installed([[^$]]) diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT.cmake new file mode 100644 index 0000000..aaa9bd4 --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT-COMPONENT.cmake @@ -0,0 +1,5 @@ +install( + SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/install_script.cmake" + CODE "write_empty_file(empty2.txt)" + COMPONENT dev + ) diff --git a/Tests/RunCMake/install/SCRIPT-all-check.cmake b/Tests/RunCMake/install/SCRIPT-all-check.cmake new file mode 100644 index 0000000..48d8e1a --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^empty1.txt;empty2.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT.cmake b/Tests/RunCMake/install/SCRIPT.cmake new file mode 100644 index 0000000..f857b54 --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT.cmake @@ -0,0 +1,4 @@ +install( + SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/install_script.cmake" + CODE "write_empty_file(empty2.txt)" + ) diff --git a/Tests/RunCMake/install/TARGETS-CONFIGURATIONS-all-check.cmake b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS-all-check.cmake new file mode 100644 index 0000000..2866e7f --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^src;src/main-d.c$]]) diff --git a/Tests/RunCMake/install/TARGETS-CONFIGURATIONS.cmake b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS.cmake new file mode 100644 index 0000000..5531cd2 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS.cmake @@ -0,0 +1,2 @@ +install(FILES main.c DESTINATION src CONFIGURATIONS Debug RENAME main-d.c) +install(FILES main.c DESTINATION src CONFIGURATIONS Release RENAME main-r.c) diff --git a/Tests/RunCMake/install/TARGETS-InstallFromSubDir-all-check.cmake b/Tests/RunCMake/install/TARGETS-InstallFromSubDir-all-check.cmake new file mode 100644 index 0000000..1d747c3 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-InstallFromSubDir-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin;bin/myexe(\.exe)?;bin/subexe(\.exe)?$]]) diff --git a/Tests/RunCMake/install/TARGETS-InstallFromSubDir.cmake b/Tests/RunCMake/install/TARGETS-InstallFromSubDir.cmake new file mode 100644 index 0000000..8615d6e --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-InstallFromSubDir.cmake @@ -0,0 +1,4 @@ +enable_language(C) +add_executable(myexe main.c) +add_subdirectory(TARGETS-InstallFromSubDir) +install(TARGETS myexe subexe DESTINATION bin) diff --git a/Tests/RunCMake/install/TARGETS-InstallFromSubDir/CMakeLists.txt b/Tests/RunCMake/install/TARGETS-InstallFromSubDir/CMakeLists.txt new file mode 100644 index 0000000..477d938 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-InstallFromSubDir/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(subexe ../main.c) diff --git a/Tests/RunCMake/install/TARGETS-OPTIONAL-all-check.cmake b/Tests/RunCMake/install/TARGETS-OPTIONAL-all-check.cmake new file mode 100644 index 0000000..bcf71dd --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-OPTIONAL-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin;bin/myexe(\.exe)?$]]) diff --git a/Tests/RunCMake/install/TARGETS-OPTIONAL-stderr.txt b/Tests/RunCMake/install/TARGETS-OPTIONAL-stderr.txt new file mode 100644 index 0000000..86e3ec0 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-OPTIONAL-stderr.txt @@ -0,0 +1 @@ +^WARNING: Target "notall" has EXCLUDE_FROM_ALL set and will not be built by default but an install rule has been provided for it\. CMake does not define behavior for this case\.$ diff --git a/Tests/RunCMake/install/TARGETS-OPTIONAL.cmake b/Tests/RunCMake/install/TARGETS-OPTIONAL.cmake new file mode 100644 index 0000000..d3c5cda --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-OPTIONAL.cmake @@ -0,0 +1,4 @@ +enable_language(C) +add_executable(myexe main.c) +add_executable(notall EXCLUDE_FROM_ALL main.c) +install(TARGETS myexe notall DESTINATION bin OPTIONAL) diff --git a/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake new file mode 100644 index 0000000..5daecc8 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake @@ -0,0 +1,13 @@ +if(WIN32) + set(test123 [[bin/test1out\.exe;bin/test2deb\.exe;bin/test3exc\.exe]]) + set(libtest45 [[bin/libtest4\.dll;bin/libtest4\.dll\.a;bin/libtest5ar\.a]]) + set(test45 [[bin/test4\.dll;bin/test4\.lib;bin/test5ar\.lib]]) + + check_installed("^bin;(${libtest45};${test123})|(${test123};${test45})\$") +elseif(CYGWIN) + check_installed([[^bin;bin/cygtest4\.dll;bin/libtest4\.dll\.a;bin/libtest5ar\.a;bin/test1out\.exe;bin/test2deb\.exe;bin/test3exc\.exe$]]) +elseif(APPLE) + check_installed([[^bin;bin/libtest4lib\.dylib;bin/libtest5ar\.a;bin/test1out;bin/test2deb;bin/test3exc$]]) +else() + check_installed([[^bin;bin/libtest4lib\.so;bin/libtest5ar\.a;bin/test1out;bin/test2deb;bin/test3exc$]]) +endif() diff --git a/Tests/RunCMake/install/TARGETS-OUTPUT_NAME.cmake b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME.cmake new file mode 100644 index 0000000..67e7069 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME.cmake @@ -0,0 +1,27 @@ +enable_language(C) + +add_executable(test1 main.c) +set_property(TARGET test1 PROPERTY OUTPUT_NAME test1out) +set_property(TARGET test1 PROPERTY RELEASE_OUTPUT_NAME test1rel) + +add_executable(test2 main.c) +set_property(TARGET test2 PROPERTY OUTPUT_NAME test2out) +set_property(TARGET test2 PROPERTY DEBUG_OUTPUT_NAME test2deb) + +add_executable(test3 main.c) +set_property(TARGET test3 PROPERTY RUNTIME_OUTPUT_NAME test3exc) + +add_library(test4 SHARED obj1.c) +set_property(TARGET test4 PROPERTY LIBRARY_OUTPUT_NAME test4lib) + +add_library(test5 STATIC obj1.c) +set_property(TARGET test5 PROPERTY ARCHIVE_OUTPUT_NAME test5ar) + +install(TARGETS + test1 + test2 + test3 + test4 + test5 + DESTINATION bin + ) diff --git a/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake b/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake new file mode 100644 index 0000000..6245839 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^include;include/obj1\.h;lib;lib/(mylib\.lib|(lib|cyg)mylib\.a)$]]) diff --git a/Tests/RunCMake/install/TARGETS-Parts.cmake b/Tests/RunCMake/install/TARGETS-Parts.cmake new file mode 100644 index 0000000..2a46ab9 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-Parts.cmake @@ -0,0 +1,7 @@ +enable_language(C) +add_library(mylib STATIC obj1.c) +set_property(TARGET mylib PROPERTY PUBLIC_HEADER obj1.h) +install(TARGETS mylib + ARCHIVE DESTINATION lib + PUBLIC_HEADER DESTINATION include + ) diff --git a/Tests/RunCMake/install/TARGETS-RPATH-all-check.cmake b/Tests/RunCMake/install/TARGETS-RPATH-all-check.cmake new file mode 100644 index 0000000..fa52d65 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-RPATH-all-check.cmake @@ -0,0 +1,14 @@ +execute_process( + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/myexe" + RESULT_VARIABLE MYEXE_RESULT + OUTPUT_VARIABLE MYEXE_OUTPUT + ERROR_VARIABLE MYEXE_ERROR + ) + +if(NOT MYEXE_RESULT EQUAL "0") + set(RunCMake_TEST_FAILED "myexe returned [${MYEXE_RESULT}], was expecting [0]") +elseif(NOT MYEXE_OUTPUT STREQUAL "") + set(RunCMake_TEST_FAILED "myexe printed nonempty output:\n${MYEXE_OUTPUT}") +elseif(NOT MYEXE_ERROR STREQUAL "") + set(RunCMake_TEST_FAILED "myexe printed nonempty error:\n${MYEXE_ERROR}") +endif() diff --git a/Tests/RunCMake/install/TARGETS-RPATH.cmake b/Tests/RunCMake/install/TARGETS-RPATH.cmake new file mode 100644 index 0000000..b75deff --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-RPATH.cmake @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.9) + +enable_language(C) + +set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) +add_library(mylib SHARED obj1.c) +add_executable(myexe testobj1.c) +target_link_libraries(myexe mylib) +set_property(TARGET myexe PROPERTY INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/root-all/bin") +set_target_properties(mylib PROPERTIES VERSION 1.0 SOVERSION 1) + +install(TARGETS mylib myexe + DESTINATION bin + ) diff --git a/Tests/RunCMake/install/install_script.cmake b/Tests/RunCMake/install/install_script.cmake new file mode 100644 index 0000000..1f8522c --- /dev/null +++ b/Tests/RunCMake/install/install_script.cmake @@ -0,0 +1,5 @@ +function(write_empty_file FILENAME) + file(WRITE "${CMAKE_INSTALL_PREFIX}/${FILENAME}" "") +endfunction() + +write_empty_file(empty1.txt) diff --git a/Tests/RunCMake/install/obj1.c b/Tests/RunCMake/install/obj1.c index 2411aab..70007df 100644 --- a/Tests/RunCMake/install/obj1.c +++ b/Tests/RunCMake/install/obj1.c @@ -1,4 +1,7 @@ -int obj1(void) +#ifdef _WIN32 +__declspec(dllexport) +#endif + int obj1(void) { return 0; } diff --git a/Tests/RunCMake/install/obj1.h b/Tests/RunCMake/install/obj1.h new file mode 100644 index 0000000..d88d5d2 --- /dev/null +++ b/Tests/RunCMake/install/obj1.h @@ -0,0 +1,6 @@ +#ifndef OBJ1_H +#define OBJ1_H + +int obj1(void); + +#endif /* OBJ1_H */ diff --git a/Tests/RunCMake/install/pattern/empty.c b/Tests/RunCMake/install/pattern/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/install/pattern/empty.c diff --git a/Tests/RunCMake/install/pattern/empty.h b/Tests/RunCMake/install/pattern/empty.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/install/pattern/empty.h diff --git a/Tests/RunCMake/install/pattern/empty.txt b/Tests/RunCMake/install/pattern/empty.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/install/pattern/empty.txt diff --git a/Tests/RunCMake/install/postinstall.cmake b/Tests/RunCMake/install/postinstall.cmake new file mode 100644 index 0000000..7607f40 --- /dev/null +++ b/Tests/RunCMake/install/postinstall.cmake @@ -0,0 +1 @@ +file(WRITE "${CMAKE_INSTALL_PREFIX}/postinstall" "postinstall") diff --git a/Tests/RunCMake/install/preinstall.cmake b/Tests/RunCMake/install/preinstall.cmake new file mode 100644 index 0000000..4b28d16 --- /dev/null +++ b/Tests/RunCMake/install/preinstall.cmake @@ -0,0 +1 @@ +file(WRITE "${CMAKE_INSTALL_PREFIX}/preinstall" "preinstall") diff --git a/Tests/SimpleInstallS2/scripts/sample_script b/Tests/RunCMake/install/script index 81f9f53..81f9f53 100755 --- a/Tests/SimpleInstallS2/scripts/sample_script +++ b/Tests/RunCMake/install/script diff --git a/Tests/SimpleInstallS2/scripts/sample_script.bat b/Tests/RunCMake/install/script.bat index a9af38c..a9af38c 100755 --- a/Tests/SimpleInstallS2/scripts/sample_script.bat +++ b/Tests/RunCMake/install/script.bat diff --git a/Tests/RunCMake/install/testobj1.c b/Tests/RunCMake/install/testobj1.c new file mode 100644 index 0000000..081ef20 --- /dev/null +++ b/Tests/RunCMake/install/testobj1.c @@ -0,0 +1,9 @@ +#ifdef _WIN32 +__declspec(dllimport) +#endif + int obj1(void); + +int main(void) +{ + return obj1(); +} diff --git a/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt b/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt index 6e15c0b..9b9c5e0 100644 --- a/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt +++ b/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at INSERT-InvalidIndex.cmake:2 \(list\): - list index: 3 out of range \(-3, 2\) + list index: 4 out of range \(-3, 3\) Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/INSERT-InvalidIndex.cmake b/Tests/RunCMake/list/INSERT-InvalidIndex.cmake index 4103d97..12ac114 100644 --- a/Tests/RunCMake/list/INSERT-InvalidIndex.cmake +++ b/Tests/RunCMake/list/INSERT-InvalidIndex.cmake @@ -1,2 +1,2 @@ set(mylist alpha bravo charlie) -list(INSERT mylist 3 delta) +list(INSERT mylist 4 delta) diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake index bdc23a4..a8a0b57 100644 --- a/Tests/RunCMake/list/RunCMakeTest.cmake +++ b/Tests/RunCMake/list/RunCMakeTest.cmake @@ -20,7 +20,6 @@ run_cmake(JOIN-TooManyArguments) run_cmake(LENGTH-TooManyArguments) run_cmake(REMOVE_DUPLICATES-TooManyArguments) run_cmake(REVERSE-TooManyArguments) -run_cmake(SORT-TooManyArguments) run_cmake(SUBLIST-TooManyArguments) run_cmake(FILTER-NotList) @@ -84,3 +83,16 @@ run_cmake(TRANSFORM-GENEX_STRIP) run_cmake(TRANSFORM-APPEND) run_cmake(TRANSFORM-PREPEND) run_cmake(TRANSFORM-REPLACE) + +# argument tests +run_cmake(SORT-WrongOption) +run_cmake(SORT-BadCaseOption) +run_cmake(SORT-BadCompareOption) +run_cmake(SORT-BadOrderOption) +run_cmake(SORT-DuplicateOrderOption) +run_cmake(SORT-DuplicateCompareOption) +run_cmake(SORT-DuplicateCaseOption) +run_cmake(SORT-NoCaseOption) + +# Successful tests +run_cmake(SORT) diff --git a/Tests/RunCMake/list/SORT-BadCaseOption-result.txt b/Tests/RunCMake/list/SORT-BadCaseOption-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SORT-BadCaseOption-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SORT-BadCaseOption-stderr.txt b/Tests/RunCMake/list/SORT-BadCaseOption-stderr.txt new file mode 100644 index 0000000..87dd502 --- /dev/null +++ b/Tests/RunCMake/list/SORT-BadCaseOption-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SORT-BadCaseOption.cmake:1 \(list\): + list sub-command SORT value "BAD_CASE_OPTION" for option "CASE" is invalid. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SORT-BadCaseOption.cmake b/Tests/RunCMake/list/SORT-BadCaseOption.cmake new file mode 100644 index 0000000..ac5c102 --- /dev/null +++ b/Tests/RunCMake/list/SORT-BadCaseOption.cmake @@ -0,0 +1 @@ +list(SORT mylist CASE BAD_CASE_OPTION) diff --git a/Tests/RunCMake/list/SORT-BadCompareOption-result.txt b/Tests/RunCMake/list/SORT-BadCompareOption-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SORT-BadCompareOption-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SORT-BadCompareOption-stderr.txt b/Tests/RunCMake/list/SORT-BadCompareOption-stderr.txt new file mode 100644 index 0000000..51b4de2 --- /dev/null +++ b/Tests/RunCMake/list/SORT-BadCompareOption-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at SORT-BadCompareOption.cmake:1 \(list\): + list sub-command SORT value "BAD_COMPARE_OPTION" for option "COMPARE" is + invalid. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SORT-BadCompareOption.cmake b/Tests/RunCMake/list/SORT-BadCompareOption.cmake new file mode 100644 index 0000000..d5c632e --- /dev/null +++ b/Tests/RunCMake/list/SORT-BadCompareOption.cmake @@ -0,0 +1 @@ +list(SORT mylist COMPARE BAD_COMPARE_OPTION) diff --git a/Tests/RunCMake/list/SORT-BadOrderOption-result.txt b/Tests/RunCMake/list/SORT-BadOrderOption-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SORT-BadOrderOption-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SORT-BadOrderOption-stderr.txt b/Tests/RunCMake/list/SORT-BadOrderOption-stderr.txt new file mode 100644 index 0000000..7984e5c --- /dev/null +++ b/Tests/RunCMake/list/SORT-BadOrderOption-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at SORT-BadOrderOption.cmake:1 \(list\): + list sub-command SORT value "BAD_ODER_OPTION" for option "ORDER" is + invalid. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SORT-BadOrderOption.cmake b/Tests/RunCMake/list/SORT-BadOrderOption.cmake new file mode 100644 index 0000000..e232197 --- /dev/null +++ b/Tests/RunCMake/list/SORT-BadOrderOption.cmake @@ -0,0 +1 @@ +list(SORT mylist ORDER BAD_ODER_OPTION) diff --git a/Tests/RunCMake/list/SORT-DuplicateCaseOption-result.txt b/Tests/RunCMake/list/SORT-DuplicateCaseOption-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SORT-DuplicateCaseOption-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SORT-DuplicateCaseOption-stderr.txt b/Tests/RunCMake/list/SORT-DuplicateCaseOption-stderr.txt new file mode 100644 index 0000000..b893f50 --- /dev/null +++ b/Tests/RunCMake/list/SORT-DuplicateCaseOption-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SORT-DuplicateCaseOption.cmake:2 \(list\): + list sub-command SORT option "CASE" has been specified multiple times. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SORT-DuplicateCaseOption.cmake b/Tests/RunCMake/list/SORT-DuplicateCaseOption.cmake new file mode 100644 index 0000000..ba52b24 --- /dev/null +++ b/Tests/RunCMake/list/SORT-DuplicateCaseOption.cmake @@ -0,0 +1,2 @@ +set (mylist a b c) +list(SORT mylist CASE INSENSITIVE CASE INSENSITIVE ) diff --git a/Tests/RunCMake/list/SORT-DuplicateCompareOption-result.txt b/Tests/RunCMake/list/SORT-DuplicateCompareOption-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SORT-DuplicateCompareOption-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SORT-DuplicateCompareOption-stderr.txt b/Tests/RunCMake/list/SORT-DuplicateCompareOption-stderr.txt new file mode 100644 index 0000000..83624be --- /dev/null +++ b/Tests/RunCMake/list/SORT-DuplicateCompareOption-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SORT-DuplicateCompareOption.cmake:2 \(list\): + list sub-command SORT option "COMPARE" has been specified multiple times. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SORT-DuplicateCompareOption.cmake b/Tests/RunCMake/list/SORT-DuplicateCompareOption.cmake new file mode 100644 index 0000000..fd2e31d --- /dev/null +++ b/Tests/RunCMake/list/SORT-DuplicateCompareOption.cmake @@ -0,0 +1,2 @@ +set (mylist a b c) +list(SORT mylist COMPARE STRING COMPARE STRING) diff --git a/Tests/RunCMake/list/SORT-DuplicateOrderOption-result.txt b/Tests/RunCMake/list/SORT-DuplicateOrderOption-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SORT-DuplicateOrderOption-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SORT-DuplicateOrderOption-stderr.txt b/Tests/RunCMake/list/SORT-DuplicateOrderOption-stderr.txt new file mode 100644 index 0000000..9e95178 --- /dev/null +++ b/Tests/RunCMake/list/SORT-DuplicateOrderOption-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SORT-DuplicateOrderOption.cmake:2 \(list\): + list sub-command SORT option "ORDER" has been specified multiple times. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SORT-DuplicateOrderOption.cmake b/Tests/RunCMake/list/SORT-DuplicateOrderOption.cmake new file mode 100644 index 0000000..26d9c7d --- /dev/null +++ b/Tests/RunCMake/list/SORT-DuplicateOrderOption.cmake @@ -0,0 +1,2 @@ +set (mylist a b c) +list(SORT mylist ORDER ASCENDING ORDER ASCENDING) diff --git a/Tests/RunCMake/list/SORT-NoCaseOption-result.txt b/Tests/RunCMake/list/SORT-NoCaseOption-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SORT-NoCaseOption-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SORT-NoCaseOption-stderr.txt b/Tests/RunCMake/list/SORT-NoCaseOption-stderr.txt new file mode 100644 index 0000000..5c63e77 --- /dev/null +++ b/Tests/RunCMake/list/SORT-NoCaseOption-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SORT-NoCaseOption.cmake:1 \(list\): + list sub-command SORT missing argument for option "CASE". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SORT-NoCaseOption.cmake b/Tests/RunCMake/list/SORT-NoCaseOption.cmake new file mode 100644 index 0000000..57cc429 --- /dev/null +++ b/Tests/RunCMake/list/SORT-NoCaseOption.cmake @@ -0,0 +1 @@ +list(SORT mylist CASE) diff --git a/Tests/RunCMake/list/SORT-TooManyArguments-stderr.txt b/Tests/RunCMake/list/SORT-TooManyArguments-stderr.txt deleted file mode 100644 index d3fad60..0000000 --- a/Tests/RunCMake/list/SORT-TooManyArguments-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -^CMake Error at SORT-TooManyArguments.cmake:1 \(list\): - list sub-command SORT only takes one argument. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SORT-WrongOption-result.txt b/Tests/RunCMake/list/SORT-WrongOption-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/SORT-WrongOption-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/SORT-WrongOption-stderr.txt b/Tests/RunCMake/list/SORT-WrongOption-stderr.txt new file mode 100644 index 0000000..597cb29 --- /dev/null +++ b/Tests/RunCMake/list/SORT-WrongOption-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at SORT-WrongOption.cmake:1 \(list\): + list sub-command SORT option "one_too_many" is unknown. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/SORT-TooManyArguments.cmake b/Tests/RunCMake/list/SORT-WrongOption.cmake index 81b195d..81b195d 100644 --- a/Tests/RunCMake/list/SORT-TooManyArguments.cmake +++ b/Tests/RunCMake/list/SORT-WrongOption.cmake diff --git a/Tests/RunCMake/list/SORT.cmake b/Tests/RunCMake/list/SORT.cmake new file mode 100644 index 0000000..4a9e064 --- /dev/null +++ b/Tests/RunCMake/list/SORT.cmake @@ -0,0 +1,114 @@ +set(source_unsorted + c/B.h + a/c.h + B/a.h + ) + +## Test with default options +set(expected + B/a.h + a/c.h + c/B.h + ) +set(list ${source_unsorted}) +list(SORT list) +if (NOT expected STREQUAL list) + message(FATAL_ERROR "wrong sort result with command list(SORT list CASE SENSITIVE ORDER ASCENDING COMPARE STRING)") +endif () + + +## Test CASE INSENSITIVE ORDER ASCENDING COMPARE STRING +set(expected + a/c.h + B/a.h + c/B.h + ) +set(list ${source_unsorted}) +list(SORT list CASE INSENSITIVE ORDER ASCENDING COMPARE STRING) +if (NOT expected STREQUAL list) + message(FATAL_ERROR "wrong sort result with command list(SORT list CASE INSENSITIVE ORDER ASCENDING COMPARE STRING)") +endif () + +## Test CASE INSENSITIVE ORDER DESCENDING COMPARE STRING +set(expected + c/B.h + B/a.h + a/c.h + ) +set(list ${source_unsorted}) +list(SORT list CASE INSENSITIVE ORDER DESCENDING COMPARE STRING) +if (NOT expected STREQUAL list) + message(FATAL_ERROR "wrong sort result with command list(SORT list CASE INSENSITIVE ORDER DESCENDING COMPARE STRING)") +endif () + +## Test CASE SENSITIVE ORDER ASCENDING COMPARE STRING +set(expected + B/a.h + a/c.h + c/B.h + ) +set(list ${source_unsorted}) +list(SORT list CASE SENSITIVE ORDER ASCENDING COMPARE STRING) +if (NOT expected STREQUAL list) + message(FATAL_ERROR "wrong sort result with command list(SORT list CASE SENSITIVE ORDER ASCENDING COMPARE STRING)") +endif () + +## Test CASE SENSITIVE ORDER DESCENDING COMPARE STRING +set(expected + c/B.h + a/c.h + B/a.h + ) +set(list ${source_unsorted}) +list(SORT list CASE SENSITIVE ORDER DESCENDING COMPARE STRING) +if (NOT expected STREQUAL list) + message(FATAL_ERROR "wrong sort result with command list(SORT list CASE SENSITIVE ORDER DESCENDING COMPARE STRING)") +endif () + +## Test CASE INSENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME +set(expected + B/a.h + c/B.h + a/c.h + ) +set(list ${source_unsorted}) +list(SORT list CASE INSENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME) +if (NOT expected STREQUAL list) + message(FATAL_ERROR "wrong sort result with command list(SORT list CASE INSENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME)") +endif () + +## Test CASE INSENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME +set(expected + a/c.h + c/B.h + B/a.h + ) +set(list ${source_unsorted}) +list(SORT list CASE INSENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME) +if (NOT expected STREQUAL list) + message(FATAL_ERROR "wrong sort result with command list(SORT list CASE INSENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME)") +endif () + +## Test CASE SENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME +set(expected + c/B.h + B/a.h + a/c.h + ) +set(list ${source_unsorted}) +list(SORT list CASE SENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME) +if (NOT expected STREQUAL list) + message(FATAL_ERROR "wrong sort result with command list(SORT list CASE SENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME)") +endif () + +## Test CASE SENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME +set(expected + a/c.h + B/a.h + c/B.h + ) +set(list ${source_unsorted}) +list(SORT list CASE SENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME) +if (NOT expected STREQUAL list) + message(FATAL_ERROR "wrong sort result with command list(SORT list CASE SENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME)") +endif () diff --git a/Tests/RunCMake/math/CMakeLists.txt b/Tests/RunCMake/math/CMakeLists.txt new file mode 100644 index 0000000..12cd3c7 --- /dev/null +++ b/Tests/RunCMake/math/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/math/MATH-DivideByZero-result.txt b/Tests/RunCMake/math/MATH-DivideByZero-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/math/MATH-DivideByZero-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/math/MATH-DivideByZero-stderr.txt b/Tests/RunCMake/math/MATH-DivideByZero-stderr.txt new file mode 100644 index 0000000..66ad633 --- /dev/null +++ b/Tests/RunCMake/math/MATH-DivideByZero-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at MATH-DivideByZero.cmake:1 \(math\): + math cannot evaluate the expression: "100/0": divide by zero. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/math/MATH-DivideByZero.cmake b/Tests/RunCMake/math/MATH-DivideByZero.cmake new file mode 100644 index 0000000..3ac161e --- /dev/null +++ b/Tests/RunCMake/math/MATH-DivideByZero.cmake @@ -0,0 +1 @@ +math(EXPR var "100/0") diff --git a/Tests/RunCMake/math/MATH-DoubleOption-result.txt b/Tests/RunCMake/math/MATH-DoubleOption-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/math/MATH-DoubleOption-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/math/MATH-DoubleOption-stderr.txt b/Tests/RunCMake/math/MATH-DoubleOption-stderr.txt new file mode 100644 index 0000000..767a060 --- /dev/null +++ b/Tests/RunCMake/math/MATH-DoubleOption-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at MATH-DoubleOption.cmake:1 \(math\): + math EXPR called with incorrect arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/math/MATH-DoubleOption.cmake b/Tests/RunCMake/math/MATH-DoubleOption.cmake new file mode 100644 index 0000000..7bcb78e --- /dev/null +++ b/Tests/RunCMake/math/MATH-DoubleOption.cmake @@ -0,0 +1 @@ +math(EXPR var "10*10" OUTPUT_FORMAT DECIMAL OUTPUT_FORMAT HEXADECIMAL) diff --git a/Tests/RunCMake/math/MATH-InvalidExpression-result.txt b/Tests/RunCMake/math/MATH-InvalidExpression-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/math/MATH-InvalidExpression-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/math/MATH-InvalidExpression-stderr.txt b/Tests/RunCMake/math/MATH-InvalidExpression-stderr.txt new file mode 100644 index 0000000..9e73ed5 --- /dev/null +++ b/Tests/RunCMake/math/MATH-InvalidExpression-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at MATH-InvalidExpression.cmake:1 \(math\): + math cannot parse the expression: "INVALID": syntax error, unexpected \$end, + expecting exp_PLUS or exp_MINUS or exp_OPENPARENT or exp_NUMBER \(7\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/math/MATH-InvalidExpression.cmake b/Tests/RunCMake/math/MATH-InvalidExpression.cmake new file mode 100644 index 0000000..6e37128 --- /dev/null +++ b/Tests/RunCMake/math/MATH-InvalidExpression.cmake @@ -0,0 +1 @@ +math(EXPR var "INVALID") diff --git a/Tests/RunCMake/math/MATH-ToleratedExpression-stderr.txt b/Tests/RunCMake/math/MATH-ToleratedExpression-stderr.txt new file mode 100644 index 0000000..732ce6f --- /dev/null +++ b/Tests/RunCMake/math/MATH-ToleratedExpression-stderr.txt @@ -0,0 +1,8 @@ +^CMake Warning \(dev\) at MATH-ToleratedExpression.cmake:1 \(math\): + Unexpected character in expression at position 1: ' + + Unexpected character in expression at position 7: ' + +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/math/MATH-ToleratedExpression.cmake b/Tests/RunCMake/math/MATH-ToleratedExpression.cmake new file mode 100644 index 0000000..d1be218 --- /dev/null +++ b/Tests/RunCMake/math/MATH-ToleratedExpression.cmake @@ -0,0 +1,4 @@ +math(EXPR var "'2*1-1'") +if(NOT var EQUAL 1) + message(FATAL_ERROR "Expression did not evaluate to 1") +endif() diff --git a/Tests/RunCMake/math/MATH-TooManyArguments-result.txt b/Tests/RunCMake/math/MATH-TooManyArguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/math/MATH-TooManyArguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/math/MATH-TooManyArguments-stderr.txt b/Tests/RunCMake/math/MATH-TooManyArguments-stderr.txt new file mode 100644 index 0000000..fdcfecf --- /dev/null +++ b/Tests/RunCMake/math/MATH-TooManyArguments-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at MATH-TooManyArguments.cmake:1 \(math\): + math EXPR called with incorrect arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/math/MATH-TooManyArguments.cmake b/Tests/RunCMake/math/MATH-TooManyArguments.cmake new file mode 100644 index 0000000..969dc80 --- /dev/null +++ b/Tests/RunCMake/math/MATH-TooManyArguments.cmake @@ -0,0 +1 @@ +math(EXPR var "10*10" OUTPUT_FORMAT DECIMAL OUTPUT_FORMAT ) diff --git a/Tests/RunCMake/math/MATH-WrongArgument-result.txt b/Tests/RunCMake/math/MATH-WrongArgument-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/math/MATH-WrongArgument-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/math/MATH-WrongArgument-stderr.txt b/Tests/RunCMake/math/MATH-WrongArgument-stderr.txt new file mode 100644 index 0000000..bbe54bf --- /dev/null +++ b/Tests/RunCMake/math/MATH-WrongArgument-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at MATH-WrongArgument.cmake:1 \(math\): + math sub-command EXPR option "OUT" is unknown. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/math/MATH-WrongArgument.cmake b/Tests/RunCMake/math/MATH-WrongArgument.cmake new file mode 100644 index 0000000..fb6d2e7 --- /dev/null +++ b/Tests/RunCMake/math/MATH-WrongArgument.cmake @@ -0,0 +1 @@ +math(EXPR var "10*10" OUT HEX ) diff --git a/Tests/RunCMake/math/MATH.cmake b/Tests/RunCMake/math/MATH.cmake new file mode 100644 index 0000000..a5f50cd --- /dev/null +++ b/Tests/RunCMake/math/MATH.cmake @@ -0,0 +1,12 @@ +macro(math_test expression expected) + math(EXPR evaluated ${expression} ${ARGN}) + if (NOT evaluated STREQUAL ${expected}) + message(FATAL_ERROR "wrong math result: ${evaluated} != ${expected}") + endif () +endmacro() + + +math_test("100 * 10" 1000) +math_test("100 * 10" 1000 OUTPUT_FORMAT DECIMAL) +math_test("100 * 0xA" 1000 OUTPUT_FORMAT DECIMAL) +math_test("100 * 0xA" 0x3e8 OUTPUT_FORMAT HEXADECIMAL) diff --git a/Tests/RunCMake/math/RunCMakeTest.cmake b/Tests/RunCMake/math/RunCMakeTest.cmake new file mode 100644 index 0000000..a4d5c31 --- /dev/null +++ b/Tests/RunCMake/math/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCMake) + +run_cmake(MATH) +run_cmake(MATH-WrongArgument) +run_cmake(MATH-DoubleOption) +run_cmake(MATH-TooManyArguments) +run_cmake(MATH-InvalidExpression) +run_cmake(MATH-ToleratedExpression) +run_cmake(MATH-DivideByZero) diff --git a/Tests/RunCMake/option/CMP0077-NEW.cmake b/Tests/RunCMake/option/CMP0077-NEW.cmake new file mode 100644 index 0000000..d4c518b --- /dev/null +++ b/Tests/RunCMake/option/CMP0077-NEW.cmake @@ -0,0 +1,14 @@ + +#Verify that option DOESN'T overwrite existing normal variable when the policy +#is set to NEW +cmake_policy(SET CMP0077 NEW) +set(OPT_LOCAL_VAR FALSE) +option(OPT_LOCAL_VAR "TEST_VAR" ON) +if(OPT_LOCAL_VAR) + message(FATAL_ERROR "option failed to overwrite existing normal variable") +endif() + +get_property(_exists_in_cache CACHE OPT_LOCAL_VAR PROPERTY VALUE SET) +if(_exists_in_cache) + message(FATAL_ERROR "value should not exist in cache as it was already a local variable") +endif() diff --git a/Tests/RunCMake/option/CMP0077-OLD.cmake b/Tests/RunCMake/option/CMP0077-OLD.cmake new file mode 100644 index 0000000..4c52d4b --- /dev/null +++ b/Tests/RunCMake/option/CMP0077-OLD.cmake @@ -0,0 +1,9 @@ + +#Verify that option overwrites existing normal variable when the policy +#is set to OLD +cmake_policy(SET CMP0077 OLD) +set(OPT_LOCAL_VAR FALSE) +option(OPT_LOCAL_VAR "TEST_VAR" ON) +if(NOT OPT_LOCAL_VAR) + message(FATAL_ERROR "option failed to overwrite existing normal variable") +endif() diff --git a/Tests/RunCMake/option/CMP0077-SECOND-PASS.cmake b/Tests/RunCMake/option/CMP0077-SECOND-PASS.cmake new file mode 100644 index 0000000..f62a853 --- /dev/null +++ b/Tests/RunCMake/option/CMP0077-SECOND-PASS.cmake @@ -0,0 +1,14 @@ + +#Verify that when both a cache and local version of a value exist that CMake +#doesn't produce a CMP0077 warning and that we get the expected values. +option(OPT_LOCAL_VAR "TEST_VAR" ON) +set(OPT_LOCAL_VAR FALSE) +option(OPT_LOCAL_VAR "TEST_VAR" ON) +if(OPT_LOCAL_VAR) + message(FATAL_ERROR "option improperly set a cache variable that already exists") +endif() + +get_property(_exists_in_cache CACHE OPT_LOCAL_VAR PROPERTY VALUE SET) +if(NOT _exists_in_cache) + message(FATAL_ERROR "value should exist in cache") +endif() diff --git a/Tests/RunCMake/option/CMP0077-WARN-stderr.txt b/Tests/RunCMake/option/CMP0077-WARN-stderr.txt new file mode 100644 index 0000000..0d02ffb --- /dev/null +++ b/Tests/RunCMake/option/CMP0077-WARN-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at CMP0077-WARN.cmake:5 \(option\): + Policy CMP0077 is not set: option\(\) honors normal variables. Run "cmake + --help-policy CMP0077" for policy details. Use the cmake_policy command to + set the policy and suppress this warning. + + For compatibility with older versions of CMake, option is clearing the + normal variable 'OPT_LOCAL_VAR'. diff --git a/Tests/RunCMake/option/CMP0077-WARN.cmake b/Tests/RunCMake/option/CMP0077-WARN.cmake new file mode 100644 index 0000000..7f99456 --- /dev/null +++ b/Tests/RunCMake/option/CMP0077-WARN.cmake @@ -0,0 +1,5 @@ + +#Verify that option overwrites existing normal variable when the policy +#is set to OLD +set(OPT_LOCAL_VAR FALSE) +option(OPT_LOCAL_VAR "TEST_VAR" ON) diff --git a/Tests/RunCMake/option/CMakeLists.txt b/Tests/RunCMake/option/CMakeLists.txt new file mode 100644 index 0000000..11dc49a --- /dev/null +++ b/Tests/RunCMake/option/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.12) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/option/RunCMakeTest.cmake b/Tests/RunCMake/option/RunCMakeTest.cmake new file mode 100644 index 0000000..979afa1 --- /dev/null +++ b/Tests/RunCMake/option/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) + +run_cmake(CMP0077-OLD) +run_cmake(CMP0077-NEW) +run_cmake(CMP0077-WARN) +run_cmake(CMP0077-SECOND-PASS) diff --git a/Tests/RunCMake/set_property/LINK_OPTIONS-stdout.txt b/Tests/RunCMake/set_property/LINK_OPTIONS-stdout.txt new file mode 100644 index 0000000..033792a --- /dev/null +++ b/Tests/RunCMake/set_property/LINK_OPTIONS-stdout.txt @@ -0,0 +1,2 @@ +-- Target LINK_OPTIONS is 'a;b;c;d;;e' +-- Directory LINK_OPTIONS is 'a;b;c;d;;e' diff --git a/Tests/RunCMake/set_property/LINK_OPTIONS.cmake b/Tests/RunCMake/set_property/LINK_OPTIONS.cmake new file mode 100644 index 0000000..6daf41b --- /dev/null +++ b/Tests/RunCMake/set_property/LINK_OPTIONS.cmake @@ -0,0 +1,3 @@ +include(Common.cmake) +test_target_property(LINK_OPTIONS) +test_directory_property(LINK_OPTIONS) diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake index b966e89..77da703 100644 --- a/Tests/RunCMake/set_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake @@ -5,6 +5,7 @@ run_cmake(COMPILE_FEATURES) run_cmake(COMPILE_OPTIONS) run_cmake(IMPORTED_GLOBAL) run_cmake(INCLUDE_DIRECTORIES) +run_cmake(LINK_OPTIONS) run_cmake(LINK_LIBRARIES) run_cmake(SOURCES) run_cmake(TYPE) diff --git a/Tests/RunCMake/target_link_options/CMakeLists.txt b/Tests/RunCMake/target_link_options/CMakeLists.txt new file mode 100644 index 0000000..14ef56e --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.11) + +project(${RunCMake_TEST} LANGUAGES NONE) + +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER-check.cmake b/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER-check.cmake new file mode 100644 index 0000000..d0ef8de --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER-check.cmake @@ -0,0 +1,2 @@ + +include ("${CMAKE_CURRENT_LIST_DIR}/LINKER_expansion-validation.cmake") diff --git a/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER_SHELL-check.cmake b/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER_SHELL-check.cmake new file mode 100644 index 0000000..d0ef8de --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER_SHELL-check.cmake @@ -0,0 +1,2 @@ + +include ("${CMAKE_CURRENT_LIST_DIR}/LINKER_expansion-validation.cmake") diff --git a/Tests/RunCMake/target_link_options/LINKER_expansion-validation.cmake b/Tests/RunCMake/target_link_options/LINKER_expansion-validation.cmake new file mode 100644 index 0000000..1af8f13 --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINKER_expansion-validation.cmake @@ -0,0 +1,15 @@ + +if (actual_stdout MATCHES "LINKER:") + set (RunCMake_TEST_FAILED "LINKER: prefix was not expanded.") + return() +endif() + +if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/LINKER.txt") + set (RunCMake_TEST_FAILED "${RunCMake_TEST_BINARY_DIR}/LINKER.txt: Reference file not found.") + return() +endif() +file(READ "${RunCMake_TEST_BINARY_DIR}/LINKER.txt" linker_flag) + +if (NOT actual_stdout MATCHES "${linker_flag}") + set (RunCMake_TEST_FAILED "LINKER: was not expanded correctly.") +endif() diff --git a/Tests/RunCMake/target_link_options/LINKER_expansion.cmake b/Tests/RunCMake/target_link_options/LINKER_expansion.cmake new file mode 100644 index 0000000..b344867 --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINKER_expansion.cmake @@ -0,0 +1,49 @@ + +enable_language(C) + +add_executable(dump dump.c) + +# ensure no temp file will be used +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}") + + +# Use LINKER alone +add_library(linker SHARED LinkOptionsLib.c) +target_link_options(linker PRIVATE "LINKER:-foo,bar") + +# use LAUNCH facility to dump linker command +set_property(TARGET linker PROPERTY RULE_LAUNCH_LINK "\"${CMAKE_CURRENT_BINARY_DIR}/dump${CMAKE_EXECUTABLE_SUFFIX}\"") + +add_dependencies (linker dump) + + +# Use LINKER with SHELL +add_library(linker_shell SHARED LinkOptionsLib.c) +target_link_options(linker_shell PRIVATE "LINKER:SHELL:-foo bar") + +# use LAUNCH facility to dump linker command +set_property(TARGET linker_shell PROPERTY RULE_LAUNCH_LINK "\"${CMAKE_CURRENT_BINARY_DIR}/dump${CMAKE_EXECUTABLE_SUFFIX}\"") + +add_dependencies (linker_shell dump) + + +# generate reference for LINKER flag +if (CMAKE_C_LINKER_WRAPPER_FLAG) + set(linker_flag ${CMAKE_C_LINKER_WRAPPER_FLAG}) + list(GET linker_flag -1 linker_space) + if (linker_space STREQUAL " ") + list(REMOVE_AT linker_flag -1) + else() + set(linker_space) + endif() + list (JOIN linker_flag " " linker_flag) + if (CMAKE_C_LINKER_WRAPPER_FLAG_SEP) + string (APPEND linker_flag "${linker_space}" "-foo${CMAKE_C_LINKER_WRAPPER_FLAG_SEP}bar") + else() + set (linker_flag "${linker_flag}${linker_space}-foo ${linker_flag}${linker_space}bar") + endif() +else() + set(linker_flag "-foo bar") +endif() +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LINKER.txt" "${linker_flag}") diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-check.cmake new file mode 100644 index 0000000..7799506 --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-check.cmake @@ -0,0 +1,7 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_PRIVATE") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_PRIVATE'.") +endif() +if (actual_stdout MATCHES "BADFLAG_INTERFACE") + string (APPEND RunCMake_TEST_FAILED "\nFound unexpected 'BADFLAG_INTERFACE'.") +endif() diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-check.cmake new file mode 100644 index 0000000..a686de9 --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-check.cmake @@ -0,0 +1,7 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_RELEASE") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_RELEASE'.") +endif() +if (actual_stdout MATCHES "SHELL:") + string (APPEND RunCMake_TEST_FAILED "\nFound unexpected prefix 'SHELL:'.") +endif() diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-check.cmake new file mode 100644 index 0000000..6c5ffdb --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_INTERFACE") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_INTERFACE'.") +endif() diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-check.cmake new file mode 100644 index 0000000..a686de9 --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-check.cmake @@ -0,0 +1,7 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_RELEASE") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_RELEASE'.") +endif() +if (actual_stdout MATCHES "SHELL:") + string (APPEND RunCMake_TEST_FAILED "\nFound unexpected prefix 'SHELL:'.") +endif() diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-check.cmake new file mode 100644 index 0000000..a686de9 --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-check.cmake @@ -0,0 +1,7 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_RELEASE") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_RELEASE'.") +endif() +if (actual_stdout MATCHES "SHELL:") + string (APPEND RunCMake_TEST_FAILED "\nFound unexpected prefix 'SHELL:'.") +endif() diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake new file mode 100644 index 0000000..f17195d --- /dev/null +++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake @@ -0,0 +1,39 @@ + +enable_language(C) + +set(obj "${CMAKE_C_OUTPUT_EXTENSION}") +if(BORLAND) + set(pre -) +endif() + +# basic configuration +add_library(LinkOptions SHARED LinkOptionsLib.c) +target_link_options(LinkOptions + PRIVATE ${pre}BADFLAG_PRIVATE${obj} + INTERFACE ${pre}BADFLAG_INTERFACE${obj}) + + +# INTERFACE_LINK_OPTIONS +add_library(LinkOptions_producer SHARED LinkOptionsLib.c) +target_link_options(LinkOptions_producer + INTERFACE ${pre}BADFLAG_INTERFACE${obj}) + +add_executable(LinkOptions_consumer LinkOptionsExe.c) +target_link_libraries(LinkOptions_consumer PRIVATE LinkOptions_producer) + + +# shared library with generator expression +add_library(LinkOptions_shared SHARED LinkOptionsLib.c) +target_link_options(LinkOptions_shared PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}> + "SHELL:" # produces no options + ) + + +# module library with generator expression +add_library(LinkOptions_mod MODULE LinkOptionsLib.c) +target_link_options(LinkOptions_mod PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>) + + +# executable with generator expression +add_executable(LinkOptions_exe LinkOptionsExe.c) +target_link_options(LinkOptions_exe PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>) diff --git a/Tests/RunCMake/target_link_options/LinkOptionsExe.c b/Tests/RunCMake/target_link_options/LinkOptionsExe.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/target_link_options/LinkOptionsExe.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/target_link_options/LinkOptionsLib.c b/Tests/RunCMake/target_link_options/LinkOptionsLib.c new file mode 100644 index 0000000..9bbd24c --- /dev/null +++ b/Tests/RunCMake/target_link_options/LinkOptionsLib.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) +__declspec(dllexport) +#endif + int flags_lib(void) +{ + return 0; +} diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake new file mode 100644 index 0000000..121a0ce --- /dev/null +++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake @@ -0,0 +1,39 @@ + +include(RunCMake) + +macro(run_cmake_target test subtest target) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN}) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endmacro() + +if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") + # Intel compiler does not reject bad flags or objects! + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + + run_cmake(LINK_OPTIONS) + + run_cmake_target(LINK_OPTIONS basic LinkOptions) + run_cmake_target(LINK_OPTIONS interface LinkOptions_consumer) + run_cmake_target(LINK_OPTIONS shared LinkOptions_shared --config Release) + run_cmake_target(LINK_OPTIONS mod LinkOptions_mod --config Release) + run_cmake_target(LINK_OPTIONS exe LinkOptions_exe --config Release) + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) +endif() + +run_cmake(bad_SHELL_usage) + +if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)") + run_cmake(LINKER_expansion) + + run_cmake_target(LINKER_expansion LINKER linker) + run_cmake_target(LINKER_expansion LINKER_SHELL linker_shell) +endif() diff --git a/Tests/RunCMake/target_link_options/bad_SHELL_usage-result.txt b/Tests/RunCMake/target_link_options/bad_SHELL_usage-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_options/bad_SHELL_usage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_options/bad_SHELL_usage-stderr.txt b/Tests/RunCMake/target_link_options/bad_SHELL_usage-stderr.txt new file mode 100644 index 0000000..bffd80a --- /dev/null +++ b/Tests/RunCMake/target_link_options/bad_SHELL_usage-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at bad_SHELL_usage.cmake:4 \(add_library\): + 'SHELL:' prefix is not supported as part of 'LINKER:' arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:5 \(include\) diff --git a/Tests/RunCMake/target_link_options/bad_SHELL_usage.cmake b/Tests/RunCMake/target_link_options/bad_SHELL_usage.cmake new file mode 100644 index 0000000..b0adf19 --- /dev/null +++ b/Tests/RunCMake/target_link_options/bad_SHELL_usage.cmake @@ -0,0 +1,5 @@ + +enable_language(C) + +add_library(example SHARED LinkOptionsLib.c) +target_link_options(example PRIVATE "LINKER:-foo,SHELL:-bar") diff --git a/Tests/RunCMake/target_link_options/dump.c b/Tests/RunCMake/target_link_options/dump.c new file mode 100644 index 0000000..8baa313 --- /dev/null +++ b/Tests/RunCMake/target_link_options/dump.c @@ -0,0 +1,13 @@ + +#include "stdio.h" + +int main(int argc, char* argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + printf("%s ", argv[i]); + printf("\n"); + + return 0; +} diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt deleted file mode 100644 index a07f687..0000000 --- a/Tests/SimpleInstall/CMakeLists.txt +++ /dev/null @@ -1,398 +0,0 @@ -cmake_minimum_required (VERSION 3.9) -project (TestSimpleInstall) -set(CMAKE_VERBOSE_MAKEFILE 1) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY - "${TestSimpleInstall_BINARY_DIR}/bin") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY - "${TestSimpleInstall_BINARY_DIR}/lib/static") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY - "${TestSimpleInstall_BINARY_DIR}/lib") - -# Skip generating the rpath pointing at the build tree to make sure -# the executable is installed with the proper rpath in the install -# tree. -set(CMAKE_SKIP_BUILD_RPATH 1) - -# Make sure the executable can run from the install tree. -set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib) - -# Skip the dependency that causes a build when installing. This -# avoids infinite loops when the post-build rule below installs. -set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1) -set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY 1) - -set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") - -set(EXTRA_INSTALL_FLAGS) -message("Extra install: ${EXTRA_INSTALL_FLAGS}") - -if(STAGE2) - set(LIBPATHS - ${CMAKE_INSTALL_PREFIX}/MyTest/lib/static - ${CMAKE_INSTALL_PREFIX}/MyTest/lib - ) - set(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX} test1rel) - set(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX}) - set(t4NAMES test4out test4out${CMAKE_DEBUG_POSTFIX}) - - # Make sure the install script ran. - set(CMAKE_INSTALL_SCRIPT_DID_RUN 0) - include(${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake OPTIONAL) - if(CMAKE_INSTALL_SCRIPT_DID_RUN) - message(STATUS "Stage 1 did run install script 2.") - else() - message(SEND_ERROR "Stage 1 did not run install script 2.") - endif() - - if(CYGWIN OR MINGW) - set(LIBPATHS ${LIBPATHS} "${CMAKE_INSTALL_PREFIX}/MyTest/bin") - endif() - message("Search for library in: ${LIBPATHS}") - - set(TEST1_LIBRARY "TEST1_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) - set(TEST2_LIBRARY "TEST2_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) - set(TEST4_LIBRARY "TEST4_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) - - find_library(TEST1_LIBRARY - NAMES ${t1NAMES} - PATHS ${LIBPATHS} - DOC "First library") - find_library(TEST2_LIBRARY - NAMES ${t2NAMES} - PATHS ${LIBPATHS} - DOC "Second library") - find_library(TEST4_LIBRARY - NAMES ${t4NAMES} - PATHS ${LIBPATHS} - DOC "Fourth library") - - # Test importing a library found on disk. - add_library(lib_test4 UNKNOWN IMPORTED) - set_property(TARGET lib_test4 PROPERTY IMPORTED_LOCATION ${TEST4_LIBRARY}) - - include_directories(${CMAKE_INSTALL_PREFIX}/MyTest/include) - add_executable (SimpleInstExeS2 inst2.cxx foo.c foo.h) - target_link_libraries(SimpleInstExeS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} lib_test4) - set(install_target SimpleInstExeS2) - - if("${TEST1_LIBRARY}" MATCHES "static") - message(STATUS "test1 correctly found in lib/static") - else() - message(SEND_ERROR "test1 not found in lib/static!") - endif() - - # Check for failure of configuration-specific installation. - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h") - message(FATAL_ERROR "Debug-configuration file installed for Release!") - endif() - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") - message(FATAL_ERROR "Release-configuration file installed for Debug!") - endif() - - # Check for failure of directory installation. - if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h") - message(FATAL_ERROR "Directory installation did not install TSD.h") - endif() - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") - message(FATAL_ERROR "Directory installation installed CVS directory.") - endif() - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") - message(FATAL_ERROR "Directory installation installed CVS directory.") - endif() - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CMakeLists.txt") - message(FATAL_ERROR "Directory installation installed CMakeLists.txt.") - endif() - if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.h") - message(FATAL_ERROR "Directory installation did not install alternate TSD.h") - endif() - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.cxx") - message(FATAL_ERROR "Directory installation installed alternate TSD.cxx") - endif() - - # Check that scripts properly installed. - if(WIN32 AND NOT CYGWIN) - set(BAT .bat) - else() - set(BAT) - endif() - foreach(loc share share/old1 share/old2 share/old3 share/alt) - set(CUR_SCRIPT "${CMAKE_INSTALL_PREFIX}/MyTest/${loc}/sample_script${BAT}") - execute_process( - COMMAND ${CUR_SCRIPT} - RESULT_VARIABLE SAMPLE_SCRIPT_RESULT - OUTPUT_VARIABLE SAMPLE_SCRIPT_OUTPUT - ) - if(NOT "${SAMPLE_SCRIPT_RESULT}" STREQUAL "0") - message(FATAL_ERROR - "Sample script [${CUR_SCRIPT}] failed: [${SAMPLE_SCRIPT_RESULT}]") - endif() - if(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output") - message(FATAL_ERROR - "Bad sample script [${CUR_SCRIPT}] output: [${SAMPLE_SCRIPT_OUTPUT}]") - endif() - endforeach() - - # Check for failure of empty directory installation. - if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty") - message(FATAL_ERROR "Empty directory installation did not install.") - endif() - file(GLOB EMPTY_FILES "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty/*") - if(EMPTY_FILES) - message(FATAL_ERROR "Empty directory installed [${EMPTY_FILES}].") - endif() - - # Make sure the test executable can run from the install tree. - set_target_properties(SimpleInstExeS2 PROPERTIES - INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) - - install_targets(/MyTest/bin SimpleInstExeS2) - -# try to import the exported targets again - set(SimpleInstallS1_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib) - find_package(SimpleInstallS1 REQUIRED) - get_target_property(simpleInstallImported S1_SimpleInstall IMPORTED) - if(NOT simpleInstallImported) - message(FATAL_ERROR "Target S1_SimpleInstall could not be imported") - endif() - -else() - # Wipe out the install directory to do a fresh test. - file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/MyTest) - - # this is stage 1, so create libraries and modules and install everything - add_library(test1 STATIC lib1.cxx) - add_library(test2 SHARED lib2.cxx) - add_library(test3 MODULE lib3.cxx) - add_library(test4 SHARED lib4.cxx) - - # Test <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME properties. - set_property(TARGET test4 PROPERTY ARCHIVE_OUTPUT_NAME test4out) - set_property(TARGET test4 PROPERTY LIBRARY_OUTPUT_NAME test4out) - - add_executable (SimpleInstall inst.cxx foo.c foo.h) - target_link_libraries(SimpleInstall test1 test2 test4) - set(install_target SimpleInstall) - - set_target_properties(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) - # Disable VERSION test until it is implemented in the Xcode generator. - if(NOT XCODE) - set_target_properties(SimpleInstall PROPERTIES VERSION 1.2) - endif() - - # Make sure the test executable can run from the install tree. - set_target_properties(SimpleInstall PROPERTIES - INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) - - # Test per-configuration output name. - set_target_properties(test1 PROPERTIES RELEASE_OUTPUT_NAME test1rel) - set_target_properties(test2 PROPERTIES PUBLIC_HEADER foo.h) - - if(CMAKE_GENERATOR MATCHES "Makefiles") - add_subdirectory(TestSubDir) - add_dependencies(SimpleInstall TSD) - endif() - - add_dependencies(SimpleInstall test3) - add_dependencies(test2 test3) - add_dependencies(test4 test2) - - install(TARGETS SimpleInstall test1 test2 test3 EXPORT SimpleInstallS1 - RUNTIME DESTINATION MyTest/bin COMPONENT Runtime # .exe, .dll - LIBRARY DESTINATION MyTest/lib COMPONENT Runtime # .so, mod.dll - ARCHIVE DESTINATION MyTest/lib/static COMPONENT Development # .a, .lib - PUBLIC_HEADER DESTINATION MyTest/include COMPONENT Development - ) - - install(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - RUNTIME DESTINATION MyTest/bin - LIBRARY DESTINATION MyTest/lib - ARCHIVE DESTINATION MyTest/lib/static - OPTIONAL # for coverage...target should always exist - ) - install(FILES lib1.h DESTINATION MyTest/include/$<1:foo>$<0:/wrong>) - install(FILES lib2.h - DESTINATION $<1:MyTest/include/foo>$<0:/wrong> - COMPONENT Development - PERMISSIONS OWNER_READ OWNER_WRITE - RENAME lib2renamed.h - ) - - # Test old-style install commands. - install_files(/MyTest/include FILES lib3.h) - install_files(/MyTest/include/old .h lib3) - install_files(/MyTest/include/old "^lib2.h$") - install_programs(/MyTest/share/old1 FILES - scripts/sample_script scripts/sample_script.bat) - install_programs(/MyTest/share/old2 - scripts/sample_script scripts/sample_script.bat) - -# "export" the targets collected in "SimpleInstallS1" - install(EXPORT SimpleInstallS1 FILE SimpleInstallS1Config.cmake - DESTINATION MyTest/lib - NAMESPACE S1_ ) - - export(TARGETS SimpleInstall test1 test2 test3 - FILE "${CMAKE_CURRENT_BINARY_DIR}/SimpleInstallS1Config.cmake" - NAMESPACE S2_ ) - - add_subdirectory(scripts) - - # Test optional installation. - install(FILES does_not_exist.h DESTINATION MyTest/include/foo OPTIONAL) - - # Test configuration-specific installation. - install(FILES lib1.h RENAME lib1release.h CONFIGURATIONS Release - DESTINATION MyTest/include/Release - ) - install(FILES lib1.h RENAME lib1debug.h CONFIGURATIONS Debug - DESTINATION MyTest/include/Debug - ) - - # Test directory installation. - file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") - file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") - install( - DIRECTORY TestSubDir $<1:scripts/>$<0:/wrong> DESTINATION $<1:MyTest/share>$<0:/wrong> - FILE_PERMISSIONS OWNER_READ OWNER_WRITE - DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE - PATTERN "CVS" EXCLUDE - REGEX "\\.txt$" EXCLUDE - PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ - ) - - # Alternate directory installation for coverage. - install( - DIRECTORY $<1:scripts/>$<0:/wrong> DESTINATION $<1:MyTest/share/alt>$<0:/wrong> - COMPONENT Development - USE_SOURCE_PERMISSIONS - PATTERN "CVS" EXCLUDE - REGEX "\\.txt$" EXCLUDE - ) - install( - DIRECTORY TestSubDir DESTINATION $<1:MyTest/share/alt>$<0:/wrong> - FILE_PERMISSIONS OWNER_READ OWNER_WRITE - DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE - FILES_MATCHING PATTERN "*.h" - ) - - # Test empty directory installation. - install(DIRECTORY DESTINATION MyTest/share/empty) - - # Test optional directory installation. - install(DIRECTORY does-not-exist DESTINATION MyTest/share OPTIONAL) - - # Test user-specified install scripts, with and without COMPONENT. - install( - SCRIPT InstallScript1.cmake - CODE "set(INSTALL_CODE_DID_RUN 1)" - SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript2.cmake - ) - install( - SCRIPT InstallScript3.cmake - CODE "set(INSTALL_CODE_WITH_COMPONENT_DID_RUN 1)" - SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript4.cmake - COMPONENT Development - ) - set_directory_properties(PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES - "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") - - set_target_properties(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT - ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) - set_target_properties(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT - ${CMAKE_CURRENT_SOURCE_DIR}/PostInstall.cmake) - set_target_properties(test4 PROPERTIES VERSION 1.2 SOVERSION 3 - INSTALL_NAME_DIR @executable_path/../lib) -endif() - -get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if(_isMultiConfig) - set(SI_CONFIG --config $<CONFIGURATION>) -else() - set(SI_CONFIG) -endif() - -# Dummy test of CPack -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Test of packaging with cpack") -set(CPACK_PACKAGE_VENDOR "Kitware") -set(CPACK_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/PackageScript.cmake") - -if(WIN32 AND NOT UNIX) - find_program(NSIS_MAKENSIS NAMES makensis - PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS] - DOC "Where is makensis.exe located" - ) - if(NOT NSIS_MAKENSIS) - set(CPACK_GENERATOR TGZ) - endif() -endif() -if(UNIX AND NOT APPLE) - set(CPACK_GENERATOR "TGZ;STGZ;TZ") - # find_program(found_compress - # NAMES compress) - # if(found_compress) - # find_program(file_command NAMES file) - # if(NOT file_command) - # set(file_command file) - # endif() - # execute_process(COMMAND ${file_command} ${found_compress} - # OUTPUT_VARIABLE output) - # set(SKIP_TZ FALSE) - # if("${output}" MATCHES "script") - # set(SKIP_TZ TRUE) - # endif() - # if("${output}" MATCHES "dummy.sh") - # set(SKIP_TZ TRUE) - # endif() - # if(NOT SKIP_TZ) - # message("compress found and it was not a script") - # message("output from file command: [${output}]") - # list(APPEND CPACK_GENERATOR "TZ") - # else() - # message("compress found, but it was a script so don't use it") - # message("output from file command: [${output}]") - # endif() - # endif() - find_program(found_bz2 - NAMES bzip2) - if(found_bz2) - list(APPEND CPACK_GENERATOR "TBZ2") - endif() -endif() - -set(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") -set(CMAKE_INSTALL_MFC_LIBRARIES 1) -set(CMAKE_INSTALL_DEBUG_LIBRARIES 1) -set(CMAKE_INSTALL_UCRT_LIBRARIES 1) -set(CMAKE_INSTALL_OPENMP_LIBRARIES 1) -include(InstallRequiredSystemLibraries) - -if(CTEST_TEST_CPACK) - set(package_command COMMAND - ${CMAKE_COMMAND} --build . --target package ${SI_CONFIG} - ) - - # Avoid settings that require the .zip file command line tools... - # (just build an NSIS installer without component support) - # - set(CPACK_BINARY_ZIP OFF) - set(CPACK_MONOLITHIC_INSTALL ON) -else() - set(package_command) -endif() - -include(CPack) - -set(install_command COMMAND - ${CMAKE_COMMAND} --build . --target install ${SI_CONFIG} - ) - -add_custom_command( - TARGET ${install_target} - POST_BUILD - ${install_command} - ${package_command} - COMMENT "Install Project" - ) diff --git a/Tests/SimpleInstall/InstallScript1.cmake b/Tests/SimpleInstall/InstallScript1.cmake deleted file mode 100644 index ef9da57..0000000 --- a/Tests/SimpleInstall/InstallScript1.cmake +++ /dev/null @@ -1,5 +0,0 @@ -message("This is install script 1.") -set(INSTALL_SCRIPT_1_DID_RUN 1) -if(INSTALL_CODE_DID_RUN) - message(FATAL_ERROR "Install script 1 did not run before install code.") -endif() diff --git a/Tests/SimpleInstall/InstallScript2.cmake b/Tests/SimpleInstall/InstallScript2.cmake deleted file mode 100644 index c1d20a3..0000000 --- a/Tests/SimpleInstall/InstallScript2.cmake +++ /dev/null @@ -1,14 +0,0 @@ -message("This is install script 2.") -if(INSTALL_SCRIPT_1_DID_RUN) - message("Install script ordering works.") -else() - message(FATAL_ERROR "Install script 1 did not run before install script 2.") -endif() -if(INSTALL_CODE_DID_RUN) - message("Install code ordering works.") -else() - message(FATAL_ERROR "Install script 2 did not run after install code.") -endif() -file(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake" - "set(CMAKE_INSTALL_SCRIPT_DID_RUN 1)\n" - ) diff --git a/Tests/SimpleInstall/InstallScript3.cmake b/Tests/SimpleInstall/InstallScript3.cmake deleted file mode 100644 index 6485156..0000000 --- a/Tests/SimpleInstall/InstallScript3.cmake +++ /dev/null @@ -1,12 +0,0 @@ -message("This is install script 3.") -set(INSTALL_SCRIPT_3_DID_RUN 1) -if(INSTALL_CODE_WITH_COMPONENT_DID_RUN) - message(FATAL_ERROR "Install script 3 did not run before install code with component.") -endif() - -if(CMAKE_INSTALL_COMPONENT) -if(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") - message("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"") - message(FATAL_ERROR "Install script 3 should only run for \"Development\" INSTALL COMPONENT.") -endif() -endif() diff --git a/Tests/SimpleInstall/InstallScript4.cmake b/Tests/SimpleInstall/InstallScript4.cmake deleted file mode 100644 index 34d0a73..0000000 --- a/Tests/SimpleInstall/InstallScript4.cmake +++ /dev/null @@ -1,22 +0,0 @@ -message("This is install script 4.") -if(INSTALL_SCRIPT_3_DID_RUN) - message("Install script ordering works.") -else() - message(FATAL_ERROR "Install script 3 did not run before install script 4.") -endif() -if(INSTALL_CODE_WITH_COMPONENT_DID_RUN) - message("Install code ordering works.") -else() - message(FATAL_ERROR "Install script 4 did not run after install with component code.") -endif() - -if(CMAKE_INSTALL_COMPONENT) -if(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") - message("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"") - message(FATAL_ERROR "Install script 4 should only run for \"Development\" INSTALL COMPONENT.") -endif() -endif() - -file(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScript4Out.cmake" - "set(CMAKE_INSTALL_SCRIPT_4_DID_RUN 1)\n" - ) diff --git a/Tests/SimpleInstall/PackageScript.cmake b/Tests/SimpleInstall/PackageScript.cmake deleted file mode 100644 index 53b7909..0000000 --- a/Tests/SimpleInstall/PackageScript.cmake +++ /dev/null @@ -1,10 +0,0 @@ -message("This is packaging script") -message("It writes a file with all variables available in ${CMAKE_INSTALL_PREFIX}/AllVariables.txt") - -file(WRITE ${CMAKE_INSTALL_PREFIX}/AllVariables.txt "") -get_cmake_property(res VARIABLES) -foreach(var ${res}) - file(APPEND ${CMAKE_INSTALL_PREFIX}/AllVariables.txt - "${var} \"${${var}}\"\n") -endforeach() - diff --git a/Tests/SimpleInstall/PostInstall.cmake b/Tests/SimpleInstall/PostInstall.cmake deleted file mode 100644 index d616221..0000000 --- a/Tests/SimpleInstall/PostInstall.cmake +++ /dev/null @@ -1,6 +0,0 @@ -message("In post install") -if(PRE_INSTALL_DID_RUN) - message("Pre and post install work fine") -else() - message(FATAL_ERROR "Pre install did not run before post install") -endif() diff --git a/Tests/SimpleInstall/PreInstall.cmake b/Tests/SimpleInstall/PreInstall.cmake deleted file mode 100644 index 7a9851e..0000000 --- a/Tests/SimpleInstall/PreInstall.cmake +++ /dev/null @@ -1,2 +0,0 @@ -message("This is in pre install") -set(PRE_INSTALL_DID_RUN 1) diff --git a/Tests/SimpleInstall/TestSubDir/CMakeLists.txt b/Tests/SimpleInstall/TestSubDir/CMakeLists.txt deleted file mode 100644 index 860e104..0000000 --- a/Tests/SimpleInstall/TestSubDir/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_executable(TSD TSD.cxx TSD_utils.cxx) -install_files(/MyTest/include FILES TSD.h) -install_targets(/MyTest/bin TSD) diff --git a/Tests/SimpleInstall/TestSubDir/TSD.cxx b/Tests/SimpleInstall/TestSubDir/TSD.cxx deleted file mode 100644 index 8fc3878..0000000 --- a/Tests/SimpleInstall/TestSubDir/TSD.cxx +++ /dev/null @@ -1,10 +0,0 @@ -#include <stdio.h> - -#include "TSD.h" - -int main() -{ - int res = TSD("TEST"); - printf("Hello from TSD\n"); - return res; -} diff --git a/Tests/SimpleInstall/TestSubDir/TSD.h b/Tests/SimpleInstall/TestSubDir/TSD.h deleted file mode 100644 index 6a3c1af..0000000 --- a/Tests/SimpleInstall/TestSubDir/TSD.h +++ /dev/null @@ -1 +0,0 @@ -int TSD(const char*); diff --git a/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx b/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx deleted file mode 100644 index 0f32894..0000000 --- a/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx +++ /dev/null @@ -1,9 +0,0 @@ -#include <string.h> - -int TSD(const char* foo) -{ - if (strcmp(foo, "TEST") == 0) { - return 0; - } - return 1; -} diff --git a/Tests/SimpleInstall/foo.c b/Tests/SimpleInstall/foo.c deleted file mode 100644 index 45d5b2b..0000000 --- a/Tests/SimpleInstall/foo.c +++ /dev/null @@ -1,6 +0,0 @@ -char* foo = "Foo"; - -int SomeFunctionInFoo() -{ - return 5; -} diff --git a/Tests/SimpleInstall/foo.h b/Tests/SimpleInstall/foo.h deleted file mode 100644 index 216cdf6..0000000 --- a/Tests/SimpleInstall/foo.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -extern char* foo; -extern int SomeFunctionInFoo(); - -#ifdef __cplusplus -} -#endif diff --git a/Tests/SimpleInstall/inst.cxx b/Tests/SimpleInstall/inst.cxx deleted file mode 100644 index 7815f86..0000000 --- a/Tests/SimpleInstall/inst.cxx +++ /dev/null @@ -1,34 +0,0 @@ -#include "foo.h" - -#ifdef STAGE_2 -# include <foo/lib1.h> -# include <foo/lib2renamed.h> -# include <lib3.h> -# include <old/lib2.h> -# include <old/lib3.h> -#else -# include "lib1.h" -# include "lib2.h" -#endif - -#include "lib4.h" - -#include <stdio.h> - -int main() -{ - if (Lib1Func() != 2.0) { - printf("Problem with lib1\n"); - return 1; - } - if (Lib2Func() != 1.0) { - printf("Problem with lib2\n"); - return 1; - } - if (Lib4Func() != 4.0) { - printf("Problem with lib4\n"); - return 1; - } - printf("The value of Foo: %s\n", foo); - return SomeFunctionInFoo() - 5; -} diff --git a/Tests/SimpleInstall/inst2.cxx b/Tests/SimpleInstall/inst2.cxx deleted file mode 100644 index c70b93a..0000000 --- a/Tests/SimpleInstall/inst2.cxx +++ /dev/null @@ -1,2 +0,0 @@ -#define STAGE_2 -#include "inst.cxx" diff --git a/Tests/SimpleInstall/lib1.cxx b/Tests/SimpleInstall/lib1.cxx deleted file mode 100644 index 7aa9052..0000000 --- a/Tests/SimpleInstall/lib1.cxx +++ /dev/null @@ -1,6 +0,0 @@ -#include "lib1.h" - -float Lib1Func() -{ - return 2.0; -} diff --git a/Tests/SimpleInstall/lib1.h b/Tests/SimpleInstall/lib1.h deleted file mode 100644 index 0d64e76..0000000 --- a/Tests/SimpleInstall/lib1.h +++ /dev/null @@ -1 +0,0 @@ -extern float Lib1Func(); diff --git a/Tests/SimpleInstall/lib2.cxx b/Tests/SimpleInstall/lib2.cxx deleted file mode 100644 index dccc48b..0000000 --- a/Tests/SimpleInstall/lib2.cxx +++ /dev/null @@ -1,6 +0,0 @@ -#include "lib2.h" - -float Lib2Func() -{ - return 1.0; -} diff --git a/Tests/SimpleInstall/lib2.h b/Tests/SimpleInstall/lib2.h deleted file mode 100644 index 044e775..0000000 --- a/Tests/SimpleInstall/lib2.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifdef _WIN32 -# ifdef test2_EXPORTS -# define CM_TEST_LIB_EXPORT __declspec(dllexport) -# else -# define CM_TEST_LIB_EXPORT __declspec(dllimport) -# endif -#else -# define CM_TEST_LIB_EXPORT -#endif - -CM_TEST_LIB_EXPORT float Lib2Func(); diff --git a/Tests/SimpleInstall/lib3.cxx b/Tests/SimpleInstall/lib3.cxx deleted file mode 100644 index da8dbf9..0000000 --- a/Tests/SimpleInstall/lib3.cxx +++ /dev/null @@ -1,6 +0,0 @@ -#include "lib3.h" - -float Lib3Func() -{ - return 2.0; -} diff --git a/Tests/SimpleInstall/lib3.h b/Tests/SimpleInstall/lib3.h deleted file mode 100644 index e02bbc4..0000000 --- a/Tests/SimpleInstall/lib3.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifdef _WIN32 -# ifdef test3_EXPORTS -# define CM_TEST_LIB_EXPORT __declspec(dllexport) -# else -# define CM_TEST_LIB_EXPORT __declspec(dllimport) -# endif -#else -# define CM_TEST_LIB_EXPORT -#endif - -CM_TEST_LIB_EXPORT float Lib3Func(); diff --git a/Tests/SimpleInstall/lib4.cxx b/Tests/SimpleInstall/lib4.cxx deleted file mode 100644 index fbede5c..0000000 --- a/Tests/SimpleInstall/lib4.cxx +++ /dev/null @@ -1,6 +0,0 @@ -#include "lib4.h" - -float Lib4Func() -{ - return 4.0; -} diff --git a/Tests/SimpleInstall/lib4.h b/Tests/SimpleInstall/lib4.h deleted file mode 100644 index e1a221e..0000000 --- a/Tests/SimpleInstall/lib4.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifdef _WIN32 -# ifdef test4_EXPORTS -# define CM_TEST_LIB_EXPORT __declspec(dllexport) -# else -# define CM_TEST_LIB_EXPORT __declspec(dllimport) -# endif -#else -# define CM_TEST_LIB_EXPORT -#endif - -CM_TEST_LIB_EXPORT float Lib4Func(); diff --git a/Tests/SimpleInstall/scripts/.gitattributes b/Tests/SimpleInstall/scripts/.gitattributes deleted file mode 100644 index 5e3db2f..0000000 --- a/Tests/SimpleInstall/scripts/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -sample_script crlf=input diff --git a/Tests/SimpleInstall/scripts/CMakeLists.txt b/Tests/SimpleInstall/scripts/CMakeLists.txt deleted file mode 100644 index ec34e8c..0000000 --- a/Tests/SimpleInstall/scripts/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -install_programs(/MyTest/share/old3 "^sample_script(\\.bat)?$") diff --git a/Tests/SimpleInstall/scripts/sample_script b/Tests/SimpleInstall/scripts/sample_script deleted file mode 100755 index 81f9f53..0000000 --- a/Tests/SimpleInstall/scripts/sample_script +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -echo "Sample Script Output" diff --git a/Tests/SimpleInstall/scripts/sample_script.bat b/Tests/SimpleInstall/scripts/sample_script.bat deleted file mode 100755 index a9af38c..0000000 --- a/Tests/SimpleInstall/scripts/sample_script.bat +++ /dev/null @@ -1 +0,0 @@ -@echo Sample Script Output diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt deleted file mode 100644 index 22150ca..0000000 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ /dev/null @@ -1,397 +0,0 @@ -cmake_minimum_required (VERSION 3.9) -project (TestSimpleInstall) -set(CMAKE_VERBOSE_MAKEFILE 1) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY - "${TestSimpleInstall_BINARY_DIR}/bin") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY - "${TestSimpleInstall_BINARY_DIR}/lib/static") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY - "${TestSimpleInstall_BINARY_DIR}/lib") - -# Skip generating the rpath pointing at the build tree to make sure -# the executable is installed with the proper rpath in the install -# tree. -set(CMAKE_SKIP_BUILD_RPATH 1) - -# Make sure the executable can run from the install tree. -set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib) - -# Skip the dependency that causes a build when installing. This -# avoids infinite loops when the post-build rule below installs. -set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1) -set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY 1) - -set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") - -set(EXTRA_INSTALL_FLAGS) -message("Extra install: ${EXTRA_INSTALL_FLAGS}") - -if(STAGE2) - set(LIBPATHS - ${CMAKE_INSTALL_PREFIX}/MyTest/lib/static - ${CMAKE_INSTALL_PREFIX}/MyTest/lib - ) - set(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX} test1rel) - set(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX}) - set(t4NAMES test4out test4out${CMAKE_DEBUG_POSTFIX}) - - # Make sure the install script ran. - set(CMAKE_INSTALL_SCRIPT_DID_RUN 0) - include(${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake OPTIONAL) - if(CMAKE_INSTALL_SCRIPT_DID_RUN) - message(STATUS "Stage 1 did run install script 2.") - else() - message(SEND_ERROR "Stage 1 did not run install script 2.") - endif() - - if(CYGWIN OR MINGW) - set(LIBPATHS ${LIBPATHS} "${CMAKE_INSTALL_PREFIX}/MyTest/bin") - endif() - message("Search for library in: ${LIBPATHS}") - - set(TEST1_LIBRARY "TEST1_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) - set(TEST2_LIBRARY "TEST2_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) - set(TEST4_LIBRARY "TEST4_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) - - find_library(TEST1_LIBRARY - NAMES ${t1NAMES} - PATHS ${LIBPATHS} - DOC "First library") - find_library(TEST2_LIBRARY - NAMES ${t2NAMES} - PATHS ${LIBPATHS} - DOC "Second library") - find_library(TEST4_LIBRARY - NAMES ${t4NAMES} - PATHS ${LIBPATHS} - DOC "Fourth library") - - # Test importing a library found on disk. - add_library(lib_test4 UNKNOWN IMPORTED) - set_property(TARGET lib_test4 PROPERTY IMPORTED_LOCATION ${TEST4_LIBRARY}) - - include_directories(${CMAKE_INSTALL_PREFIX}/MyTest/include) - add_executable (SimpleInstExeS2 inst2.cxx foo.c foo.h) - target_link_libraries(SimpleInstExeS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} lib_test4) - set(install_target SimpleInstExeS2) - - if("${TEST1_LIBRARY}" MATCHES "static") - message(STATUS "test1 correctly found in lib/static") - else() - message(SEND_ERROR "test1 not found in lib/static!") - endif() - - # Check for failure of configuration-specific installation. - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h") - message(FATAL_ERROR "Debug-configuration file installed for Release!") - endif() - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") - message(FATAL_ERROR "Release-configuration file installed for Debug!") - endif() - - # Check for failure of directory installation. - if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h") - message(FATAL_ERROR "Directory installation did not install TSD.h") - endif() - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") - message(FATAL_ERROR "Directory installation installed CVS directory.") - endif() - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") - message(FATAL_ERROR "Directory installation installed CVS directory.") - endif() - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CMakeLists.txt") - message(FATAL_ERROR "Directory installation installed CMakeLists.txt.") - endif() - if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.h") - message(FATAL_ERROR "Directory installation did not install alternate TSD.h") - endif() - if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.cxx") - message(FATAL_ERROR "Directory installation installed alternate TSD.cxx") - endif() - - # Check that scripts properly installed. - if(WIN32 AND NOT CYGWIN) - set(BAT .bat) - else() - set(BAT) - endif() - foreach(loc share share/old1 share/old2 share/old3 share/alt) - set(CUR_SCRIPT "${CMAKE_INSTALL_PREFIX}/MyTest/${loc}/sample_script${BAT}") - execute_process( - COMMAND ${CUR_SCRIPT} - RESULT_VARIABLE SAMPLE_SCRIPT_RESULT - OUTPUT_VARIABLE SAMPLE_SCRIPT_OUTPUT - ) - if(NOT "${SAMPLE_SCRIPT_RESULT}" STREQUAL "0") - message(FATAL_ERROR - "Sample script [${CUR_SCRIPT}] failed: [${SAMPLE_SCRIPT_RESULT}]") - endif() - if(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output") - message(FATAL_ERROR - "Bad sample script [${CUR_SCRIPT}] output: [${SAMPLE_SCRIPT_OUTPUT}]") - endif() - endforeach() - - # Check for failure of empty directory installation. - if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty") - message(FATAL_ERROR "Empty directory installation did not install.") - endif() - file(GLOB EMPTY_FILES "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty/*") - if(EMPTY_FILES) - message(FATAL_ERROR "Empty directory installed [${EMPTY_FILES}].") - endif() - - # Make sure the test executable can run from the install tree. - set_target_properties(SimpleInstExeS2 PROPERTIES - INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) - - install_targets(/MyTest/bin SimpleInstExeS2) - -# try to import the exported targets again - set(SimpleInstallS1_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib) - find_package(SimpleInstallS1 REQUIRED) - get_target_property(simpleInstallImported S1_SimpleInstall IMPORTED) - if(NOT simpleInstallImported) - message(FATAL_ERROR "Target S1_SimpleInstall could not be imported") - endif() - -else() - # Wipe out the install directory to do a fresh test. - file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/MyTest) - - # this is stage 1, so create libraries and modules and install everything - add_library(test1 STATIC lib1.cxx) - add_library(test2 SHARED lib2.cxx) - add_library(test3 MODULE lib3.cxx) - add_library(test4 SHARED lib4.cxx) - - # Test <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME properties. - set_property(TARGET test4 PROPERTY ARCHIVE_OUTPUT_NAME test4out) - set_property(TARGET test4 PROPERTY LIBRARY_OUTPUT_NAME test4out) - - add_executable (SimpleInstall inst.cxx foo.c foo.h) - target_link_libraries(SimpleInstall test1 test2 test4) - set(install_target SimpleInstall) - - set_target_properties(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) - # Disable VERSION test until it is implemented in the Xcode generator. - if(NOT XCODE) - set_target_properties(SimpleInstall PROPERTIES VERSION 1.2) - endif() - - # Make sure the test executable can run from the install tree. - set_target_properties(SimpleInstall PROPERTIES - INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) - - # Test per-configuration output name. - set_target_properties(test1 PROPERTIES RELEASE_OUTPUT_NAME test1rel) - set_target_properties(test2 PROPERTIES PUBLIC_HEADER foo.h) - - if(CMAKE_GENERATOR MATCHES "Makefiles") - add_subdirectory(TestSubDir) - add_dependencies(SimpleInstall TSD) - endif() - - add_dependencies(SimpleInstall test3) - add_dependencies(test2 test3) - add_dependencies(test4 test2) - - install(TARGETS SimpleInstall test1 test2 test3 EXPORT SimpleInstallS1 - RUNTIME DESTINATION MyTest/bin COMPONENT Runtime # .exe, .dll - LIBRARY DESTINATION MyTest/lib COMPONENT Runtime # .so, mod.dll - ARCHIVE DESTINATION MyTest/lib/static COMPONENT Development # .a, .lib - PUBLIC_HEADER DESTINATION MyTest/include COMPONENT Development - ) - - install(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - RUNTIME DESTINATION MyTest/bin - LIBRARY DESTINATION MyTest/lib - ARCHIVE DESTINATION MyTest/lib/static - OPTIONAL # for coverage...target should always exist - ) - install(FILES lib1.h DESTINATION MyTest/include/$<1:foo>$<0:/wrong>) - install(FILES lib2.h - DESTINATION $<1:MyTest/include/foo>$<0:/wrong> - COMPONENT Development - PERMISSIONS OWNER_READ OWNER_WRITE - RENAME lib2renamed.h - ) - - # Test old-style install commands. - install_files(/MyTest/include FILES lib3.h) - install_files(/MyTest/include/old .h lib3) - install_files(/MyTest/include/old "^lib2.h$") - install_programs(/MyTest/share/old1 FILES - scripts/sample_script scripts/sample_script.bat) - install_programs(/MyTest/share/old2 - scripts/sample_script scripts/sample_script.bat) - -# "export" the targets collected in "SimpleInstallS1" - install(EXPORT SimpleInstallS1 FILE SimpleInstallS1Config.cmake - DESTINATION MyTest/lib - NAMESPACE S1_ ) - - export(TARGETS SimpleInstall test1 test2 test3 - FILE "${CMAKE_CURRENT_BINARY_DIR}/SimpleInstallS1Config.cmake" - NAMESPACE S2_ ) - - add_subdirectory(scripts) - - # Test optional installation. - install(FILES does_not_exist.h DESTINATION MyTest/include/foo OPTIONAL) - - # Test configuration-specific installation. - install(FILES lib1.h RENAME lib1release.h CONFIGURATIONS Release - DESTINATION MyTest/include/Release - ) - install(FILES lib1.h RENAME lib1debug.h CONFIGURATIONS Debug - DESTINATION MyTest/include/Debug - ) - - # Test directory installation. - file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") - file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") - install( - DIRECTORY TestSubDir $<1:scripts/>$<0:/wrong> DESTINATION $<1:MyTest/share>$<0:/wrong> - FILE_PERMISSIONS OWNER_READ OWNER_WRITE - DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE - PATTERN "CVS" EXCLUDE - REGEX "\\.txt$" EXCLUDE - PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ - ) - - # Alternate directory installation for coverage. - install( - DIRECTORY $<1:scripts/>$<0:/wrong> DESTINATION $<1:MyTest/share/alt>$<0:/wrong> - COMPONENT Development - USE_SOURCE_PERMISSIONS - PATTERN "CVS" EXCLUDE - REGEX "\\.txt$" EXCLUDE - ) - install( - DIRECTORY TestSubDir DESTINATION $<1:MyTest/share/alt>$<0:/wrong> - FILE_PERMISSIONS OWNER_READ OWNER_WRITE - DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE - FILES_MATCHING PATTERN "*.h" - ) - - # Test empty directory installation. - install(DIRECTORY DESTINATION MyTest/share/empty) - - # Test optional directory installation. - install(DIRECTORY does-not-exist DESTINATION MyTest/share OPTIONAL) - - # Test user-specified install scripts, with and without COMPONENT. - install( - SCRIPT InstallScript1.cmake - CODE "set(INSTALL_CODE_DID_RUN 1)" - SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript2.cmake - ) - install( - SCRIPT InstallScript3.cmake - CODE "set(INSTALL_CODE_WITH_COMPONENT_DID_RUN 1)" - SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript4.cmake - COMPONENT Development - ) - set_directory_properties(PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES - "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") - - set_target_properties(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT - ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) - set_target_properties(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT - ${CMAKE_CURRENT_SOURCE_DIR}/PostInstall.cmake) - set_target_properties(test4 PROPERTIES VERSION 1.2 SOVERSION 3 - INSTALL_NAME_DIR @executable_path/../lib) -endif() - -get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if(_isMultiConfig) - set(SI_CONFIG --config $<CONFIGURATION>) -else() - set(SI_CONFIG) -endif() - -# Dummy test of CPack -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Test of packaging with cpack") -set(CPACK_PACKAGE_VENDOR "Kitware") -set(CPACK_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/PackageScript.cmake") - -if(WIN32 AND NOT UNIX) - find_program(NSIS_MAKENSIS NAMES makensis - PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS] - DOC "Where is makensis.exe located" - ) - if(NOT NSIS_MAKENSIS) - set(CPACK_GENERATOR TGZ) - endif() -endif() -if(UNIX AND NOT APPLE) - set(CPACK_GENERATOR "TGZ;STGZ;TZ") - # find_program(found_compress - # NAMES compress) - # if(found_compress) - # find_program(file_command NAMES file) - # if(NOT file_command) - # set(file_command file) - # endif() - # execute_process(COMMAND ${file_command} ${found_compress} - # OUTPUT_VARIABLE output) - # set(SKIP_TZ FALSE) - # if("${output}" MATCHES "script") - # set(SKIP_TZ TRUE) - # endif() - # if("${output}" MATCHES "dummy.sh") - # set(SKIP_TZ TRUE) - # endif() - # if(NOT SKIP_TZ) - # message("compress found and it was not a script") - # message("output from file command: [${output}]") - # list(APPEND CPACK_GENERATOR "TZ") - # else() - # message("compress found, but it was a script so don't use it") - # message("output from file command: [${output}]") - # endif() - # endif() - find_program(found_bz2 - NAMES bzip2) - if(found_bz2) - list(APPEND CPACK_GENERATOR "TBZ2") - endif() -endif() - -set(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") -set(CMAKE_INSTALL_MFC_LIBRARIES 1) -set(CMAKE_INSTALL_DEBUG_LIBRARIES 1) -set(CMAKE_INSTALL_UCRT_LIBRARIES 1) -include(InstallRequiredSystemLibraries) - -if(CTEST_TEST_CPACK) - set(package_command COMMAND - ${CMAKE_COMMAND} --build . --target package ${SI_CONFIG} - ) - - # Avoid settings that require the .zip file command line tools... - # (just build an NSIS installer without component support) - # - set(CPACK_BINARY_ZIP OFF) - set(CPACK_MONOLITHIC_INSTALL ON) -else() - set(package_command) -endif() - -include(CPack) - -set(install_command COMMAND - ${CMAKE_COMMAND} --build . --target install ${SI_CONFIG} - ) - -add_custom_command( - TARGET ${install_target} - POST_BUILD - ${install_command} - ${package_command} - COMMENT "Install Project" - ) diff --git a/Tests/SimpleInstallS2/InstallScript1.cmake b/Tests/SimpleInstallS2/InstallScript1.cmake deleted file mode 100644 index ef9da57..0000000 --- a/Tests/SimpleInstallS2/InstallScript1.cmake +++ /dev/null @@ -1,5 +0,0 @@ -message("This is install script 1.") -set(INSTALL_SCRIPT_1_DID_RUN 1) -if(INSTALL_CODE_DID_RUN) - message(FATAL_ERROR "Install script 1 did not run before install code.") -endif() diff --git a/Tests/SimpleInstallS2/InstallScript2.cmake b/Tests/SimpleInstallS2/InstallScript2.cmake deleted file mode 100644 index c1d20a3..0000000 --- a/Tests/SimpleInstallS2/InstallScript2.cmake +++ /dev/null @@ -1,14 +0,0 @@ -message("This is install script 2.") -if(INSTALL_SCRIPT_1_DID_RUN) - message("Install script ordering works.") -else() - message(FATAL_ERROR "Install script 1 did not run before install script 2.") -endif() -if(INSTALL_CODE_DID_RUN) - message("Install code ordering works.") -else() - message(FATAL_ERROR "Install script 2 did not run after install code.") -endif() -file(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake" - "set(CMAKE_INSTALL_SCRIPT_DID_RUN 1)\n" - ) diff --git a/Tests/SimpleInstallS2/InstallScript3.cmake b/Tests/SimpleInstallS2/InstallScript3.cmake deleted file mode 100644 index 6485156..0000000 --- a/Tests/SimpleInstallS2/InstallScript3.cmake +++ /dev/null @@ -1,12 +0,0 @@ -message("This is install script 3.") -set(INSTALL_SCRIPT_3_DID_RUN 1) -if(INSTALL_CODE_WITH_COMPONENT_DID_RUN) - message(FATAL_ERROR "Install script 3 did not run before install code with component.") -endif() - -if(CMAKE_INSTALL_COMPONENT) -if(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") - message("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"") - message(FATAL_ERROR "Install script 3 should only run for \"Development\" INSTALL COMPONENT.") -endif() -endif() diff --git a/Tests/SimpleInstallS2/InstallScript4.cmake b/Tests/SimpleInstallS2/InstallScript4.cmake deleted file mode 100644 index 34d0a73..0000000 --- a/Tests/SimpleInstallS2/InstallScript4.cmake +++ /dev/null @@ -1,22 +0,0 @@ -message("This is install script 4.") -if(INSTALL_SCRIPT_3_DID_RUN) - message("Install script ordering works.") -else() - message(FATAL_ERROR "Install script 3 did not run before install script 4.") -endif() -if(INSTALL_CODE_WITH_COMPONENT_DID_RUN) - message("Install code ordering works.") -else() - message(FATAL_ERROR "Install script 4 did not run after install with component code.") -endif() - -if(CMAKE_INSTALL_COMPONENT) -if(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") - message("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"") - message(FATAL_ERROR "Install script 4 should only run for \"Development\" INSTALL COMPONENT.") -endif() -endif() - -file(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScript4Out.cmake" - "set(CMAKE_INSTALL_SCRIPT_4_DID_RUN 1)\n" - ) diff --git a/Tests/SimpleInstallS2/PackageScript.cmake b/Tests/SimpleInstallS2/PackageScript.cmake deleted file mode 100644 index 53b7909..0000000 --- a/Tests/SimpleInstallS2/PackageScript.cmake +++ /dev/null @@ -1,10 +0,0 @@ -message("This is packaging script") -message("It writes a file with all variables available in ${CMAKE_INSTALL_PREFIX}/AllVariables.txt") - -file(WRITE ${CMAKE_INSTALL_PREFIX}/AllVariables.txt "") -get_cmake_property(res VARIABLES) -foreach(var ${res}) - file(APPEND ${CMAKE_INSTALL_PREFIX}/AllVariables.txt - "${var} \"${${var}}\"\n") -endforeach() - diff --git a/Tests/SimpleInstallS2/PostInstall.cmake b/Tests/SimpleInstallS2/PostInstall.cmake deleted file mode 100644 index d616221..0000000 --- a/Tests/SimpleInstallS2/PostInstall.cmake +++ /dev/null @@ -1,6 +0,0 @@ -message("In post install") -if(PRE_INSTALL_DID_RUN) - message("Pre and post install work fine") -else() - message(FATAL_ERROR "Pre install did not run before post install") -endif() diff --git a/Tests/SimpleInstallS2/PreInstall.cmake b/Tests/SimpleInstallS2/PreInstall.cmake deleted file mode 100644 index 7a9851e..0000000 --- a/Tests/SimpleInstallS2/PreInstall.cmake +++ /dev/null @@ -1,2 +0,0 @@ -message("This is in pre install") -set(PRE_INSTALL_DID_RUN 1) diff --git a/Tests/SimpleInstallS2/TestSubDir/CMakeLists.txt b/Tests/SimpleInstallS2/TestSubDir/CMakeLists.txt deleted file mode 100644 index 860e104..0000000 --- a/Tests/SimpleInstallS2/TestSubDir/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_executable(TSD TSD.cxx TSD_utils.cxx) -install_files(/MyTest/include FILES TSD.h) -install_targets(/MyTest/bin TSD) diff --git a/Tests/SimpleInstallS2/TestSubDir/TSD.cxx b/Tests/SimpleInstallS2/TestSubDir/TSD.cxx deleted file mode 100644 index 8fc3878..0000000 --- a/Tests/SimpleInstallS2/TestSubDir/TSD.cxx +++ /dev/null @@ -1,10 +0,0 @@ -#include <stdio.h> - -#include "TSD.h" - -int main() -{ - int res = TSD("TEST"); - printf("Hello from TSD\n"); - return res; -} diff --git a/Tests/SimpleInstallS2/TestSubDir/TSD.h b/Tests/SimpleInstallS2/TestSubDir/TSD.h deleted file mode 100644 index 6a3c1af..0000000 --- a/Tests/SimpleInstallS2/TestSubDir/TSD.h +++ /dev/null @@ -1 +0,0 @@ -int TSD(const char*); diff --git a/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx b/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx deleted file mode 100644 index 0f32894..0000000 --- a/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx +++ /dev/null @@ -1,9 +0,0 @@ -#include <string.h> - -int TSD(const char* foo) -{ - if (strcmp(foo, "TEST") == 0) { - return 0; - } - return 1; -} diff --git a/Tests/SimpleInstallS2/foo.c b/Tests/SimpleInstallS2/foo.c deleted file mode 100644 index 45d5b2b..0000000 --- a/Tests/SimpleInstallS2/foo.c +++ /dev/null @@ -1,6 +0,0 @@ -char* foo = "Foo"; - -int SomeFunctionInFoo() -{ - return 5; -} diff --git a/Tests/SimpleInstallS2/foo.h b/Tests/SimpleInstallS2/foo.h deleted file mode 100644 index 216cdf6..0000000 --- a/Tests/SimpleInstallS2/foo.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -extern char* foo; -extern int SomeFunctionInFoo(); - -#ifdef __cplusplus -} -#endif diff --git a/Tests/SimpleInstallS2/inst.cxx b/Tests/SimpleInstallS2/inst.cxx deleted file mode 100644 index 7815f86..0000000 --- a/Tests/SimpleInstallS2/inst.cxx +++ /dev/null @@ -1,34 +0,0 @@ -#include "foo.h" - -#ifdef STAGE_2 -# include <foo/lib1.h> -# include <foo/lib2renamed.h> -# include <lib3.h> -# include <old/lib2.h> -# include <old/lib3.h> -#else -# include "lib1.h" -# include "lib2.h" -#endif - -#include "lib4.h" - -#include <stdio.h> - -int main() -{ - if (Lib1Func() != 2.0) { - printf("Problem with lib1\n"); - return 1; - } - if (Lib2Func() != 1.0) { - printf("Problem with lib2\n"); - return 1; - } - if (Lib4Func() != 4.0) { - printf("Problem with lib4\n"); - return 1; - } - printf("The value of Foo: %s\n", foo); - return SomeFunctionInFoo() - 5; -} diff --git a/Tests/SimpleInstallS2/inst2.cxx b/Tests/SimpleInstallS2/inst2.cxx deleted file mode 100644 index c70b93a..0000000 --- a/Tests/SimpleInstallS2/inst2.cxx +++ /dev/null @@ -1,2 +0,0 @@ -#define STAGE_2 -#include "inst.cxx" diff --git a/Tests/SimpleInstallS2/lib1.cxx b/Tests/SimpleInstallS2/lib1.cxx deleted file mode 100644 index 7aa9052..0000000 --- a/Tests/SimpleInstallS2/lib1.cxx +++ /dev/null @@ -1,6 +0,0 @@ -#include "lib1.h" - -float Lib1Func() -{ - return 2.0; -} diff --git a/Tests/SimpleInstallS2/lib1.h b/Tests/SimpleInstallS2/lib1.h deleted file mode 100644 index 0d64e76..0000000 --- a/Tests/SimpleInstallS2/lib1.h +++ /dev/null @@ -1 +0,0 @@ -extern float Lib1Func(); diff --git a/Tests/SimpleInstallS2/lib2.cxx b/Tests/SimpleInstallS2/lib2.cxx deleted file mode 100644 index dccc48b..0000000 --- a/Tests/SimpleInstallS2/lib2.cxx +++ /dev/null @@ -1,6 +0,0 @@ -#include "lib2.h" - -float Lib2Func() -{ - return 1.0; -} diff --git a/Tests/SimpleInstallS2/lib2.h b/Tests/SimpleInstallS2/lib2.h deleted file mode 100644 index 044e775..0000000 --- a/Tests/SimpleInstallS2/lib2.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifdef _WIN32 -# ifdef test2_EXPORTS -# define CM_TEST_LIB_EXPORT __declspec(dllexport) -# else -# define CM_TEST_LIB_EXPORT __declspec(dllimport) -# endif -#else -# define CM_TEST_LIB_EXPORT -#endif - -CM_TEST_LIB_EXPORT float Lib2Func(); diff --git a/Tests/SimpleInstallS2/lib3.cxx b/Tests/SimpleInstallS2/lib3.cxx deleted file mode 100644 index da8dbf9..0000000 --- a/Tests/SimpleInstallS2/lib3.cxx +++ /dev/null @@ -1,6 +0,0 @@ -#include "lib3.h" - -float Lib3Func() -{ - return 2.0; -} diff --git a/Tests/SimpleInstallS2/lib3.h b/Tests/SimpleInstallS2/lib3.h deleted file mode 100644 index e02bbc4..0000000 --- a/Tests/SimpleInstallS2/lib3.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifdef _WIN32 -# ifdef test3_EXPORTS -# define CM_TEST_LIB_EXPORT __declspec(dllexport) -# else -# define CM_TEST_LIB_EXPORT __declspec(dllimport) -# endif -#else -# define CM_TEST_LIB_EXPORT -#endif - -CM_TEST_LIB_EXPORT float Lib3Func(); diff --git a/Tests/SimpleInstallS2/lib4.cxx b/Tests/SimpleInstallS2/lib4.cxx deleted file mode 100644 index fbede5c..0000000 --- a/Tests/SimpleInstallS2/lib4.cxx +++ /dev/null @@ -1,6 +0,0 @@ -#include "lib4.h" - -float Lib4Func() -{ - return 4.0; -} diff --git a/Tests/SimpleInstallS2/lib4.h b/Tests/SimpleInstallS2/lib4.h deleted file mode 100644 index e1a221e..0000000 --- a/Tests/SimpleInstallS2/lib4.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifdef _WIN32 -# ifdef test4_EXPORTS -# define CM_TEST_LIB_EXPORT __declspec(dllexport) -# else -# define CM_TEST_LIB_EXPORT __declspec(dllimport) -# endif -#else -# define CM_TEST_LIB_EXPORT -#endif - -CM_TEST_LIB_EXPORT float Lib4Func(); diff --git a/Tests/SimpleInstallS2/scripts/.gitattributes b/Tests/SimpleInstallS2/scripts/.gitattributes deleted file mode 100644 index 5e3db2f..0000000 --- a/Tests/SimpleInstallS2/scripts/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -sample_script crlf=input diff --git a/Tests/SimpleInstallS2/scripts/CMakeLists.txt b/Tests/SimpleInstallS2/scripts/CMakeLists.txt deleted file mode 100644 index ec34e8c..0000000 --- a/Tests/SimpleInstallS2/scripts/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -install_programs(/MyTest/share/old3 "^sample_script(\\.bat)?$") diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index cc29b77..4c3d901 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -88,3 +88,14 @@ add_test(NAME UseSWIG.ModuleVersion2 COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + + +add_test(NAME UseSWIG.UseTargetINCLUDE_DIRECTORIES COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES" + "${CMake_BINARY_DIR}/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES" + ${build_generator_args} + --build-project TestModuleVersion2 + --build-options ${build_options} + ) diff --git a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt new file mode 100644 index 0000000..d0855bf --- /dev/null +++ b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestUseTargetINCLUDE_DIRECTORIES CXX) + +include(CTest) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + +set(UseSWIG_TARGET_NAME_PREFERENCE STANDARD) +unset(CMAKE_SWIG_FLAGS) + +set_property(SOURCE "example.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "example.i" PROPERTY COMPILE_OPTIONS -includeall) + +swig_add_library(example1 + LANGUAGE python + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/example1" + SOURCES example.i ../example.cxx) +set_target_properties (example1 PROPERTIES + INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.." + SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE + OUTPUT_NAME example1 + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1") +target_link_libraries(example1 PRIVATE Python3::Python) + + +# Check that source property override target property +set_property(SOURCE "example.i" PROPERTY USE_TARGET_INCLUDE_DIRECTORIES TRUE) + +swig_add_library(example2 + LANGUAGE python + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/example2" + SOURCES example.i ../example.cxx) +set_target_properties (example2 PROPERTIES + INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.." + SWIG_USE_TARGET_INCLUDE_DIRECTORIES FALSE + OUTPUT_NAME example2 + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2") +target_link_libraries(example2 PRIVATE Python3::Python) diff --git a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i new file mode 100644 index 0000000..fbdf724 --- /dev/null +++ b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i @@ -0,0 +1,9 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" diff --git a/Tests/VSNASM/CMakeLists.txt b/Tests/VSNASM/CMakeLists.txt index c2e29df..821d022 100644 --- a/Tests/VSNASM/CMakeLists.txt +++ b/Tests/VSNASM/CMakeLists.txt @@ -1,10 +1,20 @@ cmake_minimum_required(VERSION 2.8.12) project(VSNASM C ASM_NASM) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) add_definitions(-DTESTx64) string(APPEND CMAKE_ASM_NASM_FLAGS " -DTEST2x64") else() add_definitions(-DTESTi386) endif() + +# Test quoting for definitions with spaces. +add_definitions("-DEAX_COMMA_SPACE_ZERO=eax, 0") + +# Test quoting for file names with spaces. The file is generated because CMake +# itself cannot have files with spaces. +file(READ bar.asm BAR_ASM_CONTENTS) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/bar baz.asm" "${BAR_ASM_CONTENTS}") + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -add_executable(VSNASM main.c foo.asm) +add_executable(VSNASM main.c foo.asm "${CMAKE_CURRENT_BINARY_DIR}/bar baz.asm") diff --git a/Tests/VSNASM/bar.asm b/Tests/VSNASM/bar.asm new file mode 100644 index 0000000..b486d82 --- /dev/null +++ b/Tests/VSNASM/bar.asm @@ -0,0 +1,13 @@ +section .text +%ifdef TEST2x64 +global bar +%else +global _bar +%endif +%ifdef TESTx64 +bar: +%else +_bar: +%endif + mov EAX_COMMA_SPACE_ZERO + ret diff --git a/Tests/VSNASM/include/foo-proc.asm b/Tests/VSNASM/include/foo-proc.asm index 450a791..eb5bb2b 100644 --- a/Tests/VSNASM/include/foo-proc.asm +++ b/Tests/VSNASM/include/foo-proc.asm @@ -3,5 +3,5 @@ foo: %else _foo: %endif - mov eax, 0 + mov EAX_COMMA_SPACE_ZERO ret diff --git a/Tests/VSNASM/main.c b/Tests/VSNASM/main.c index 18ddb78..b1401b6 100644 --- a/Tests/VSNASM/main.c +++ b/Tests/VSNASM/main.c @@ -1,5 +1,6 @@ extern int foo(void); +extern int bar(void); int main(void) { - return foo(); + return foo() + bar(); } |