diff options
Diffstat (limited to 'Tests/RunCMake/target_sources')
123 files changed, 800 insertions, 3 deletions
diff --git a/Tests/RunCMake/target_sources/AddCustomTargetCheckProperty.cmake b/Tests/RunCMake/target_sources/AddCustomTargetCheckProperty.cmake new file mode 100644 index 0000000000..1787e877b2 --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetCheckProperty.cmake @@ -0,0 +1,16 @@ +add_custom_target(target1 ALL) +target_sources(target1 PRIVATE main.cpp) +get_property(actualProp1 TARGET target1 PROPERTY SOURCES) +set(desiredProp1 main.cpp) +if(NOT desiredProp1 STREQUAL actualProp1) + message("source property not set. desired: \"${desiredProp1}\" actual: \"${actualProp1}\"") +endif() + +add_custom_target(target2 ALL SOURCES main.cpp) +target_sources(target2 PRIVATE empty_1.cpp empty_2.cpp) +target_sources(target2 PRIVATE empty_3.cpp) +get_property(actualProp2 TARGET target2 PROPERTY SOURCES) +set(desiredProp2 main.cpp empty_1.cpp empty_2.cpp empty_3.cpp) +if (NOT desiredProp2 STREQUAL actualProp2) + message("source property not set. desired: \"${desiredProp2}\" actual: \"${actualProp2}\"") +endif() diff --git a/Tests/RunCMake/target_sources/AddCustomTargetGenx.cmake b/Tests/RunCMake/target_sources/AddCustomTargetGenx.cmake new file mode 100644 index 0000000000..0078eab0f9 --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetGenx.cmake @@ -0,0 +1,2 @@ +add_custom_target(target ALL) +target_sources(target PRIVATE $<IF:1,${CMAKE_CURRENT_LIST_DIR}/main.cpp,${CMAKE_CURRENT_LIST_DIR}/empty_1.cpp>) diff --git a/Tests/RunCMake/target_sources/AddCustomTargetInterfaceSources-result.txt b/Tests/RunCMake/target_sources/AddCustomTargetInterfaceSources-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetInterfaceSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/AddCustomTargetInterfaceSources-stderr.txt b/Tests/RunCMake/target_sources/AddCustomTargetInterfaceSources-stderr.txt new file mode 100644 index 0000000000..9334bf6ffe --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetInterfaceSources-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at AddCustomTargetInterfaceSources.cmake:2 \(target_sources\): + target_sources may only set PRIVATE properties on custom targets +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_sources/AddCustomTargetInterfaceSources.cmake b/Tests/RunCMake/target_sources/AddCustomTargetInterfaceSources.cmake new file mode 100644 index 0000000000..42a8ca2f11 --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetInterfaceSources.cmake @@ -0,0 +1,2 @@ +add_custom_target(target ALL) +target_sources(target INTERFACE main.cpp) diff --git a/Tests/RunCMake/target_sources/AddCustomTargetPrivateSources.cmake b/Tests/RunCMake/target_sources/AddCustomTargetPrivateSources.cmake new file mode 100644 index 0000000000..11f0258c8e --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetPrivateSources.cmake @@ -0,0 +1,2 @@ +add_custom_target(target ALL) +target_sources(target PRIVATE main.cpp) diff --git a/Tests/RunCMake/target_sources/AddCustomTargetPublicSources-result.txt b/Tests/RunCMake/target_sources/AddCustomTargetPublicSources-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetPublicSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/AddCustomTargetPublicSources-stderr.txt b/Tests/RunCMake/target_sources/AddCustomTargetPublicSources-stderr.txt new file mode 100644 index 0000000000..afba4beed5 --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetPublicSources-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at AddCustomTargetPublicSources.cmake:2 \(target_sources\): + target_sources may only set PRIVATE properties on custom targets +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_sources/AddCustomTargetPublicSources.cmake b/Tests/RunCMake/target_sources/AddCustomTargetPublicSources.cmake new file mode 100644 index 0000000000..d9e82c02f5 --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetPublicSources.cmake @@ -0,0 +1,2 @@ +add_custom_target(target ALL) +target_sources(target PUBLIC main.cpp) diff --git a/Tests/RunCMake/target_sources/AddCustomTargetSources-result.txt b/Tests/RunCMake/target_sources/AddCustomTargetSources-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/AddCustomTargetSources-stderr.txt b/Tests/RunCMake/target_sources/AddCustomTargetSources-stderr.txt new file mode 100644 index 0000000000..4a153e9673 --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetSources-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at AddCustomTargetSources.cmake:2 \(target_sources\): + target_sources called with invalid arguments +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_sources/AddCustomTargetSources.cmake b/Tests/RunCMake/target_sources/AddCustomTargetSources.cmake new file mode 100644 index 0000000000..dd688d30d1 --- /dev/null +++ b/Tests/RunCMake/target_sources/AddCustomTargetSources.cmake @@ -0,0 +1,2 @@ +add_custom_target(target ALL) +target_sources(target main.cpp) diff --git a/Tests/RunCMake/target_sources/CMP0026-LOCATION-result.txt b/Tests/RunCMake/target_sources/CMP0026-LOCATION-result.txt new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/Tests/RunCMake/target_sources/CMP0026-LOCATION-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/target_sources/CMP0026-LOCATION-stderr.txt b/Tests/RunCMake/target_sources/CMP0026-LOCATION-stderr.txt new file mode 100644 index 0000000000..d7ccedb1b4 --- /dev/null +++ b/Tests/RunCMake/target_sources/CMP0026-LOCATION-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0026-LOCATION.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0026 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/CMP0026-LOCATION.cmake b/Tests/RunCMake/target_sources/CMP0026-LOCATION.cmake new file mode 100644 index 0000000000..642856cde7 --- /dev/null +++ b/Tests/RunCMake/target_sources/CMP0026-LOCATION.cmake @@ -0,0 +1,14 @@ + +cmake_policy(SET CMP0026 OLD) +enable_language(CXX) + +add_library(objlib OBJECT + empty_1.cpp +) + +add_executable(my_exe + empty_2.cpp + $<TARGET_OBJECTS:objlib> +) + +get_target_property( loc my_exe LOCATION) diff --git a/Tests/RunCMake/target_sources/CMP0076-OLD-result.txt b/Tests/RunCMake/target_sources/CMP0076-OLD-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/CMP0076-OLD-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/CMP0076-OLD-stderr.txt b/Tests/RunCMake/target_sources/CMP0076-OLD-stderr.txt new file mode 100644 index 0000000000..d47dd4de30 --- /dev/null +++ b/Tests/RunCMake/target_sources/CMP0076-OLD-stderr.txt @@ -0,0 +1,4 @@ +CMake Error in CMakeLists.txt: + Target "iface" contains relative path in its INTERFACE_SOURCES: + + "empty_1.cpp" diff --git a/Tests/RunCMake/target_sources/CMP0076-OLD.cmake b/Tests/RunCMake/target_sources/CMP0076-OLD.cmake new file mode 100644 index 0000000000..4d8c268efa --- /dev/null +++ b/Tests/RunCMake/target_sources/CMP0076-OLD.cmake @@ -0,0 +1,10 @@ +cmake_policy(SET CMP0076 OLD) + +add_library(iface INTERFACE) +target_sources(iface INTERFACE empty_1.cpp) + +get_property(iface_sources TARGET iface PROPERTY INTERFACE_SOURCES) +message(STATUS "iface: ${iface_sources}") + +add_executable(main main.cpp) +target_link_libraries(main iface) diff --git a/Tests/RunCMake/target_sources/CMP0076-WARN-result.txt b/Tests/RunCMake/target_sources/CMP0076-WARN-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/CMP0076-WARN-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/CMP0076-WARN-stderr.txt b/Tests/RunCMake/target_sources/CMP0076-WARN-stderr.txt new file mode 100644 index 0000000000..bd888eed55 --- /dev/null +++ b/Tests/RunCMake/target_sources/CMP0076-WARN-stderr.txt @@ -0,0 +1,21 @@ +CMake Warning \(dev\) at CMP0076-WARN/CMakeLists\.txt:[0-9]+ \(target_sources\): + Policy CMP0076 is not set: target_sources\(\) command converts relative paths + to absolute. Run "cmake --help-policy CMP0076" for policy details. Use + the cmake_policy command to set the policy and suppress this warning. + + An interface source of target "publiclib" has a relative path. +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning \(dev\) at CMP0076-WARN/CMakeLists\.txt:[0-9]+ \(target_sources\): + Policy CMP0076 is not set: target_sources\(\) command converts relative paths + to absolute. Run "cmake --help-policy CMP0076" for policy details. Use + the cmake_policy command to set the policy and suppress this warning. + + A private source from a directory other than that of target "publiclib" has + a relative path. +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Error in CMakeLists.txt: + Target "publiclib" contains relative path in its INTERFACE_SOURCES: + + "CMP0076-WARN/subdir_empty_1.cpp" diff --git a/Tests/RunCMake/target_sources/CMP0076-WARN.cmake b/Tests/RunCMake/target_sources/CMP0076-WARN.cmake new file mode 100644 index 0000000000..2e07331120 --- /dev/null +++ b/Tests/RunCMake/target_sources/CMP0076-WARN.cmake @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.12) + +add_library(publiclib) + +add_subdirectory(CMP0076-WARN) + +add_executable(main main.cpp) +target_link_libraries(main publiclib) diff --git a/Tests/RunCMake/target_sources/CMP0076-WARN/CMakeLists.txt b/Tests/RunCMake/target_sources/CMP0076-WARN/CMakeLists.txt new file mode 100644 index 0000000000..f9c7d6d5e5 --- /dev/null +++ b/Tests/RunCMake/target_sources/CMP0076-WARN/CMakeLists.txt @@ -0,0 +1,3 @@ + +target_sources(publiclib INTERFACE CMP0076-WARN/subdir_empty_1.cpp + PRIVATE empty_1.cpp) diff --git a/Tests/RunCMake/target_sources/CMP0076-WARN/subdir_empty_1.cpp b/Tests/RunCMake/target_sources/CMP0076-WARN/subdir_empty_1.cpp new file mode 100644 index 0000000000..11ec041d1e --- /dev/null +++ b/Tests/RunCMake/target_sources/CMP0076-WARN/subdir_empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/CMakeLists.txt b/Tests/RunCMake/target_sources/CMakeLists.txt index 14ef56e8e8..727f93a925 100644 --- a/Tests/RunCMake/target_sources/CMakeLists.txt +++ b/Tests/RunCMake/target_sources/CMakeLists.txt @@ -1,5 +1,3 @@ cmake_minimum_required(VERSION 3.11) - project(${RunCMake_TEST} LANGUAGES NONE) - include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/target_sources/ConfigNotAllowed-result.txt b/Tests/RunCMake/target_sources/ConfigNotAllowed-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/ConfigNotAllowed-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/ConfigNotAllowed-stderr.txt b/Tests/RunCMake/target_sources/ConfigNotAllowed-stderr.txt new file mode 100644 index 0000000000..bc4afb7882 --- /dev/null +++ b/Tests/RunCMake/target_sources/ConfigNotAllowed-stderr.txt @@ -0,0 +1,12 @@ +CMake Error in CMakeLists.txt: + Target "somelib" has source files which vary by configuration. This is not + supported by the "[^"]+" generator. + + Config "Debug": + + .*/Tests/RunCMake/target_sources/empty_1.cpp + .*/Tests/RunCMake/target_sources/empty_2.cpp + + Config "Release": + + .*/Tests/RunCMake/target_sources/empty_1.cpp diff --git a/Tests/RunCMake/target_sources/ConfigNotAllowed.cmake b/Tests/RunCMake/target_sources/ConfigNotAllowed.cmake new file mode 100644 index 0000000000..02af379722 --- /dev/null +++ b/Tests/RunCMake/target_sources/ConfigNotAllowed.cmake @@ -0,0 +1,2 @@ + +add_library(somelib empty_1.cpp $<$<CONFIG:Debug>:empty_2.cpp>) diff --git a/Tests/RunCMake/target_sources/empty_keyword_args.cmake b/Tests/RunCMake/target_sources/EmptyKeywordArgs.cmake index 5cee451fdf..5cee451fdf 100644 --- a/Tests/RunCMake/target_sources/empty_keyword_args.cmake +++ b/Tests/RunCMake/target_sources/EmptyKeywordArgs.cmake diff --git a/Tests/RunCMake/target_sources/ExportBuild-result.txt b/Tests/RunCMake/target_sources/ExportBuild-result.txt new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/Tests/RunCMake/target_sources/ExportBuild-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/target_sources/ExportBuild.cmake b/Tests/RunCMake/target_sources/ExportBuild.cmake new file mode 100644 index 0000000000..b626aa6cd1 --- /dev/null +++ b/Tests/RunCMake/target_sources/ExportBuild.cmake @@ -0,0 +1,5 @@ + +add_library(iface INTERFACE) +target_sources(iface INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/empty_1.cpp") + +export(TARGETS iface FILE ${CMAKE_CURRENT_BINARY_DIR}/targets.cmake) diff --git a/Tests/RunCMake/target_sources/FileSetChangeScope-result.txt b/Tests/RunCMake/target_sources/FileSetChangeScope-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeScope-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetChangeScope-stderr.txt b/Tests/RunCMake/target_sources/FileSetChangeScope-stderr.txt new file mode 100644 index 0000000000..600d006956 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeScope-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at FileSetChangeScope\.cmake:[0-9]+ \(target_sources\): + target_sources Scope PUBLIC for file set "a" does not match original scope + INTERFACE +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetChangeScope.cmake b/Tests/RunCMake/target_sources/FileSetChangeScope.cmake new file mode 100644 index 0000000000..9d835fe9fe --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeScope.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 INTERFACE FILE_SET a TYPE HEADERS) +target_sources(lib1 PUBLIC FILE_SET a) diff --git a/Tests/RunCMake/target_sources/FileSetChangeType-result.txt b/Tests/RunCMake/target_sources/FileSetChangeType-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeType-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetChangeType-stderr.txt b/Tests/RunCMake/target_sources/FileSetChangeType-stderr.txt new file mode 100644 index 0000000000..85fc71858f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeType-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at FileSetChangeType\.cmake:[0-9]+ \(target_sources\): + target_sources Type "RESOURCES" for file set "a" does not match original + type "HEADERS" +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetChangeType.cmake b/Tests/RunCMake/target_sources/FileSetChangeType.cmake new file mode 100644 index 0000000000..69eb6bc3af --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeType.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS) +target_sources(lib1 PRIVATE FILE_SET a TYPE RESOURCES) diff --git a/Tests/RunCMake/target_sources/FileSetDefaultWrongType-result.txt b/Tests/RunCMake/target_sources/FileSetDefaultWrongType-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetDefaultWrongType-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetDefaultWrongType-stderr.txt b/Tests/RunCMake/target_sources/FileSetDefaultWrongType-stderr.txt new file mode 100644 index 0000000000..faf0f5a33b --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetDefaultWrongType-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetDefaultWrongType\.cmake:[0-9]+ \(target_sources\): + target_sources File set TYPE may only be "HEADERS" +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetDefaultWrongType.cmake b/Tests/RunCMake/target_sources/FileSetDefaultWrongType.cmake new file mode 100644 index 0000000000..c810d664f7 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetDefaultWrongType.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET UNKNOWN) diff --git a/Tests/RunCMake/target_sources/FileSetDirectories.cmake b/Tests/RunCMake/target_sources/FileSetDirectories.cmake new file mode 100644 index 0000000000..af30b1ece1 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetDirectories.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_subdirectory(dir3) +add_subdirectory(dir4) diff --git a/Tests/RunCMake/target_sources/FileSetExport.cmake b/Tests/RunCMake/target_sources/FileSetExport.cmake new file mode 100644 index 0000000000..cde826aeb1 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetExport.cmake @@ -0,0 +1,21 @@ +enable_language(C) + +add_library(lib1 STATIC lib1.c) +target_sources(lib1 + PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES error.c + PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h + PUBLIC FILE_SET b TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h2.h + INTERFACE FILE_SET c TYPE HEADERS BASE_DIRS "$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir>" FILES "$<1:dir/dir.h>" + INTERFACE FILE_SET d TYPE HEADERS BASE_DIRS FILES "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>/empty.h" + INTERFACE FILE_SET e TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>" FILES "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>/empty2.h" + INTERFACE FILE_SET f TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES "${CMAKE_CURRENT_SOURCE_DIR}/empty3.h" + INTERFACE FILE_SET g TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/dir1" "${CMAKE_CURRENT_SOURCE_DIR}/dir2" FILES "${CMAKE_CURRENT_SOURCE_DIR}/dir1/file1.h" "${CMAKE_CURRENT_SOURCE_DIR}/dir2/file2.h" + INTERFACE FILE_SET dir3 TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/dir3" FILES dir3/dir3.h + ) + +install(TARGETS lib1 EXPORT export FILE_SET HEADERS FILE_SET a FILE_SET b FILE_SET c DESTINATION include/dir FILE_SET d FILE_SET e FILE_SET f DESTINATION include/$<IF:$<CONFIG:Debug>,debug,release> FILE_SET g FILE_SET dir3 DESTINATION include/dir3) +install(EXPORT export FILE export.cmake NAMESPACE install:: DESTINATION lib/cmake) +export(EXPORT export FILE export.cmake NAMESPACE export::) + +add_library(lib2 STATIC lib2.c) +target_link_libraries(lib2 PRIVATE lib1) diff --git a/Tests/RunCMake/target_sources/FileSetFileNoExist-result.txt b/Tests/RunCMake/target_sources/FileSetFileNoExist-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFileNoExist-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetFileNoExist-stderr.txt b/Tests/RunCMake/target_sources/FileSetFileNoExist-stderr.txt new file mode 100644 index 0000000000..9a2ca6ae59 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFileNoExist-stderr.txt @@ -0,0 +1,10 @@ +^CMake Error at FileSetFileNoExist\.cmake:[0-9]+ \(add_library\): + Cannot find source file: + + [^ +]*/Tests/RunCMake/target_sources/noexist\.h +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) + + +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/target_sources/FileSetFileNoExist.cmake b/Tests/RunCMake/target_sources/FileSetFileNoExist.cmake new file mode 100644 index 0000000000..0df8186820 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFileNoExist.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES noexist.h) diff --git a/Tests/RunCMake/target_sources/FileSetImport.cmake b/Tests/RunCMake/target_sources/FileSetImport.cmake new file mode 100644 index 0000000000..9c7358a305 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetImport.cmake @@ -0,0 +1,97 @@ +enable_language(C) + +get_property(_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + +function(assert_prop_eq tgt prop value) + unset(actual_value) + get_property(actual_value TARGET ${tgt} PROPERTY ${prop}) + if(NOT actual_value STREQUAL value) + message(SEND_ERROR "Expected value of ${prop}:\n ${value}\nActual value:\n ${actual_value}") + endif() +endfunction() + +get_filename_component(export_build_dir "${CMAKE_BINARY_DIR}" DIRECTORY) +string(APPEND export_build_dir "/FileSetExport-build") + +include("${export_build_dir}/export.cmake") +include("${export_build_dir}/install/lib/cmake/export.cmake") + +assert_prop_eq(export::lib1 HEADER_SETS "") +assert_prop_eq(export::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;e;f;g;dir3") +assert_prop_eq(export::lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/error.c") +assert_prop_eq(export::lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(export::lib1 HEADER_SET_b "${CMAKE_CURRENT_SOURCE_DIR}/h2.h") +assert_prop_eq(export::lib1 HEADER_DIRS_b "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(export::lib1 HEADER_SET_c "$<1:dir/dir.h>") +assert_prop_eq(export::lib1 HEADER_DIRS_c "$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir>") +assert_prop_eq(export::lib1 HEADER_SET_d "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>/empty.h") +assert_prop_eq(export::lib1 HEADER_DIRS_d "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(export::lib1 HEADER_SET_e "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>/empty2.h") +assert_prop_eq(export::lib1 HEADER_DIRS_e "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>") +assert_prop_eq(export::lib1 HEADER_SET_f "${CMAKE_CURRENT_SOURCE_DIR}/empty3.h") +assert_prop_eq(export::lib1 HEADER_DIRS_f "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(export::lib1 HEADER_SET_g "${CMAKE_CURRENT_SOURCE_DIR}/dir1/file1.h;${CMAKE_CURRENT_SOURCE_DIR}/dir2/file2.h") +assert_prop_eq(export::lib1 HEADER_DIRS_g "${CMAKE_CURRENT_SOURCE_DIR}/dir1;${CMAKE_CURRENT_SOURCE_DIR}/dir2") +assert_prop_eq(export::lib1 INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR};$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir>;${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>;${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/dir1;${CMAKE_CURRENT_SOURCE_DIR}/dir2;${CMAKE_CURRENT_SOURCE_DIR}/dir3;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir>>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir1>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir2>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir3>") + +assert_prop_eq(install::lib1 HEADER_SETS "") +assert_prop_eq(install::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;e;f;g;dir3") +assert_prop_eq(install::lib1 HEADER_SET "${export_build_dir}/install/include/error.c") +assert_prop_eq(install::lib1 HEADER_DIRS "${export_build_dir}/install/include") +assert_prop_eq(install::lib1 HEADER_SET_b "${export_build_dir}/install/include/h2.h") +assert_prop_eq(install::lib1 HEADER_DIRS_b "${export_build_dir}/install/include") +assert_prop_eq(install::lib1 HEADER_SET_c "${export_build_dir}/install/include/dir/dir.h") +assert_prop_eq(install::lib1 HEADER_DIRS_c "${export_build_dir}/install/include/dir") +if(_multi_config) + assert_prop_eq(install::lib1 HEADER_SET_d "$<$<CONFIG:Debug>:${export_build_dir}/install/include/debug/empty.h>;$<$<CONFIG:Release>:${export_build_dir}/install/include/release/empty.h>") +else() + assert_prop_eq(install::lib1 HEADER_SET_d "${export_build_dir}/install/include/debug/empty.h") +endif() +assert_prop_eq(install::lib1 HEADER_DIRS_d "${export_build_dir}/install/include") +if(_multi_config) + assert_prop_eq(install::lib1 HEADER_SET_e "$<$<CONFIG:Debug>:${export_build_dir}/install/include/empty2.h>;$<$<CONFIG:Release>:${export_build_dir}/install/include/empty2.h>") +else() + assert_prop_eq(install::lib1 HEADER_SET_e "${export_build_dir}/install/include/empty2.h") +endif() +assert_prop_eq(install::lib1 HEADER_DIRS_e "${export_build_dir}/install/include") +if(_multi_config) + assert_prop_eq(install::lib1 HEADER_SET_f "$<$<CONFIG:Debug>:${export_build_dir}/install/include/debug/empty3.h>;$<$<CONFIG:Release>:${export_build_dir}/install/include/release/empty3.h>") + assert_prop_eq(install::lib1 HEADER_DIRS_f "$<$<CONFIG:Debug>:${export_build_dir}/install/include/debug>;$<$<CONFIG:Release>:${export_build_dir}/install/include/release>") +else() + assert_prop_eq(install::lib1 HEADER_SET_f "${export_build_dir}/install/include/debug/empty3.h") + assert_prop_eq(install::lib1 HEADER_DIRS_f "${export_build_dir}/install/include/debug") +endif() +assert_prop_eq(install::lib1 HEADER_SET_g "${export_build_dir}/install/include/file1.h;${export_build_dir}/install/include/file2.h") +assert_prop_eq(install::lib1 HEADER_DIRS_g "${export_build_dir}/install/include") +if(_multi_config) + assert_prop_eq(install::lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include/dir>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:$<$<CONFIG:Debug>:${export_build_dir}/install/include/debug>>;$<BUILD_INTERFACE:$<$<CONFIG:Release>:${export_build_dir}/install/include/release>>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include/dir3>") +else() + assert_prop_eq(install::lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include/dir>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include/debug>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include/dir3>") +endif() + +file(GLOB_RECURSE actual + LIST_DIRECTORIES TRUE + RELATIVE "${CMAKE_BINARY_DIR}/../FileSetExport-build/install/include" + "${CMAKE_BINARY_DIR}/../FileSetExport-build/install/include/*" + ) +if(actual) + list(SORT actual) +endif() +if(_multi_config) + set(expect "^debug;debug/empty\\.h;debug/empty3\\.h;dir;dir/dir\\.h;dir3;dir3/dir3\.h;empty2\\.h;error\\.c;file1\\.h;file2\\.h;h2\\.h;release;release/empty\\.h;release/empty3\\.h$") +else() + set(expect "^debug;debug/empty\\.h;debug/empty3\\.h;dir;dir/dir\\.h;dir3;dir3/dir3\.h;empty2\\.h;error\\.c;file1\\.h;file2\\.h;h2\\.h$") +endif() +if(NOT "${actual}" MATCHES "${expect}") + message(SEND_ERROR "Installed files: + ${actual} +do not match what we expected: + ${expect} +in directory: + ${CMAKE_INSTALL_PREFIX}") +endif() + +add_library(lib2_export STATIC lib2.c) +target_link_libraries(lib2_export PRIVATE export::lib1) +add_library(lib2_install STATIC lib2.c) +target_link_libraries(lib2_install PRIVATE install::lib1) diff --git a/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-result.txt b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-stderr.txt b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-stderr.txt new file mode 100644 index 0000000000..694f227cbf --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at FileSetInstallMissingSetsInterface\.cmake:[0-9]+ \(install\): + install TARGETS target lib1 is exported but not all of its file sets are + installed +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface.cmake b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface.cmake new file mode 100644 index 0000000000..face69e4ed --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 INTERFACE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h) +install(TARGETS lib1 EXPORT a) diff --git a/Tests/RunCMake/target_sources/FileSetInstallMissingSetsPrivate.cmake b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsPrivate.cmake new file mode 100644 index 0000000000..84778d104c --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsPrivate.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h) +install(TARGETS lib1 EXPORT a) + +add_library(lib2 STATIC empty.c) +target_sources(lib2 INTERFACE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h) +install(TARGETS lib2) diff --git a/Tests/RunCMake/target_sources/FileSetNoExistInterface-result.txt b/Tests/RunCMake/target_sources/FileSetNoExistInterface-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistInterface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetNoExistInterface-stderr.txt b/Tests/RunCMake/target_sources/FileSetNoExistInterface-stderr.txt new file mode 100644 index 0000000000..3972c89efe --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistInterface-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetNoExistInterface\.cmake:[0-9]+ \(set_property\): + Header set "a" has not yet been created\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoExistInterface.cmake b/Tests/RunCMake/target_sources/FileSetNoExistInterface.cmake new file mode 100644 index 0000000000..266bc6161e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistInterface.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +set_property(TARGET lib1 PROPERTY INTERFACE_HEADER_SETS "a") + +# Error happens at configure-time, so this doesn't help. +target_sources(lib1 INTERFACE FILE_SET a TYPE HEADERS) diff --git a/Tests/RunCMake/target_sources/FileSetNoExistPrivate-result.txt b/Tests/RunCMake/target_sources/FileSetNoExistPrivate-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistPrivate-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetNoExistPrivate-stderr.txt b/Tests/RunCMake/target_sources/FileSetNoExistPrivate-stderr.txt new file mode 100644 index 0000000000..336bafe00c --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistPrivate-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetNoExistPrivate\.cmake:[0-9]+ \(set_property\): + Header set "a" has not yet been created\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoExistPrivate.cmake b/Tests/RunCMake/target_sources/FileSetNoExistPrivate.cmake new file mode 100644 index 0000000000..f501912d1c --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistPrivate.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +set_property(TARGET lib1 PROPERTY HEADER_SETS "a") + +# Error happens at configure-time, so this doesn't help. +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS) diff --git a/Tests/RunCMake/target_sources/FileSetNoScope-result.txt b/Tests/RunCMake/target_sources/FileSetNoScope-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoScope-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetNoScope-stderr.txt b/Tests/RunCMake/target_sources/FileSetNoScope-stderr.txt new file mode 100644 index 0000000000..835ffe7b5f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoScope-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetNoScope\.cmake:[0-9]+ \(target_sources\): + target_sources File set "a" is not in HEADER_SETS or INTERFACE_HEADER_SETS +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoScope.cmake b/Tests/RunCMake/target_sources/FileSetNoScope.cmake new file mode 100644 index 0000000000..79ff341500 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoScope.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h) +set_property(TARGET lib1 PROPERTY HEADER_SETS) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS FILES h2.h) diff --git a/Tests/RunCMake/target_sources/FileSetNoType-result.txt b/Tests/RunCMake/target_sources/FileSetNoType-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoType-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetNoType-stderr.txt b/Tests/RunCMake/target_sources/FileSetNoType-stderr.txt new file mode 100644 index 0000000000..5405fdb778 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoType-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetNoType\.cmake:[0-9]+ \(target_sources\): + target_sources Must specify a TYPE when creating file set +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoType.cmake b/Tests/RunCMake/target_sources/FileSetNoType.cmake new file mode 100644 index 0000000000..961525d5cb --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoType.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a) diff --git a/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-result.txt b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-stderr.txt b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-stderr.txt new file mode 100644 index 0000000000..551b9e7cf7 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at FileSetOverlappingBaseDirs\.cmake:[0-9]+ \(target_sources\): + Base directories in file set cannot be subdirectories of each other: + + [^ +]*/Tests/RunCMake/target_sources/\. + [^ +]*/Tests/RunCMake/target_sources/dir3 +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs.cmake b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs.cmake new file mode 100644 index 0000000000..eba4191cbc --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS $<1:${CMAKE_CURRENT_SOURCE_DIR}/.$<SEMICOLON>${CMAKE_CURRENT_SOURCE_DIR}/dir3> FILES h1.h) diff --git a/Tests/RunCMake/target_sources/FileSetProperties.cmake b/Tests/RunCMake/target_sources/FileSetProperties.cmake new file mode 100644 index 0000000000..ce010a30db --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetProperties.cmake @@ -0,0 +1,67 @@ +enable_language(C) + +function(assert_prop_undef tgt prop) + unset(actual_value) + get_property(actual_value TARGET ${tgt} PROPERTY ${prop}) + if(DEFINED actual_value) + message(SEND_ERROR "${prop} should be undefined, actual value:\n ${actual_value}") + endif() +endfunction() + +function(assert_prop_eq tgt prop value) + unset(actual_value) + get_property(actual_value TARGET ${tgt} PROPERTY ${prop}) + if(NOT actual_value STREQUAL value) + message(SEND_ERROR "Expected value of ${prop}:\n ${value}\nActual value:\n ${actual_value}") + endif() +endfunction() + +add_library(lib1 STATIC empty.c) +assert_prop_eq(lib1 HEADER_SETS "") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "") +assert_prop_undef(lib1 INCLUDE_DIRECTORIES) +assert_prop_undef(lib1 INTERFACE_INCLUDE_DIRECTORIES) + +target_sources(lib1 PUBLIC FILE_SET a TYPE HEADERS BASE_DIRS "." FILES h1.h h2.h) +assert_prop_eq(lib1 HEADER_SETS "a") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a") +assert_prop_eq(lib1 HEADER_DIRS_a "${CMAKE_CURRENT_SOURCE_DIR}/.") +assert_prop_eq(lib1 HEADER_SET_a "${CMAKE_CURRENT_SOURCE_DIR}/h1.h;${CMAKE_CURRENT_SOURCE_DIR}/h2.h") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>") + +target_sources(lib1 PUBLIC FILE_SET a FILES h3.h) +assert_prop_eq(lib1 HEADER_SETS "a") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a") +assert_prop_eq(lib1 HEADER_DIRS_a "${CMAKE_CURRENT_SOURCE_DIR}/.") +assert_prop_eq(lib1 HEADER_SET_a "${CMAKE_CURRENT_SOURCE_DIR}/h1.h;${CMAKE_CURRENT_SOURCE_DIR}/h2.h;${CMAKE_CURRENT_SOURCE_DIR}/h3.h") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>") + +target_sources(lib1 PRIVATE FILE_SET b TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/dir" FILES dir/dir.h) +assert_prop_eq(lib1 HEADER_SETS "a;b") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a") +assert_prop_eq(lib1 HEADER_DIRS_b "${CMAKE_CURRENT_SOURCE_DIR}/dir") +assert_prop_eq(lib1 HEADER_SET_b "${CMAKE_CURRENT_SOURCE_DIR}/dir/dir.h") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>") + +target_sources(lib1 INTERFACE FILE_SET c TYPE HEADERS) +assert_prop_eq(lib1 HEADER_SETS "a;b") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a;c") +assert_prop_eq(lib1 HEADER_DIRS_c "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(lib1 HEADER_SET_c "") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") + +target_sources(lib1 PUBLIC FILE_SET HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES h1.h) +assert_prop_eq(lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/h1.h") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") + +target_sources(lib1 PUBLIC FILE_SET HEADERS FILES h2.h) +assert_prop_eq(lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/h1.h;${CMAKE_CURRENT_SOURCE_DIR}/h2.h") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-result.txt b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-stderr.txt b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-stderr.txt new file mode 100644 index 0000000000..f4bd4471ad --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at FileSetWrongBaseDirs\.cmake:[0-9]+ \(target_sources\): + File: + + [^ +]*/Tests/RunCMake/target_sources/h1\.h + + must be in one of the file set's base directories: + + [^ +]*/Tests/RunCMake/target_sources/dir3 +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirs.cmake b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs.cmake new file mode 100644 index 0000000000..38d3abdbb4 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/dir3 FILES h1.h) diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-result.txt b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-stderr.txt b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-stderr.txt new file mode 100644 index 0000000000..6bb0ec64aa --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at reldir/CMakeLists\.txt:[0-9]+ \(target_sources\): + File: + + [^ +]*/Tests/RunCMake/target_sources/reldir/\.\./h1\.h + + must be in one of the file set's base directories: + + [^ +]*/Tests/RunCMake/target_sources/reldir/\. diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative.cmake b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative.cmake new file mode 100644 index 0000000000..2ca8a8e4d6 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +add_subdirectory(reldir) diff --git a/Tests/RunCMake/target_sources/FileSetWrongType-result.txt b/Tests/RunCMake/target_sources/FileSetWrongType-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongType-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetWrongType-stderr.txt b/Tests/RunCMake/target_sources/FileSetWrongType-stderr.txt new file mode 100644 index 0000000000..8ffa786183 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongType-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetWrongType\.cmake:[0-9]+ \(target_sources\): + target_sources File set TYPE may only be "HEADERS" +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetWrongType.cmake b/Tests/RunCMake/target_sources/FileSetWrongType.cmake new file mode 100644 index 0000000000..b7dee72e9c --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongType.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE UNKNOWN) diff --git a/Tests/RunCMake/target_sources/OriginDebug-result.txt b/Tests/RunCMake/target_sources/OriginDebug-result.txt new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/Tests/RunCMake/target_sources/OriginDebug-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/target_sources/OriginDebug-stderr.txt b/Tests/RunCMake/target_sources/OriginDebug-stderr.txt new file mode 100644 index 0000000000..502d5f1536 --- /dev/null +++ b/Tests/RunCMake/target_sources/OriginDebug-stderr.txt @@ -0,0 +1,31 @@ +CMake Debug Log at OriginDebug.cmake:13 \(add_library\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/target_sources/empty_2.cpp + +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) +.* +CMake Debug Log at OriginDebug.cmake:16 \(set_property\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/target_sources/empty_3.cpp + +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) +.* +CMake Debug Log at OriginDebug.cmake:20 \(target_sources\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/target_sources/empty_4.cpp + +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) +.* +CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/target_sources/empty_1.cpp + +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_sources/OriginDebug.cmake b/Tests/RunCMake/target_sources/OriginDebug.cmake new file mode 100644 index 0000000000..d40a1d82a9 --- /dev/null +++ b/Tests/RunCMake/target_sources/OriginDebug.cmake @@ -0,0 +1,20 @@ + +cmake_minimum_required(VERSION 3.0) + +project(OriginDebug) + +set(CMAKE_DEBUG_TARGET_PROPERTIES SOURCES) + +add_library(iface INTERFACE) +set_property(TARGET iface PROPERTY INTERFACE_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/empty_1.cpp" +) + +add_library(OriginDebug empty_2.cpp) +target_link_libraries(OriginDebug iface) + +set_property(TARGET OriginDebug APPEND PROPERTY SOURCES + empty_3.cpp +) + +target_sources(OriginDebug PRIVATE empty_4.cpp) diff --git a/Tests/RunCMake/target_sources/RelativePathInInterface-stdout.txt b/Tests/RunCMake/target_sources/RelativePathInInterface-stdout.txt new file mode 100644 index 0000000000..19818b8b42 --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInInterface-stdout.txt @@ -0,0 +1 @@ +-- iface: .*Tests/RunCMake/target_sources/empty_1.cpp diff --git a/Tests/RunCMake/target_sources/RelativePathInInterface.cmake b/Tests/RunCMake/target_sources/RelativePathInInterface.cmake new file mode 100644 index 0000000000..25b22ddc6a --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInInterface.cmake @@ -0,0 +1,11 @@ +cmake_policy(SET CMP0076 NEW) +enable_language(CXX) + +add_library(iface INTERFACE) +target_sources(iface INTERFACE empty_1.cpp) + +get_property(iface_sources TARGET iface PROPERTY INTERFACE_SOURCES) +message(STATUS "iface: ${iface_sources}") + +add_executable(main main.cpp) +target_link_libraries(main iface) diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx-stdout.txt b/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx-stdout.txt new file mode 100644 index 0000000000..a51a792598 --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx-stdout.txt @@ -0,0 +1 @@ +-- genexlib: \$<1:.*Tests/RunCMake/target_sources/RelativePathInSubdirGenEx/subdir_empty_1.cpp>;\$<1:.*Tests/RunCMake/target_sources/RelativePathInSubdirGenEx/../empty_1.cpp>;\$<1:empty_2.cpp> diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx.cmake b/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx.cmake new file mode 100644 index 0000000000..9afcea56aa --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx.cmake @@ -0,0 +1,11 @@ +cmake_policy(SET CMP0076 NEW) +enable_language(CXX) + +add_library(genexlib) +add_subdirectory(RelativePathInSubdirGenEx) + +get_property(genexlib_sources TARGET genexlib PROPERTY SOURCES) +message(STATUS "genexlib: ${genexlib_sources}") + +add_executable(genexmain main.cpp) +target_link_libraries(genexmain genexlib) diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx/CMakeLists.txt b/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx/CMakeLists.txt new file mode 100644 index 0000000000..3bcf454da5 --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx/CMakeLists.txt @@ -0,0 +1,4 @@ + +target_sources(genexlib PUBLIC $<1:${CMAKE_CURRENT_LIST_DIR}/subdir_empty_1.cpp> + $<1:${CMAKE_CURRENT_LIST_DIR}/../empty_1.cpp> + PRIVATE $<1:empty_2.cpp>) diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx/subdir_empty_1.cpp b/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx/subdir_empty_1.cpp new file mode 100644 index 0000000000..11ec041d1e --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirGenEx/subdir_empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirInclude-stdout.txt b/Tests/RunCMake/target_sources/RelativePathInSubdirInclude-stdout.txt new file mode 100644 index 0000000000..c42c88b475 --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirInclude-stdout.txt @@ -0,0 +1 @@ +-- privatelib: .*Tests/RunCMake/target_sources/RelativePathInSubdirInclude/subdir_empty_1.cpp;empty_1.cpp diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirInclude.cmake b/Tests/RunCMake/target_sources/RelativePathInSubdirInclude.cmake new file mode 100644 index 0000000000..f5954c47bc --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirInclude.cmake @@ -0,0 +1,9 @@ +cmake_policy(SET CMP0076 NEW) +enable_language(CXX) + +add_library(privatelib) + +include("RelativePathInSubdirInclude/CMakeLists.txt") + +get_property(privatelib_sources TARGET privatelib PROPERTY SOURCES) +message(STATUS "privatelib: ${privatelib_sources}") diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirInclude/CMakeLists.txt b/Tests/RunCMake/target_sources/RelativePathInSubdirInclude/CMakeLists.txt new file mode 100644 index 0000000000..3dcb13545a --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirInclude/CMakeLists.txt @@ -0,0 +1,3 @@ + +target_sources(privatelib PRIVATE "${CMAKE_CURRENT_LIST_DIR}/subdir_empty_1.cpp" + empty_1.cpp) diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirInclude/subdir_empty_1.cpp b/Tests/RunCMake/target_sources/RelativePathInSubdirInclude/subdir_empty_1.cpp new file mode 100644 index 0000000000..11ec041d1e --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirInclude/subdir_empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirInterface-stdout.txt b/Tests/RunCMake/target_sources/RelativePathInSubdirInterface-stdout.txt new file mode 100644 index 0000000000..ebbb29fb3c --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirInterface-stdout.txt @@ -0,0 +1 @@ +-- iface: .*Tests/RunCMake/target_sources/RelativePathInSubdirInterface/subdir_empty_1.cpp;.*Tests/RunCMake/target_sources/RelativePathInSubdirInterface/subdir_empty_2.cpp;.*Tests/RunCMake/target_sources/RelativePathInSubdirInterface/../empty_1.cpp;.*Tests/RunCMake/target_sources/RelativePathInSubdirInterface/../empty_2.cpp diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirInterface.cmake b/Tests/RunCMake/target_sources/RelativePathInSubdirInterface.cmake new file mode 100644 index 0000000000..6a4e2006d2 --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirInterface.cmake @@ -0,0 +1,12 @@ +cmake_policy(SET CMP0076 NEW) +enable_language(CXX) + +add_library(iface INTERFACE) + +add_subdirectory(RelativePathInSubdirInterface) + +get_property(iface_sources TARGET iface PROPERTY INTERFACE_SOURCES) +message(STATUS "iface: ${iface_sources}") + +add_executable(main main.cpp) +target_link_libraries(main iface) diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirInterface/CMakeLists.txt b/Tests/RunCMake/target_sources/RelativePathInSubdirInterface/CMakeLists.txt new file mode 100644 index 0000000000..02e69669e5 --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirInterface/CMakeLists.txt @@ -0,0 +1,5 @@ + +target_sources(iface INTERFACE subdir_empty_1.cpp + "${CMAKE_CURRENT_LIST_DIR}/subdir_empty_2.cpp" + ../empty_1.cpp + "${CMAKE_CURRENT_LIST_DIR}/../empty_2.cpp") diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirInterface/subdir_empty_1.cpp b/Tests/RunCMake/target_sources/RelativePathInSubdirInterface/subdir_empty_1.cpp new file mode 100644 index 0000000000..11ec041d1e --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirInterface/subdir_empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirInterface/subdir_empty_2.cpp b/Tests/RunCMake/target_sources/RelativePathInSubdirInterface/subdir_empty_2.cpp new file mode 100644 index 0000000000..11ec041d1e --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirInterface/subdir_empty_2.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate-stdout.txt b/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate-stdout.txt new file mode 100644 index 0000000000..104f1de240 --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate-stdout.txt @@ -0,0 +1 @@ +-- privatelib: .*Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/subdir_empty_1.cpp;.*Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/subdir_empty_2.cpp;.*Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/../empty_1.cpp;.*Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/../empty_2.cpp diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate.cmake b/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate.cmake new file mode 100644 index 0000000000..dd16e3f8a0 --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate.cmake @@ -0,0 +1,9 @@ +cmake_policy(SET CMP0076 NEW) +enable_language(CXX) + +add_library(privatelib) + +add_subdirectory(RelativePathInSubdirPrivate) + +get_property(privatelib_sources TARGET privatelib PROPERTY SOURCES) +message(STATUS "privatelib: ${privatelib_sources}") diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/CMakeLists.txt b/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/CMakeLists.txt new file mode 100644 index 0000000000..56ee853e1c --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/CMakeLists.txt @@ -0,0 +1,5 @@ + +target_sources(privatelib PRIVATE subdir_empty_1.cpp + "${CMAKE_CURRENT_LIST_DIR}/subdir_empty_2.cpp" + ../empty_1.cpp + "${CMAKE_CURRENT_LIST_DIR}/../empty_2.cpp") diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/subdir_empty_1.cpp b/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/subdir_empty_1.cpp new file mode 100644 index 0000000000..11ec041d1e --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/subdir_empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/subdir_empty_2.cpp b/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/subdir_empty_2.cpp new file mode 100644 index 0000000000..11ec041d1e --- /dev/null +++ b/Tests/RunCMake/target_sources/RelativePathInSubdirPrivate/subdir_empty_2.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/RunCMakeTest.cmake b/Tests/RunCMake/target_sources/RunCMakeTest.cmake index b67c5983eb..9828fa21bd 100644 --- a/Tests/RunCMake/target_sources/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_sources/RunCMakeTest.cmake @@ -1,3 +1,80 @@ include(RunCMake) -run_cmake(empty_keyword_args) +if(RunCMake_GENERATOR STREQUAL "Xcode") + run_cmake(ConfigNotAllowed) +endif() + +run_cmake(EmptyKeywordArgs) +run_cmake(OriginDebug) +run_cmake(CMP0026-LOCATION) +run_cmake(CMP0076-OLD) +run_cmake(CMP0076-WARN) +run_cmake(RelativePathInInterface) +run_cmake(RelativePathInSubdirGenEx) +run_cmake(RelativePathInSubdirInterface) +run_cmake(RelativePathInSubdirPrivate) +run_cmake(RelativePathInSubdirInclude) +run_cmake(ExportBuild) +run_cmake(AddCustomTargetPublicSources) +run_cmake(AddCustomTargetPrivateSources) +run_cmake(AddCustomTargetInterfaceSources) +run_cmake(AddCustomTargetSources) +run_cmake(AddCustomTargetCheckProperty) +run_cmake(AddCustomTargetGenx) + +run_cmake(FileSetProperties) +run_cmake(FileSetNoType) +run_cmake(FileSetWrongType) +run_cmake(FileSetDefaultWrongType) +run_cmake(FileSetChangeScope) +run_cmake(FileSetChangeType) +run_cmake(FileSetWrongBaseDirs) +run_cmake(FileSetWrongBaseDirsRelative) +run_cmake(FileSetOverlappingBaseDirs) +run_cmake(FileSetInstallMissingSetsPrivate) +run_cmake(FileSetInstallMissingSetsInterface) +run_cmake(FileSetNoScope) +run_cmake(FileSetNoExistPrivate) +run_cmake(FileSetNoExistInterface) +run_cmake(FileSetDirectories) + +set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0115=NEW) +run_cmake(FileSetFileNoExist) +unset(RunCMake_TEST_OPTIONS) + +function(run_export_import name) + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(_config_options "-DCMAKE_CONFIGURATION_TYPES=Debug\\\\;Release") + else() + set(_config_options -DCMAKE_BUILD_TYPE=Debug) + endif() + + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}Export-build") + set(RunCMake_TEST_OPTIONS "--install-prefix=${RunCMake_TEST_BINARY_DIR}/install" ${_config_options}) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${name}Export) + run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --build . --config Debug) + run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --install . --config Debug) + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --build . --config Release) + run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --install . --config Release) + endif() + unset(RunCMake_TEST_OPTIONS) + + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}Import-build") + unset(RunCMake_TEST_OPTIONS) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${name}Import) + run_cmake_command(${name}Import-build ${CMAKE_COMMAND} --build . --config Debug) + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + run_cmake_command(${name}Import-build ${CMAKE_COMMAND} --build . --config Release) + endif() + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endfunction() + +run_export_import(FileSet) diff --git a/Tests/RunCMake/target_sources/debug/empty.h b/Tests/RunCMake/target_sources/debug/empty.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/debug/empty.h diff --git a/Tests/RunCMake/target_sources/debug/empty2.h b/Tests/RunCMake/target_sources/debug/empty2.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/debug/empty2.h diff --git a/Tests/RunCMake/target_sources/dir/dir.h b/Tests/RunCMake/target_sources/dir/dir.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir/dir.h diff --git a/Tests/RunCMake/target_sources/dir1/file1.h b/Tests/RunCMake/target_sources/dir1/file1.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir1/file1.h diff --git a/Tests/RunCMake/target_sources/dir2/file2.h b/Tests/RunCMake/target_sources/dir2/file2.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir2/file2.h diff --git a/Tests/RunCMake/target_sources/dir3/CMakeLists.txt b/Tests/RunCMake/target_sources/dir3/CMakeLists.txt new file mode 100644 index 0000000000..e23ceb8266 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir3/CMakeLists.txt @@ -0,0 +1 @@ +add_library(lib1 STATIC ../empty.c) diff --git a/Tests/RunCMake/target_sources/dir3/dir3.h b/Tests/RunCMake/target_sources/dir3/dir3.h new file mode 100644 index 0000000000..e45c25a12a --- /dev/null +++ b/Tests/RunCMake/target_sources/dir3/dir3.h @@ -0,0 +1,4 @@ +#ifndef DIR3_H +#define DIR3_H + +#endif diff --git a/Tests/RunCMake/target_sources/dir4/CMakeLists.txt b/Tests/RunCMake/target_sources/dir4/CMakeLists.txt new file mode 100644 index 0000000000..6475685c84 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir4/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(lib1 PRIVATE FILE_SET HEADERS BASE_DIRS ${CMAKE_SOURCE_DIR} FILES + $<1:dir3.h> + dir4.h + ) diff --git a/Tests/RunCMake/target_sources/dir4/dir4.h b/Tests/RunCMake/target_sources/dir4/dir4.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir4/dir4.h diff --git a/Tests/RunCMake/target_sources/empty.c b/Tests/RunCMake/target_sources/empty.c new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/empty.c diff --git a/Tests/RunCMake/target_sources/empty3.h b/Tests/RunCMake/target_sources/empty3.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/empty3.h diff --git a/Tests/RunCMake/target_sources/empty_1.cpp b/Tests/RunCMake/target_sources/empty_1.cpp new file mode 100644 index 0000000000..11ec041d1e --- /dev/null +++ b/Tests/RunCMake/target_sources/empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/empty_2.cpp b/Tests/RunCMake/target_sources/empty_2.cpp new file mode 100644 index 0000000000..11ec041d1e --- /dev/null +++ b/Tests/RunCMake/target_sources/empty_2.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/empty_3.cpp b/Tests/RunCMake/target_sources/empty_3.cpp new file mode 100644 index 0000000000..11ec041d1e --- /dev/null +++ b/Tests/RunCMake/target_sources/empty_3.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/empty_4.cpp b/Tests/RunCMake/target_sources/empty_4.cpp new file mode 100644 index 0000000000..11ec041d1e --- /dev/null +++ b/Tests/RunCMake/target_sources/empty_4.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/error.c b/Tests/RunCMake/target_sources/error.c new file mode 100644 index 0000000000..f10e687006 --- /dev/null +++ b/Tests/RunCMake/target_sources/error.c @@ -0,0 +1 @@ +#error "This should not be compiled" diff --git a/Tests/RunCMake/target_sources/h1.h b/Tests/RunCMake/target_sources/h1.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/h1.h diff --git a/Tests/RunCMake/target_sources/h2.h b/Tests/RunCMake/target_sources/h2.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/h2.h diff --git a/Tests/RunCMake/target_sources/h3.h b/Tests/RunCMake/target_sources/h3.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/h3.h diff --git a/Tests/RunCMake/target_sources/lib1.c b/Tests/RunCMake/target_sources/lib1.c new file mode 100644 index 0000000000..95042def18 --- /dev/null +++ b/Tests/RunCMake/target_sources/lib1.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + void lib1(void) +{ +} diff --git a/Tests/RunCMake/target_sources/lib2.c b/Tests/RunCMake/target_sources/lib2.c new file mode 100644 index 0000000000..a060dc9c7d --- /dev/null +++ b/Tests/RunCMake/target_sources/lib2.c @@ -0,0 +1,8 @@ +#include <dir3.h> + +#ifdef _WIN32 +__declspec(dllexport) +#endif + void lib2(void) +{ +} diff --git a/Tests/RunCMake/target_sources/main.cpp b/Tests/RunCMake/target_sources/main.cpp new file mode 100644 index 0000000000..766b7751bf --- /dev/null +++ b/Tests/RunCMake/target_sources/main.cpp @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/target_sources/reldir/CMakeLists.txt b/Tests/RunCMake/target_sources/reldir/CMakeLists.txt new file mode 100644 index 0000000000..df22b25273 --- /dev/null +++ b/Tests/RunCMake/target_sources/reldir/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(lib1 STATIC ../empty.c) +target_sources(lib1 PRIVATE FILE_SET HEADERS BASE_DIRS . FILES ../h1.h) diff --git a/Tests/RunCMake/target_sources/release/empty.h b/Tests/RunCMake/target_sources/release/empty.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/release/empty.h diff --git a/Tests/RunCMake/target_sources/release/empty2.h b/Tests/RunCMake/target_sources/release/empty2.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_sources/release/empty2.h |