Xcode generator fails to install a static library that depends on OBJECT library.
Here's a simple CMakeList.txt
cmake_minimum_required(VERSION 3.9)
include(GNUInstallDirs)
add_library(simple-object OBJECT simple.cpp simple.hpp)
add_library(simple-static STATIC $<TARGET_OBJECTS:simple-object>)
install(TARGETS simple-static EXPORT "simple-targets" DESTINATION ${CMAKE_INSTALL_LIBDIR})
Running cmake -G Xcode .. ; cmake --build . --target install
results in the following error:
=== BUILD AGGREGATE TARGET install OF PROJECT Project WITH CONFIGURATION Debug ===
Check dependencies
Write auxiliary files
write-file /Users/dmakarov/work/test/simple/xcode/Project.build/Debug/install.build/Script-BB8A1A7D4E5A468B96A8FB0A.sh
chmod 0755 /Users/dmakarov/work/test/simple/xcode/Project.build/Debug/install.build/Script-BB8A1A7D4E5A468B96A8FB0A.sh
PhaseScriptExecution CMake\ PostBuild\ Rules xcode/Project.build/Debug/install.build/Script-BB8A1A7D4E5A468B96A8FB0A.sh
cd /Users/dmakarov/work/test/simple
/bin/sh -c /Users/dmakarov/work/test/simple/xcode/Project.build/Debug/install.build/Script-BB8A1A7D4E5A468B96A8FB0A.sh
/usr/local/Cellar/cmake/3.9.6/bin/cmake -DBUILD_TYPE=Debug -P cmake_install.cmake
-- Install configuration: "Debug"
CMake Error at cmake_install.cmake:32 (file):
file INSTALL cannot find
"/Users/dmakarov/work/test/simple/xcode/Debug/libsimple-static.a".
make: *** [install_buildpart_0] Error 1
Command /bin/sh failed with exit code 2
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution CMake\ PostBuild\ Rules xcode/Project.build/Debug/install.build/Script-BB8A1A7D4E5A468B96A8FB0A.sh
(1 failure)
This is because the static library libsimple-static.a
is never built, instead a library libsimple-object.a
is built in Project.build/Debug/simple-object.build/Objects-normal
ll Project.build/Debug/simple-object.build/Objects-normal/
total 176
-rw-r--r-- 1 dmakarov staff 88K Nov 13 09:11 libsimple-object.a
drwxr-xr-x 6 dmakarov staff 192B Nov 13 09:11 x86_64
Edited by Dmitri Makarov