diff options
Diffstat (limited to 'Tests')
59 files changed, 386 insertions, 24 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/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/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/CMakeLists.txt b/Tests/CMakeLists.txt index fcefaf9..440cdf0 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -225,6 +225,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(ObjectLibrary UseCshared) ADD_TEST_MACRO(NewlineArgs NewlineArgs) ADD_TEST_MACRO(SetLang SetLang) + ADD_TEST_MACRO(EmptyProperty EmptyProperty) ADD_TEST_MACRO(ExternalOBJ ExternalOBJ) ADD_TEST_MACRO(LoadCommand LoadedCommand) ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory) diff --git a/Tests/CompileDefinitions/compiletest_mixed_c.c b/Tests/CompileDefinitions/compiletest_mixed_c.c index 698c989..a270b2b 100644 --- a/Tests/CompileDefinitions/compiletest_mixed_c.c +++ b/Tests/CompileDefinitions/compiletest_mixed_c.c @@ -13,6 +13,10 @@ #error Unexpected LINK_LANGUAGE_IS_C #endif +#ifndef C_EXECUTABLE_LINK_LANGUAGE_IS_C +#error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define +#endif + void someFunc(void) { diff --git a/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp index c686854..ae6befc 100644 --- a/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp +++ b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp @@ -13,6 +13,10 @@ #error Unexpected LINK_LANGUAGE_IS_C #endif +#ifndef C_EXECUTABLE_LINK_LANGUAGE_IS_C +#error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define +#endif + int main(int argc, char **argv) { return 0; diff --git a/Tests/CompileDefinitions/target_prop/CMakeLists.txt b/Tests/CompileDefinitions/target_prop/CMakeLists.txt index 6bf9c5c..a0d3f4e 100644 --- a/Tests/CompileDefinitions/target_prop/CMakeLists.txt +++ b/Tests/CompileDefinitions/target_prop/CMakeLists.txt @@ -23,9 +23,9 @@ set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS LETTER_LIST3=\"$<JOIN:A;B;C;D,,->\" LETTER_LIST4=\"$<JOIN:A;B;C;D,-,->\" LETTER_LIST5=\"$<JOIN:A;B;C;D,-,>\" - "$<$<LINK_LANGUAGE:CXX>:LINK_CXX_DEFINE>" - "$<$<LINK_LANGUAGE:C>:LINK_C_DEFINE>" - "LINK_LANGUAGE_IS_$<LINK_LANGUAGE>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:LINK_CXX_DEFINE>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:LINK_C_DEFINE>" + "LINK_LANGUAGE_IS_$<TARGET_PROPERTY:LINKER_LANGUAGE>" ) set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS @@ -36,16 +36,17 @@ set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS add_executable(target_prop_c_executable ../compiletest.c) set_property(TARGET target_prop_c_executable APPEND PROPERTY COMPILE_DEFINITIONS - "$<$<LINK_LANGUAGE:CXX>:LINK_CXX_DEFINE>" - "$<$<LINK_LANGUAGE:C>:LINK_C_DEFINE>" - "LINK_LANGUAGE_IS_$<LINK_LANGUAGE>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:LINK_CXX_DEFINE>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:LINK_C_DEFINE>" + "LINK_LANGUAGE_IS_$<TARGET_PROPERTY:LINKER_LANGUAGE>" ) # Resulting link language will be CXX add_executable(target_prop_mixed_executable ../compiletest_mixed_c.c ../compiletest_mixed_cxx.cpp) set_property(TARGET target_prop_mixed_executable APPEND PROPERTY COMPILE_DEFINITIONS - "$<$<LINK_LANGUAGE:CXX>:LINK_CXX_DEFINE>" - "$<$<LINK_LANGUAGE:C>:LINK_C_DEFINE>" - "LINK_LANGUAGE_IS_$<LINK_LANGUAGE>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:LINK_CXX_DEFINE>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:LINK_C_DEFINE>" + "LINK_LANGUAGE_IS_$<TARGET_PROPERTY:LINKER_LANGUAGE>" + "C_EXECUTABLE_LINK_LANGUAGE_IS_$<TARGET_PROPERTY:target_prop_c_executable,LINKER_LANGUAGE>" ) diff --git a/Tests/EmptyProperty/CMakeLists.txt b/Tests/EmptyProperty/CMakeLists.txt new file mode 100644 index 0000000..39e75f3 --- /dev/null +++ b/Tests/EmptyProperty/CMakeLists.txt @@ -0,0 +1,9 @@ +project (EmptyProperty) + +set_property(DIRECTORY APPEND + PROPERTY + COMPILE_DEFINITIONS) + +include(CTest) + +add_executable(EmptyProperty EmptyProperty.cxx) diff --git a/Tests/EmptyProperty/EmptyProperty.cxx b/Tests/EmptyProperty/EmptyProperty.cxx new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/Tests/EmptyProperty/EmptyProperty.cxx @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index f810f3b..49f1c58 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -140,6 +140,12 @@ install(FILES ) add_include_lib(testLibIncludeRequired6) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired7/testLibIncludeRequired7.h" "// No content\n") +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired7/testLibIncludeRequired7.h" + DESTINATION include/testLibIncludeRequired7 +) + set_property(TARGET testLibRequired APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:testLibIncludeRequired1,INTERFACE_INCLUDE_DIRECTORIES> @@ -154,6 +160,7 @@ set_property(TARGET testLibRequired APPEND PROPERTY $<BUILD_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired5,INTERFACE_INCLUDE_DIRECTORIES>> # Test that the below is non-fatal $<$<STREQUAL:one,two>:$<TARGET_PROPERTY:not_a_target,INTERFACE_INCLUDE_DIRECTORIES>> + $<INSTALL_INTERFACE:include/testLibIncludeRequired7> ) set_property(TARGET testLibRequired APPEND PROPERTY @@ -271,9 +278,26 @@ install(TARGETS testLibRequired testLibIncludeRequired5 testLibIncludeRequired6 testSharedLibRequired - EXPORT RequiredExp DESTINATION lib ) + EXPORT RequiredExp DESTINATION lib + INCLUDES DESTINATION + installIncludesTest + $<INSTALL_PREFIX>/installIncludesTest2) install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredTargets.cmake DESTINATION lib/cmake/testLibRequired) +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest/installIncludesTest.h" "// No content\n") + +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest2") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest2/installIncludesTest2.h" "// No content\n") +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest/installIncludesTest.h" + DESTINATION installIncludesTest +) +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest2/installIncludesTest2.h" + DESTINATION installIncludesTest2 +) + install(TARGETS testLibDepends testSharedLibDepends EXPORT DependsExp DESTINATION lib ) install(EXPORT DependsExp FILE testLibDependsTargets.cmake DESTINATION lib/cmake/testLibDepends) @@ -312,6 +336,12 @@ install( FRAMEWORK DESTINATION Frameworks BUNDLE DESTINATION Applications ) +if (APPLE) + file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/testLib4.framework/Headers) + file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/testLib4.framework/Headers) + file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Release/testLib4.framework/Headers) + install(FILES testLib4.h DESTINATION Frameworks/testLib4.framework/Headers) +endif() install( TARGETS testExe2libImp testLib3Imp diff --git a/Tests/ExportImport/Export/testLib4.h b/Tests/ExportImport/Export/testLib4.h new file mode 100644 index 0000000..9eeda7c --- /dev/null +++ b/Tests/ExportImport/Export/testLib4.h @@ -0,0 +1,2 @@ + +#define TESTLIB4_H diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index aa8847b..2627354 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -210,6 +210,10 @@ if (run_pic_test) target_compile_definitions(deps_shared_iface PRIVATE CHECK_PIC_WORKS) endif() +if(APPLE) + add_subdirectory(framework_interface) +endif() + #----------------------------------------------------------------------------- # Test that targets imported from the build tree have their dependencies # evaluated correctly. The above already tests the same for the install tree. diff --git a/Tests/ExportImport/Import/A/deps_iface.c b/Tests/ExportImport/Import/A/deps_iface.c index e73ca26..48a4c44 100644 --- a/Tests/ExportImport/Import/A/deps_iface.c +++ b/Tests/ExportImport/Import/A/deps_iface.c @@ -2,6 +2,10 @@ #include "testLibIncludeRequired1.h" #include "testLibIncludeRequired2.h" #include "testLibIncludeRequired6.h" +#include "testLibIncludeRequired7.h" + +#include "installIncludesTest.h" +#include "installIncludesTest2.h" #ifndef testLibRequired_IFACE_DEFINE #error Expected testLibRequired_IFACE_DEFINE diff --git a/Tests/ExportImport/Import/A/framework_interface/CMakeLists.txt b/Tests/ExportImport/Import/A/framework_interface/CMakeLists.txt new file mode 100644 index 0000000..0e00655 --- /dev/null +++ b/Tests/ExportImport/Import/A/framework_interface/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_library(exp_framework_test framework_test.cpp) +get_target_property(exp_loc exp_testLib4 LOCATION) +target_link_libraries(exp_framework_test ${exp_loc}) + + +add_library(bld_framework_test framework_test.cpp) +get_target_property(bld_loc bld_testLib4 LOCATION) +target_link_libraries(bld_framework_test ${bld_loc}) diff --git a/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp b/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp new file mode 100644 index 0000000..357f64f --- /dev/null +++ b/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp @@ -0,0 +1,6 @@ + +#include <testLib4/testLib4.h> + +#ifndef TESTLIB4_H +#error Expected define TESTLIB4_H +#endif diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index ab936ca..7ac6ede 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -138,6 +138,31 @@ add_custom_target(check-part2 ALL VERBATIM ) +add_library(imported1 SHARED IMPORTED) +set_property(TARGET imported1 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) +set_property(TARGET imported1 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) +set_property(TARGET imported1 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) +set_property(TARGET imported1 PROPERTY INTERFACE_INCLUDE_DIRECTORIES /imported1/include) + +add_library(imported2 SHARED IMPORTED) +set_property(TARGET imported2 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) +set_property(TARGET imported2 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) +set_property(TARGET imported2 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) +set_property(TARGET imported2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES /imported2/include) + +add_library(imported3 SHARED IMPORTED) +set_property(TARGET imported3 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) +set_property(TARGET imported3 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) +# Both Debug and Release should not be true when this is evaluated. +set_property(TARGET imported3 APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:DEBUG>:$<TARGET_PROPERTY:imported1,INTERFACE_INCLUDE_DIRECTORIES>>) +set_property(TARGET imported3 APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:RELEASE>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>) + +add_library(imported4 SHARED IMPORTED) +set_property(TARGET imported4 APPEND PROPERTY + INCLUDE_DIRECTORIES $<TARGET_PROPERTY:imported3,INTERFACE_INCLUDE_DIRECTORIES>) + add_custom_target(check-part3 ALL COMMAND ${CMAKE_COMMAND} -Dtest_version_greater_1=$<VERSION_GREATER:1.0,1.1.1> @@ -146,6 +171,11 @@ add_custom_target(check-part3 ALL -Dtest_version_less_2=$<VERSION_LESS:1.0,1.1.1> -Dtest_version_equal_1=$<VERSION_EQUAL:1.0.1,1.1> -Dtest_version_equal_2=$<VERSION_EQUAL:1.1,1.1> + -Dconfig=$<CONFIGURATION> + -Dtest_imported_debug=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES> + -Dtest_imported_release=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES> + -Dtest_imported_relwithdebinfo=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES> + -Dtest_imported_minsizerel=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES> -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)" VERBATIM diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake index 70d6571..af290a5 100644 --- a/Tests/GeneratorExpression/check-part3.cmake +++ b/Tests/GeneratorExpression/check-part3.cmake @@ -7,3 +7,16 @@ check(test_version_less_1 "0") check(test_version_less_2 "1") check(test_version_equal_1 "0") check(test_version_equal_2 "1") + +foreach(c debug release relwithdebinfo minsizerel) + if(config AND NOT config STREQUAL NoConfig) + if(NOT "${test_imported_${c}}" MATCHES "^;/imported2/include$" + AND NOT "${test_imported_${c}}" MATCHES "^/imported1/include;$") + message(SEND_ERROR "test_imported_${c} is not correct: ${test_imported_${c}}") + endif() + else() + if(NOT "${test_imported_${c}}" MATCHES "^;$") + message(SEND_ERROR "test_imported_${c} is not an empty list: ${test_imported_${c}}") + endif() + endif() +endforeach() diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt index 6919261..8e2bd0a 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -156,15 +156,15 @@ target_include_directories(TargetIncludeDirectories PRIVATE "${CMAKE_CURRENT_BIN # Test that the language generator expressions work set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES - "$<$<LINK_LANGUAGE:C>:${CMAKE_CURRENT_BINARY_DIR}/bad>" - "$<$<LINK_LANGUAGE:CXX>:${CMAKE_CURRENT_BINARY_DIR}/good>" - "$<$<STREQUAL:$<LINK_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/bad>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/good>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>" ) add_executable(TargetIncludeDirectories_C main.c) set_property(TARGET TargetIncludeDirectories_C APPEND PROPERTY INCLUDE_DIRECTORIES - "$<$<LINK_LANGUAGE:CXX>:${CMAKE_CURRENT_BINARY_DIR}/bad>" - "$<$<LINK_LANGUAGE:C>:${CMAKE_CURRENT_BINARY_DIR}/good>" - "$<$<STREQUAL:$<LINK_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/bad>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/good>" + "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>" ) 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/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/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/Languages/LINK_LANGUAGE-genex-stderr.txt b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt index 8e0591d..a5d5d50 100644 --- a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt +++ b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt @@ -1,6 +1,7 @@ CMake Error: Error evaluating generator expression: - \$<LINK_LANGUAGE> + \$<TARGET_PROPERTY:LINKER_LANGUAGE> - \$<LINK_LANGUAGE> expression can not be used while evaluating link libraries + LINKER_LANGUAGE target property can not be used while evaluating link + libraries diff --git a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake index e0f8c57..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) -target_link_libraries(foo $<$<STREQUAL:$<LINK_LANGUAGE>,anything>:bar>) +add_library(foo STATIC empty.cpp) +add_library(bar STATIC empty.cpp) +target_link_libraries(foo $<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,anything>:bar>) diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index 520dd44..e582960 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -9,3 +9,4 @@ run_cmake(RelativePathInInterface) run_cmake(ImportedTarget) run_cmake(RelativePathInGenex) run_cmake(CMP0021) +run_cmake(TargetInterfaceIncludes) diff --git a/Tests/RunCMake/include_directories/TargetInterfaceIncludes-result.txt b/Tests/RunCMake/include_directories/TargetInterfaceIncludes-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/include_directories/TargetInterfaceIncludes-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/TargetInterfaceIncludes-stderr.txt b/Tests/RunCMake/include_directories/TargetInterfaceIncludes-stderr.txt new file mode 100644 index 0000000..d153927 --- /dev/null +++ b/Tests/RunCMake/include_directories/TargetInterfaceIncludes-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at TargetInterfaceIncludes.cmake:3 \(install\): + install TARGETS given INCLUDES DESTINATION, but EXPORT set not specified. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/include_directories/TargetInterfaceIncludes.cmake b/Tests/RunCMake/include_directories/TargetInterfaceIncludes.cmake new file mode 100644 index 0000000..92f31fc --- /dev/null +++ b/Tests/RunCMake/include_directories/TargetInterfaceIncludes.cmake @@ -0,0 +1,4 @@ + +add_library(empty empty.cpp) +install(TARGETS empty DESTINATION lib INCLUDES DESTINATION include) +# install(EXPORT ) 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" |