diff options
Diffstat (limited to 'Tests')
41 files changed, 448 insertions, 1 deletions
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt index a5eb0f6..fdb1638 100644 --- a/Tests/AliasTarget/CMakeLists.txt +++ b/Tests/AliasTarget/CMakeLists.txt @@ -45,3 +45,6 @@ get_property(_alt2 TARGET PREFIX::Foo PROPERTY ALIASED_TARGET) if (NOT ${_alt2} STREQUAL foo) message(SEND_ERROR "ALIASED_TARGET is not foo.") endif() + +add_library(iface INTERFACE) +add_library(Alias::Iface ALIAS iface) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 504f4bb..9afc112 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -246,6 +246,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(CompileOptions CompileOptions) ADD_TEST_MACRO(CompatibleInterface CompatibleInterface) ADD_TEST_MACRO(AliasTarget AliasTarget) + ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary) set_tests_properties(EmptyLibrary PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test") ADD_TEST_MACRO(CrossCompile CrossCompile) diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt index ae1d2fa..5ee9fd7 100644 --- a/Tests/CompatibleInterface/CMakeLists.txt +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -6,7 +6,7 @@ project(CompatibleInterface) include(GenerateExportHeader) set(CMAKE_INCLUDE_CURRENT_DIR ON) -add_library(iface1 empty.cpp) +add_library(iface1 INTERFACE) set_property(TARGET iface1 APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL BOOL_PROP1 diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index f225ce1..cbae967 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -436,3 +436,5 @@ export(TARGETS testExe2 testLib4 testLib5 testLib6 testExe3 testExe2lib NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake ) + +add_subdirectory(Interface) diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt new file mode 100644 index 0000000..fc9c0c7 --- /dev/null +++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt @@ -0,0 +1,49 @@ + +add_library(headeronly INTERFACE) +set_property(TARGET headeronly PROPERTY INTERFACE_INCLUDE_DIRECTORIES + "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headeronly>" + "$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/headeronly>" +) +set_property(TARGET headeronly PROPERTY INTERFACE_COMPILE_DEFINITIONS "HEADERONLY_DEFINE") + +include(GenerateExportHeader) +add_library(sharedlib SHARED sharedlib.cpp) +generate_export_header(sharedlib) +set_property(TARGET sharedlib PROPERTY INCLUDE_DIRECTORIES + "${CMAKE_CURRENT_SOURCE_DIR}/sharedlib" + "${CMAKE_CURRENT_BINARY_DIR}" +) +set_property(TARGET sharedlib PROPERTY INTERFACE_INCLUDE_DIRECTORIES + "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/sharedlib;${CMAKE_CURRENT_BINARY_DIR}>" + "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/sharedlib>" +) + +set_property(TARGET sharedlib PROPERTY INTERFACE_COMPILE_DEFINITIONS "SHAREDLIB_DEFINE") + +add_library(sharediface INTERFACE) +target_link_libraries(sharediface INTERFACE sharedlib) + +export(TARGETS sharediface sharedlib headeronly + NAMESPACE bld_ + FILE ../ExportInterfaceBuildTree.cmake +) + +install(TARGETS headeronly sharediface sharedlib + EXPORT expInterface + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib NAMELINK_SKIP + ARCHIVE DESTINATION lib + FRAMEWORK DESTINATION Frameworks + BUNDLE DESTINATION Applications +) +install(FILES + headeronly/headeronly.h + DESTINATION include/headeronly +) +install(FILES + sharedlib/sharedlib.h + "${CMAKE_CURRENT_BINARY_DIR}/sharedlib_export.h" + DESTINATION include/sharedlib +) + +install(EXPORT expInterface NAMESPACE exp_ DESTINATION lib/exp) diff --git a/Tests/ExportImport/Export/Interface/headeronly/headeronly.h b/Tests/ExportImport/Export/Interface/headeronly/headeronly.h new file mode 100644 index 0000000..3673c21 --- /dev/null +++ b/Tests/ExportImport/Export/Interface/headeronly/headeronly.h @@ -0,0 +1,7 @@ + +enum { one }; + +struct HeaderOnly +{ + int foo() const { return 0; } +}; diff --git a/Tests/ExportImport/Export/Interface/sharedlib.cpp b/Tests/ExportImport/Export/Interface/sharedlib.cpp new file mode 100644 index 0000000..88ca713 --- /dev/null +++ b/Tests/ExportImport/Export/Interface/sharedlib.cpp @@ -0,0 +1,7 @@ + +#include "sharedlib.h" + +int SharedLibObject::foo() const +{ + return 0; +} diff --git a/Tests/ExportImport/Export/Interface/sharedlib/sharedlib.h b/Tests/ExportImport/Export/Interface/sharedlib/sharedlib.h new file mode 100644 index 0000000..aad9ef3 --- /dev/null +++ b/Tests/ExportImport/Export/Interface/sharedlib/sharedlib.h @@ -0,0 +1,7 @@ + +#include "sharedlib_export.h" + +struct SHAREDLIB_EXPORT SharedLibObject +{ + int foo() const; +}; diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt index 9c2d597..5e809a2 100644 --- a/Tests/ExportImport/Import/CMakeLists.txt +++ b/Tests/ExportImport/Import/CMakeLists.txt @@ -19,3 +19,6 @@ add_executable(imp_testTransExe1b imp_testTransExe1.c) target_link_libraries(imp_testTransExe1b imp_lib1b) add_subdirectory(try_compile) + +# Test package INTERFACE controls +add_subdirectory(Interface) diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt new file mode 100644 index 0000000..c7bd13e --- /dev/null +++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt @@ -0,0 +1,55 @@ + +# Import targets from the exported build tree. +include(${Import_BINARY_DIR}/../Export/ExportInterfaceBuildTree.cmake) + +# Import targets from the exported install tree. +include(${CMAKE_INSTALL_PREFIX}/lib/exp/expInterface.cmake) + +add_library(define_iface INTERFACE) +set_property(TARGET define_iface PROPERTY + INTERFACE_COMPILE_DEFINITIONS DEFINE_IFACE_DEFINE) + +add_executable(headeronlytest_bld headeronlytest.cpp) +target_link_libraries(headeronlytest_bld bld_headeronly) + +set_property(TARGET bld_sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES define_iface) + +add_executable(interfacetest_bld interfacetest.cpp) +target_link_libraries(interfacetest_bld bld_sharediface) + +include(CheckCXXSourceCompiles) + +macro(do_try_compile prefix) + + set(CMAKE_REQUIRED_LIBRARIES ${prefix}headeronly) + check_cxx_source_compiles( + " + #include \"headeronly.h\" + + #ifndef HEADERONLY_DEFINE + #error Expected HEADERONLY_DEFINE + #endif + + int main(int,char**) + { + HeaderOnly ho; + return ho.foo(); + } + " ${prefix}IFACE_TRY_COMPILE) + + if(NOT ${prefix}IFACE_TRY_COMPILE) + message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}") + endif() +endmacro() + +do_try_compile(bld_) + +add_executable(headeronlytest_exp headeronlytest.cpp) +target_link_libraries(headeronlytest_exp exp_headeronly) + +set_property(TARGET exp_sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES define_iface) + +add_executable(interfacetest_exp interfacetest.cpp) +target_link_libraries(interfacetest_exp exp_sharediface) + +do_try_compile(exp_) diff --git a/Tests/ExportImport/Import/Interface/headeronlytest.cpp b/Tests/ExportImport/Import/Interface/headeronlytest.cpp new file mode 100644 index 0000000..20674a7 --- /dev/null +++ b/Tests/ExportImport/Import/Interface/headeronlytest.cpp @@ -0,0 +1,17 @@ + +#include "headeronly.h" + +#ifndef HEADERONLY_DEFINE +#error Expected HEADERONLY_DEFINE +#endif + +#ifdef SHAREDLIB_DEFINE +#error Unexpected SHAREDLIB_DEFINE +#endif + + +int main(int,char**) +{ + HeaderOnly ho; + return ho.foo(); +} diff --git a/Tests/ExportImport/Import/Interface/interfacetest.cpp b/Tests/ExportImport/Import/Interface/interfacetest.cpp new file mode 100644 index 0000000..786458d --- /dev/null +++ b/Tests/ExportImport/Import/Interface/interfacetest.cpp @@ -0,0 +1,20 @@ + +#include "sharedlib.h" + +#ifndef SHAREDLIB_DEFINE +#error Expected SHAREDLIB_DEFINE +#endif + +#ifdef HEADERONLY_DEFINE +#error Unexpected HEADERONLY_DEFINE +#endif + +#ifndef DEFINE_IFACE_DEFINE +#error Expected DEFINE_IFACE_DEFINE +#endif + +int main(int,char**) +{ + SharedLibObject slo; + return slo.foo(); +} diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt new file mode 100644 index 0000000..53aeb03 --- /dev/null +++ b/Tests/InterfaceLibrary/CMakeLists.txt @@ -0,0 +1,15 @@ + +cmake_minimum_required(VERSION 2.8) + +project(InterfaceLibrary) + +add_library(iface_nodepends INTERFACE) +target_compile_definitions(iface_nodepends INTERFACE IFACE_DEFINE) + +add_executable(InterfaceLibrary definetestexe.cpp) +target_link_libraries(InterfaceLibrary iface_nodepends) + +add_subdirectory(libsdir) + +add_executable(sharedlibtestexe sharedlibtestexe.cpp) +target_link_libraries(sharedlibtestexe shared_iface) diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp new file mode 100644 index 0000000..decd37c --- /dev/null +++ b/Tests/InterfaceLibrary/definetestexe.cpp @@ -0,0 +1,9 @@ + +#ifndef IFACE_DEFINE +#error Expected IFACE_DEFINE +#endif + +int main(int,char**) +{ + return 0; +} diff --git a/Tests/InterfaceLibrary/libsdir/CMakeLists.txt b/Tests/InterfaceLibrary/libsdir/CMakeLists.txt new file mode 100644 index 0000000..6999646 --- /dev/null +++ b/Tests/InterfaceLibrary/libsdir/CMakeLists.txt @@ -0,0 +1,26 @@ + +include(GenerateExportHeader) + +add_library(sharedlib SHARED sharedlib.cpp) +generate_export_header(sharedlib) + +add_library(shareddependlib SHARED shareddependlib.cpp) +generate_export_header(shareddependlib) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) + +target_link_libraries(sharedlib PUBLIC shareddependlib) + +target_include_directories(shareddependlib + PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/shareddependlib") +target_compile_definitions(shareddependlib + INTERFACE $<1:SHAREDDEPENDLIB_DEFINE>) + +target_include_directories(sharedlib + PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/sharedlib") +target_compile_definitions(shareddependlib + INTERFACE $<1:SHAREDLIB_DEFINE>) + +add_library(shared_iface INTERFACE) +target_link_libraries(shared_iface INTERFACE sharedlib) diff --git a/Tests/InterfaceLibrary/libsdir/shareddependlib.cpp b/Tests/InterfaceLibrary/libsdir/shareddependlib.cpp new file mode 100644 index 0000000..378ba81 --- /dev/null +++ b/Tests/InterfaceLibrary/libsdir/shareddependlib.cpp @@ -0,0 +1,7 @@ + +#include "shareddependlib.h" + +int SharedDependLibObject::foo() const +{ + return 0; +} diff --git a/Tests/InterfaceLibrary/libsdir/shareddependlib/shareddependlib.h b/Tests/InterfaceLibrary/libsdir/shareddependlib/shareddependlib.h new file mode 100644 index 0000000..ad9b484 --- /dev/null +++ b/Tests/InterfaceLibrary/libsdir/shareddependlib/shareddependlib.h @@ -0,0 +1,12 @@ + +#ifndef SHAREDDEPENDLIB_H +#define SHAREDDEPENDLIB_H + +#include "shareddependlib_export.h" + +struct SHAREDDEPENDLIB_EXPORT SharedDependLibObject +{ + int foo() const; +}; + +#endif diff --git a/Tests/InterfaceLibrary/libsdir/sharedlib.cpp b/Tests/InterfaceLibrary/libsdir/sharedlib.cpp new file mode 100644 index 0000000..c49ce90 --- /dev/null +++ b/Tests/InterfaceLibrary/libsdir/sharedlib.cpp @@ -0,0 +1,12 @@ + +#include "sharedlib.h" + +SharedDependLibObject SharedLibObject::object() const +{ + SharedDependLibObject sdlo; + return sdlo; +} +int SharedLibObject::foo() const +{ + return 0; +} diff --git a/Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h b/Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h new file mode 100644 index 0000000..5b3c7db --- /dev/null +++ b/Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h @@ -0,0 +1,15 @@ + +#ifndef SHAREDLIB_H +#define SHAREDLIB_H + +#include "sharedlib_export.h" + +#include "shareddependlib.h" + +struct SHAREDLIB_EXPORT SharedLibObject +{ + SharedDependLibObject object() const; + int foo() const; +}; + +#endif diff --git a/Tests/InterfaceLibrary/sharedlibtestexe.cpp b/Tests/InterfaceLibrary/sharedlibtestexe.cpp new file mode 100644 index 0000000..c677f70 --- /dev/null +++ b/Tests/InterfaceLibrary/sharedlibtestexe.cpp @@ -0,0 +1,19 @@ + +#ifndef SHAREDLIB_DEFINE +#error Expected SHAREDLIB_DEFINE +#endif + +#ifndef SHAREDDEPENDLIB_DEFINE +#error Expected SHAREDDEPENDLIB_DEFINE +#endif + +#include "sharedlib.h" +#include "shareddependlib.h" + +int main(int,char**) +{ + SharedLibObject sl; + SharedDependLibObject sdl = sl.object(); + + return sdl.foo() + sl.foo(); +} diff --git a/Tests/PositionIndependentTargets/CMakeLists.txt b/Tests/PositionIndependentTargets/CMakeLists.txt index eec893d..e79f3b7 100644 --- a/Tests/PositionIndependentTargets/CMakeLists.txt +++ b/Tests/PositionIndependentTargets/CMakeLists.txt @@ -9,5 +9,6 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}") # For pic_test.h add_subdirectory(global) add_subdirectory(targets) +add_subdirectory(interface) add_executable(PositionIndependentTargets main.cpp) diff --git a/Tests/PositionIndependentTargets/interface/CMakeLists.txt b/Tests/PositionIndependentTargets/interface/CMakeLists.txt new file mode 100644 index 0000000..65f3b76 --- /dev/null +++ b/Tests/PositionIndependentTargets/interface/CMakeLists.txt @@ -0,0 +1,27 @@ + +add_library(piciface INTERFACE) +set_property(TARGET piciface PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE ON) + +add_executable(test_empty_iface "${CMAKE_CURRENT_SOURCE_DIR}/../pic_main.cpp") +target_link_libraries(test_empty_iface piciface) + +add_library(sharedlib SHARED "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp") +target_link_libraries(sharedlib piciface) +set_property(TARGET sharedlib PROPERTY DEFINE_SYMBOL PIC_TEST_BUILD_DLL) + +add_executable(test_iface_via_shared "${CMAKE_CURRENT_SOURCE_DIR}/../pic_main.cpp") +target_link_libraries(test_iface_via_shared sharedlib) + +add_library(sharedlibpic SHARED "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp") +set_property(TARGET sharedlibpic PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE ON) +set_property(TARGET sharedlibpic PROPERTY DEFINE_SYMBOL PIC_TEST_BUILD_DLL) + +add_library(shared_iface INTERFACE) +target_link_libraries(shared_iface INTERFACE sharedlibpic) + +add_executable(test_shared_via_iface "${CMAKE_CURRENT_SOURCE_DIR}/../pic_main.cpp") +target_link_libraries(test_shared_via_iface shared_iface) + +add_executable(test_shared_via_iface_non_conflict "${CMAKE_CURRENT_SOURCE_DIR}/../pic_main.cpp") +set_property(TARGET test_shared_via_iface_non_conflict PROPERTY POSITION_INDEPENDENT_CODE ON) +target_link_libraries(test_shared_via_iface_non_conflict shared_iface) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 35c8e13..ee490b8 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -100,6 +100,7 @@ add_RunCMake_test(variable_watch) add_RunCMake_test(CMP0004) add_RunCMake_test(TargetPolicies) add_RunCMake_test(alias_targets) +add_RunCMake_test(interface_library) find_package(Qt4 QUIET) find_package(Qt5Core QUIET) diff --git a/Tests/RunCMake/PositionIndependentCode/Conflict4-result.txt b/Tests/RunCMake/PositionIndependentCode/Conflict4-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Conflict4-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/PositionIndependentCode/Conflict4-stderr.txt b/Tests/RunCMake/PositionIndependentCode/Conflict4-stderr.txt new file mode 100644 index 0000000..76d5ea0 --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Conflict4-stderr.txt @@ -0,0 +1,4 @@ +CMake Error: Property POSITION_INDEPENDENT_CODE on target "conflict" is +implied to be FALSE because it was used to determine the link libraries +already. The INTERFACE_POSITION_INDEPENDENT_CODE property on +dependency "picon" is in conflict. diff --git a/Tests/RunCMake/PositionIndependentCode/Conflict4.cmake b/Tests/RunCMake/PositionIndependentCode/Conflict4.cmake new file mode 100644 index 0000000..ff5dfb3 --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Conflict4.cmake @@ -0,0 +1,8 @@ + +add_library(piciface INTERFACE) + +add_library(picon INTERFACE) +set_property(TARGET picon PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE ON) + +add_executable(conflict "main.cpp") +target_link_libraries(conflict picon $<$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>:piciface>) diff --git a/Tests/RunCMake/PositionIndependentCode/Conflict5-result.txt b/Tests/RunCMake/PositionIndependentCode/Conflict5-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Conflict5-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/PositionIndependentCode/Conflict5-stderr.txt b/Tests/RunCMake/PositionIndependentCode/Conflict5-stderr.txt new file mode 100644 index 0000000..ecd0492 --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Conflict5-stderr.txt @@ -0,0 +1,3 @@ +CMake Error: The INTERFACE_POSITION_INDEPENDENT_CODE property of "picoff" does +not agree with the value of POSITION_INDEPENDENT_CODE already determined +for "conflict". diff --git a/Tests/RunCMake/PositionIndependentCode/Conflict5.cmake b/Tests/RunCMake/PositionIndependentCode/Conflict5.cmake new file mode 100644 index 0000000..e6055f4 --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Conflict5.cmake @@ -0,0 +1,9 @@ + +add_library(picon INTERFACE) +set_property(TARGET picon PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE ON) + +add_library(picoff INTERFACE) +set_property(TARGET picoff PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE OFF) + +add_executable(conflict "main.cpp") +target_link_libraries(conflict picon picoff) diff --git a/Tests/RunCMake/PositionIndependentCode/Conflict6-result.txt b/Tests/RunCMake/PositionIndependentCode/Conflict6-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Conflict6-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/PositionIndependentCode/Conflict6-stderr.txt b/Tests/RunCMake/PositionIndependentCode/Conflict6-stderr.txt new file mode 100644 index 0000000..0254e55 --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Conflict6-stderr.txt @@ -0,0 +1,4 @@ +Property POSITION_INDEPENDENT_CODE on target "conflict" is +implied to be FALSE because it was used to determine the link libraries +already. The INTERFACE_POSITION_INDEPENDENT_CODE property on +dependency "picon" is in conflict. diff --git a/Tests/RunCMake/PositionIndependentCode/Conflict6.cmake b/Tests/RunCMake/PositionIndependentCode/Conflict6.cmake new file mode 100644 index 0000000..7ea7c5f --- /dev/null +++ b/Tests/RunCMake/PositionIndependentCode/Conflict6.cmake @@ -0,0 +1,8 @@ + +add_library(picoff INTERFACE) + +add_library(picon INTERFACE) +set_property(TARGET picon PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE ON) + +add_executable(conflict "main.cpp") +target_link_libraries(conflict picon $<$<NOT:$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>>:picoff>) diff --git a/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake b/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake index 64a340c..3a2009b 100644 --- a/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake +++ b/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake @@ -3,3 +3,6 @@ include(RunCMake) run_cmake(Conflict1) run_cmake(Conflict2) run_cmake(Conflict3) +run_cmake(Conflict4) +run_cmake(Conflict5) +run_cmake(Conflict6) diff --git a/Tests/RunCMake/interface_library/CMakeLists.txt b/Tests/RunCMake/interface_library/CMakeLists.txt new file mode 100644 index 0000000..12cd3c7 --- /dev/null +++ b/Tests/RunCMake/interface_library/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake new file mode 100644 index 0000000..56caf68 --- /dev/null +++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake @@ -0,0 +1,4 @@ +include(RunCMake) + +run_cmake(invalid_name) +run_cmake(target_commands) diff --git a/Tests/RunCMake/interface_library/invalid_name-result.txt b/Tests/RunCMake/interface_library/invalid_name-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/interface_library/invalid_name-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/invalid_name-stderr.txt b/Tests/RunCMake/interface_library/invalid_name-stderr.txt new file mode 100644 index 0000000..e14fcde --- /dev/null +++ b/Tests/RunCMake/interface_library/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/interface_library/invalid_name.cmake b/Tests/RunCMake/interface_library/invalid_name.cmake new file mode 100644 index 0000000..9a965aa --- /dev/null +++ b/Tests/RunCMake/interface_library/invalid_name.cmake @@ -0,0 +1,6 @@ + +add_library(if$ace INTERFACE) + +add_library(iface::target INTERFACE) + +add_library(if$target_imported INTERFACE IMPORTED) diff --git a/Tests/RunCMake/interface_library/target_commands-result.txt b/Tests/RunCMake/interface_library/target_commands-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/interface_library/target_commands-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/target_commands-stderr.txt b/Tests/RunCMake/interface_library/target_commands-stderr.txt new file mode 100644 index 0000000..be11b77 --- /dev/null +++ b/Tests/RunCMake/interface_library/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 be 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 be 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 be 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 be set INTERFACE properties on + INTERFACE targets +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/interface_library/target_commands.cmake b/Tests/RunCMake/interface_library/target_commands.cmake new file mode 100644 index 0000000..3182e89 --- /dev/null +++ b/Tests/RunCMake/interface_library/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) |