diff options
author | Brad King <brad.king@kitware.com> | 2020-07-21 17:41:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-07-22 17:42:58 (GMT) |
commit | 4ac9ee10ade455d50c5ca687876f30fd9e0b640a (patch) | |
tree | a4693204bcc2e09e0eb8259167090a3a0292a751 /Tests/RunCMake/InterfaceLibrary | |
parent | d45f0d719e0be324959d7ba5e9d84596592fc19a (diff) | |
download | CMake-4ac9ee10ade455d50c5ca687876f30fd9e0b640a.zip CMake-4ac9ee10ade455d50c5ca687876f30fd9e0b640a.tar.gz CMake-4ac9ee10ade455d50c5ca687876f30fd9e0b640a.tar.bz2 |
Tests: Rename test RunCMake.{interface_library => InterfaceLibrary}
Our RunCMake.<lower-case> namespace is meant for testing individual
CMake language commands.
Diffstat (limited to 'Tests/RunCMake/InterfaceLibrary')
32 files changed, 447 insertions, 0 deletions
diff --git a/Tests/RunCMake/InterfaceLibrary/CMakeLists.txt b/Tests/RunCMake/InterfaceLibrary/CMakeLists.txt new file mode 100644 index 0000000..74b3ff8 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.3) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value-result.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value-stderr.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value-stderr.txt new file mode 100644 index 0000000..454c655 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value-stderr.txt @@ -0,0 +1,44 @@ +^CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property value + + -flag + + may not start with '-'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property value + + item1;item2 + + may not contain ';'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property value + + /path/to/item1 + + may not contain '/'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property value + + \\path\\to\\item1 + + may not contain '\\'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-bad-value.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property value + + c:\\path\\to\\item1 + + may not contain ':'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value.cmake b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value.cmake new file mode 100644 index 0000000..1af65b4 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-bad-value.cmake @@ -0,0 +1,6 @@ +add_library(MyTarget INTERFACE IMPORTED) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME -flag) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME item1 item2) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME /path/to/item1) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME \\path\\to\\item1) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME c:\\path\\to\\item1) diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface-result.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface-stderr.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface-stderr.txt new file mode 100644 index 0000000..3a329d2 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface-stderr.txt @@ -0,0 +1,45 @@ +^CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may not be APPENDed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME_DEBUG property may be set only on imported INTERFACE + library targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME_DEBUG property may not be APPENDed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-iface.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface.cmake b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface.cmake new file mode 100644 index 0000000..fe6841a --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-iface.cmake @@ -0,0 +1,17 @@ +add_custom_target(MyCustom) +set_property(TARGET MyCustom PROPERTY IMPORTED_LIBNAME item1) +set_property(TARGET MyCustom APPEND PROPERTY IMPORTED_LIBNAME item2) +set_property(TARGET MyCustom PROPERTY IMPORTED_LIBNAME_DEBUG item1) +set_property(TARGET MyCustom APPEND PROPERTY IMPORTED_LIBNAME_DEBUG item2) + +add_library(MyStatic STATIC IMPORTED) +set_property(TARGET MyStatic PROPERTY IMPORTED_LIBNAME item1) + +add_library(MyShared SHARED IMPORTED) +set_property(TARGET MyShared PROPERTY IMPORTED_LIBNAME item1) + +add_library(MyModule MODULE IMPORTED) +set_property(TARGET MyModule PROPERTY IMPORTED_LIBNAME item1) + +add_executable(MyExe IMPORTED) +set_property(TARGET MyExe PROPERTY IMPORTED_LIBNAME item1) diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported-result.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported-stderr.txt b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported-stderr.txt new file mode 100644 index 0000000..e9d94cf --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported-stderr.txt @@ -0,0 +1,21 @@ +^CMake Error at IMPORTED_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may be set only on imported INTERFACE library + targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME property may not be APPENDed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME_DEBUG property may be set only on imported INTERFACE + library targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at IMPORTED_LIBNAME-non-imported.cmake:[0-9]+ \(set_property\): + IMPORTED_LIBNAME_DEBUG property may not be APPENDed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported.cmake b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported.cmake new file mode 100644 index 0000000..07a67d7 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IMPORTED_LIBNAME-non-imported.cmake @@ -0,0 +1,5 @@ +add_library(MyTarget INTERFACE) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME item1) +set_property(TARGET MyTarget APPEND PROPERTY IMPORTED_LIBNAME item2) +set_property(TARGET MyTarget PROPERTY IMPORTED_LIBNAME_DEBUG item1) +set_property(TARGET MyTarget APPEND PROPERTY IMPORTED_LIBNAME_DEBUG item2) diff --git a/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake b/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake new file mode 100644 index 0000000..5a6af1d --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake @@ -0,0 +1,13 @@ +include(RunCMake) + +run_cmake(invalid_name) +run_cmake(target_commands) +run_cmake(no_shared_libs) +run_cmake(whitelist) +run_cmake(invalid_signature) +run_cmake(global-interface) +run_cmake(genex_link) +run_cmake(add_custom_command-TARGET) +run_cmake(IMPORTED_LIBNAME-bad-value) +run_cmake(IMPORTED_LIBNAME-non-iface) +run_cmake(IMPORTED_LIBNAME-non-imported) diff --git a/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET-result.txt b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET-stderr.txt b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET-stderr.txt new file mode 100644 index 0000000..c095262 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at add_custom_command-TARGET.cmake:4 \(add_custom_command\): + Target "iface" is an INTERFACE library that may not have PRE_BUILD, + PRE_LINK, or POST_BUILD commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET.cmake b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET.cmake new file mode 100644 index 0000000..a5136ef --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/add_custom_command-TARGET.cmake @@ -0,0 +1,6 @@ + +add_library(iface INTERFACE) + +add_custom_command(TARGET iface + COMMAND "${CMAKE_COMMAND}" -E echo test +) diff --git a/Tests/RunCMake/InterfaceLibrary/genex_link-result.txt b/Tests/RunCMake/InterfaceLibrary/genex_link-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/genex_link-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/InterfaceLibrary/genex_link.cmake b/Tests/RunCMake/InterfaceLibrary/genex_link.cmake new file mode 100644 index 0000000..0dbf029 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/genex_link.cmake @@ -0,0 +1,22 @@ + +cmake_minimum_required(VERSION 2.8.12.20131125 FATAL_ERROR) + +project(genex_link) + +set(_main_cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp) +file(WRITE ${_main_cpp} + "int main(int argc, char** argv) { return 0; }\n" +) + +add_library(foo::bar INTERFACE IMPORTED) +set_target_properties(foo::bar + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}" + # When not using a generator expression here, no error is generated + INTERFACE_LINK_LIBRARIES "$<$<NOT:$<CONFIG:DEBUG>>:foo_bar.lib>" +) + +add_executable(main ${_main_cpp}) +target_include_directories(main PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + +target_link_libraries(main foo::bar) diff --git a/Tests/RunCMake/InterfaceLibrary/global-interface-result.txt b/Tests/RunCMake/InterfaceLibrary/global-interface-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/global-interface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/InterfaceLibrary/global-interface-stderr.txt b/Tests/RunCMake/InterfaceLibrary/global-interface-stderr.txt new file mode 100644 index 0000000..38585eb --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/global-interface-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at global-interface.cmake:2 \(add_library\): + Cannot find source file: + + GLOBAL + + Tried extensions \.c \.C .* +.* +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/InterfaceLibrary/global-interface.cmake b/Tests/RunCMake/InterfaceLibrary/global-interface.cmake new file mode 100644 index 0000000..d2bfc64 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/global-interface.cmake @@ -0,0 +1,2 @@ + +add_library(iface GLOBAL INTERFACE) diff --git a/Tests/RunCMake/InterfaceLibrary/invalid_name-result.txt b/Tests/RunCMake/InterfaceLibrary/invalid_name-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/invalid_name-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/InterfaceLibrary/invalid_name-stderr.txt b/Tests/RunCMake/InterfaceLibrary/invalid_name-stderr.txt new file mode 100644 index 0000000..e14fcde --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/invalid_name-stderr.txt @@ -0,0 +1,15 @@ +CMake Error at invalid_name.cmake:2 \(add_library\): + add_library Invalid name for INTERFACE library target: if\$ace +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_name.cmake:4 \(add_library\): + add_library Invalid name for INTERFACE library target: iface::target +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_name.cmake:6 \(add_library\): + add_library Invalid name for IMPORTED INTERFACE library target: + if\$target_imported +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/InterfaceLibrary/invalid_name.cmake b/Tests/RunCMake/InterfaceLibrary/invalid_name.cmake new file mode 100644 index 0000000..575fcc6 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/invalid_name.cmake @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 2.8.12) +add_library(if$ace INTERFACE) + +add_library(iface::target INTERFACE) + +add_library(if$target_imported INTERFACE IMPORTED) diff --git a/Tests/RunCMake/InterfaceLibrary/invalid_signature-result.txt b/Tests/RunCMake/InterfaceLibrary/invalid_signature-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/invalid_signature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/InterfaceLibrary/invalid_signature-stderr.txt b/Tests/RunCMake/InterfaceLibrary/invalid_signature-stderr.txt new file mode 100644 index 0000000..6374b33 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/invalid_signature-stderr.txt @@ -0,0 +1,89 @@ +CMake Error at invalid_signature.cmake:2 \(add_library\): + add_library INTERFACE library requires no source arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:3 \(add_library\): + add_library INTERFACE library specified with conflicting/multiple types. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:4 \(add_library\): + add_library INTERFACE library specified with conflicting/multiple types. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:5 \(add_library\): + add_library INTERFACE library specified with conflicting/multiple types. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:6 \(add_library\): + add_library INTERFACE library specified with conflicting/multiple types. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:7 \(add_library\): + add_library INTERFACE library specified with conflicting/multiple types. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:8 \(add_library\): + add_library INTERFACE library specified with conflicting/multiple types. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:9 \(add_library\): + add_library INTERFACE library specified with conflicting STATIC type. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:10 \(add_library\): + add_library INTERFACE library specified with conflicting SHARED type. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:11 \(add_library\): + add_library INTERFACE library specified with conflicting MODULE type. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:12 \(add_library\): + add_library INTERFACE library specified with conflicting OBJECT type. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:13 \(add_library\): + add_library INTERFACE library specified with conflicting UNKNOWN type. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:14 \(add_library\): + add_library INTERFACE library specified with conflicting ALIAS type. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:15 \(add_library\): + add_library INTERFACE library specified with conflicting ALIAS type. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:16 \(add_library\): + add_library INTERFACE library specified with conflicting/multiple types. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:17 \(add_library\): + add_library INTERFACE library may not be used with EXCLUDE_FROM_ALL. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:18 \(add_library\): + add_library INTERFACE library may not be used with EXCLUDE_FROM_ALL. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at invalid_signature.cmake:20 \(add_library\): + add_library GLOBAL option may only be used with IMPORTED libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/InterfaceLibrary/invalid_signature.cmake b/Tests/RunCMake/InterfaceLibrary/invalid_signature.cmake new file mode 100644 index 0000000..4e53534 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/invalid_signature.cmake @@ -0,0 +1,20 @@ + +add_library(iface1 INTERFACE empty.cpp) +add_library(iface3 STATIC INTERFACE) +add_library(iface4 STATIC INTERFACE empty.cpp) +add_library(iface5 SHARED INTERFACE) +add_library(iface6 MODULE INTERFACE) +add_library(iface7 OBJECT INTERFACE) +add_library(iface8 UNKNOWN INTERFACE) +add_library(iface9 INTERFACE STATIC) +add_library(iface10 INTERFACE SHARED) +add_library(iface11 INTERFACE MODULE) +add_library(iface12 INTERFACE OBJECT) +add_library(iface13 INTERFACE UNKNOWN) +add_library(iface14 INTERFACE ALIAS) +add_library(iface15 ALIAS INTERFACE) +add_library(iface16 INTERFACE INTERFACE) +add_library(iface17 INTERFACE EXCLUDE_FROM_ALL) +add_library(iface18 EXCLUDE_FROM_ALL INTERFACE) +# add_library(iface19 GLOBAL INTERFACE) Tested separately +add_library(iface20 INTERFACE GLOBAL) diff --git a/Tests/RunCMake/InterfaceLibrary/no_shared_libs.cmake b/Tests/RunCMake/InterfaceLibrary/no_shared_libs.cmake new file mode 100644 index 0000000..ed81878 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/no_shared_libs.cmake @@ -0,0 +1,5 @@ + +cmake_minimum_required(VERSION 2.8.12.20131009) +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) +add_library(foo INTERFACE) +target_compile_definitions(foo INTERFACE FOO_DEFINE) diff --git a/Tests/RunCMake/InterfaceLibrary/target_commands-result.txt b/Tests/RunCMake/InterfaceLibrary/target_commands-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/target_commands-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/InterfaceLibrary/target_commands-stderr.txt b/Tests/RunCMake/InterfaceLibrary/target_commands-stderr.txt new file mode 100644 index 0000000..9362a75 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/target_commands-stderr.txt @@ -0,0 +1,47 @@ +CMake Error at target_commands.cmake:4 \(target_link_libraries\): + INTERFACE library can only be used with the INTERFACE keyword of + target_link_libraries +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at target_commands.cmake:5 \(target_link_libraries\): + INTERFACE library can only be used with the INTERFACE keyword of + target_link_libraries +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at target_commands.cmake:6 \(target_link_libraries\): + INTERFACE library can only be used with the INTERFACE keyword of + target_link_libraries +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at target_commands.cmake:7 \(target_link_libraries\): + INTERFACE library can only be used with the INTERFACE keyword of + target_link_libraries +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at target_commands.cmake:9 \(target_include_directories\): + target_include_directories may only set INTERFACE properties on INTERFACE + targets +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at target_commands.cmake:10 \(target_include_directories\): + target_include_directories may only set INTERFACE properties on INTERFACE + targets +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at target_commands.cmake:12 \(target_compile_definitions\): + target_compile_definitions may only set INTERFACE properties on INTERFACE + targets +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at target_commands.cmake:13 \(target_compile_definitions\): + target_compile_definitions may only set INTERFACE properties on INTERFACE + targets +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/InterfaceLibrary/target_commands.cmake b/Tests/RunCMake/InterfaceLibrary/target_commands.cmake new file mode 100644 index 0000000..3182e89 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/target_commands.cmake @@ -0,0 +1,13 @@ + +add_library(iface INTERFACE) + +target_link_libraries(iface PRIVATE foo) +target_link_libraries(iface PUBLIC foo) +target_link_libraries(iface foo) +target_link_libraries(iface LINK_INTERFACE_LIBRARIES foo) + +target_include_directories(iface PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") +target_include_directories(iface PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") + +target_compile_definitions(iface PRIVATE SOME_DEFINE) +target_compile_definitions(iface PUBLIC SOME_DEFINE) diff --git a/Tests/RunCMake/InterfaceLibrary/whitelist-result.txt b/Tests/RunCMake/InterfaceLibrary/whitelist-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/whitelist-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/InterfaceLibrary/whitelist-stderr.txt b/Tests/RunCMake/InterfaceLibrary/whitelist-stderr.txt new file mode 100644 index 0000000..577c0cc --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/whitelist-stderr.txt @@ -0,0 +1,19 @@ +CMake Error at whitelist.cmake:4 \(set_property\): + INTERFACE_LIBRARY targets may only have whitelisted properties. The + property "OUTPUT_NAME" is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at whitelist.cmake:5 \(set_property\): + INTERFACE_LIBRARY targets may only have whitelisted properties. The + property "OUTPUT_NAME" is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at whitelist.cmake:6 \(get_target_property\): + INTERFACE_LIBRARY targets may only have whitelisted properties. The + property "OUTPUT_NAME" is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/InterfaceLibrary/whitelist.cmake b/Tests/RunCMake/InterfaceLibrary/whitelist.cmake new file mode 100644 index 0000000..0db6375 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/whitelist.cmake @@ -0,0 +1,25 @@ + +add_library(iface INTERFACE) + +set_property(TARGET iface PROPERTY OUTPUT_NAME output) +set_property(TARGET iface APPEND PROPERTY OUTPUT_NAME append) +get_target_property(outname iface OUTPUT_NAME) + +# Properties starting with `_` are allowed. +set_property(TARGET iface PROPERTY "_custom_property" output) +set_property(TARGET iface APPEND PROPERTY "_custom_property" append) +get_target_property(outname iface "_custom_property") + +# Properties starting with a lowercase letter are allowed. +set_property(TARGET iface PROPERTY "custom_property" output) +set_property(TARGET iface APPEND PROPERTY "custom_property" append) +get_target_property(outname iface "custom_property") + +# PUBLIC_HEADER / PRIVATE_HEADER properties are allowed +set_property(TARGET iface PROPERTY PUBLIC_HEADER foo.h) +set_property(TARGET iface APPEND PROPERTY PUBLIC_HEADER bar.h) +get_target_property(outname iface PUBLIC_HEADER) + +set_property(TARGET iface PROPERTY PRIVATE_HEADER foo.h) +set_property(TARGET iface APPEND PROPERTY PRIVATE_HEADER bar.h) +get_target_property(outname iface PRIVATE_HEADER) |