Commit 56831016 authored by Brad King's avatar Brad King
Browse files

Test OBJECT library failure cases

Add "RunCMake.ObjectLibrary" test to verify that unsupported use cases
are rejected with errors:

* An OBJECT library may not reference another object library
* An OBJECT library may not be referenced in target_link_libraries
* An OBJECT library may not contain non-compiling sources
* An OBJECT library may not have pre/post build/link commands
* An OBJECT library may not be installed, exported, or imported

Also verify that invalid $<TARGET_OBJECTS:...> expressions are
diagnosed.
parent 69d3d183
......@@ -40,5 +40,7 @@ macro(add_RunCMake_test test)
)
endmacro()
add_RunCMake_test(ObjectLibrary)
add_RunCMake_test(build_command)
add_RunCMake_test(find_package)
CMake Error at BadObjSource1.cmake:1 \(add_library\):
OBJECT library "A" contains:
bad.def
but may contain only headers and sources that compile.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
CMake Error at BadObjSource2.cmake:1 \(add_library\):
OBJECT library "A" contains:
bad.obj
but may contain only headers and sources that compile.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
CMake Error at BadSourceExpression1.cmake:1 \(add_library\):
Unrecognized generator expression:
\$<BAD_EXPRESSION>
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
add_library(A STATIC a.c $<BAD_EXPRESSION>)
CMake Error at BadSourceExpression2.cmake:1 \(add_library\):
Objects of target "DoesNotExist" referenced but no such target exists.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
add_library(A STATIC a.c $<TARGET_OBJECTS:DoesNotExist>)
CMake Error at BadSourceExpression3.cmake:2 \(add_library\):
Objects of target "NotObjLib" referenced but is not an OBJECT library.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
add_library(NotObjLib STATIC a.c)
add_library(A STATIC a.c $<TARGET_OBJECTS:NotObjLib>)
cmake_minimum_required(VERSION 2.8)
project(${RunCMake_TEST} C)
include(${RunCMake_TEST}.cmake)
CMake Error at Export.cmake:2 \(export\):
export given OBJECT library "A" which may not be exported.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
add_library(A OBJECT a.c)
export(TARGETS A FILE AExport.cmake)
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