Commit 55ed21e7 authored by Deniz Bahadir's avatar Deniz Bahadir Committed by Brad King

Tests: Add tests for missing sources in add_executable and add_library.

parent 90b931e1
......@@ -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)
......
cmake_minimum_required(VERSION 3.1)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
^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\)$
add_executable(TestExeWithoutSources)
^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\)$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_executable(TestExeWithoutSources)
target_link_libraries(TestExeWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
^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\)$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_executable(TestExeWithoutSources)
target_sources(TestExeWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
include(RunCMake)
run_cmake(NoSources)
run_cmake(OnlyObjectSources)
run_cmake(NoSourcesButLinkObjects)
cmake_minimum_required(VERSION 3.1)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
add_library(TestInterfaceLibWithoutSources INTERFACE)
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestInterfaceLibWithoutSources INTERFACE)
target_link_libraries(TestInterfaceLibWithoutSources INTERFACE $<TARGET_OBJECTS:ObjectLibDependency>)
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestInterfaceLibWithoutSources INTERFACE)
target_sources(TestInterfaceLibWithoutSources INTERFACE $<TARGET_OBJECTS:ObjectLibDependency>)
^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\".)?$
add_library(TestModuleLibWithoutSources MODULE)
^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\".)*$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestModuleLibWithoutSources MODULE)
target_link_libraries(TestModuleLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
^You have called ADD_LIBRARY for library TestModuleLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestModuleLibWithoutSources MODULE)
target_sources(TestModuleLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
^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)*$
add_library(TestObjectLibWithoutSources OBJECT)
^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\)$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestObjectLibWithoutSources OBJECT)
target_link_libraries(TestObjectLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
^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\)$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestObjectLibWithoutSources OBJECT)
target_sources(TestObjectLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
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()
^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\".)*$
add_library(TestSharedLibWithoutSources SHARED)
^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\".)*$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestSharedLibWithoutSources SHARED)
target_link_libraries(TestSharedLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
^You have called ADD_LIBRARY for library TestSharedLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestSharedLibWithoutSources SHARED)
target_sources(TestSharedLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
^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)+$
add_library(TestStaticLibWithoutSources STATIC)
^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)+$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestStaticLibWithoutSources STATIC)
target_link_libraries(TestStaticLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
^You have called ADD_LIBRARY for library TestStaticLibWithoutSources without any source files. This typically indicates a problem with your CMakeLists.txt file$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestStaticLibWithoutSources STATIC)
target_sources(TestStaticLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED)
^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\)$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED)
target_link_libraries(TestUnknownLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
^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\)$
enable_language(CXX)
add_library(ObjectLibDependency OBJECT test.cpp)
add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED)
target_sources(TestUnknownLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment