CMake: use GCC dependency generation for DAPSS files
This commit is contained in:
+17
-9
@@ -54,13 +54,12 @@ function(add_daps_target target_name)
|
|||||||
list(APPEND include_flags "-I${include_dir}")
|
list(APPEND include_flags "-I${include_dir}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Add current source directory to includes if it's not already there
|
list(APPEND include_flags "-I${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
if(source_dir)
|
|
||||||
list(APPEND include_flags "-I${source_dir}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Convert list to space-separated string
|
# Add source subdirectory to includes when SOURCES lists a path prefix
|
||||||
string(REPLACE ";" " " include_flags_str "${include_flags}")
|
if(source_dir)
|
||||||
|
list(APPEND include_flags "-I${CMAKE_CURRENT_SOURCE_DIR}/${source_dir}")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Find C compiler if not already set
|
# Find C compiler if not already set
|
||||||
if(NOT CMAKE_C_COMPILER)
|
if(NOT CMAKE_C_COMPILER)
|
||||||
@@ -70,11 +69,20 @@ function(add_daps_target target_name)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Create custom command to preprocess the file
|
set(depfile "${output_file}.d")
|
||||||
|
|
||||||
|
# Preprocess with -MD so #included .dapss files become build dependencies
|
||||||
|
# (e.g. body specs that #include ../elp_4k_usb_cam.dapss).
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${output_file}
|
OUTPUT ${output_file}
|
||||||
COMMAND sh -c "\"${CMAKE_C_COMPILER}\" -E -P -x c ${include_flags_str} \"${CMAKE_CURRENT_SOURCE_DIR}/${source_file}\" > \"${output_file}\""
|
COMMAND "${CMAKE_C_COMPILER}"
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${source_file}
|
-E -P -x c
|
||||||
|
${include_flags}
|
||||||
|
-MD -MQ "${output_file}" -MF "${depfile}"
|
||||||
|
-o "${output_file}"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/${source_file}"
|
||||||
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${source_file}"
|
||||||
|
DEPFILE "${depfile}"
|
||||||
COMMENT "Preprocessing ${source_file} to ${base_name}.daps"
|
COMMENT "Preprocessing ${source_file} to ${base_name}.daps"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user