From 0951b1fe072da311e9adb55337ef364e2b6c01d0 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Wed, 17 Jun 2020 10:51:39 +0200 Subject: Tests: Split RunCMake.target_link_libraries test Fixes: #20836 --- Tests/RunCMake/CMakeLists.txt | 3 + .../target_link_libraries-ALIAS/AliasTargets.cmake | 36 +++++++++++ .../target_link_libraries-ALIAS/CMakeLists.txt | 3 + .../target_link_libraries-ALIAS/RunCMakeTest.cmake | 23 +++++++ Tests/RunCMake/target_link_libraries-ALIAS/func.c | 7 +++ Tests/RunCMake/target_link_libraries-ALIAS/lib.c | 10 +++ Tests/RunCMake/target_link_libraries-ALIAS/main.c | 12 ++++ .../CMakeLists.txt | 3 + .../RunCMakeTest.cmake | 41 ++++++++++++ .../target_link_libraries-LINK_LANGUAGE/empty.c | 0 .../target_link_libraries-LINK_LANGUAGE/func.c | 7 +++ .../target_link_libraries-LINK_LANGUAGE/func.cxx | 7 +++ .../genex_LINK_LANGUAGE-bad-mix-lang-result.txt | 1 + .../genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt | 2 + .../genex_LINK_LANGUAGE-bad-mix-lang.cmake | 8 +++ .../genex_LINK_LANGUAGE-bad-usage-result.txt | 1 + .../genex_LINK_LANGUAGE-bad-usage-stderr.txt | 8 +++ .../genex_LINK_LANGUAGE-bad-usage.cmake | 4 ++ .../genex_LINK_LANGUAGE.cmake | 72 +++++++++++++++++++++ .../target_link_libraries-LINK_LANGUAGE/lib.c | 10 +++ .../target_link_libraries-LINK_LANGUAGE/main.c | 12 ++++ .../target_link_libraries-LINK_LANGUAGE/main.cxx | 12 ++++ .../CMakeLists.txt | 3 + .../RunCMakeTest.cmake | 38 +++++++++++ .../target_link_libraries-LINK_LANG_AND_ID/empty.c | 0 .../target_link_libraries-LINK_LANG_AND_ID/func.c | 7 +++ .../func.cxx | 7 +++ .../genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt | 1 + .../genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt | 2 + .../genex_LINK_LANG_AND_ID-bad-mix-lang.cmake | 8 +++ .../genex_LINK_LANG_AND_ID-basic-result.txt | 1 + .../genex_LINK_LANG_AND_ID-exe_c-result.txt | 1 + .../genex_LINK_LANG_AND_ID-exe_cxx-result.txt | 1 + .../genex_LINK_LANG_AND_ID-interface-result.txt | 1 + .../genex_LINK_LANG_AND_ID-no_language-result.txt | 1 + .../genex_LINK_LANG_AND_ID.cmake | 73 ++++++++++++++++++++++ .../target_link_libraries-LINK_LANG_AND_ID/lib.c | 10 +++ .../target_link_libraries-LINK_LANG_AND_ID/main.c | 12 ++++ .../main.cxx | 12 ++++ .../target_link_libraries/AliasTargets.cmake | 36 ----------- .../target_link_libraries/RunCMakeTest.cmake | 68 -------------------- Tests/RunCMake/target_link_libraries/func.c | 7 --- Tests/RunCMake/target_link_libraries/func.cxx | 7 --- .../genex_LINK_LANGUAGE-bad-mix-lang-result.txt | 1 - .../genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt | 2 - .../genex_LINK_LANGUAGE-bad-mix-lang.cmake | 8 --- .../genex_LINK_LANGUAGE-bad-usage-result.txt | 1 - .../genex_LINK_LANGUAGE-bad-usage-stderr.txt | 8 --- .../genex_LINK_LANGUAGE-bad-usage.cmake | 4 -- .../genex_LINK_LANGUAGE.cmake | 72 --------------------- .../genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt | 1 - .../genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt | 2 - .../genex_LINK_LANG_AND_ID-bad-mix-lang.cmake | 8 --- .../genex_LINK_LANG_AND_ID-basic-result.txt | 1 - .../genex_LINK_LANG_AND_ID-exe_c-result.txt | 1 - .../genex_LINK_LANG_AND_ID-exe_cxx-result.txt | 1 - .../genex_LINK_LANG_AND_ID-interface-result.txt | 1 - .../genex_LINK_LANG_AND_ID-no_language-result.txt | 1 - .../genex_LINK_LANG_AND_ID.cmake | 73 ---------------------- Tests/RunCMake/target_link_libraries/main.c | 12 ---- Tests/RunCMake/target_link_libraries/main.cxx | 12 ---- 61 files changed, 460 insertions(+), 327 deletions(-) create mode 100644 Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake create mode 100644 Tests/RunCMake/target_link_libraries-ALIAS/CMakeLists.txt create mode 100644 Tests/RunCMake/target_link_libraries-ALIAS/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/target_link_libraries-ALIAS/func.c create mode 100644 Tests/RunCMake/target_link_libraries-ALIAS/lib.c create mode 100644 Tests/RunCMake/target_link_libraries-ALIAS/main.c create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/CMakeLists.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/empty.c create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/func.c create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/func.cxx create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-stderr.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/lib.c create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/main.c create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/main.cxx create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/CMakeLists.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/empty.c create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/func.c create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/func.cxx create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-basic-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_c-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_cxx-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-interface-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-no_language-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/lib.c create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/main.c create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/main.cxx delete mode 100644 Tests/RunCMake/target_link_libraries/AliasTargets.cmake delete mode 100644 Tests/RunCMake/target_link_libraries/func.c delete mode 100644 Tests/RunCMake/target_link_libraries/func.cxx delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang.cmake delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage-stderr.txt delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage.cmake delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE.cmake delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-basic-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-exe_c-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-exe_cxx-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-interface-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-no_language-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID.cmake delete mode 100644 Tests/RunCMake/target_link_libraries/main.c delete mode 100644 Tests/RunCMake/target_link_libraries/main.cxx diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 866e7c0..6c634b5 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -494,6 +494,9 @@ add_RunCMake_test(File_Generate) add_RunCMake_test(ExportWithoutLanguage) add_RunCMake_test(target_link_directories) add_RunCMake_test(target_link_libraries) +add_RunCMake_test(target_link_libraries-ALIAS) +add_RunCMake_test(target_link_libraries-LINK_LANGUAGE) +add_RunCMake_test(target_link_libraries-LINK_LANG_AND_ID) 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} -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake b/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake new file mode 100644 index 0000000..73f8a7d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake @@ -0,0 +1,36 @@ + +cmake_minimum_required(VERSION 3.16...3.17) + +enable_language(C) + +add_library (func SHARED func.c) + +set (binary_dir "${CMAKE_BINARY_DIR}") +get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if (is_multi_config) + string (APPEND binary_dir "/Release") +endif() + + +add_library(import-local SHARED IMPORTED) +set_property(TARGET import-local PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_SHARED_LIBRARY_SUFFIX}") +set_property(TARGET import-local PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_IMPORT_LIBRARY_SUFFIX}") +add_library(alias-local ALIAS import-local) + +add_library (lib-local SHARED lib.c) +target_link_libraries (lib-local PRIVATE import-local) + +add_executable (main-local main.c) +target_link_libraries (main-local PRIVATE import-local) + + +add_library(import-global SHARED IMPORTED GLOBAL) +set_property(TARGET import-global PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_SHARED_LIBRARY_SUFFIX}") +set_property(TARGET import-global PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_IMPORT_LIBRARY_SUFFIX}") +add_library(alias-global ALIAS import-global) + +add_library (lib-global SHARED lib.c) +target_link_libraries (lib-global PRIVATE import-global) + +add_executable (main-global main.c) +target_link_libraries (main-global PRIVATE import-global) diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-ALIAS/CMakeLists.txt new file mode 100644 index 0000000..9cf020f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-ALIAS/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-ALIAS/RunCMakeTest.cmake new file mode 100644 index 0000000..4d24a6e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-ALIAS/RunCMakeTest.cmake @@ -0,0 +1,23 @@ +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() + +set(RunCMake_TEST_OUTPUT_MERGE TRUE) +if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) +endif() +run_cmake(AliasTargets) +run_cmake_target(AliasTargets func func --config Release) +run_cmake_target(AliasTargets lib-local lib-local --config Release) +run_cmake_target(AliasTargets main-local main-local --config Release) +run_cmake_target(AliasTargets lib-global lib-global --config Release) +run_cmake_target(AliasTargets main-global main-global --config Release) +unset(RunCMake_TEST_OPTIONS) +unset(RunCMake_TEST_OUTPUT_MERGE) diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/func.c b/Tests/RunCMake/target_link_libraries-ALIAS/func.c new file mode 100644 index 0000000..415a9bf --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-ALIAS/func.c @@ -0,0 +1,7 @@ + +#if defined(_WIN32) +__declspec(dllexport) +#endif + void func_c() +{ +} diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/lib.c b/Tests/RunCMake/target_link_libraries-ALIAS/lib.c new file mode 100644 index 0000000..b2d1b66 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-ALIAS/lib.c @@ -0,0 +1,10 @@ + +#if defined(_WIN32) +__declspec(dllimport) +#endif + void func_c(); + +void lib() +{ + func_c(); +} diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/main.c b/Tests/RunCMake/target_link_libraries-ALIAS/main.c new file mode 100644 index 0000000..a908dea --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-ALIAS/main.c @@ -0,0 +1,12 @@ + +#if defined(_WIN32) +__declspec(dllimport) +#endif + void func_c(); + +int main() +{ + func_c(); + + return 0; +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/CMakeLists.txt new file mode 100644 index 0000000..9cf020f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/RunCMakeTest.cmake new file mode 100644 index 0000000..487bf25 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/RunCMakeTest.cmake @@ -0,0 +1,41 @@ +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() + +run_cmake(genex_LINK_LANGUAGE-bad-usage) + +if (RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Visual Studio|Xcode|Watcom WMake") + + run_cmake(genex_LINK_LANGUAGE-bad-mix-lang) + + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + + run_cmake(genex_LINK_LANGUAGE) + + run_cmake_target(genex_LINK_LANGUAGE lib LinkLibraries_lib --config Release) + run_cmake_target(genex_LINK_LANGUAGE lib2 LinkLibraries_lib2 --config Release) + run_cmake_target(genex_LINK_LANGUAGE lib3 LinkLibraries_lib3 --config Release) + run_cmake_target(genex_LINK_LANGUAGE exe LinkLibraries_exe --config Release) + run_cmake_target(genex_LINK_LANGUAGE C_import LinkLibraries_C_import --config Release) + run_cmake_target(genex_LINK_LANGUAGE CXX_import LinkLibraries_CXX_import --config Release) + run_cmake_target(genex_LINK_LANGUAGE C_interface LinkLibraries_C_interface --config Release) + run_cmake_target(genex_LINK_LANGUAGE CXX_interface LinkLibraries_CXX_interface --config Release) + run_cmake_target(genex_LINK_LANGUAGE C_interface2 LinkLibraries_C_interface2 --config Release) + run_cmake_target(genex_LINK_LANGUAGE CXX_interface2 LinkLibraries_CXX_interface2 --config Release) + run_cmake_target(genex_LINK_LANGUAGE C_static LinkLibraries_C_static --config Release) + run_cmake_target(genex_LINK_LANGUAGE CXX_static LinkLibraries_CXX_static --config Release) + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) + +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/empty.c b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/empty.c new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/func.c b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/func.c new file mode 100644 index 0000000..415a9bf --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/func.c @@ -0,0 +1,7 @@ + +#if defined(_WIN32) +__declspec(dllexport) +#endif + void func_c() +{ +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/func.cxx b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/func.cxx new file mode 100644 index 0000000..a12caca --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/func.cxx @@ -0,0 +1,7 @@ + +#if defined(_WIN32) +__declspec(dllexport) +#endif + void func_cxx() +{ +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt new file mode 100644 index 0000000..2ecdc0c --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: Evaluation of \$ or \$ changes +the linker language for target "LinkLibraries_bad_mix_languages" \(from 'C' to 'CXX'\) which is invalid. diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang.cmake new file mode 100644 index 0000000..e8efa75 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang.cmake @@ -0,0 +1,8 @@ + +enable_language(C) +enable_language(CXX) + +add_library(static_CXX STATIC func.cxx) + +add_executable(LinkLibraries_bad_mix_languages main.c) +target_link_libraries (LinkLibraries_bad_mix_languages PRIVATE $<$:static_CXX>) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-stderr.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-stderr.txt new file mode 100644 index 0000000..469f1fe --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at genex_LINK_LANGUAGE-bad-usage.cmake:4 \(target_link_libraries\): + Error evaluating generator expression: + + \$ + + \$ is not supported in link libraries expression. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage.cmake new file mode 100644 index 0000000..81cfb0c --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(simple SHARED empty.c) +target_link_libraries(simple PRIVATE lib$) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE.cmake new file mode 100644 index 0000000..f3fe955 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE.cmake @@ -0,0 +1,72 @@ + +cmake_minimum_required(VERSION 3.16...3.17) + +enable_language(C) +enable_language(CXX) + +add_library(shared_C SHARED func.c) +add_library(shared_CXX SHARED func.cxx) + + +add_library(static1_C STATIC empty.c) +target_link_libraries (static1_C INTERFACE $<$:shared_C>) + +add_library(static2_C STATIC empty.c) +target_link_libraries (static2_C PRIVATE $<$:shared_C>) + + +set (binary_dir "${CMAKE_BINARY_DIR}") +get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if (is_multi_config) + string (APPEND binary_dir "/Release") +endif() +add_library(import STATIC IMPORTED) +set_property(TARGET import PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}static1_C${CMAKE_STATIC_LIBRARY_SUFFIX}") +target_link_libraries (import INTERFACE $<$:shared_C>) +target_link_libraries (import INTERFACE $<$:shared_CXX>) + + +add_library(interface INTERFACE) +target_link_libraries (interface INTERFACE $<$:shared_C> + $<$:shared_CXX>) + + +add_library(interface2 INTERFACE) +target_link_libraries (interface2 INTERFACE import) + + +add_library(static3 STATIC empty.c) +target_link_libraries (static3 PRIVATE interface) + + +add_library(LinkLibraries_lib SHARED lib.c) +target_link_libraries (LinkLibraries_lib PRIVATE $<$:shared_C>) + +add_library(LinkLibraries_lib2 SHARED lib.c) +target_link_libraries (LinkLibraries_lib2 PRIVATE $<$:static1_C>) + +add_library(LinkLibraries_lib3 SHARED lib.c) +target_link_libraries (LinkLibraries_lib3 PRIVATE $<$:static2_C>) + +add_executable(LinkLibraries_exe main.c) +target_link_libraries (LinkLibraries_exe PRIVATE $<$:shared_C>) + +add_executable(LinkLibraries_C_import main.c) +target_link_libraries (LinkLibraries_C_import PRIVATE import) +add_executable(LinkLibraries_CXX_import main.cxx) +target_link_libraries (LinkLibraries_CXX_import PRIVATE import) + +add_executable(LinkLibraries_C_interface main.c) +target_link_libraries (LinkLibraries_C_interface PRIVATE interface) +add_executable(LinkLibraries_CXX_interface main.cxx) +target_link_libraries (LinkLibraries_CXX_interface PRIVATE interface) + +add_executable(LinkLibraries_C_interface2 main.c) +target_link_libraries (LinkLibraries_C_interface2 PRIVATE interface2) +add_executable(LinkLibraries_CXX_interface2 main.cxx) +target_link_libraries (LinkLibraries_CXX_interface2 PRIVATE interface2) + +add_executable(LinkLibraries_C_static main.c) +target_link_libraries (LinkLibraries_C_static PRIVATE static3) +add_executable(LinkLibraries_CXX_static main.cxx) +target_link_libraries (LinkLibraries_CXX_static PRIVATE static3) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/lib.c b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/lib.c new file mode 100644 index 0000000..b2d1b66 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/lib.c @@ -0,0 +1,10 @@ + +#if defined(_WIN32) +__declspec(dllimport) +#endif + void func_c(); + +void lib() +{ + func_c(); +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/main.c b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/main.c new file mode 100644 index 0000000..a908dea --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/main.c @@ -0,0 +1,12 @@ + +#if defined(_WIN32) +__declspec(dllimport) +#endif + void func_c(); + +int main() +{ + func_c(); + + return 0; +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/main.cxx b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/main.cxx new file mode 100644 index 0000000..ffaa3b4 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/main.cxx @@ -0,0 +1,12 @@ + +#if defined(_WIN32) +__declspec(dllimport) +#endif + void func_cxx(); + +int main() +{ + func_cxx(); + + return 0; +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/CMakeLists.txt new file mode 100644 index 0000000..9cf020f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/RunCMakeTest.cmake new file mode 100644 index 0000000..7cbc922 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/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 (RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Visual Studio|Xcode|Watcom WMake") + + run_cmake(genex_LINK_LANG_AND_ID-bad-mix-lang) + + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + + run_cmake(genex_LINK_LANG_AND_ID) + + run_cmake_target(genex_LINK_LANG_AND_ID lib LinkLibraries_lib --config Release) + run_cmake_target(genex_LINK_LANG_AND_ID lib2 LinkLibraries_lib2 --config Release) + run_cmake_target(genex_LINK_LANG_AND_ID lib3 LinkLibraries_lib3 --config Release) + run_cmake_target(genex_LINK_LANG_AND_ID exe LinkLibraries_exe --config Release) + run_cmake_target(genex_LINK_LANG_AND_ID C_import LinkLibraries_C_import --config Release) + run_cmake_target(genex_LINK_LANG_AND_ID CXX_import LinkLibraries_CXX_import --config Release) + run_cmake_target(genex_LINK_LANG_AND_ID C_interface LinkLibraries_C_interface --config Release) + run_cmake_target(genex_LINK_LANG_AND_ID CXX_interface LinkLibraries_CXX_interface --config Release) + run_cmake_target(genex_LINK_LANG_AND_ID C_interface2 LinkLibraries_C_interface2 --config Release) + run_cmake_target(genex_LINK_LANG_AND_ID CXX_interface2 LinkLibraries_CXX_interface2 --config Release) + run_cmake_target(genex_LINK_LANG_AND_ID CXX_static LinkLibraries_CXX_static --config Release) + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) + +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/empty.c b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/empty.c new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/func.c b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/func.c new file mode 100644 index 0000000..415a9bf --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/func.c @@ -0,0 +1,7 @@ + +#if defined(_WIN32) +__declspec(dllexport) +#endif + void func_c() +{ +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/func.cxx b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/func.cxx new file mode 100644 index 0000000..a12caca --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/func.cxx @@ -0,0 +1,7 @@ + +#if defined(_WIN32) +__declspec(dllexport) +#endif + void func_cxx() +{ +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt new file mode 100644 index 0000000..2ecdc0c --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: Evaluation of \$ or \$ changes +the linker language for target "LinkLibraries_bad_mix_languages" \(from 'C' to 'CXX'\) which is invalid. diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake new file mode 100644 index 0000000..f80010a --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake @@ -0,0 +1,8 @@ + +enable_language(C) +enable_language(CXX) + +add_library(static_CXX STATIC func.cxx) + +add_executable(LinkLibraries_bad_mix_languages main.c) +target_link_libraries (LinkLibraries_bad_mix_languages PRIVATE $<$:static_CXX>) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-basic-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_c-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_c-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_c-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_cxx-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_cxx-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_cxx-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-interface-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-interface-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-interface-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-no_language-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-no_language-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-no_language-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID.cmake new file mode 100644 index 0000000..9feccd0 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID.cmake @@ -0,0 +1,73 @@ + +cmake_minimum_required(VERSION 3.16...3.17) + +enable_language(C) +enable_language(CXX) + + +add_library(shared_C SHARED func.c) +add_library(shared_CXX SHARED func.cxx) + + +add_library(static1_C STATIC empty.c) +target_link_libraries (static1_C INTERFACE $<$:shared_C>) + +add_library(static2_C STATIC empty.c) +target_link_libraries (static2_C PRIVATE $<$:shared_C>) + + +set (binary_dir "${CMAKE_BINARY_DIR}") +get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if (is_multi_config) + string (APPEND binary_dir "/Release") +endif() +add_library(import STATIC IMPORTED) +set_property(TARGET import PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}static1_C${CMAKE_STATIC_LIBRARY_SUFFIX}") +target_link_libraries (import INTERFACE $<$:shared_C>) +target_link_libraries (import INTERFACE $<$:shared_CXX>) + + +add_library(interface INTERFACE) +target_link_libraries (interface INTERFACE $<$:shared_C> + $<$:shared_CXX>) + + +add_library(interface2 INTERFACE) +target_link_libraries (interface2 INTERFACE import) + + +add_library(static3 STATIC empty.c) +target_link_libraries (static3 PRIVATE interface) + + +add_library(LinkLibraries_lib SHARED lib.c) +target_link_libraries (LinkLibraries_lib PRIVATE $<$:shared_C>) + +add_library(LinkLibraries_lib2 SHARED lib.c) +target_link_libraries (LinkLibraries_lib2 PRIVATE $<$:static1_C>) + +add_library(LinkLibraries_lib3 SHARED lib.c) +target_link_libraries (LinkLibraries_lib3 PRIVATE $<$:static2_C>) + +add_executable(LinkLibraries_exe main.c) +target_link_libraries (LinkLibraries_exe PRIVATE $<$:shared_C>) + +add_executable(LinkLibraries_C_import main.c) +target_link_libraries (LinkLibraries_C_import PRIVATE import) +add_executable(LinkLibraries_CXX_import main.cxx) +target_link_libraries (LinkLibraries_CXX_import PRIVATE import) + +add_executable(LinkLibraries_C_interface main.c) +target_link_libraries (LinkLibraries_C_interface PRIVATE interface) +add_executable(LinkLibraries_CXX_interface main.cxx) +target_link_libraries (LinkLibraries_CXX_interface PRIVATE interface) + +add_executable(LinkLibraries_C_interface2 main.c) +target_link_libraries (LinkLibraries_C_interface2 PRIVATE interface2) +add_executable(LinkLibraries_CXX_interface2 main.cxx) +target_link_libraries (LinkLibraries_CXX_interface2 PRIVATE interface2) + +add_executable(LinkLibraries_C_static main.c) +target_link_libraries (LinkLibraries_C_static PRIVATE static3) +add_executable(LinkLibraries_CXX_static main.cxx) +target_link_libraries (LinkLibraries_CXX_static PRIVATE static3) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/lib.c b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/lib.c new file mode 100644 index 0000000..b2d1b66 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/lib.c @@ -0,0 +1,10 @@ + +#if defined(_WIN32) +__declspec(dllimport) +#endif + void func_c(); + +void lib() +{ + func_c(); +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/main.c b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/main.c new file mode 100644 index 0000000..a908dea --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/main.c @@ -0,0 +1,12 @@ + +#if defined(_WIN32) +__declspec(dllimport) +#endif + void func_c(); + +int main() +{ + func_c(); + + return 0; +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/main.cxx b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/main.cxx new file mode 100644 index 0000000..ffaa3b4 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/main.cxx @@ -0,0 +1,12 @@ + +#if defined(_WIN32) +__declspec(dllimport) +#endif + void func_cxx(); + +int main() +{ + func_cxx(); + + return 0; +} diff --git a/Tests/RunCMake/target_link_libraries/AliasTargets.cmake b/Tests/RunCMake/target_link_libraries/AliasTargets.cmake deleted file mode 100644 index 73f8a7d..0000000 --- a/Tests/RunCMake/target_link_libraries/AliasTargets.cmake +++ /dev/null @@ -1,36 +0,0 @@ - -cmake_minimum_required(VERSION 3.16...3.17) - -enable_language(C) - -add_library (func SHARED func.c) - -set (binary_dir "${CMAKE_BINARY_DIR}") -get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if (is_multi_config) - string (APPEND binary_dir "/Release") -endif() - - -add_library(import-local SHARED IMPORTED) -set_property(TARGET import-local PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_SHARED_LIBRARY_SUFFIX}") -set_property(TARGET import-local PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_IMPORT_LIBRARY_SUFFIX}") -add_library(alias-local ALIAS import-local) - -add_library (lib-local SHARED lib.c) -target_link_libraries (lib-local PRIVATE import-local) - -add_executable (main-local main.c) -target_link_libraries (main-local PRIVATE import-local) - - -add_library(import-global SHARED IMPORTED GLOBAL) -set_property(TARGET import-global PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_SHARED_LIBRARY_SUFFIX}") -set_property(TARGET import-global PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_IMPORT_LIBRARY_SUFFIX}") -add_library(alias-global ALIAS import-global) - -add_library (lib-global SHARED lib.c) -target_link_libraries (lib-global PRIVATE import-global) - -add_executable (main-global main.c) -target_link_libraries (main-global PRIVATE import-global) diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index 1f4077c..189592d 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -30,71 +30,3 @@ run_cmake(StaticPrivateDepNotExported) run_cmake(StaticPrivateDepNotTarget) run_cmake(UNKNOWN-IMPORTED-GLOBAL) run_cmake(empty_keyword_args) - -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() - -set(RunCMake_TEST_OUTPUT_MERGE TRUE) -if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) - set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) -endif() -run_cmake(AliasTargets) -run_cmake_target(AliasTargets func func --config Release) -run_cmake_target(AliasTargets lib-local lib-local --config Release) -run_cmake_target(AliasTargets main-local main-local --config Release) -run_cmake_target(AliasTargets lib-global lib-global --config Release) -run_cmake_target(AliasTargets main-global main-global --config Release) -unset(RunCMake_TEST_OPTIONS) -unset(RunCMake_TEST_OUTPUT_MERGE) - -run_cmake(genex_LINK_LANGUAGE-bad-usage) - -if (RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Visual Studio|Xcode|Watcom WMake") - - run_cmake(genex_LINK_LANGUAGE-bad-mix-lang) - run_cmake(genex_LINK_LANG_AND_ID-bad-mix-lang) - - set(RunCMake_TEST_OUTPUT_MERGE TRUE) - if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) - set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) - endif() - - run_cmake(genex_LINK_LANGUAGE) - - run_cmake_target(genex_LINK_LANGUAGE lib LinkLibraries_lib --config Release) - run_cmake_target(genex_LINK_LANGUAGE lib2 LinkLibraries_lib2 --config Release) - run_cmake_target(genex_LINK_LANGUAGE lib3 LinkLibraries_lib3 --config Release) - run_cmake_target(genex_LINK_LANGUAGE exe LinkLibraries_exe --config Release) - run_cmake_target(genex_LINK_LANGUAGE C_import LinkLibraries_C_import --config Release) - run_cmake_target(genex_LINK_LANGUAGE CXX_import LinkLibraries_CXX_import --config Release) - run_cmake_target(genex_LINK_LANGUAGE C_interface LinkLibraries_C_interface --config Release) - run_cmake_target(genex_LINK_LANGUAGE CXX_interface LinkLibraries_CXX_interface --config Release) - run_cmake_target(genex_LINK_LANGUAGE C_interface2 LinkLibraries_C_interface2 --config Release) - run_cmake_target(genex_LINK_LANGUAGE CXX_interface2 LinkLibraries_CXX_interface2 --config Release) - run_cmake_target(genex_LINK_LANGUAGE C_static LinkLibraries_C_static --config Release) - run_cmake_target(genex_LINK_LANGUAGE CXX_static LinkLibraries_CXX_static --config Release) - - run_cmake(genex_LINK_LANG_AND_ID) - - run_cmake_target(genex_LINK_LANG_AND_ID lib LinkLibraries_lib --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID lib2 LinkLibraries_lib2 --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID lib3 LinkLibraries_lib3 --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID exe LinkLibraries_exe --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID C_import LinkLibraries_C_import --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID CXX_import LinkLibraries_CXX_import --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID C_interface LinkLibraries_C_interface --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID CXX_interface LinkLibraries_CXX_interface --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID C_interface2 LinkLibraries_C_interface2 --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID CXX_interface2 LinkLibraries_CXX_interface2 --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID CXX_static LinkLibraries_CXX_static --config Release) - - unset(RunCMake_TEST_OPTIONS) - unset(RunCMake_TEST_OUTPUT_MERGE) - -endif() diff --git a/Tests/RunCMake/target_link_libraries/func.c b/Tests/RunCMake/target_link_libraries/func.c deleted file mode 100644 index 415a9bf..0000000 --- a/Tests/RunCMake/target_link_libraries/func.c +++ /dev/null @@ -1,7 +0,0 @@ - -#if defined(_WIN32) -__declspec(dllexport) -#endif - void func_c() -{ -} diff --git a/Tests/RunCMake/target_link_libraries/func.cxx b/Tests/RunCMake/target_link_libraries/func.cxx deleted file mode 100644 index a12caca..0000000 --- a/Tests/RunCMake/target_link_libraries/func.cxx +++ /dev/null @@ -1,7 +0,0 @@ - -#if defined(_WIN32) -__declspec(dllexport) -#endif - void func_cxx() -{ -} diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang-result.txt b/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt b/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt deleted file mode 100644 index 2ecdc0c..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -CMake Error: Evaluation of \$ or \$ changes -the linker language for target "LinkLibraries_bad_mix_languages" \(from 'C' to 'CXX'\) which is invalid. diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang.cmake b/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang.cmake deleted file mode 100644 index e8efa75..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-mix-lang.cmake +++ /dev/null @@ -1,8 +0,0 @@ - -enable_language(C) -enable_language(CXX) - -add_library(static_CXX STATIC func.cxx) - -add_executable(LinkLibraries_bad_mix_languages main.c) -target_link_libraries (LinkLibraries_bad_mix_languages PRIVATE $<$:static_CXX>) diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage-result.txt b/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage-stderr.txt b/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage-stderr.txt deleted file mode 100644 index 469f1fe..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage-stderr.txt +++ /dev/null @@ -1,8 +0,0 @@ -CMake Error at genex_LINK_LANGUAGE-bad-usage.cmake:4 \(target_link_libraries\): - Error evaluating generator expression: - - \$ - - \$ is not supported in link libraries expression. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage.cmake b/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage.cmake deleted file mode 100644 index 81cfb0c..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE-bad-usage.cmake +++ /dev/null @@ -1,4 +0,0 @@ -enable_language(C) - -add_library(simple SHARED empty.c) -target_link_libraries(simple PRIVATE lib$) diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE.cmake b/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE.cmake deleted file mode 100644 index f3fe955..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANGUAGE.cmake +++ /dev/null @@ -1,72 +0,0 @@ - -cmake_minimum_required(VERSION 3.16...3.17) - -enable_language(C) -enable_language(CXX) - -add_library(shared_C SHARED func.c) -add_library(shared_CXX SHARED func.cxx) - - -add_library(static1_C STATIC empty.c) -target_link_libraries (static1_C INTERFACE $<$:shared_C>) - -add_library(static2_C STATIC empty.c) -target_link_libraries (static2_C PRIVATE $<$:shared_C>) - - -set (binary_dir "${CMAKE_BINARY_DIR}") -get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if (is_multi_config) - string (APPEND binary_dir "/Release") -endif() -add_library(import STATIC IMPORTED) -set_property(TARGET import PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}static1_C${CMAKE_STATIC_LIBRARY_SUFFIX}") -target_link_libraries (import INTERFACE $<$:shared_C>) -target_link_libraries (import INTERFACE $<$:shared_CXX>) - - -add_library(interface INTERFACE) -target_link_libraries (interface INTERFACE $<$:shared_C> - $<$:shared_CXX>) - - -add_library(interface2 INTERFACE) -target_link_libraries (interface2 INTERFACE import) - - -add_library(static3 STATIC empty.c) -target_link_libraries (static3 PRIVATE interface) - - -add_library(LinkLibraries_lib SHARED lib.c) -target_link_libraries (LinkLibraries_lib PRIVATE $<$:shared_C>) - -add_library(LinkLibraries_lib2 SHARED lib.c) -target_link_libraries (LinkLibraries_lib2 PRIVATE $<$:static1_C>) - -add_library(LinkLibraries_lib3 SHARED lib.c) -target_link_libraries (LinkLibraries_lib3 PRIVATE $<$:static2_C>) - -add_executable(LinkLibraries_exe main.c) -target_link_libraries (LinkLibraries_exe PRIVATE $<$:shared_C>) - -add_executable(LinkLibraries_C_import main.c) -target_link_libraries (LinkLibraries_C_import PRIVATE import) -add_executable(LinkLibraries_CXX_import main.cxx) -target_link_libraries (LinkLibraries_CXX_import PRIVATE import) - -add_executable(LinkLibraries_C_interface main.c) -target_link_libraries (LinkLibraries_C_interface PRIVATE interface) -add_executable(LinkLibraries_CXX_interface main.cxx) -target_link_libraries (LinkLibraries_CXX_interface PRIVATE interface) - -add_executable(LinkLibraries_C_interface2 main.c) -target_link_libraries (LinkLibraries_C_interface2 PRIVATE interface2) -add_executable(LinkLibraries_CXX_interface2 main.cxx) -target_link_libraries (LinkLibraries_CXX_interface2 PRIVATE interface2) - -add_executable(LinkLibraries_C_static main.c) -target_link_libraries (LinkLibraries_C_static PRIVATE static3) -add_executable(LinkLibraries_CXX_static main.cxx) -target_link_libraries (LinkLibraries_CXX_static PRIVATE static3) diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt b/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt b/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt deleted file mode 100644 index 2ecdc0c..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -CMake Error: Evaluation of \$ or \$ changes -the linker language for target "LinkLibraries_bad_mix_languages" \(from 'C' to 'CXX'\) which is invalid. diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake b/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake deleted file mode 100644 index f80010a..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake +++ /dev/null @@ -1,8 +0,0 @@ - -enable_language(C) -enable_language(CXX) - -add_library(static_CXX STATIC func.cxx) - -add_executable(LinkLibraries_bad_mix_languages main.c) -target_link_libraries (LinkLibraries_bad_mix_languages PRIVATE $<$:static_CXX>) diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-basic-result.txt b/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-basic-result.txt deleted file mode 100644 index 8d98f9d..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-basic-result.txt +++ /dev/null @@ -1 +0,0 @@ -.* diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-exe_c-result.txt b/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-exe_c-result.txt deleted file mode 100644 index 8d98f9d..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-exe_c-result.txt +++ /dev/null @@ -1 +0,0 @@ -.* diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-exe_cxx-result.txt b/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-exe_cxx-result.txt deleted file mode 100644 index 8d98f9d..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-exe_cxx-result.txt +++ /dev/null @@ -1 +0,0 @@ -.* diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-interface-result.txt b/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-interface-result.txt deleted file mode 100644 index 8d98f9d..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-interface-result.txt +++ /dev/null @@ -1 +0,0 @@ -.* diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-no_language-result.txt b/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-no_language-result.txt deleted file mode 100644 index 573541a..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID-no_language-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID.cmake b/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID.cmake deleted file mode 100644 index 9feccd0..0000000 --- a/Tests/RunCMake/target_link_libraries/genex_LINK_LANG_AND_ID.cmake +++ /dev/null @@ -1,73 +0,0 @@ - -cmake_minimum_required(VERSION 3.16...3.17) - -enable_language(C) -enable_language(CXX) - - -add_library(shared_C SHARED func.c) -add_library(shared_CXX SHARED func.cxx) - - -add_library(static1_C STATIC empty.c) -target_link_libraries (static1_C INTERFACE $<$:shared_C>) - -add_library(static2_C STATIC empty.c) -target_link_libraries (static2_C PRIVATE $<$:shared_C>) - - -set (binary_dir "${CMAKE_BINARY_DIR}") -get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if (is_multi_config) - string (APPEND binary_dir "/Release") -endif() -add_library(import STATIC IMPORTED) -set_property(TARGET import PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}static1_C${CMAKE_STATIC_LIBRARY_SUFFIX}") -target_link_libraries (import INTERFACE $<$:shared_C>) -target_link_libraries (import INTERFACE $<$:shared_CXX>) - - -add_library(interface INTERFACE) -target_link_libraries (interface INTERFACE $<$:shared_C> - $<$:shared_CXX>) - - -add_library(interface2 INTERFACE) -target_link_libraries (interface2 INTERFACE import) - - -add_library(static3 STATIC empty.c) -target_link_libraries (static3 PRIVATE interface) - - -add_library(LinkLibraries_lib SHARED lib.c) -target_link_libraries (LinkLibraries_lib PRIVATE $<$:shared_C>) - -add_library(LinkLibraries_lib2 SHARED lib.c) -target_link_libraries (LinkLibraries_lib2 PRIVATE $<$:static1_C>) - -add_library(LinkLibraries_lib3 SHARED lib.c) -target_link_libraries (LinkLibraries_lib3 PRIVATE $<$:static2_C>) - -add_executable(LinkLibraries_exe main.c) -target_link_libraries (LinkLibraries_exe PRIVATE $<$:shared_C>) - -add_executable(LinkLibraries_C_import main.c) -target_link_libraries (LinkLibraries_C_import PRIVATE import) -add_executable(LinkLibraries_CXX_import main.cxx) -target_link_libraries (LinkLibraries_CXX_import PRIVATE import) - -add_executable(LinkLibraries_C_interface main.c) -target_link_libraries (LinkLibraries_C_interface PRIVATE interface) -add_executable(LinkLibraries_CXX_interface main.cxx) -target_link_libraries (LinkLibraries_CXX_interface PRIVATE interface) - -add_executable(LinkLibraries_C_interface2 main.c) -target_link_libraries (LinkLibraries_C_interface2 PRIVATE interface2) -add_executable(LinkLibraries_CXX_interface2 main.cxx) -target_link_libraries (LinkLibraries_CXX_interface2 PRIVATE interface2) - -add_executable(LinkLibraries_C_static main.c) -target_link_libraries (LinkLibraries_C_static PRIVATE static3) -add_executable(LinkLibraries_CXX_static main.cxx) -target_link_libraries (LinkLibraries_CXX_static PRIVATE static3) diff --git a/Tests/RunCMake/target_link_libraries/main.c b/Tests/RunCMake/target_link_libraries/main.c deleted file mode 100644 index a908dea..0000000 --- a/Tests/RunCMake/target_link_libraries/main.c +++ /dev/null @@ -1,12 +0,0 @@ - -#if defined(_WIN32) -__declspec(dllimport) -#endif - void func_c(); - -int main() -{ - func_c(); - - return 0; -} diff --git a/Tests/RunCMake/target_link_libraries/main.cxx b/Tests/RunCMake/target_link_libraries/main.cxx deleted file mode 100644 index ffaa3b4..0000000 --- a/Tests/RunCMake/target_link_libraries/main.cxx +++ /dev/null @@ -1,12 +0,0 @@ - -#if defined(_WIN32) -__declspec(dllimport) -#endif - void func_cxx(); - -int main() -{ - func_cxx(); - - return 0; -} -- cgit v0.12 From 5f97e449122804c2f34a1f8b119ca76faf0e7773 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 16 Jun 2020 11:02:53 -0400 Subject: Tests: Shorten case names in RunCMake.target_link_libraries-* tests Drop the portion of the case names that repeats the name of the containing test. --- .../RunCMakeTest.cmake | 32 +++++----- .../bad-mix-lang-result.txt | 1 + .../bad-mix-lang-stderr.txt | 2 + .../bad-mix-lang.cmake | 8 +++ .../bad-usage-result.txt | 1 + .../bad-usage-stderr.txt | 8 +++ .../bad-usage.cmake | 4 ++ .../genex.cmake | 72 +++++++++++++++++++++ .../genex_LINK_LANGUAGE-bad-mix-lang-result.txt | 1 - .../genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt | 2 - .../genex_LINK_LANGUAGE-bad-mix-lang.cmake | 8 --- .../genex_LINK_LANGUAGE-bad-usage-result.txt | 1 - .../genex_LINK_LANGUAGE-bad-usage-stderr.txt | 8 --- .../genex_LINK_LANGUAGE-bad-usage.cmake | 4 -- .../genex_LINK_LANGUAGE.cmake | 72 --------------------- .../RunCMakeTest.cmake | 28 ++++----- .../bad-mix-lang-result.txt | 1 + .../bad-mix-lang-stderr.txt | 2 + .../bad-mix-lang.cmake | 8 +++ .../basic-result.txt | 1 + .../exe_c-result.txt | 1 + .../exe_cxx-result.txt | 1 + .../genex.cmake | 73 ++++++++++++++++++++++ .../genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt | 1 - .../genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt | 2 - .../genex_LINK_LANG_AND_ID-bad-mix-lang.cmake | 8 --- .../genex_LINK_LANG_AND_ID-basic-result.txt | 1 - .../genex_LINK_LANG_AND_ID-exe_c-result.txt | 1 - .../genex_LINK_LANG_AND_ID-exe_cxx-result.txt | 1 - .../genex_LINK_LANG_AND_ID-interface-result.txt | 1 - .../genex_LINK_LANG_AND_ID-no_language-result.txt | 1 - .../genex_LINK_LANG_AND_ID.cmake | 73 ---------------------- .../interface-result.txt | 1 + .../no_language-result.txt | 1 + 34 files changed, 215 insertions(+), 215 deletions(-) create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang-stderr.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage-stderr.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex.cmake delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang.cmake delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-stderr.txt delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage.cmake delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang-stderr.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/basic-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/exe_c-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/exe_cxx-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex.cmake delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-basic-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_c-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_cxx-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-interface-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-no_language-result.txt delete mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID.cmake create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/interface-result.txt create mode 100644 Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/no_language-result.txt diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/RunCMakeTest.cmake index 487bf25..0f0e5d8 100644 --- a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/RunCMakeTest.cmake @@ -9,31 +9,31 @@ macro(run_cmake_target test subtest target) unset(RunCMake_TEST_NO_CLEAN) endmacro() -run_cmake(genex_LINK_LANGUAGE-bad-usage) +run_cmake(bad-usage) if (RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Visual Studio|Xcode|Watcom WMake") - run_cmake(genex_LINK_LANGUAGE-bad-mix-lang) + run_cmake(bad-mix-lang) set(RunCMake_TEST_OUTPUT_MERGE TRUE) if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) endif() - run_cmake(genex_LINK_LANGUAGE) - - run_cmake_target(genex_LINK_LANGUAGE lib LinkLibraries_lib --config Release) - run_cmake_target(genex_LINK_LANGUAGE lib2 LinkLibraries_lib2 --config Release) - run_cmake_target(genex_LINK_LANGUAGE lib3 LinkLibraries_lib3 --config Release) - run_cmake_target(genex_LINK_LANGUAGE exe LinkLibraries_exe --config Release) - run_cmake_target(genex_LINK_LANGUAGE C_import LinkLibraries_C_import --config Release) - run_cmake_target(genex_LINK_LANGUAGE CXX_import LinkLibraries_CXX_import --config Release) - run_cmake_target(genex_LINK_LANGUAGE C_interface LinkLibraries_C_interface --config Release) - run_cmake_target(genex_LINK_LANGUAGE CXX_interface LinkLibraries_CXX_interface --config Release) - run_cmake_target(genex_LINK_LANGUAGE C_interface2 LinkLibraries_C_interface2 --config Release) - run_cmake_target(genex_LINK_LANGUAGE CXX_interface2 LinkLibraries_CXX_interface2 --config Release) - run_cmake_target(genex_LINK_LANGUAGE C_static LinkLibraries_C_static --config Release) - run_cmake_target(genex_LINK_LANGUAGE CXX_static LinkLibraries_CXX_static --config Release) + run_cmake(genex) + + run_cmake_target(genex lib LinkLibraries_lib --config Release) + run_cmake_target(genex lib2 LinkLibraries_lib2 --config Release) + run_cmake_target(genex lib3 LinkLibraries_lib3 --config Release) + run_cmake_target(genex exe LinkLibraries_exe --config Release) + run_cmake_target(genex C_import LinkLibraries_C_import --config Release) + run_cmake_target(genex CXX_import LinkLibraries_CXX_import --config Release) + run_cmake_target(genex C_interface LinkLibraries_C_interface --config Release) + run_cmake_target(genex CXX_interface LinkLibraries_CXX_interface --config Release) + run_cmake_target(genex C_interface2 LinkLibraries_C_interface2 --config Release) + run_cmake_target(genex CXX_interface2 LinkLibraries_CXX_interface2 --config Release) + run_cmake_target(genex C_static LinkLibraries_C_static --config Release) + run_cmake_target(genex CXX_static LinkLibraries_CXX_static --config Release) unset(RunCMake_TEST_OPTIONS) unset(RunCMake_TEST_OUTPUT_MERGE) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang-stderr.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang-stderr.txt new file mode 100644 index 0000000..2ecdc0c --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: Evaluation of \$ or \$ changes +the linker language for target "LinkLibraries_bad_mix_languages" \(from 'C' to 'CXX'\) which is invalid. diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang.cmake new file mode 100644 index 0000000..e8efa75 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-mix-lang.cmake @@ -0,0 +1,8 @@ + +enable_language(C) +enable_language(CXX) + +add_library(static_CXX STATIC func.cxx) + +add_executable(LinkLibraries_bad_mix_languages main.c) +target_link_libraries (LinkLibraries_bad_mix_languages PRIVATE $<$:static_CXX>) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage-stderr.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage-stderr.txt new file mode 100644 index 0000000..d61f789 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at bad-usage.cmake:4 \(target_link_libraries\): + Error evaluating generator expression: + + \$ + + \$ is not supported in link libraries expression. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage.cmake new file mode 100644 index 0000000..81cfb0c --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/bad-usage.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(simple SHARED empty.c) +target_link_libraries(simple PRIVATE lib$) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex.cmake new file mode 100644 index 0000000..f3fe955 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex.cmake @@ -0,0 +1,72 @@ + +cmake_minimum_required(VERSION 3.16...3.17) + +enable_language(C) +enable_language(CXX) + +add_library(shared_C SHARED func.c) +add_library(shared_CXX SHARED func.cxx) + + +add_library(static1_C STATIC empty.c) +target_link_libraries (static1_C INTERFACE $<$:shared_C>) + +add_library(static2_C STATIC empty.c) +target_link_libraries (static2_C PRIVATE $<$:shared_C>) + + +set (binary_dir "${CMAKE_BINARY_DIR}") +get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if (is_multi_config) + string (APPEND binary_dir "/Release") +endif() +add_library(import STATIC IMPORTED) +set_property(TARGET import PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}static1_C${CMAKE_STATIC_LIBRARY_SUFFIX}") +target_link_libraries (import INTERFACE $<$:shared_C>) +target_link_libraries (import INTERFACE $<$:shared_CXX>) + + +add_library(interface INTERFACE) +target_link_libraries (interface INTERFACE $<$:shared_C> + $<$:shared_CXX>) + + +add_library(interface2 INTERFACE) +target_link_libraries (interface2 INTERFACE import) + + +add_library(static3 STATIC empty.c) +target_link_libraries (static3 PRIVATE interface) + + +add_library(LinkLibraries_lib SHARED lib.c) +target_link_libraries (LinkLibraries_lib PRIVATE $<$:shared_C>) + +add_library(LinkLibraries_lib2 SHARED lib.c) +target_link_libraries (LinkLibraries_lib2 PRIVATE $<$:static1_C>) + +add_library(LinkLibraries_lib3 SHARED lib.c) +target_link_libraries (LinkLibraries_lib3 PRIVATE $<$:static2_C>) + +add_executable(LinkLibraries_exe main.c) +target_link_libraries (LinkLibraries_exe PRIVATE $<$:shared_C>) + +add_executable(LinkLibraries_C_import main.c) +target_link_libraries (LinkLibraries_C_import PRIVATE import) +add_executable(LinkLibraries_CXX_import main.cxx) +target_link_libraries (LinkLibraries_CXX_import PRIVATE import) + +add_executable(LinkLibraries_C_interface main.c) +target_link_libraries (LinkLibraries_C_interface PRIVATE interface) +add_executable(LinkLibraries_CXX_interface main.cxx) +target_link_libraries (LinkLibraries_CXX_interface PRIVATE interface) + +add_executable(LinkLibraries_C_interface2 main.c) +target_link_libraries (LinkLibraries_C_interface2 PRIVATE interface2) +add_executable(LinkLibraries_CXX_interface2 main.cxx) +target_link_libraries (LinkLibraries_CXX_interface2 PRIVATE interface2) + +add_executable(LinkLibraries_C_static main.c) +target_link_libraries (LinkLibraries_C_static PRIVATE static3) +add_executable(LinkLibraries_CXX_static main.cxx) +target_link_libraries (LinkLibraries_CXX_static PRIVATE static3) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt deleted file mode 100644 index 2ecdc0c..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -CMake Error: Evaluation of \$ or \$ changes -the linker language for target "LinkLibraries_bad_mix_languages" \(from 'C' to 'CXX'\) which is invalid. diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang.cmake deleted file mode 100644 index e8efa75..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-mix-lang.cmake +++ /dev/null @@ -1,8 +0,0 @@ - -enable_language(C) -enable_language(CXX) - -add_library(static_CXX STATIC func.cxx) - -add_executable(LinkLibraries_bad_mix_languages main.c) -target_link_libraries (LinkLibraries_bad_mix_languages PRIVATE $<$:static_CXX>) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-stderr.txt b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-stderr.txt deleted file mode 100644 index 469f1fe..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage-stderr.txt +++ /dev/null @@ -1,8 +0,0 @@ -CMake Error at genex_LINK_LANGUAGE-bad-usage.cmake:4 \(target_link_libraries\): - Error evaluating generator expression: - - \$ - - \$ is not supported in link libraries expression. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage.cmake deleted file mode 100644 index 81cfb0c..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE-bad-usage.cmake +++ /dev/null @@ -1,4 +0,0 @@ -enable_language(C) - -add_library(simple SHARED empty.c) -target_link_libraries(simple PRIVATE lib$) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE.cmake deleted file mode 100644 index f3fe955..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANGUAGE/genex_LINK_LANGUAGE.cmake +++ /dev/null @@ -1,72 +0,0 @@ - -cmake_minimum_required(VERSION 3.16...3.17) - -enable_language(C) -enable_language(CXX) - -add_library(shared_C SHARED func.c) -add_library(shared_CXX SHARED func.cxx) - - -add_library(static1_C STATIC empty.c) -target_link_libraries (static1_C INTERFACE $<$:shared_C>) - -add_library(static2_C STATIC empty.c) -target_link_libraries (static2_C PRIVATE $<$:shared_C>) - - -set (binary_dir "${CMAKE_BINARY_DIR}") -get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if (is_multi_config) - string (APPEND binary_dir "/Release") -endif() -add_library(import STATIC IMPORTED) -set_property(TARGET import PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}static1_C${CMAKE_STATIC_LIBRARY_SUFFIX}") -target_link_libraries (import INTERFACE $<$:shared_C>) -target_link_libraries (import INTERFACE $<$:shared_CXX>) - - -add_library(interface INTERFACE) -target_link_libraries (interface INTERFACE $<$:shared_C> - $<$:shared_CXX>) - - -add_library(interface2 INTERFACE) -target_link_libraries (interface2 INTERFACE import) - - -add_library(static3 STATIC empty.c) -target_link_libraries (static3 PRIVATE interface) - - -add_library(LinkLibraries_lib SHARED lib.c) -target_link_libraries (LinkLibraries_lib PRIVATE $<$:shared_C>) - -add_library(LinkLibraries_lib2 SHARED lib.c) -target_link_libraries (LinkLibraries_lib2 PRIVATE $<$:static1_C>) - -add_library(LinkLibraries_lib3 SHARED lib.c) -target_link_libraries (LinkLibraries_lib3 PRIVATE $<$:static2_C>) - -add_executable(LinkLibraries_exe main.c) -target_link_libraries (LinkLibraries_exe PRIVATE $<$:shared_C>) - -add_executable(LinkLibraries_C_import main.c) -target_link_libraries (LinkLibraries_C_import PRIVATE import) -add_executable(LinkLibraries_CXX_import main.cxx) -target_link_libraries (LinkLibraries_CXX_import PRIVATE import) - -add_executable(LinkLibraries_C_interface main.c) -target_link_libraries (LinkLibraries_C_interface PRIVATE interface) -add_executable(LinkLibraries_CXX_interface main.cxx) -target_link_libraries (LinkLibraries_CXX_interface PRIVATE interface) - -add_executable(LinkLibraries_C_interface2 main.c) -target_link_libraries (LinkLibraries_C_interface2 PRIVATE interface2) -add_executable(LinkLibraries_CXX_interface2 main.cxx) -target_link_libraries (LinkLibraries_CXX_interface2 PRIVATE interface2) - -add_executable(LinkLibraries_C_static main.c) -target_link_libraries (LinkLibraries_C_static PRIVATE static3) -add_executable(LinkLibraries_CXX_static main.cxx) -target_link_libraries (LinkLibraries_CXX_static PRIVATE static3) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/RunCMakeTest.cmake index 7cbc922..3b16f9e 100644 --- a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/RunCMakeTest.cmake @@ -11,26 +11,26 @@ endmacro() if (RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Visual Studio|Xcode|Watcom WMake") - run_cmake(genex_LINK_LANG_AND_ID-bad-mix-lang) + run_cmake(bad-mix-lang) set(RunCMake_TEST_OUTPUT_MERGE TRUE) if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) endif() - run_cmake(genex_LINK_LANG_AND_ID) - - run_cmake_target(genex_LINK_LANG_AND_ID lib LinkLibraries_lib --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID lib2 LinkLibraries_lib2 --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID lib3 LinkLibraries_lib3 --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID exe LinkLibraries_exe --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID C_import LinkLibraries_C_import --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID CXX_import LinkLibraries_CXX_import --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID C_interface LinkLibraries_C_interface --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID CXX_interface LinkLibraries_CXX_interface --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID C_interface2 LinkLibraries_C_interface2 --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID CXX_interface2 LinkLibraries_CXX_interface2 --config Release) - run_cmake_target(genex_LINK_LANG_AND_ID CXX_static LinkLibraries_CXX_static --config Release) + run_cmake(genex) + + run_cmake_target(genex lib LinkLibraries_lib --config Release) + run_cmake_target(genex lib2 LinkLibraries_lib2 --config Release) + run_cmake_target(genex lib3 LinkLibraries_lib3 --config Release) + run_cmake_target(genex exe LinkLibraries_exe --config Release) + run_cmake_target(genex C_import LinkLibraries_C_import --config Release) + run_cmake_target(genex CXX_import LinkLibraries_CXX_import --config Release) + run_cmake_target(genex C_interface LinkLibraries_C_interface --config Release) + run_cmake_target(genex CXX_interface LinkLibraries_CXX_interface --config Release) + run_cmake_target(genex C_interface2 LinkLibraries_C_interface2 --config Release) + run_cmake_target(genex CXX_interface2 LinkLibraries_CXX_interface2 --config Release) + run_cmake_target(genex CXX_static LinkLibraries_CXX_static --config Release) unset(RunCMake_TEST_OPTIONS) unset(RunCMake_TEST_OUTPUT_MERGE) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang-stderr.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang-stderr.txt new file mode 100644 index 0000000..2ecdc0c --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: Evaluation of \$ or \$ changes +the linker language for target "LinkLibraries_bad_mix_languages" \(from 'C' to 'CXX'\) which is invalid. diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang.cmake new file mode 100644 index 0000000..f80010a --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/bad-mix-lang.cmake @@ -0,0 +1,8 @@ + +enable_language(C) +enable_language(CXX) + +add_library(static_CXX STATIC func.cxx) + +add_executable(LinkLibraries_bad_mix_languages main.c) +target_link_libraries (LinkLibraries_bad_mix_languages PRIVATE $<$:static_CXX>) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/basic-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/exe_c-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/exe_c-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/exe_c-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/exe_cxx-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/exe_cxx-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/exe_cxx-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex.cmake new file mode 100644 index 0000000..9feccd0 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex.cmake @@ -0,0 +1,73 @@ + +cmake_minimum_required(VERSION 3.16...3.17) + +enable_language(C) +enable_language(CXX) + + +add_library(shared_C SHARED func.c) +add_library(shared_CXX SHARED func.cxx) + + +add_library(static1_C STATIC empty.c) +target_link_libraries (static1_C INTERFACE $<$:shared_C>) + +add_library(static2_C STATIC empty.c) +target_link_libraries (static2_C PRIVATE $<$:shared_C>) + + +set (binary_dir "${CMAKE_BINARY_DIR}") +get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if (is_multi_config) + string (APPEND binary_dir "/Release") +endif() +add_library(import STATIC IMPORTED) +set_property(TARGET import PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}static1_C${CMAKE_STATIC_LIBRARY_SUFFIX}") +target_link_libraries (import INTERFACE $<$:shared_C>) +target_link_libraries (import INTERFACE $<$:shared_CXX>) + + +add_library(interface INTERFACE) +target_link_libraries (interface INTERFACE $<$:shared_C> + $<$:shared_CXX>) + + +add_library(interface2 INTERFACE) +target_link_libraries (interface2 INTERFACE import) + + +add_library(static3 STATIC empty.c) +target_link_libraries (static3 PRIVATE interface) + + +add_library(LinkLibraries_lib SHARED lib.c) +target_link_libraries (LinkLibraries_lib PRIVATE $<$:shared_C>) + +add_library(LinkLibraries_lib2 SHARED lib.c) +target_link_libraries (LinkLibraries_lib2 PRIVATE $<$:static1_C>) + +add_library(LinkLibraries_lib3 SHARED lib.c) +target_link_libraries (LinkLibraries_lib3 PRIVATE $<$:static2_C>) + +add_executable(LinkLibraries_exe main.c) +target_link_libraries (LinkLibraries_exe PRIVATE $<$:shared_C>) + +add_executable(LinkLibraries_C_import main.c) +target_link_libraries (LinkLibraries_C_import PRIVATE import) +add_executable(LinkLibraries_CXX_import main.cxx) +target_link_libraries (LinkLibraries_CXX_import PRIVATE import) + +add_executable(LinkLibraries_C_interface main.c) +target_link_libraries (LinkLibraries_C_interface PRIVATE interface) +add_executable(LinkLibraries_CXX_interface main.cxx) +target_link_libraries (LinkLibraries_CXX_interface PRIVATE interface) + +add_executable(LinkLibraries_C_interface2 main.c) +target_link_libraries (LinkLibraries_C_interface2 PRIVATE interface2) +add_executable(LinkLibraries_CXX_interface2 main.cxx) +target_link_libraries (LinkLibraries_CXX_interface2 PRIVATE interface2) + +add_executable(LinkLibraries_C_static main.c) +target_link_libraries (LinkLibraries_C_static PRIVATE static3) +add_executable(LinkLibraries_CXX_static main.cxx) +target_link_libraries (LinkLibraries_CXX_static PRIVATE static3) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt deleted file mode 100644 index 2ecdc0c..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang-stderr.txt +++ /dev/null @@ -1,2 +0,0 @@ -CMake Error: Evaluation of \$ or \$ changes -the linker language for target "LinkLibraries_bad_mix_languages" \(from 'C' to 'CXX'\) which is invalid. diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake deleted file mode 100644 index f80010a..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-bad-mix-lang.cmake +++ /dev/null @@ -1,8 +0,0 @@ - -enable_language(C) -enable_language(CXX) - -add_library(static_CXX STATIC func.cxx) - -add_executable(LinkLibraries_bad_mix_languages main.c) -target_link_libraries (LinkLibraries_bad_mix_languages PRIVATE $<$:static_CXX>) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-basic-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-basic-result.txt deleted file mode 100644 index 8d98f9d..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-basic-result.txt +++ /dev/null @@ -1 +0,0 @@ -.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_c-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_c-result.txt deleted file mode 100644 index 8d98f9d..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_c-result.txt +++ /dev/null @@ -1 +0,0 @@ -.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_cxx-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_cxx-result.txt deleted file mode 100644 index 8d98f9d..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-exe_cxx-result.txt +++ /dev/null @@ -1 +0,0 @@ -.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-interface-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-interface-result.txt deleted file mode 100644 index 8d98f9d..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-interface-result.txt +++ /dev/null @@ -1 +0,0 @@ -.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-no_language-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-no_language-result.txt deleted file mode 100644 index 573541a..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID-no_language-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID.cmake b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID.cmake deleted file mode 100644 index 9feccd0..0000000 --- a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/genex_LINK_LANG_AND_ID.cmake +++ /dev/null @@ -1,73 +0,0 @@ - -cmake_minimum_required(VERSION 3.16...3.17) - -enable_language(C) -enable_language(CXX) - - -add_library(shared_C SHARED func.c) -add_library(shared_CXX SHARED func.cxx) - - -add_library(static1_C STATIC empty.c) -target_link_libraries (static1_C INTERFACE $<$:shared_C>) - -add_library(static2_C STATIC empty.c) -target_link_libraries (static2_C PRIVATE $<$:shared_C>) - - -set (binary_dir "${CMAKE_BINARY_DIR}") -get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if (is_multi_config) - string (APPEND binary_dir "/Release") -endif() -add_library(import STATIC IMPORTED) -set_property(TARGET import PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}static1_C${CMAKE_STATIC_LIBRARY_SUFFIX}") -target_link_libraries (import INTERFACE $<$:shared_C>) -target_link_libraries (import INTERFACE $<$:shared_CXX>) - - -add_library(interface INTERFACE) -target_link_libraries (interface INTERFACE $<$:shared_C> - $<$:shared_CXX>) - - -add_library(interface2 INTERFACE) -target_link_libraries (interface2 INTERFACE import) - - -add_library(static3 STATIC empty.c) -target_link_libraries (static3 PRIVATE interface) - - -add_library(LinkLibraries_lib SHARED lib.c) -target_link_libraries (LinkLibraries_lib PRIVATE $<$:shared_C>) - -add_library(LinkLibraries_lib2 SHARED lib.c) -target_link_libraries (LinkLibraries_lib2 PRIVATE $<$:static1_C>) - -add_library(LinkLibraries_lib3 SHARED lib.c) -target_link_libraries (LinkLibraries_lib3 PRIVATE $<$:static2_C>) - -add_executable(LinkLibraries_exe main.c) -target_link_libraries (LinkLibraries_exe PRIVATE $<$:shared_C>) - -add_executable(LinkLibraries_C_import main.c) -target_link_libraries (LinkLibraries_C_import PRIVATE import) -add_executable(LinkLibraries_CXX_import main.cxx) -target_link_libraries (LinkLibraries_CXX_import PRIVATE import) - -add_executable(LinkLibraries_C_interface main.c) -target_link_libraries (LinkLibraries_C_interface PRIVATE interface) -add_executable(LinkLibraries_CXX_interface main.cxx) -target_link_libraries (LinkLibraries_CXX_interface PRIVATE interface) - -add_executable(LinkLibraries_C_interface2 main.c) -target_link_libraries (LinkLibraries_C_interface2 PRIVATE interface2) -add_executable(LinkLibraries_CXX_interface2 main.cxx) -target_link_libraries (LinkLibraries_CXX_interface2 PRIVATE interface2) - -add_executable(LinkLibraries_C_static main.c) -target_link_libraries (LinkLibraries_C_static PRIVATE static3) -add_executable(LinkLibraries_CXX_static main.cxx) -target_link_libraries (LinkLibraries_CXX_static PRIVATE static3) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/interface-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/interface-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/interface-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/no_language-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/no_language-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LANG_AND_ID/no_language-result.txt @@ -0,0 +1 @@ +0 -- cgit v0.12