From 5683101669e677b5b8d7b50d817da54156afd626 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 12 Mar 2012 14:51:30 -0400 Subject: 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 $ expressions are diagnosed. --- Tests/RunCMake/ObjectLibrary/BadObjSource1-result.txt | 1 + Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt | 8 ++++++++ Tests/RunCMake/ObjectLibrary/BadObjSource1.cmake | 1 + Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt | 1 + Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt | 8 ++++++++ Tests/RunCMake/ObjectLibrary/BadObjSource2.cmake | 1 + .../ObjectLibrary/BadSourceExpression1-result.txt | 1 + .../ObjectLibrary/BadSourceExpression1-stderr.txt | 6 ++++++ Tests/RunCMake/ObjectLibrary/BadSourceExpression1.cmake | 1 + .../ObjectLibrary/BadSourceExpression2-result.txt | 1 + .../ObjectLibrary/BadSourceExpression2-stderr.txt | 4 ++++ Tests/RunCMake/ObjectLibrary/BadSourceExpression2.cmake | 1 + .../ObjectLibrary/BadSourceExpression3-result.txt | 1 + .../ObjectLibrary/BadSourceExpression3-stderr.txt | 4 ++++ Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake | 2 ++ Tests/RunCMake/ObjectLibrary/CMakeLists.txt | 3 +++ Tests/RunCMake/ObjectLibrary/Export-result.txt | 1 + Tests/RunCMake/ObjectLibrary/Export-stderr.txt | 4 ++++ Tests/RunCMake/ObjectLibrary/Export.cmake | 2 ++ Tests/RunCMake/ObjectLibrary/Import-result.txt | 1 + Tests/RunCMake/ObjectLibrary/Import-stderr.txt | 4 ++++ Tests/RunCMake/ObjectLibrary/Import.cmake | 1 + Tests/RunCMake/ObjectLibrary/Install-result.txt | 1 + Tests/RunCMake/ObjectLibrary/Install-stderr.txt | 4 ++++ Tests/RunCMake/ObjectLibrary/Install.cmake | 2 ++ Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt | 1 + Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt | 4 ++++ Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake | 2 ++ Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt | 1 + Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt | 6 ++++++ Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake | 3 +++ Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt | 1 + Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt | 6 ++++++ Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake | 3 +++ Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt | 1 + Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt | 4 ++++ Tests/RunCMake/ObjectLibrary/ObjWithObj.cmake | 2 ++ Tests/RunCMake/ObjectLibrary/PostBuild-result.txt | 1 + Tests/RunCMake/ObjectLibrary/PostBuild-stderr.txt | 5 +++++ Tests/RunCMake/ObjectLibrary/PostBuild.cmake | 4 ++++ Tests/RunCMake/ObjectLibrary/PreBuild-result.txt | 1 + Tests/RunCMake/ObjectLibrary/PreBuild-stderr.txt | 5 +++++ Tests/RunCMake/ObjectLibrary/PreBuild.cmake | 4 ++++ Tests/RunCMake/ObjectLibrary/PreLink-result.txt | 1 + Tests/RunCMake/ObjectLibrary/PreLink-stderr.txt | 5 +++++ Tests/RunCMake/ObjectLibrary/PreLink.cmake | 4 ++++ Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake | 17 +++++++++++++++++ Tests/RunCMake/ObjectLibrary/a.c | 1 + Tests/RunCMake/ObjectLibrary/bad.def | 0 Tests/RunCMake/ObjectLibrary/bad.obj | 0 50 files changed, 146 insertions(+) create mode 100644 Tests/RunCMake/ObjectLibrary/BadObjSource1-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/BadObjSource1.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/BadObjSource2.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/BadSourceExpression1-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/BadSourceExpression1.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/BadSourceExpression2-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/BadSourceExpression2.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/BadSourceExpression3-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/CMakeLists.txt create mode 100644 Tests/RunCMake/ObjectLibrary/Export-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/Export-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/Export.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/Import-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/Import-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/Import.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/Install-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/Install-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/Install.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/ObjWithObj.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/PostBuild-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/PostBuild-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/PostBuild.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/PreBuild-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/PreBuild-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/PreBuild.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/PreLink-result.txt create mode 100644 Tests/RunCMake/ObjectLibrary/PreLink-stderr.txt create mode 100644 Tests/RunCMake/ObjectLibrary/PreLink.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/a.c create mode 100644 Tests/RunCMake/ObjectLibrary/bad.def create mode 100644 Tests/RunCMake/ObjectLibrary/bad.obj (limited to 'Tests/RunCMake/ObjectLibrary') diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource1-result.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt new file mode 100644 index 0000000000..b31225b488 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt @@ -0,0 +1,8 @@ +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\) diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource1.cmake b/Tests/RunCMake/ObjectLibrary/BadObjSource1.cmake new file mode 100644 index 0000000000..aa3514d90c --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource1.cmake @@ -0,0 +1 @@ +add_library(A OBJECT a.c bad.def) diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt new file mode 100644 index 0000000000..906cf0b642 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt @@ -0,0 +1,8 @@ +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\) diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource2.cmake b/Tests/RunCMake/ObjectLibrary/BadObjSource2.cmake new file mode 100644 index 0000000000..7957c99f2e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource2.cmake @@ -0,0 +1 @@ +add_library(A OBJECT a.c bad.obj) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-result.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt new file mode 100644 index 0000000000..a1cac36fa6 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at BadSourceExpression1.cmake:1 \(add_library\): + Unrecognized generator expression: + + \$ +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1.cmake b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1.cmake new file mode 100644 index 0000000000..020c9a00f6 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1.cmake @@ -0,0 +1 @@ +add_library(A STATIC a.c $) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-result.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt new file mode 100644 index 0000000000..f1fcbe85f1 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt @@ -0,0 +1,4 @@ +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\) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2.cmake b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2.cmake new file mode 100644 index 0000000000..ed5dc43350 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2.cmake @@ -0,0 +1 @@ +add_library(A STATIC a.c $) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-result.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt new file mode 100644 index 0000000000..ad14a35137 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt @@ -0,0 +1,4 @@ +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\) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake new file mode 100644 index 0000000000..c3d9a622d0 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake @@ -0,0 +1,2 @@ +add_library(NotObjLib STATIC a.c) +add_library(A STATIC a.c $) diff --git a/Tests/RunCMake/ObjectLibrary/CMakeLists.txt b/Tests/RunCMake/ObjectLibrary/CMakeLists.txt new file mode 100644 index 0000000000..a7f077912a --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} C) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ObjectLibrary/Export-result.txt b/Tests/RunCMake/ObjectLibrary/Export-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Export-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/Export-stderr.txt b/Tests/RunCMake/ObjectLibrary/Export-stderr.txt new file mode 100644 index 0000000000..bdadca488a --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Export-stderr.txt @@ -0,0 +1,4 @@ +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\) diff --git a/Tests/RunCMake/ObjectLibrary/Export.cmake b/Tests/RunCMake/ObjectLibrary/Export.cmake new file mode 100644 index 0000000000..a3f104e297 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Export.cmake @@ -0,0 +1,2 @@ +add_library(A OBJECT a.c) +export(TARGETS A FILE AExport.cmake) diff --git a/Tests/RunCMake/ObjectLibrary/Import-result.txt b/Tests/RunCMake/ObjectLibrary/Import-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Import-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/Import-stderr.txt b/Tests/RunCMake/ObjectLibrary/Import-stderr.txt new file mode 100644 index 0000000000..74b496ab89 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Import-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Import.cmake:1 \(add_library\): + The OBJECT library type may not be used for IMPORTED libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/Import.cmake b/Tests/RunCMake/ObjectLibrary/Import.cmake new file mode 100644 index 0000000000..806b44a25e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Import.cmake @@ -0,0 +1 @@ +add_library(A OBJECT IMPORTED) diff --git a/Tests/RunCMake/ObjectLibrary/Install-result.txt b/Tests/RunCMake/ObjectLibrary/Install-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Install-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/Install-stderr.txt b/Tests/RunCMake/ObjectLibrary/Install-stderr.txt new file mode 100644 index 0000000000..d2f9f4a37a --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Install-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Install.cmake:2 \(install\): + install TARGETS given OBJECT library "A" which may not be installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/Install.cmake b/Tests/RunCMake/ObjectLibrary/Install.cmake new file mode 100644 index 0000000000..c1d214bd4b --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Install.cmake @@ -0,0 +1,2 @@ +add_library(A OBJECT a.c) +install(TARGETS A DESTINATION lib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt b/Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt new file mode 100644 index 0000000000..90e828bdb1 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LinkObjLHS.cmake:2 \(target_link_libraries\): + Object library target "AnObjLib" may not link to anything. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake new file mode 100644 index 0000000000..5d7831a23c --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake @@ -0,0 +1,2 @@ +add_library(AnObjLib OBJECT a.c) +target_link_libraries(AnObjLib OtherLib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt new file mode 100644 index 0000000000..8809f8933b --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at LinkObjRHS1.cmake:3 \(target_link_libraries\): + Target "AnObjLib" of type OBJECT_LIBRARY may not be linked into another + target. One may link only to STATIC or SHARED libraries, or to executables + with the ENABLE_EXPORTS property set. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake new file mode 100644 index 0000000000..113d6a841a --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake @@ -0,0 +1,3 @@ +add_library(A STATIC a.c) +add_library(AnObjLib OBJECT a.c) +target_link_libraries(A AnObjLib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt new file mode 100644 index 0000000000..3295fcac30 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at LinkObjRHS2.cmake:1 \(add_library\): + Target "A" links to OBJECT library "AnObjLib" but this is not allowed. One + may link only to STATIC or SHARED libraries, or to executables with the + ENABLE_EXPORTS property set. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake new file mode 100644 index 0000000000..616372949b --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake @@ -0,0 +1,3 @@ +add_library(A SHARED a.c) +target_link_libraries(A AnObjLib) +add_library(AnObjLib OBJECT a.c) diff --git a/Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt b/Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt b/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt new file mode 100644 index 0000000000..d67b4ae320 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at ObjWithObj.cmake:2 \(add_library\): + Only executables and non-OBJECT libraries may reference target objects. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/ObjWithObj.cmake b/Tests/RunCMake/ObjectLibrary/ObjWithObj.cmake new file mode 100644 index 0000000000..d0ef34bfe7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/ObjWithObj.cmake @@ -0,0 +1,2 @@ +add_library(A OBJECT a.c) +add_library(B OBJECT $) diff --git a/Tests/RunCMake/ObjectLibrary/PostBuild-result.txt b/Tests/RunCMake/ObjectLibrary/PostBuild-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PostBuild-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/PostBuild-stderr.txt b/Tests/RunCMake/ObjectLibrary/PostBuild-stderr.txt new file mode 100644 index 0000000000..4b067bbc33 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PostBuild-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at PostBuild.cmake:2 \(add_custom_command\): + Target "A" is an OBJECT library that may not have PRE_BUILD, PRE_LINK, or + POST_BUILD commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/PostBuild.cmake b/Tests/RunCMake/ObjectLibrary/PostBuild.cmake new file mode 100644 index 0000000000..dea9a099e8 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PostBuild.cmake @@ -0,0 +1,4 @@ +add_library(A OBJECT a.c) +add_custom_command(TARGET A POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "A post-build" + ) diff --git a/Tests/RunCMake/ObjectLibrary/PreBuild-result.txt b/Tests/RunCMake/ObjectLibrary/PreBuild-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreBuild-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/PreBuild-stderr.txt b/Tests/RunCMake/ObjectLibrary/PreBuild-stderr.txt new file mode 100644 index 0000000000..3b27a6da52 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreBuild-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at PreBuild.cmake:2 \(add_custom_command\): + Target "A" is an OBJECT library that may not have PRE_BUILD, PRE_LINK, or + POST_BUILD commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/PreBuild.cmake b/Tests/RunCMake/ObjectLibrary/PreBuild.cmake new file mode 100644 index 0000000000..e4424c100a --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreBuild.cmake @@ -0,0 +1,4 @@ +add_library(A OBJECT a.c) +add_custom_command(TARGET A PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "A pre-build" + ) diff --git a/Tests/RunCMake/ObjectLibrary/PreLink-result.txt b/Tests/RunCMake/ObjectLibrary/PreLink-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreLink-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/PreLink-stderr.txt b/Tests/RunCMake/ObjectLibrary/PreLink-stderr.txt new file mode 100644 index 0000000000..947b9f177f --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreLink-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at PreLink.cmake:2 \(add_custom_command\): + Target "A" is an OBJECT library that may not have PRE_BUILD, PRE_LINK, or + POST_BUILD commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/PreLink.cmake b/Tests/RunCMake/ObjectLibrary/PreLink.cmake new file mode 100644 index 0000000000..b889055112 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreLink.cmake @@ -0,0 +1,4 @@ +add_library(A OBJECT a.c) +add_custom_command(TARGET A PRE_LINK + COMMAND ${CMAKE_COMMAND} -E echo "A pre-link" + ) diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake new file mode 100644 index 0000000000..a74eaa8ebc --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake @@ -0,0 +1,17 @@ +include(RunCMake) + +run_cmake(BadSourceExpression1) +run_cmake(BadSourceExpression2) +run_cmake(BadSourceExpression3) +run_cmake(BadObjSource1) +run_cmake(BadObjSource2) +run_cmake(Export) +run_cmake(Import) +run_cmake(Install) +run_cmake(LinkObjLHS) +run_cmake(LinkObjRHS1) +run_cmake(LinkObjRHS2) +run_cmake(ObjWithObj) +run_cmake(PostBuild) +run_cmake(PreBuild) +run_cmake(PreLink) diff --git a/Tests/RunCMake/ObjectLibrary/a.c b/Tests/RunCMake/ObjectLibrary/a.c new file mode 100644 index 0000000000..af20d3ff65 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/a.c @@ -0,0 +1 @@ +int a(void) { return 0; } diff --git a/Tests/RunCMake/ObjectLibrary/bad.def b/Tests/RunCMake/ObjectLibrary/bad.def new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/ObjectLibrary/bad.obj b/Tests/RunCMake/ObjectLibrary/bad.obj new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.1 From db7ef82402bed3d941bea73d266ac5919f4eee15 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 12 Mar 2012 15:02:42 -0400 Subject: Test OBJECT library language propagation Teach the RunCMake.ObjectLibrary test to verify that languages used in an OBJECT library are propagated to targets that use it so that the languages can be included in link analysis. --- Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake | 15 +++++++++++++++ Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake | 1 + Tests/RunCMake/ObjectLibrary/a.cxx | 1 + 3 files changed, 17 insertions(+) create mode 100644 Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake create mode 100644 Tests/RunCMake/ObjectLibrary/a.cxx (limited to 'Tests/RunCMake/ObjectLibrary') diff --git a/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake b/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake new file mode 100644 index 0000000000..0796c21ba3 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake @@ -0,0 +1,15 @@ +enable_language(CXX) +add_library(A OBJECT a.cxx) +add_library(B STATIC a.c $) + +# Verify that object library languages are propagated. +export(TARGETS B NAMESPACE Exp FILE BExport.cmake) +include(${CMAKE_CURRENT_BINARY_DIR}/BExport.cmake) +get_property(configs TARGET ExpB PROPERTY IMPORTED_CONFIGURATIONS) +foreach(c ${configs}) + get_property(langs TARGET ExpB PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES_${c}) + list(FIND langs CXX pos) + if(${pos} LESS 0) + message(FATAL_ERROR "Target export does not list object library languages.") + endif() +endforeach() diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake index a74eaa8ebc..55db14dfd6 100644 --- a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake @@ -6,6 +6,7 @@ run_cmake(BadSourceExpression3) run_cmake(BadObjSource1) run_cmake(BadObjSource2) run_cmake(Export) +run_cmake(ExportLanguages) run_cmake(Import) run_cmake(Install) run_cmake(LinkObjLHS) diff --git a/Tests/RunCMake/ObjectLibrary/a.cxx b/Tests/RunCMake/ObjectLibrary/a.cxx new file mode 100644 index 0000000000..ae9c87c496 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/a.cxx @@ -0,0 +1 @@ +extern "C" int acxx(void) { return 0; } -- cgit v1.2.1