Skip to content

Commit

Permalink
cmake: px4_add_module improve unity build dependencies to avoid unnec…
Browse files Browse the repository at this point in the history
…essary work
  • Loading branch information
dagar committed Nov 19, 2021
1 parent 4c6621f commit 24090b7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmake/px4_add_module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,15 @@ function(px4_add_module)
# unity build
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}_unity.cpp
COMMAND cat ${SRCS} > ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}_unity.cpp
DEPENDS ${MODULE}_original ${DEPENDS} ${SRCS}
DEPENDS ${SRCS}
COMMENT "${MODULE} merging source"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${MODULE}_unity.cpp PROPERTIES GENERATED true)

add_library(${MODULE} STATIC EXCLUDE_FROM_ALL ${CMAKE_CURRENT_BINARY_DIR}/${MODULE}_unity.cpp)
target_include_directories(${MODULE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_dependencies(${MODULE} ${MODULE}_original) # build standalone module first to get clean compile errors

if(COMPILE_FLAGS)
target_compile_options(${MODULE}_original PRIVATE ${COMPILE_FLAGS})
Expand Down

0 comments on commit 24090b7

Please sign in to comment.