I’m creating a custom target to run clang-format on all the source file of a target.
Here’s what I got:
add_custom_target(format-fix
COMMAND clang-format -style=file -i $<TARGET_PROPERTY:mylib,SOURCES>
COMMAND_EXPAND_LISTS
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
The problem is, even though I listed the header files in my sources, they don’t appear in that list.
target_sources(pixel-engine
PRIVATE
src/source1.cpp
src/source2.cpp
PUBLIC FILE_SET HEADERS
BASE_DIRS src include/mylib
FILES
include/mylib/header1.hpp
include/mylib/header2.hpp
)
Only source1.cpp and source2.cpp gets formatted.
Is there a way with generator expression to get the list of all source file and the list of all headers too? Thanks.