Tests: add tests for empty-value keyword arguments in target_*

Not all of these commands accept non-compilable (i.e., IMPORTED)
targets, so those calls are currently just commented out. If they ever
do start to accept them, the tests should be enabled.
This commit is contained in:
Ben Boeckel
2018-10-26 09:11:42 -04:00
parent 9e78be8065
commit 4201a11c2b
36 changed files with 128 additions and 0 deletions

View File

@@ -342,11 +342,16 @@ endif()
add_RunCMake_test(File_Generate)
add_RunCMake_test(ExportWithoutLanguage)
add_RunCMake_test(target_link_directories)
add_RunCMake_test(target_link_libraries)
add_RunCMake_test(add_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
add_RunCMake_test(target_compile_definitions)
add_RunCMake_test(target_compile_features)
add_RunCMake_test(target_compile_options)
add_RunCMake_test(target_include_directories)
add_RunCMake_test(target_sources)
add_RunCMake_test(CheckModules)
add_RunCMake_test(CheckIPOSupported)
add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})

View File

@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.11)
project(${RunCMake_TEST} LANGUAGES NONE)
include(${RunCMake_TEST}.cmake)

View File

@@ -0,0 +1,3 @@
include(RunCMake)
run_cmake(empty_keyword_args)

View File

@@ -0,0 +1,5 @@
CMake Error at empty_keyword_args.cmake:2 \(target_compile_definitions\):
target_compile_definitions may only set INTERFACE properties on INTERFACE
targets
Call Stack \(most recent call first\):
CMakeLists.txt:5 \(include\)

View File

@@ -0,0 +1,5 @@
add_library(iface INTERFACE)
target_compile_definitions(iface PUBLIC PRIVATE INTERFACE)
# Cannot be called with non-compilable targets.
#add_library(imported UNKNOWN IMPORTED)
#target_compile_definitions(imported PUBLIC PRIVATE INTERFACE)

View File

@@ -12,3 +12,4 @@ run_cmake(no_matching_cxx_feature)
run_cmake(not_a_c_feature)
run_cmake(no_matching_c_feature)
run_cmake(cxx_not_enabled)
run_cmake(empty_keyword_args)

View File

@@ -0,0 +1,5 @@
CMake Error at empty_keyword_args.cmake:2 \(target_compile_features\):
target_compile_features may only set INTERFACE properties on INTERFACE
targets
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@@ -0,0 +1,5 @@
add_library(iface INTERFACE)
target_compile_features(iface PUBLIC PRIVATE INTERFACE)
# Cannot be called with non-compilable targets.
#add_library(imported UNKNOWN IMPORTED)
#target_compile_features(imported PUBLIC PRIVATE INTERFACE)

View File

@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.11)
project(${RunCMake_TEST} LANGUAGES NONE)
include(${RunCMake_TEST}.cmake)

View File

@@ -0,0 +1,3 @@
include(RunCMake)
run_cmake(empty_keyword_args)

View File

@@ -0,0 +1,5 @@
CMake Error at empty_keyword_args.cmake:2 \(target_compile_options\):
target_compile_options may only set INTERFACE properties on INTERFACE
targets
Call Stack \(most recent call first\):
CMakeLists.txt:5 \(include\)

View File

@@ -0,0 +1,5 @@
add_library(iface INTERFACE)
target_compile_options(iface PUBLIC PRIVATE INTERFACE)
# Cannot be called with non-compilable targets.
#add_library(imported UNKNOWN IMPORTED)
#target_compile_options(imported PUBLIC PRIVATE INTERFACE)

View File

@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.11)
project(${RunCMake_TEST} LANGUAGES NONE)
include(${RunCMake_TEST}.cmake)

View File

@@ -0,0 +1,3 @@
include(RunCMake)
run_cmake(empty_keyword_args)

View File

@@ -0,0 +1,5 @@
CMake Error at empty_keyword_args.cmake:2 \(target_include_directories\):
target_include_directories may only set INTERFACE properties on INTERFACE
targets
Call Stack \(most recent call first\):
CMakeLists.txt:5 \(include\)

View File

@@ -0,0 +1,5 @@
add_library(iface INTERFACE)
target_include_directories(iface PUBLIC PRIVATE INTERFACE)
# Cannot be called with non-compilable targets.
#add_library(imported UNKNOWN IMPORTED)
#target_include_directories(imported PUBLIC PRIVATE INTERFACE)

View File

@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.11)
project(${RunCMake_TEST} LANGUAGES NONE)
include(${RunCMake_TEST}.cmake)

View File

@@ -0,0 +1,3 @@
include(RunCMake)
run_cmake(empty_keyword_args)

View File

@@ -0,0 +1,5 @@
CMake Error at empty_keyword_args.cmake:2 \(target_link_directories\):
target_link_directories may only set INTERFACE properties on INTERFACE
targets
Call Stack \(most recent call first\):
CMakeLists.txt:5 \(include\)

View File

@@ -0,0 +1,5 @@
add_library(iface INTERFACE)
target_link_directories(iface PUBLIC PRIVATE INTERFACE)
# Cannot be called with non-compilable targets.
#add_library(imported UNKNOWN IMPORTED)
#target_link_directories(imported PUBLIC PRIVATE INTERFACE)

View File

@@ -19,3 +19,4 @@ run_cmake(SharedDepNotTarget)
run_cmake(StaticPrivateDepNotExported)
run_cmake(StaticPrivateDepNotTarget)
run_cmake(UNKNOWN-IMPORTED-GLOBAL)
run_cmake(empty_keyword_args)

View File

@@ -0,0 +1,4 @@
add_library(iface INTERFACE)
target_link_libraries(iface PUBLIC PRIVATE INTERFACE)
add_library(imported UNKNOWN IMPORTED)
target_link_libraries(imported PUBLIC PRIVATE INTERFACE)

View File

@@ -39,3 +39,5 @@ if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)")
run_cmake_target(LINKER_expansion LINKER linker)
run_cmake_target(LINKER_expansion LINKER_SHELL linker_shell)
endif()
run_cmake(empty_keyword_args)

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,4 @@
CMake Error at empty_keyword_args.cmake:2 \(target_link_options\):
target_link_options may only set INTERFACE properties on INTERFACE targets
Call Stack \(most recent call first\):
CMakeLists.txt:5 \(include\)

View File

@@ -0,0 +1,5 @@
add_library(iface INTERFACE)
target_link_options(iface PUBLIC PRIVATE INTERFACE)
# Cannot be called with non-compilable targets.
#add_library(imported UNKNOWN IMPORTED)
#target_link_options(imported PUBLIC PRIVATE INTERFACE)

View File

@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.11)
project(${RunCMake_TEST} LANGUAGES NONE)
include(${RunCMake_TEST}.cmake)

View File

@@ -0,0 +1,3 @@
include(RunCMake)
run_cmake(empty_keyword_args)

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,4 @@
CMake Error at empty_keyword_args.cmake:2 \(target_sources\):
target_sources may only set INTERFACE properties on INTERFACE targets
Call Stack \(most recent call first\):
CMakeLists.txt:5 \(include\)

View File

@@ -0,0 +1,5 @@
add_library(iface INTERFACE)
target_sources(iface PUBLIC PRIVATE INTERFACE)
# Cannot be called with non-compilable targets.
#add_library(imported UNKNOWN IMPORTED)
#target_sources(imported PUBLIC PRIVATE INTERFACE)