Skip to content

Commit

Permalink
Allow adding clang options from dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Martchus committed Jan 31, 2020
1 parent 891b96a commit 4b4d674
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/cmake/modules/ReflectionGenerator.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function (add_reflection_generator_invocation)
# parse arguments
set(OPTIONAL_ARGS)
set(ONE_VALUE_ARGS OUTPUT_DIRECTORY JSON_VISIBILITY BINARY_VISBILITY)
set(MULTI_VALUE_ARGS INPUT_FILES GENERATORS OUTPUT_LISTS CLANG_OPTIONS CLANG_OPTIONS_FROM_TARGETS JSON_CLASSES)
set(MULTI_VALUE_ARGS INPUT_FILES GENERATORS OUTPUT_LISTS CLANG_OPTIONS CLANG_OPTIONS_FROM_TARGETS CLANG_OPTIONS_FROM_DEPENDENCIES JSON_CLASSES)
cmake_parse_arguments(ARGS "${OPTIONAL_ARGS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN})

# determine file name or file path if none specified
Expand Down Expand Up @@ -130,6 +130,22 @@ function (add_reflection_generator_invocation)
list(APPEND ARGS_CLANG_OPTIONS "$<$<BOOL:${PROP}>:-I$<JOIN:${PROP},$<SEMICOLON>-I>>")
endforeach ()
endif ()
if (ARGS_CLANG_OPTIONS_FROM_DEPENDENCIES)
foreach (TARGET_NAME ${ARGS_CLANG_OPTIONS_FROM_DEPENDENCIES})
if (NOT TARGET "${TARGET_NAME}")
continue()
endif ()
# add interface compile options
set(PROP "$<TARGET_PROPERTY:${TARGET_NAME},INTERFACE_COMPILE_OPTIONS>")
list(APPEND ARGS_CLANG_OPTIONS "$<$<BOOL:${PROP}>:$<JOIN:${PROP},$<SEMICOLON>>>")
# add interface compile definitions
set(PROP "$<TARGET_PROPERTY:${TARGET_NAME},INTERFACE_COMPILE_DEFINITIONS>")
list(APPEND ARGS_CLANG_OPTIONS "$<$<BOOL:${PROP}>:-D$<JOIN:${PROP},$<SEMICOLON>-D>>")
# add interface include directories
set(PROP "$<TARGET_PROPERTY:${TARGET_NAME},INTERFACE_INCLUDE_DIRECTORIES>")
list(APPEND ARGS_CLANG_OPTIONS "$<$<BOOL:${PROP}>:-I$<JOIN:${PROP},$<SEMICOLON>-I>>")
endforeach ()
endif ()

# create a custom command for each input file
foreach (INPUT_FILE ${ARGS_INPUT_FILES})
Expand Down

0 comments on commit 4b4d674

Please sign in to comment.