[CMake] help with OBJECT libraries hierarchy

Ilias Miroslav Miroslav.Ilias at umb.sk
Wed Jun 22 06:47:15 EDT 2016


Dear experts,


I am trying to introduce OBJECT libraries into our project, http://www.diracprogram.org.<http://www.diracprogram.org>


Into local src/functionality1/CMakeLists.txt I changed


add_library(main ${local_sources})

                    to

add_library(main  OBJECT ${local_sources})


at  higher level, in src/CMakeLists.txt I changed


add_subdirectory(${PROJECT_SOURCE_DIR}/src/functionality1)
set(EXTERNAL_LIBS main ${EXTERNAL_LIBS})

                                   to

add_subdirectory(${PROJECT_SOURCE_DIR}/src/functionality1)
set(EXTERNAL_LIBS  $<TARGET_OBJECTS:main> ${EXTERNAL_LIBS})


and at the highest level of our CMake infrastructure I have linking of all object libraries for given  executable(s) :


 target_link_libraries( ${_executable}  ${EXTERNAL_LIBS}  )


However, during configuration I am getting repeating error messages  of type


"CMake Error at cmake/custom/core.cmake:75 (target_link_libraries):
  Error evaluating generator expression:

    $<TARGET_OBJECTS:main>

  The evaluation of the TARGET_OBJECTS generator expression is only suitable
  for consumption by CMake.  It is not suitable for writing out elsewhere.
Call Stack (most recent call first):
  CMakeLists.txt:77 (include)"


Any help please how to best arrange OBJECT libraries ? I have cmake version 3.5.0 .


Yours, Miro

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160622/23247ca3/attachment.html>


More information about the CMake mailing list