diff options
Diffstat (limited to 'Tests')
15 files changed, 103 insertions, 5 deletions
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 2792751..6281c40 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -53,6 +53,8 @@ write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot.hxx.in "static const char* zot = \"zot\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/dir/header.txt + "#define HEADER_STRING \"ninja\"\n" ) file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_custom.hxx.in "static const char* zot_custom = \"zot_custom\";\n") file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx @@ -93,6 +95,26 @@ if(NOT RESULT) message(SEND_ERROR "Could not build test project (1)!") endif() +# find and save the ninjadep executable +set(ninjadep ${BuildDepends_BINARY_DIR}/Project/ninjadep${CMAKE_EXECUTABLE_SUFFIX}) +if(EXISTS + "${BuildDepends_BINARY_DIR}/Project/Debug/ninjadep${CMAKE_EXECUTABLE_SUFFIX}" ) + message("found debug") + set(ninjadep + "${BuildDepends_BINARY_DIR}/Project/Debug/ninjadep${CMAKE_EXECUTABLE_SUFFIX}") +endif() +message("Running ${ninjadep} ") +execute_process(COMMAND ${ninjadep} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) +string(REGEX REPLACE "[\r\n]" " " out "${out}") +message("Run result: ${runResult} Output: \"${out}\"") + +if("${out}" STREQUAL "HEADER_STRING: ninja ") + message("Worked!") +else() + message(SEND_ERROR "Project did not rebuild properly. Output[${out}]\n" + " expected [HEADER_STRING: ninja]") +endif() + set(bar ${BuildDepends_BINARY_DIR}/Project/bar${CMAKE_EXECUTABLE_SUFFIX}) if(EXISTS "${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}" ) @@ -151,6 +173,8 @@ execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out) message("Modifying Project/foo.cxx") write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx "const char* foo() { return \"foo changed\";}" ) +file(WRITE "${BuildDepends_BINARY_DIR}/Project/dir/header.txt" + "#define HEADER_STRING \"ninja changed\"\n" ) file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot.hxx.in "static const char* zot = \"zot changed\";\n") file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_custom.hxx.in @@ -204,6 +228,18 @@ if(EXISTS message("found debug") endif() +message("Running ${ninjadep} ") +execute_process(COMMAND ${ninjadep} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) +string(REGEX REPLACE "[\r\n]" " " out "${out}") +message("Run result: ${runResult} Output: \"${out}\"") + +if("${out}" STREQUAL "HEADER_STRING: ninja changed ") + message("Worked!") +else() + message(SEND_ERROR "Project did not rebuild properly. Output[${out}]\n" + " expected [HEADER_STRING: ninja changed]") +endif() + message("Running ${bar} ") execute_process(COMMAND ${bar} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) string(REGEX REPLACE "[\r\n]" " " out "${out}") diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index f8a3d15..b4c6a07 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -123,3 +123,19 @@ add_custom_target(link_depends_no_shared_check ALL -P ${CMAKE_CURRENT_SOURCE_DIR}/link_depends_no_shared_check.cmake ) add_dependencies(link_depends_no_shared_check link_depends_no_shared_exe) + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dir/header.txt + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_BINARY_DIR}/dir/header.txt + ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h + ) + +set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/dir/header.h + PROPERTIES GENERATED 1) + +add_custom_target(header_tgt DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +add_executable(ninjadep ninjadep.cpp) +add_dependencies(ninjadep header_tgt) diff --git a/Tests/BuildDepends/Project/ninjadep.cpp b/Tests/BuildDepends/Project/ninjadep.cpp new file mode 100644 index 0000000..8d61336 --- /dev/null +++ b/Tests/BuildDepends/Project/ninjadep.cpp @@ -0,0 +1,6 @@ +#include <stdio.h> +#include "dir/header.h" + +int main() { + printf("HEADER_STRING: %s\n", HEADER_STRING); +} diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt index dd6ab41..07d7c43 100644 --- a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt @@ -16,3 +16,12 @@ assert_property(cmp0022ifacelib INTERFACE_LINK_LIBRARIES "") add_executable(cmp0022exe cmp0022exe.cpp) target_link_libraries(cmp0022exe cmp0022lib) + +add_library(staticlib1 STATIC staticlib1.cpp) +generate_export_header(staticlib1) +add_library(staticlib2 STATIC staticlib2.cpp) +generate_export_header(staticlib2) +target_link_libraries(staticlib1 LINK_PUBLIC staticlib2) + +add_executable(staticlib_exe staticlib_exe.cpp) +target_link_libraries(staticlib_exe staticlib1) diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp new file mode 100644 index 0000000..a253c46 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp @@ -0,0 +1,2 @@ + +int staticlib1() { return 0; } diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.h new file mode 100644 index 0000000..4bbf23f --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.h @@ -0,0 +1,4 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int staticlib1(); diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp new file mode 100644 index 0000000..4e38063 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp @@ -0,0 +1,2 @@ + +int staticlib2() { return 0; } diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.h new file mode 100644 index 0000000..a4e07b6 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.h @@ -0,0 +1,4 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int staticlib2(); diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib_exe.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib_exe.cpp new file mode 100644 index 0000000..97adc40 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib_exe.cpp @@ -0,0 +1,8 @@ + +#include "staticlib1.h" +#include "staticlib2.h" + +int main() +{ + return staticlib1() + staticlib2(); +} diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index ff02883..2db9282 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -91,7 +91,11 @@ gen_mcnl_test(DummyPurifyNoLogfile "\${PSEUDO_PURIFY}") gen_mcnl_test(DummyValgrindNoLogfile "\${PSEUDO_VALGRIND}") gen_mcnl_test(DummyBCNoLogfile "\${PSEUDO_BC}") -set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_PRE_MEMCHECK \"\${CTEST_MEMORYCHECK_COMMAND}\")\nset(CTEST_CUSTOM_POST_MEMCHECK \"\${CTEST_MEMORYCHECK_COMMAND}\")") +set(CTEST_EXTRA_CODE "string(REPLACE \" \" \"\\\\ \" PRE_POST_COMMAND \"\${CTEST_MEMORYCHECK_COMMAND}\") + +set(CTEST_CUSTOM_PRE_MEMCHECK \"\${PRE_POST_COMMAND} pre command\") +set(CTEST_CUSTOM_POST_MEMCHECK \"\${PRE_POST_COMMAND} post command \") +") gen_mc_test(DummyValgrindPrePost "\${PSEUDO_VALGRIND}") set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_POST_MEMCHECK \"\${ERROR_COMMAND}\")") diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 49f1c58..1910f8c 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -270,6 +270,8 @@ set_property(TARGET cmp0022NEW APPEND PROPERTY INTERFACE_LINK_LIBRARIES testLib2 set_property(TARGET cmp0022OLD APPEND PROPERTY INTERFACE_LINK_LIBRARIES testLib2) set_property(TARGET cmp0022OLD APPEND PROPERTY LINK_INTERFACE_LIBRARIES testLib3) +add_library(noIncludesInterface empty.cpp) + install(TARGETS testLibRequired testLibIncludeRequired1 testLibIncludeRequired2 @@ -278,6 +280,7 @@ install(TARGETS testLibRequired testLibIncludeRequired5 testLibIncludeRequired6 testSharedLibRequired + noIncludesInterface EXPORT RequiredExp DESTINATION lib INCLUDES DESTINATION installIncludesTest diff --git a/Tests/ExportImport/Export/empty.cpp b/Tests/ExportImport/Export/empty.cpp new file mode 100644 index 0000000..1787013 --- /dev/null +++ b/Tests/ExportImport/Export/empty.cpp @@ -0,0 +1,4 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() { return 0; } diff --git a/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt index 6c29057..ae7627e 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt +++ b/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt @@ -1,4 +1,4 @@ CMake Error at CMP0022-export.cmake:11 \(export\): Target "cmp0022NEW" has policy CMP0022 enabled, but also has old-style - INTERFACE_LINK_LIBRARIES properties populated, but it was exported without + LINK_INTERFACE_LIBRARIES properties populated, but it was exported without the EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties diff --git a/Tests/RunCMake/CMP0022/CMP0022-install-export-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-install-export-stderr.txt index 3425e8e..405dd8d 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-install-export-stderr.txt +++ b/Tests/RunCMake/CMP0022/CMP0022-install-export-stderr.txt @@ -1,4 +1,4 @@ CMake Error in CMakeLists.txt: Target "cmp0022NEW" has policy CMP0022 enabled, but also has old-style - INTERFACE_LINK_LIBRARIES properties populated, but it was exported without + LINK_INTERFACE_LIBRARIES properties populated, but it was exported without the EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties diff --git a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake index d4e31cd..64f394c 100644 --- a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake +++ b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake @@ -1,4 +1,4 @@ -add_library(foo SHARED empty.cpp) -add_library(bar SHARED empty.cpp) +add_library(foo STATIC empty.cpp) +add_library(bar STATIC empty.cpp) target_link_libraries(foo $<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,anything>:bar>) |