[CMake] CMake all_object_files target
Raphael Grimm
raphael.grimm at kit.edu
Fri Jul 20 01:39:41 EDT 2018
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5205 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://cmake.org/pipermail/cmake/attachments/20180720/6dfb9b7f/attachment-0001.bin>
More information about the CMake
mailing list