b237dbd8c3
In cmGlobalXCodeGenerator::Generate we generate a .xcodeproj for each directory in the tree containing a project() command. First we iteratively use SetGenerationRoot to add "ALL_BUILD" and other targets to each project. This leaves "CurrentProject" set to the last project when we invoke cmGlobalGenerator::Generate, which is not the same as the top-level project if any subdirectories invoke the project() command. When cmGlobalGenerator::Generate reaches CreateGeneratorTargets it constructs cmGeneratorTarget and calls ComputeTargetObjects exactly once per target. In this context the value of CurrentProject is undefined so we cannot pass it to GetObjectsNormalDirectory. Use "$(PROJECT_NAME)" instead so it will adapt automatically to each project. Also teach Tests/ObjectLibrary to cover this case.
19 lines
544 B
CMake
19 lines
544 B
CMake
project(ObjectLibraryA)
|
|
# 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()
|
|
|
|
add_definitions(-DA_DEF)
|
|
|
|
add_custom_command(
|
|
OUTPUT a1.c
|
|
DEPENDS a1.c.in
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/a1.c.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/a1.c
|
|
)
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
add_library(A OBJECT a1.c a2.c)
|