Hi,

I want to create a CMake target to build all object files. To do this, I first modified all targets to build an object file lib and link against it:

    add_library(exe_object_files OBJECT ${sources})
    set(ARMARX_EXE_OBJECT_FILES $<TARGET_OBJECTS:exe_object_files>)
    add_executable(exe $<TARGET_OBJECTS:exe_object_files>)

Since I have multiple executables, I added a target for all object files and added the targets for each executable as dependency:

    add_custom_target(all_exe_object_files)
    add_dependencies(all_exe_object_files exe_object_files)

This adds a all_exe_object_files target I can make, but making the target does nothing.
Then I tried adding the object files as sources:

    get_target_property(all_exe_object_files_sources all_exe_object_files SOURCES)
    if(NOT all_exe_object_files_sources)
        set(all_exe_object_files_sources)
    endif()
    list(APPEND all_exe_object_files_sources $<TARGET_OBJECTS:exe_object_files>)     set_target_properties(all_exe_object_files PROPERTIES SOURCES "${all_exe_object_files_sources}")

This did not help.

I guess the reason is that add_library(... OBJECT ...) behaves similar to add_custom_command and the files are only build if a target uses them (and my custom target probably does not count as using the generated files).

What am I doing wrong and how can I create a target to build all object files?

Thanks for all hints.
Regards
Raphael


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to