<div dir="ltr">I have a project where the output is a static library. The directory structure is as follows:<div><br></div><div><div>myproj</div><div>   |  CMakeLists.txt</div><div>   |- cmake_macros</div><div>   |    find_include_dirs.cmake</div>

<div>   |- libs</div><div>   |--- Mac</div><div>   |----- lib</div><div>   |         libcrypto.a</div><div>   |         ...</div><div>   |--- win</div><div>   | ...</div><div>   |</div><div>   |- src</div><div>   |--- component1</div>

<div>   |       CMakeLists.txt</div><div>   |       some_file.c</div><div>   |       ...</div><div>   |----- include</div><div>   |       CMakeLists.txt</div><div>   |       some_file.h</div><div>   |       ...</div><div>

   |--- component2</div><div>   | ...</div></div><div><br></div><div>Each component&#39;s cmake file describes the sources and headers for that component:</div><div><br></div><div><div>project(component1)</div>
<div>set(component1_SOURCES</div><div>    ${CMAKE_CURRENT_SOURCE_DIR}/some_file.c</div><div>    ${CMAKE_CURRENT_SOURCE_DIR}/some_other_file.c</div><div>)</div><div>set(component1_HEADERS</div><div>    ${CMAKE_CURRENT_SOURCE_DIR}/include/some_file.h</div>

<div>    ${CMAKE_CURRENT_SOURCE_DIR}/include/some_other_file.h</div><div>)</div><div>
add_library(component1 OBJECT ${component1_SOURCES} ${component1_HEADERS})</div></div><div><br></div><div style>The top-level cmake file includes each sub-component and builds the required library:</div><div style><br></div>
<div style><div>cmake_minimum_required (VERSION 2.8)</div><div>include(cmake_macros/find_include_dirs.cmake)</div><div><br></div><div>project (myProject C)<br></div><div><br></div><div><div># find all include directories</div>
<div>find_include_dirs(INCLUDE_DIRS)</div><div>include_directories(${INCLUDE_DIRS})</div></div><div><br></div><div><div># add subdirectories</div><div>add_subdirectory(src/component1)</div><div>add_subdirectory(src/component2)</div>
</div><div>...</div><div><br></div><div style># platform-specific compiler flags</div><div style>if (APPLE)</div><div><div>    set(ENV{CC} clang)</div><div>    set(CMAKE_C_FLAGS &quot;-std=gnu99&quot; CACHE STRING &quot;&quot; FORCE)</div>
<div>    set(CMAKE_SHARED_LINKER_FLAGS &quot;-Wl,--export-all-symbols&quot;)</div></div><div>   ...</div><div style>endif (APPLE)</div><div style><br></div><div style><div>add_library(myLib STATIC </div><div>    $&lt;TARGET_OBJECTS:component1&gt;</div>
<div>    $&lt;TARGET_OBJECTS:component2&gt;</div><div>    ...</div><div>)</div><div><br></div><div style>When run without a generator, the command-line compilation works, producing myLib.a; however, when I generate an Xcode project, I get multiple .a files, one-per component and no target that links everything together into a single library.</div>
<div style><br></div><div style>Any help would be greatly appreciated,</div><div style>---</div><div style>Mike Norman</div></div></div></div>