diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/ObjectLibrary/A/CMakeLists.txt | 20 | ||||
-rw-r--r-- | Tests/ObjectLibrary/B/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/ObjectLibrary/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt | 3 |
5 files changed, 20 insertions, 12 deletions
diff --git a/Tests/ObjectLibrary/A/CMakeLists.txt b/Tests/ObjectLibrary/A/CMakeLists.txt index 55778ea..c24c5ed 100644 --- a/Tests/ObjectLibrary/A/CMakeLists.txt +++ b/Tests/ObjectLibrary/A/CMakeLists.txt @@ -1,18 +1,26 @@ project(ObjectLibraryA C) # Add -fPIC so objects can be used in shared libraries. -# TODO: Need property for this. -if(CMAKE_SHARED_LIBRARY_C_FLAGS AND NOT WATCOM) - set(CMAKE_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_C_FLAGS}") -endif() +set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_definitions(-DA_DEF) add_custom_command( OUTPUT a1.c - DEPENDS a1.c.in + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/a1.c.in COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/a1.c.in ${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/B/CMakeLists.txt b/Tests/ObjectLibrary/B/CMakeLists.txt index a567f96..2158084 100644 --- a/Tests/ObjectLibrary/B/CMakeLists.txt +++ b/Tests/ObjectLibrary/B/CMakeLists.txt @@ -5,10 +5,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") endif() # Add -fPIC so objects can be used in shared libraries. -# TODO: Need property for this. -if(CMAKE_SHARED_LIBRARY_C_FLAGS AND NOT WATCOM) - set(CMAKE_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_C_FLAGS}") -endif() +set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_library(B OBJECT b1.c b2.c) target_include_directories(B PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt index 75c34d8..e9f553e 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>) diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt index b31225b..a09552b 100644 --- a/Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt @@ -3,6 +3,7 @@ CMake Error at BadObjSource1.cmake:1 \(add_library\): bad.def - but may contain only headers and sources that compile. + 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:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt index 906cf0b..b91ffd0 100644 --- a/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt @@ -3,6 +3,7 @@ CMake Error at BadObjSource2.cmake:1 \(add_library\): bad.obj - but may contain only headers and sources that compile. + 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:3 \(include\) |