Allow OBJECT libraries to be installed, exported, and imported

Teach install() and export() to handle the actual object files.
Disallow this on Xcode with multiple architectures because it
still cannot be cleanly supported there.

Co-Author: Brad King <brad.king@kitware.com>
This commit is contained in:
Robert Maynard
2017-03-23 09:32:08 -04:00
committed by Brad King
parent 93c89bc75c
commit eec93bceec
38 changed files with 362 additions and 94 deletions
@@ -1,4 +0,0 @@
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\)
@@ -0,0 +1,5 @@
CMake Error at ExportNotSupported.cmake:[0-9]+ \(export\):
export given OBJECT library "A" which may not be exported under Xcode with
multiple architectures.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
@@ -0,0 +1,2 @@
add_library(A OBJECT a.c)
export(TARGETS A FILE AExport.cmake)
+11
View File
@@ -1 +1,12 @@
add_library(A OBJECT IMPORTED)
# We don't actually build this example so just configure dummy
# object files to test. They do not have to exist.
set_property(TARGET A APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(A PROPERTIES
IMPORTED_OBJECTS_DEBUG "${CMAKE_CURRENT_BINARY_DIR}/does_not_exist.o"
IMPORTED_OBJECTS "${CMAKE_CURRENT_BINARY_DIR}/does_not_exist.o"
)
add_library(B $<TARGET_OBJECTS:A> b.c)
@@ -1,4 +1,5 @@
CMake Error at Import.cmake:1 \(add_library\):
The OBJECT library type may not be used for IMPORTED libraries.
CMake Error at ImportNotSupported.cmake:[0-9]+ \(add_library\):
The OBJECT library type may not be used for IMPORTED libraries under Xcode
with multiple architectures.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
@@ -0,0 +1 @@
add_library(A OBJECT IMPORTED)
@@ -1,4 +1,5 @@
CMake Error at Install.cmake:2 \(install\):
install TARGETS given OBJECT library "A" which may not be installed.
CMake Error at InstallNotSupported.cmake:[0-9]+ \(install\):
install TARGETS given OBJECT library "A" which may not be installed under
Xcode with multiple architectures.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
@@ -0,0 +1,2 @@
add_library(A OBJECT a.c)
install(TARGETS A DESTINATION lib)
@@ -5,9 +5,15 @@ run_cmake(BadSourceExpression2)
run_cmake(BadSourceExpression3)
run_cmake(BadObjSource1)
run_cmake(BadObjSource2)
run_cmake(Export)
run_cmake(Import)
run_cmake(Install)
if(RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
run_cmake(ExportNotSupported)
run_cmake(ImportNotSupported)
run_cmake(InstallNotSupported)
else()
run_cmake(Export)
run_cmake(Import)
run_cmake(Install)
endif()
run_cmake(LinkObjLHS)
run_cmake(LinkObjRHS1)
run_cmake(LinkObjRHS2)
+4
View File
@@ -0,0 +1,4 @@
int b(void)
{
return 0;
}