mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 15:20:56 -06:00
Tests: Add tests for missing sources in add_executable and add_library.
This commit is contained in:
@@ -180,6 +180,8 @@ add_RunCMake_test(Syntax)
|
||||
add_RunCMake_test(add_custom_command)
|
||||
add_RunCMake_test(add_custom_target)
|
||||
add_RunCMake_test(add_dependencies)
|
||||
add_RunCMake_test(add_executable)
|
||||
add_RunCMake_test(add_library)
|
||||
add_RunCMake_test(add_subdirectory)
|
||||
add_RunCMake_test(build_command)
|
||||
add_executable(exit_code exit_code.c)
|
||||
|
||||
3
Tests/RunCMake/add_executable/CMakeLists.txt
Normal file
3
Tests/RunCMake/add_executable/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
1
Tests/RunCMake/add_executable/NoSources-result.txt
Normal file
1
Tests/RunCMake/add_executable/NoSources-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
4
Tests/RunCMake/add_executable/NoSources-stderr.txt
Normal file
4
Tests/RunCMake/add_executable/NoSources-stderr.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
^CMake Error at NoSources.cmake:[0-9]+ \(add_executable\):
|
||||
add_executable called with incorrect number of arguments
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)$
|
||||
1
Tests/RunCMake/add_executable/NoSources.cmake
Normal file
1
Tests/RunCMake/add_executable/NoSources.cmake
Normal file
@@ -0,0 +1 @@
|
||||
add_executable(TestExeWithoutSources)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,11 @@
|
||||
^CMake Error at NoSourcesButLinkObjects.cmake:[0-9]+ \(add_executable\):
|
||||
add_executable called with incorrect number of arguments
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
|
||||
|
||||
CMake Error at NoSourcesButLinkObjects.cmake:[0-9]+ \(target_link_libraries\):
|
||||
Cannot specify link libraries for target \"TestExeWithoutSources\" which is
|
||||
not built by this project.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)$
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_executable(TestExeWithoutSources)
|
||||
target_link_libraries(TestExeWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
11
Tests/RunCMake/add_executable/OnlyObjectSources-stderr.txt
Normal file
11
Tests/RunCMake/add_executable/OnlyObjectSources-stderr.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
^CMake Error at OnlyObjectSources.cmake:[0-9]+ \(add_executable\):
|
||||
add_executable called with incorrect number of arguments
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
|
||||
|
||||
CMake Error at OnlyObjectSources.cmake:[0-9]+ \(target_sources\):
|
||||
Cannot specify sources for target \"TestExeWithoutSources\" which is not
|
||||
built by this project.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)$
|
||||
5
Tests/RunCMake/add_executable/OnlyObjectSources.cmake
Normal file
5
Tests/RunCMake/add_executable/OnlyObjectSources.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_executable(TestExeWithoutSources)
|
||||
target_sources(TestExeWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
5
Tests/RunCMake/add_executable/RunCMakeTest.cmake
Normal file
5
Tests/RunCMake/add_executable/RunCMakeTest.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(NoSources)
|
||||
run_cmake(OnlyObjectSources)
|
||||
run_cmake(NoSourcesButLinkObjects)
|
||||
0
Tests/RunCMake/add_executable/test.cpp
Normal file
0
Tests/RunCMake/add_executable/test.cpp
Normal file
3
Tests/RunCMake/add_library/CMakeLists.txt
Normal file
3
Tests/RunCMake/add_library/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
1
Tests/RunCMake/add_library/INTERFACEwithNoSources.cmake
Normal file
1
Tests/RunCMake/add_library/INTERFACEwithNoSources.cmake
Normal file
@@ -0,0 +1 @@
|
||||
add_library(TestInterfaceLibWithoutSources INTERFACE)
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestInterfaceLibWithoutSources INTERFACE)
|
||||
target_link_libraries(TestInterfaceLibWithoutSources INTERFACE $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestInterfaceLibWithoutSources INTERFACE)
|
||||
target_sources(TestInterfaceLibWithoutSources INTERFACE $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,3 @@
|
||||
^You have called ADD_LIBRARY for library TestModuleLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file(
|
||||
CMake Error: CMake can not determine linker language for target: TestModuleLibWithoutSources)+(
|
||||
CMake Error: Cannot determine link language for target \"TestModuleLibWithoutSources\".)?$
|
||||
1
Tests/RunCMake/add_library/MODULEwithNoSources.cmake
Normal file
1
Tests/RunCMake/add_library/MODULEwithNoSources.cmake
Normal file
@@ -0,0 +1 @@
|
||||
add_library(TestModuleLibWithoutSources MODULE)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,3 @@
|
||||
^You have called ADD_LIBRARY for library TestModuleLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file(
|
||||
CMake Error: CMake can not determine linker language for target: TestModuleLibWithoutSources)+(
|
||||
CMake Error: Cannot determine link language for target \"TestModuleLibWithoutSources\".)*$
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestModuleLibWithoutSources MODULE)
|
||||
target_link_libraries(TestModuleLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
@@ -0,0 +1 @@
|
||||
^You have called ADD_LIBRARY for library TestModuleLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file$
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestModuleLibWithoutSources MODULE)
|
||||
target_sources(TestModuleLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
@@ -0,0 +1 @@
|
||||
.
|
||||
@@ -0,0 +1,2 @@
|
||||
^You have called ADD_LIBRARY for library TestObjectLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file(
|
||||
CMake Error: CMake can not determine linker language for target: TestObjectLibWithoutSources)*$
|
||||
1
Tests/RunCMake/add_library/OBJECTwithNoSources.cmake
Normal file
1
Tests/RunCMake/add_library/OBJECTwithNoSources.cmake
Normal file
@@ -0,0 +1 @@
|
||||
add_library(TestObjectLibWithoutSources OBJECT)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,6 @@
|
||||
^You have called ADD_LIBRARY for library TestObjectLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file
|
||||
CMake Error at OBJECTwithNoSourcesButLinkObjects.cmake:[0-9]+ \(target_link_libraries\):
|
||||
Object library target \"TestObjectLibWithoutSources\" may not link to
|
||||
anything.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)$
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestObjectLibWithoutSources OBJECT)
|
||||
target_link_libraries(TestObjectLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,17 @@
|
||||
^You have called ADD_LIBRARY for library TestObjectLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file
|
||||
CMake Error at OBJECTwithOnlyObjectSources.cmake:[0-9]+ \(add_library\):
|
||||
OBJECT library \"TestObjectLibWithoutSources\" contains:
|
||||
|
||||
[^
|
||||
]*test(\.cpp)?\.o(bj)?
|
||||
|
||||
but may contain only sources that compile, header files, and other files
|
||||
that would not affect linking of a normal library.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
|
||||
|
||||
CMake Error at OBJECTwithOnlyObjectSources.cmake:[0-9]+ \(add_library\):
|
||||
Only executables and non-OBJECT libraries may reference target objects.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)$
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestObjectLibWithoutSources OBJECT)
|
||||
target_sources(TestObjectLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
24
Tests/RunCMake/add_library/RunCMakeTest.cmake
Normal file
24
Tests/RunCMake/add_library/RunCMakeTest.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(INTERFACEwithNoSources)
|
||||
run_cmake(OBJECTwithNoSources)
|
||||
run_cmake(STATICwithNoSources)
|
||||
run_cmake(SHAREDwithNoSources)
|
||||
run_cmake(MODULEwithNoSources)
|
||||
run_cmake(UNKNOWNwithNoSources)
|
||||
|
||||
run_cmake(INTERFACEwithOnlyObjectSources)
|
||||
run_cmake(OBJECTwithOnlyObjectSources)
|
||||
run_cmake(STATICwithOnlyObjectSources)
|
||||
run_cmake(SHAREDwithOnlyObjectSources)
|
||||
run_cmake(MODULEwithOnlyObjectSources)
|
||||
run_cmake(UNKNOWNwithOnlyObjectSources)
|
||||
|
||||
if(NOT RunCMake_GENERATOR STREQUAL "Xcode" OR NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
|
||||
run_cmake(INTERFACEwithNoSourcesButLinkObjects)
|
||||
run_cmake(OBJECTwithNoSourcesButLinkObjects)
|
||||
run_cmake(STATICwithNoSourcesButLinkObjects)
|
||||
run_cmake(SHAREDwithNoSourcesButLinkObjects)
|
||||
run_cmake(MODULEwithNoSourcesButLinkObjects)
|
||||
run_cmake(UNKNOWNwithNoSourcesButLinkObjects)
|
||||
endif()
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,3 @@
|
||||
^You have called ADD_LIBRARY for library TestSharedLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file(
|
||||
CMake Error: CMake can not determine linker language for target: TestSharedLibWithoutSources)+(
|
||||
CMake Error: Cannot determine link language for target \"TestSharedLibWithoutSources\".)*$
|
||||
1
Tests/RunCMake/add_library/SHAREDwithNoSources.cmake
Normal file
1
Tests/RunCMake/add_library/SHAREDwithNoSources.cmake
Normal file
@@ -0,0 +1 @@
|
||||
add_library(TestSharedLibWithoutSources SHARED)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,3 @@
|
||||
^You have called ADD_LIBRARY for library TestSharedLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file(
|
||||
CMake Error: CMake can not determine linker language for target: TestSharedLibWithoutSources)+(
|
||||
CMake Error: Cannot determine link language for target \"TestSharedLibWithoutSources\".)*$
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestSharedLibWithoutSources SHARED)
|
||||
target_link_libraries(TestSharedLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
@@ -0,0 +1 @@
|
||||
^You have called ADD_LIBRARY for library TestSharedLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file$
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestSharedLibWithoutSources SHARED)
|
||||
target_sources(TestSharedLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,3 @@
|
||||
^You have called ADD_LIBRARY for library TestStaticLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file(
|
||||
CMake Error: Cannot determine link language for target \"TestStaticLibWithoutSources\".)?(
|
||||
CMake Error: CMake can not determine linker language for target: TestStaticLibWithoutSources)+$
|
||||
1
Tests/RunCMake/add_library/STATICwithNoSources.cmake
Normal file
1
Tests/RunCMake/add_library/STATICwithNoSources.cmake
Normal file
@@ -0,0 +1 @@
|
||||
add_library(TestStaticLibWithoutSources STATIC)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,3 @@
|
||||
^You have called ADD_LIBRARY for library TestStaticLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file(
|
||||
CMake Error: Cannot determine link language for target \"TestStaticLibWithoutSources\".)?(
|
||||
CMake Error: CMake can not determine linker language for target: TestStaticLibWithoutSources)+$
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestStaticLibWithoutSources STATIC)
|
||||
target_link_libraries(TestStaticLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
@@ -0,0 +1 @@
|
||||
^You have called ADD_LIBRARY for library TestStaticLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file$
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestStaticLibWithoutSources STATIC)
|
||||
target_sources(TestStaticLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
1
Tests/RunCMake/add_library/UNKNOWNwithNoSources.cmake
Normal file
1
Tests/RunCMake/add_library/UNKNOWNwithNoSources.cmake
Normal file
@@ -0,0 +1 @@
|
||||
add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
^CMake Error at UNKNOWNwithNoSourcesButLinkObjects.cmake:[0-9]+ \(target_link_libraries\):
|
||||
Cannot specify link libraries for target \"TestUnknownLibWithoutSources\"
|
||||
which is not built by this project.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)$
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED)
|
||||
target_link_libraries(TestUnknownLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,4 @@
|
||||
^CMake Error at UNKNOWNwithOnlyObjectSources.cmake:[0-9]+ \(target_sources\):
|
||||
target_sources called with non-compilable target type
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)$
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED)
|
||||
target_sources(TestUnknownLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
0
Tests/RunCMake/add_library/test.cpp
Normal file
0
Tests/RunCMake/add_library/test.cpp
Normal file
Reference in New Issue
Block a user