diff options
Diffstat (limited to 'Tests')
30 files changed, 205 insertions, 1 deletions
diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt index 2240539..06019e6 100644 --- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -124,3 +124,9 @@ add_library(libConsumer empty.cpp) target_link_libraries(libConsumer debug depA) add_subdirectory(cmp0022) + +add_executable(newsignature1 newsignature1.cpp) +target_link_libraries(newsignature1 PRIVATE depC INTERFACE depD PUBLIC depB PRIVATE subdirlib INTERFACE INTERFACE PUBLIC) + +assert_property(newsignature1 INTERFACE_LINK_LIBRARIES "depD;depB") +assert_property(newsignature1 LINK_LIBRARIES "depC;depB;subdirlib") diff --git a/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp b/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp new file mode 100644 index 0000000..d1321a1 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp @@ -0,0 +1,19 @@ + +#include "depB.h" +#include "depC.h" +#include "depIfaceOnly.h" + +#include "subdirlib.h" + +int main(int, char **) +{ + DepA a; + DepB b; + DepC c; + + DepIfaceOnly iface_only; + + SubDirLibObject sd; + + return a.foo() + b.foo() + c.foo() + iface_only.foo() + sd.foo(); +} diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt index bc92a94..d44cb9c 100644 --- a/Tests/Preprocess/CMakeLists.txt +++ b/Tests/Preprocess/CMakeLists.txt @@ -259,6 +259,19 @@ set_property( ${DEF_FILE_PATH} ) +# Try reading and writing the property value to ensure the string is +# preserved. +get_property(defs1 TARGET Preprocess PROPERTY COMPILE_DEFINITIONS) +set_property(TARGET Preprocess PROPERTY COMPILE_DEFINITIONS "${defs1}") +get_property(defs2 TARGET Preprocess PROPERTY COMPILE_DEFINITIONS) +if(NOT "x${defs1}" STREQUAL "x${defs2}") + message(FATAL_ERROR "get/set/get COMPILE_DEFINITIONS round trip failed. " + "First get:\n" + " ${defs1}\n" + "Second get:\n" + " ${defs2}") +endif() + # Helper target for running test manually in build tree. add_custom_target(drive COMMAND Preprocess) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 66ce3f1..6d1bca2 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -28,7 +28,7 @@ # <SubTest>-stdout.txt = Regex matching expected stdout content # <SubTest>-stderr.txt = Regex matching expected stderr content # <SubTest>-check.cmake = Custom result check -# Note that trailing newlines will be stripped from actual test +# Note that trailing newlines will be stripped from actual and expected test # output before matching against the stdout and stderr expressions. # The code in <SubTest>-check.cmake may use variables # RunCMake_TEST_SOURCE_DIR = Top of test source tree @@ -115,3 +115,5 @@ if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") endif() add_RunCMake_test(File_Generate) +add_RunCMake_test(ExportWithoutLanguage) +add_RunCMake_test(target_link_libraries) diff --git a/Tests/RunCMake/ExportWithoutLanguage/CMakeLists.txt b/Tests/RunCMake/ExportWithoutLanguage/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/ExportWithoutLanguage/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ExportWithoutLanguage/NoLanguage-result.txt b/Tests/RunCMake/ExportWithoutLanguage/NoLanguage-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ExportWithoutLanguage/NoLanguage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExportWithoutLanguage/NoLanguage-stderr.txt b/Tests/RunCMake/ExportWithoutLanguage/NoLanguage-stderr.txt new file mode 100644 index 0000000..67a0ae3 --- /dev/null +++ b/Tests/RunCMake/ExportWithoutLanguage/NoLanguage-stderr.txt @@ -0,0 +1,6 @@ +CMake Error: CMake can not determine linker language for target: NoLanguage +CMake Error at NoLanguage.cmake:2 \(export\): + Exporting the target "NoLanguage" is not allowed since its linker language + cannot be determined +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ExportWithoutLanguage/NoLanguage.cmake b/Tests/RunCMake/ExportWithoutLanguage/NoLanguage.cmake new file mode 100644 index 0000000..2ede854 --- /dev/null +++ b/Tests/RunCMake/ExportWithoutLanguage/NoLanguage.cmake @@ -0,0 +1,2 @@ +add_library(NoLanguage header.h) +export(TARGETS NoLanguage FILE "${CMAKE_CURRENT_BINARY_DIR}/export.cmake") diff --git a/Tests/RunCMake/ExportWithoutLanguage/RunCMakeTest.cmake b/Tests/RunCMake/ExportWithoutLanguage/RunCMakeTest.cmake new file mode 100644 index 0000000..f77f4eb --- /dev/null +++ b/Tests/RunCMake/ExportWithoutLanguage/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(NoLanguage) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-result.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt new file mode 100644 index 0000000..d27686d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt @@ -0,0 +1,16 @@ +CMake Error at CMP0023-NEW-2.cmake:11 \(target_link_libraries\): + Policy CMP0023 is not set: Plain and keyword target_link_libraries + signatures cannot be mixed. Run "cmake --help-policy CMP0023" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The plain signature for target_link_libraries has already been used with + the target "foo". All uses of target_link_libraries with a target must be + either all-keyword or all-plain. + + The uses of the plain signature are here: + + \* CMP0023-NEW-2.cmake:10 \(target_link_libraries\) + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2.cmake b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2.cmake new file mode 100644 index 0000000..f8b3546 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2.cmake @@ -0,0 +1,11 @@ + +project(CMP0022-WARN) + +cmake_policy(SET CMP0023 NEW) + +add_library(foo SHARED empty_vs6_1.cpp) +add_library(bar SHARED empty_vs6_2.cpp) +add_library(bat SHARED empty_vs6_3.cpp) + +target_link_libraries(foo bar) +target_link_libraries(foo LINK_PRIVATE bat) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-result.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt new file mode 100644 index 0000000..d7be0ff --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt @@ -0,0 +1,16 @@ +CMake Error at CMP0023-NEW.cmake:11 \(target_link_libraries\): + Policy CMP0023 is not set: Plain and keyword target_link_libraries + signatures cannot be mixed. Run "cmake --help-policy CMP0023" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The plain signature for target_link_libraries has already been used with + the target "foo". All uses of target_link_libraries with a target must be + either all-keyword or all-plain. + + The uses of the plain signature are here: + + \* CMP0023-NEW.cmake:10 \(target_link_libraries\) + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW.cmake b/Tests/RunCMake/target_link_libraries/CMP0023-NEW.cmake new file mode 100644 index 0000000..f0aa63f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW.cmake @@ -0,0 +1,11 @@ + +project(CMP0022-WARN) + +cmake_policy(SET CMP0023 NEW) + +add_library(foo SHARED empty_vs6_1.cpp) +add_library(bar SHARED empty_vs6_2.cpp) +add_library(bat SHARED empty_vs6_3.cpp) + +target_link_libraries(foo bar) +target_link_libraries(foo PRIVATE bat) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt new file mode 100644 index 0000000..5147861 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt @@ -0,0 +1,16 @@ +CMake Warning \(dev\) at CMP0023-WARN-2.cmake:9 \(target_link_libraries\): + Policy CMP0023 is not set: Plain and keyword target_link_libraries + signatures cannot be mixed. Run "cmake --help-policy CMP0023" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The plain signature for target_link_libraries has already been used with + the target "foo". All uses of target_link_libraries with a target should + be either all-keyword or all-plain. + + The uses of the plain signature are here: + + \* CMP0023-WARN-2.cmake:8 \(target_link_libraries\) + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2.cmake b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2.cmake new file mode 100644 index 0000000..2e9cba8 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2.cmake @@ -0,0 +1,9 @@ + +project(CMP0022-WARN) + +add_library(foo SHARED empty_vs6_1.cpp) +add_library(bar SHARED empty_vs6_2.cpp) +add_library(bat SHARED empty_vs6_3.cpp) + +target_link_libraries(foo bar) +target_link_libraries(foo LINK_PRIVATE bat) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt new file mode 100644 index 0000000..a7474fa --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt @@ -0,0 +1,16 @@ +CMake Warning \(dev\) at CMP0023-WARN.cmake:9 \(target_link_libraries\): + Policy CMP0023 is not set: Plain and keyword target_link_libraries + signatures cannot be mixed. Run "cmake --help-policy CMP0023" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + The plain signature for target_link_libraries has already been used with + the target "foo". All uses of target_link_libraries with a target should + be either all-keyword or all-plain. + + The uses of the plain signature are here: + + \* CMP0023-WARN.cmake:8 \(target_link_libraries\) + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN.cmake b/Tests/RunCMake/target_link_libraries/CMP0023-WARN.cmake new file mode 100644 index 0000000..fcc8da0 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN.cmake @@ -0,0 +1,9 @@ + +project(CMP0022-WARN) + +add_library(foo SHARED empty_vs6_1.cpp) +add_library(bar SHARED empty_vs6_2.cpp) +add_library(bat SHARED empty_vs6_3.cpp) + +target_link_libraries(foo bar) +target_link_libraries(foo PRIVATE bat) diff --git a/Tests/RunCMake/target_link_libraries/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/target_link_libraries/MixedSignature-result.txt b/Tests/RunCMake/target_link_libraries/MixedSignature-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/MixedSignature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt b/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt new file mode 100644 index 0000000..a0c66db --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at MixedSignature.cmake:6 \(target_link_libraries\): + The PUBLIC or PRIVATE option must appear as the second argument, just after + the target name. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_link_libraries/MixedSignature.cmake b/Tests/RunCMake/target_link_libraries/MixedSignature.cmake new file mode 100644 index 0000000..fa70685 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/MixedSignature.cmake @@ -0,0 +1,6 @@ + +add_library(foo empty_vs6_1.cpp) +add_library(bar empty_vs6_2.cpp) +add_library(bat empty_vs6_3.cpp) + +target_link_libraries(foo LINK_PUBLIC bar PRIVATE bat) diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake new file mode 100644 index 0000000..f97022e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +run_cmake(CMP0023-WARN) +run_cmake(CMP0023-NEW) +run_cmake(CMP0023-WARN-2) +run_cmake(CMP0023-NEW-2) +run_cmake(MixedSignature) +run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses) diff --git a/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses-result.txt b/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses.cmake b/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses.cmake new file mode 100644 index 0000000..e32891d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/Separate-PRIVATE-LINK_PRIVATE-uses.cmake @@ -0,0 +1,9 @@ + +enable_language(CXX) + +add_library(foo empty_vs6_1.cpp) +add_library(bar empty_vs6_2.cpp) +add_library(bat empty_vs6_3.cpp) + +target_link_libraries(foo LINK_PRIVATE bar) +target_link_libraries(foo PRIVATE bat) diff --git a/Tests/RunCMake/target_link_libraries/empty.cpp b/Tests/RunCMake/target_link_libraries/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_link_libraries/empty_vs6_1.cpp b/Tests/RunCMake/target_link_libraries/empty_vs6_1.cpp new file mode 100644 index 0000000..7efedab --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/empty_vs6_1.cpp @@ -0,0 +1 @@ +#include "empty.cpp" diff --git a/Tests/RunCMake/target_link_libraries/empty_vs6_2.cpp b/Tests/RunCMake/target_link_libraries/empty_vs6_2.cpp new file mode 100644 index 0000000..7efedab --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/empty_vs6_2.cpp @@ -0,0 +1 @@ +#include "empty.cpp" diff --git a/Tests/RunCMake/target_link_libraries/empty_vs6_3.cpp b/Tests/RunCMake/target_link_libraries/empty_vs6_3.cpp new file mode 100644 index 0000000..7efedab --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/empty_vs6_3.cpp @@ -0,0 +1 @@ +#include "empty.cpp" |