diff options
Diffstat (limited to 'Tests')
32 files changed, 242 insertions, 12 deletions
diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt index cd0fe11..19ee59f 100644 --- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -103,4 +103,7 @@ target_compile_definitions(depG INTERFACE ) add_executable(targetC targetC.cpp) -target_link_libraries(targetC depG) +# Creates a generator expression for include directories like +# $<$<TARGET_DEFINED:$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:depG>>:\ +# $<TARGET_PROPERTY:$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:depG>,INTERFACE_INCLUDE_DIRECTORIES>> +target_link_libraries(targetC $<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:depG>) diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt index 329510b..cd0a37d 100644 --- a/Tests/CompatibleInterface/CMakeLists.txt +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -67,3 +67,18 @@ target_compile_definitions(CompatibleInterface PRIVATE $<$<BOOL:$<TARGET_PROPERTY:Iface2_PROP>>:SOME_DEFINE> ) + +# The COMPATIBLE_INTERFACE_* properties are only read from dependencies +# in the interface. Populating it on the CompatibleInterface target does +# not have any affect on the interpretation of the INTERFACE variants +# in dependencies. +set_property(TARGET iface1 PROPERTY + INTERFACE_NON_RELEVANT_PROP ON +) +set_property(TARGET iface2 PROPERTY + INTERFACE_NON_RELEVANT_PROP ON +) +set_property(TARGET CompatibleInterface APPEND PROPERTY + COMPATIBLE_INTERFACE_BOOL + NON_RELEVANT_PROP +) diff --git a/Tests/ObjectLibrary/A/CMakeLists.txt b/Tests/ObjectLibrary/A/CMakeLists.txt index 36c86e7..55778ea 100644 --- a/Tests/ObjectLibrary/A/CMakeLists.txt +++ b/Tests/ObjectLibrary/A/CMakeLists.txt @@ -13,6 +13,6 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/a1.c.in ${CMAKE_CURRENT_BINARY_DIR}/a1.c ) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_library(A OBJECT a1.c a2.c) +target_include_directories(A PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Tests/ObjectLibrary/B/CMakeLists.txt b/Tests/ObjectLibrary/B/CMakeLists.txt index 32d8ceb..a567f96 100644 --- a/Tests/ObjectLibrary/B/CMakeLists.txt +++ b/Tests/ObjectLibrary/B/CMakeLists.txt @@ -10,7 +10,11 @@ if(CMAKE_SHARED_LIBRARY_C_FLAGS AND NOT WATCOM) set(CMAKE_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_C_FLAGS}") endif() -add_definitions(-DB_DEF) add_library(B OBJECT b1.c b2.c) +target_include_directories(B PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_definitions(B PUBLIC B_DEF) + add_library(Bexport OBJECT b1${vs6}.c b2${vs6}.c) set_property(TARGET Bexport PROPERTY COMPILE_DEFINITIONS Bexport) +target_include_directories(Bexport PRIVATE $<TARGET_PROPERTY:B,INTERFACE_INCLUDE_DIRECTORIES>) +target_compile_definitions(Bexport PRIVATE $<TARGET_PROPERTY:B,INTERFACE_COMPILE_DEFINITIONS>) diff --git a/Tests/ObjectLibrary/B/b.h b/Tests/ObjectLibrary/B/b.h index 11b22f4..3489c71 100644 --- a/Tests/ObjectLibrary/B/b.h +++ b/Tests/ObjectLibrary/B/b.h @@ -4,8 +4,15 @@ #ifndef B_DEF # error "B_DEF not defined" #endif + #if defined(_WIN32) && defined(Bexport) # define EXPORT_B __declspec(dllexport) #else # define EXPORT_B #endif + +#if defined(_WIN32) && defined(SHARED_B) +# define IMPORT_B __declspec(dllimport) +#else +# define IMPORT_B +#endif diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt index 8723415..13a07b4 100644 --- a/Tests/ObjectLibrary/CMakeLists.txt +++ b/Tests/ObjectLibrary/CMakeLists.txt @@ -26,6 +26,9 @@ endif() # Test static library without its own sources. add_library(ABstatic STATIC ${dummy} $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B>) +target_include_directories(ABstatic PUBLIC $<TARGET_PROPERTY:B,INTERFACE_INCLUDE_DIRECTORIES>) +target_compile_definitions(ABstatic PUBLIC $<TARGET_PROPERTY:B,INTERFACE_COMPILE_DEFINITIONS>) + add_executable(UseABstatic mainAB.c) target_link_libraries(UseABstatic ABstatic) @@ -41,12 +44,17 @@ endif() # Test shared library without its own sources. add_library(ABshared SHARED ${dummy} ${ABshared_SRCS}) +target_include_directories(ABshared PUBLIC $<TARGET_PROPERTY:B,INTERFACE_INCLUDE_DIRECTORIES>) +target_compile_definitions(ABshared PUBLIC $<TARGET_PROPERTY:B,INTERFACE_COMPILE_DEFINITIONS>) + add_executable(UseABshared mainAB.c) set_property(TARGET UseABshared PROPERTY COMPILE_DEFINITIONS SHARED_B ${NO_A}) target_link_libraries(UseABshared ABshared) # Test executable without its own sources. add_library(ABmain OBJECT mainAB.c) +target_include_directories(ABmain PUBLIC $<TARGET_PROPERTY:B,INTERFACE_INCLUDE_DIRECTORIES>) +target_compile_definitions(ABmain PUBLIC $<TARGET_PROPERTY:B,INTERFACE_COMPILE_DEFINITIONS>) add_executable(UseABinternal ${dummy} $<TARGET_OBJECTS:ABmain> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B> ) diff --git a/Tests/ObjectLibrary/mainAB.c b/Tests/ObjectLibrary/mainAB.c index 556898b..38db205 100644 --- a/Tests/ObjectLibrary/mainAB.c +++ b/Tests/ObjectLibrary/mainAB.c @@ -1,8 +1,6 @@ -#if defined(_WIN32) && defined(SHARED_B) -# define IMPORT_B __declspec(dllimport) -#else -# define IMPORT_B -#endif + +#include "b.h" + extern IMPORT_B int b1(void); extern IMPORT_B int b2(void); #ifndef NO_A diff --git a/Tests/QtAutomoc/Adir/CMakeLists.txt b/Tests/QtAutomoc/Adir/CMakeLists.txt new file mode 100644 index 0000000..abd328e --- /dev/null +++ b/Tests/QtAutomoc/Adir/CMakeLists.txt @@ -0,0 +1,8 @@ + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_BUILD_INTERFACE_INCLUDES ON) + +add_library(libA SHARED libA.cpp) +target_link_libraries(libA LINK_PUBLIC Qt4::QtCore) +generate_export_header(libA) diff --git a/Tests/QtAutomoc/Adir/libA.cpp b/Tests/QtAutomoc/Adir/libA.cpp new file mode 100644 index 0000000..3968c44 --- /dev/null +++ b/Tests/QtAutomoc/Adir/libA.cpp @@ -0,0 +1,13 @@ + +#include "libA.h" + +LibA::LibA(QObject *parent) + : QObject(parent) +{ + +} + +int LibA::foo() +{ + return 0; +} diff --git a/Tests/QtAutomoc/Adir/libA.h b/Tests/QtAutomoc/Adir/libA.h new file mode 100644 index 0000000..03ad1e0 --- /dev/null +++ b/Tests/QtAutomoc/Adir/libA.h @@ -0,0 +1,18 @@ + +#ifndef LIBA_H +#define LIBA_H + +#include "liba_export.h" + +#include <QObject> + +class LIBA_EXPORT LibA : public QObject +{ + Q_OBJECT +public: + explicit LibA(QObject *parent = 0); + + int foo(); +}; + +#endif diff --git a/Tests/QtAutomoc/Bdir/CMakeLists.txt b/Tests/QtAutomoc/Bdir/CMakeLists.txt new file mode 100644 index 0000000..5497105 --- /dev/null +++ b/Tests/QtAutomoc/Bdir/CMakeLists.txt @@ -0,0 +1,10 @@ + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_BUILD_INTERFACE_INCLUDES ON) + +add_library(libB SHARED libB.cpp) +generate_export_header(libB) + +# set_property(TARGET libB APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) +target_link_libraries(libB LINK_PUBLIC libA) diff --git a/Tests/QtAutomoc/Bdir/libB.cpp b/Tests/QtAutomoc/Bdir/libB.cpp new file mode 100644 index 0000000..72f2cfa --- /dev/null +++ b/Tests/QtAutomoc/Bdir/libB.cpp @@ -0,0 +1,13 @@ + +#include "libB.h" + +LibB::LibB(QObject *parent) + : QObject(parent) +{ + +} + +int LibB::foo() +{ + return a.foo(); +} diff --git a/Tests/QtAutomoc/Bdir/libB.h b/Tests/QtAutomoc/Bdir/libB.h new file mode 100644 index 0000000..510c17f --- /dev/null +++ b/Tests/QtAutomoc/Bdir/libB.h @@ -0,0 +1,21 @@ + +#ifndef LIBB_H +#define LIBB_H + +#include "libb_export.h" + +#include <QObject> +#include "libA.h" + +class LIBB_EXPORT LibB : public QObject +{ + Q_OBJECT +public: + explicit LibB(QObject *parent = 0); + + int foo(); +private: + LibA a; +}; + +#endif diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt index 855fcf0..530818e 100644 --- a/Tests/QtAutomoc/CMakeLists.txt +++ b/Tests/QtAutomoc/CMakeLists.txt @@ -23,4 +23,18 @@ add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp set_target_properties(foo codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE) -target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} ) +include(GenerateExportHeader) +# The order is relevant here. B depends on A, and B headers depend on A +# headers both subdirectories use CMAKE_BUILD_INTERFACE_INCLUDES and we +# test that CMAKE_AUTOMOC successfully reads the include directories +# for the build interface from those targets. There has previously been +# a bug where caching of the include directories happened before +# extracting the includes to pass to moc. +add_subdirectory(Bdir) +add_subdirectory(Adir) +add_library(libC SHARED libC.cpp) +set_target_properties(libC PROPERTIES AUTOMOC TRUE) +generate_export_header(libC) +target_link_libraries(libC LINK_PUBLIC libB) + +target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} libC) diff --git a/Tests/QtAutomoc/libC.cpp b/Tests/QtAutomoc/libC.cpp new file mode 100644 index 0000000..8d61cb1 --- /dev/null +++ b/Tests/QtAutomoc/libC.cpp @@ -0,0 +1,13 @@ + +#include "libC.h" + +LibC::LibC(QObject *parent) + : QObject(parent) +{ + +} + +int LibC::foo() +{ + return b.foo(); +} diff --git a/Tests/QtAutomoc/libC.h b/Tests/QtAutomoc/libC.h new file mode 100644 index 0000000..4fb4a2c --- /dev/null +++ b/Tests/QtAutomoc/libC.h @@ -0,0 +1,22 @@ + +#ifndef LIBC_H +#define LIBC_H + +#include "libc_export.h" + +#include <QObject> +#include "libB.h" + +class LIBC_EXPORT LibC : public QObject +{ + Q_OBJECT +public: + explicit LibC(QObject *parent = 0); + + + int foo(); +private: + LibB b; +}; + +#endif diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutomoc/main.cpp index 738f677..d952171 100644 --- a/Tests/QtAutomoc/main.cpp +++ b/Tests/QtAutomoc/main.cpp @@ -48,6 +48,7 @@ #include "abc.h" #include "xyz.h" #include "yaf.h" +#include "libC.h" int main(int argv, char **args) { @@ -78,5 +79,8 @@ int main(int argv, char **args) Yaf yaf; yaf.doYaf(); + LibC lc; + lc.foo(); + return app.exec(); } diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict-stderr.txt new file mode 100644 index 0000000..5a8f99d --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict-stderr.txt @@ -0,0 +1,5 @@ +CMake Error in CMakeLists.txt: + Property "SOMETHING" appears in both the COMPATIBLE_INTERFACE_BOOL and the + COMPATIBLE_INTERFACE_STRING property in the dependencies of target "user". + This is not allowed. A property may only require compatibility in a + boolean interpretation or a string interpretation, but not both. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict.cmake new file mode 100644 index 0000000..711368a --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict.cmake @@ -0,0 +1,9 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SOMETHING) +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING SOMETHING) + +add_executable(user main.cpp) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake index 922ad7f..9768151 100644 --- a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake @@ -8,3 +8,4 @@ run_cmake(InterfaceString-mismatch-depends) run_cmake(InterfaceString-mismatch-depend-self) run_cmake(InterfaceString-mismatched-use) run_cmake(InterfaceString-builtin-prop) +run_cmake(InterfaceString-Bool-Conflict) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-result.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-stderr.txt new file mode 100644 index 0000000..fb06554 --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at BadLinked-UtilityTarget.cmake:7 \(set_property\): + Error evaluating generator expression: + + \$<LINKED:check> + + Target "check" is not an executable or library. +Call Stack \(most recent call first\): + CMakeLists.txt:8 \(include\) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget.cmake new file mode 100644 index 0000000..d114c8f --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget.cmake @@ -0,0 +1,7 @@ + +add_custom_target(check ALL + COMMAND ${CMAKE_COMMAND} -E echo check +) + +add_library(foo STATIC empty.cpp) +set_property(TARGET foo PROPERTY INCLUDE_DIRECTORIES $<LINKED:check>) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake index ea48f61..84039c4 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake @@ -16,3 +16,4 @@ run_cmake(BadInvalidName6) run_cmake(BadInvalidName7) run_cmake(BadInvalidName8) run_cmake(BadLinked) +run_cmake(BadLinked-UtilityTarget) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp b/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp new file mode 100644 index 0000000..8b1a393 --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp @@ -0,0 +1 @@ +// empty diff --git a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt index 736fe69..c17e0ae 100644 --- a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt +++ b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt @@ -23,13 +23,21 @@ CMake Debug Log at DebugIncludes.cmake:18 \(include_directories\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Debug Log at DebugIncludes.cmake:25 \(set_property\): +CMake Debug Log at DebugIncludes.cmake:26 \(target_link_libraries\): Used includes for target lll: \* .*/Tests/RunCMake/include_directories/five + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Debug Log at DebugIncludes.cmake:29 \(set_property\): + Used includes for target lll: + \* .*/Tests/RunCMake/include_directories/six + \* .*/Tests/RunCMake/include_directories/seven Call Stack \(most recent call first\): - DebugIncludes.cmake:35 \(some_macro\) - DebugIncludes.cmake:38 \(some_function\) + DebugIncludes.cmake:40 \(some_macro\) + DebugIncludes.cmake:43 \(some_function\) CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/include_directories/DebugIncludes.cmake b/Tests/RunCMake/include_directories/DebugIncludes.cmake index 51daf74..794a852 100644 --- a/Tests/RunCMake/include_directories/DebugIncludes.cmake +++ b/Tests/RunCMake/include_directories/DebugIncludes.cmake @@ -21,6 +21,10 @@ include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/four" ) +add_library(foo "${CMAKE_CURRENT_BINARY_DIR}/DebugIncludes.cpp") +target_include_directories(foo INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/five") +target_link_libraries(lll foo) + macro(some_macro) set_property(TARGET lll APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/one" @@ -28,6 +32,7 @@ macro(some_macro) "${CMAKE_CURRENT_SOURCE_DIR}/four" "${CMAKE_CURRENT_SOURCE_DIR}/five" "${CMAKE_CURRENT_SOURCE_DIR}/six" + "${CMAKE_CURRENT_SOURCE_DIR}/seven" ) endmacro() diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index de37252..ddf268c 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -2,3 +2,4 @@ include(RunCMake) run_cmake(NotFoundContent) run_cmake(DebugIncludes) +run_cmake(TID-bad-target) diff --git a/Tests/RunCMake/include_directories/TID-bad-target-result.txt b/Tests/RunCMake/include_directories/TID-bad-target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/include_directories/TID-bad-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/TID-bad-target-stderr.txt b/Tests/RunCMake/include_directories/TID-bad-target-stderr.txt new file mode 100644 index 0000000..481e358 --- /dev/null +++ b/Tests/RunCMake/include_directories/TID-bad-target-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at TID-bad-target.cmake:6 \(target_include_directories\): + target_include_directories called with non-compilable target type +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/include_directories/TID-bad-target.cmake b/Tests/RunCMake/include_directories/TID-bad-target.cmake new file mode 100644 index 0000000..32201c1 --- /dev/null +++ b/Tests/RunCMake/include_directories/TID-bad-target.cmake @@ -0,0 +1,6 @@ + +add_custom_target(check ALL + COMMAND ${CMAKE_COMMAND} -E echo check +) + +target_include_directories(check PRIVATE somedir) |