summaryrefslogtreecommitdiff
path: root/Tests/ObjectLibrary
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-07-02 15:38:10 -0400
committerBrad King <brad.king@kitware.com>2014-07-09 09:43:42 -0400
commit2c470b775ab54f565383c95200d16dc42d94fe17 (patch)
tree16072279bce09969004c90ea4dc55384c8265cf0 /Tests/ObjectLibrary
parentde4f3e2c82a92a7dfc6305a09cc32d9d5c6e8c34 (diff)
downloadcmake-2c470b775ab54f565383c95200d16dc42d94fe17.tar.gz
add_library: Allow arbitrary non-linked sources in OBJECT libraries
Loosen this restriction on OBJECT libraries to allow source files of any name to be generated by custom commands or listed for reference in IDE projects so long as they would not affect linking of a normal library. Update the rejection message to be more specific about the looser restriction. Extend the ObjectLibrary test to cover a ".cmake" file generated by a custom command in an OBJECT library.
Diffstat (limited to 'Tests/ObjectLibrary')
-rw-r--r--Tests/ObjectLibrary/A/CMakeLists.txt13
-rw-r--r--Tests/ObjectLibrary/CMakeLists.txt1
2 files changed, 13 insertions, 1 deletions
diff --git a/Tests/ObjectLibrary/A/CMakeLists.txt b/Tests/ObjectLibrary/A/CMakeLists.txt
index 3fba9f8167..c24c5ed92e 100644
--- a/Tests/ObjectLibrary/A/CMakeLists.txt
+++ b/Tests/ObjectLibrary/A/CMakeLists.txt
@@ -11,5 +11,16 @@ add_custom_command(
${CMAKE_CURRENT_BINARY_DIR}/a1.c
)
-add_library(A OBJECT a1.c a2.c)
+# Remove the custom command output to be sure it runs in an
+# incremental test. Skip this on VS 6 because it sometimes
+# re-runs CMake after the custom command runs.
+if(NOT CMAKE_GENERATOR STREQUAL "Visual Studio 6")
+ file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/a.cmake)
+endif()
+add_custom_command(
+ OUTPUT a.cmake
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/a.cmake
+ )
+
+add_library(A OBJECT a1.c a2.c a.cmake)
target_include_directories(A PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt
index 75c34d8252..e9f553e2be 100644
--- a/Tests/ObjectLibrary/CMakeLists.txt
+++ b/Tests/ObjectLibrary/CMakeLists.txt
@@ -12,6 +12,7 @@ add_library(Cshared SHARED c.c $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:Bexport>)
add_executable(UseCshared main.c)
set_property(TARGET UseCshared PROPERTY COMPILE_DEFINITIONS SHARED_C)
target_link_libraries(UseCshared Cshared)
+add_custom_command(TARGET UseCshared POST_BUILD COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/A/a.cmake)
add_executable(UseCinternal main.c c.c $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B>)