1 set(SETTINGS_GENERATED "settings_generated")
2 set(SETTINGS_GENERATED_C "${SETTINGS_GENERATED}.c")
3 set(SETTINGS_GENERATED_H "${SETTINGS_GENERATED}.h")
4 set(SETTINGS_FILE "${MAIN_SRC_DIR}/fc/settings.yaml")
5 set(SETTINGS_GENERATOR "${MAIN_UTILS_DIR}/settings.rb")
7 include(CMakeParseArguments)
9 function(enable_settings exe name)
10 get_generated_files_dir(dir ${name})
11 get_target_property(options ${exe} COMPILE_OPTIONS)
12 get_target_property(includes ${exe} INCLUDE_DIRECTORIES)
13 list(TRANSFORM includes PREPEND "-I")
14 get_target_property(defs ${exe} COMPILE_DEFINITIONS)
15 list(TRANSFORM defs PREPEND "-D")
16 list(APPEND cflags ${options})
17 list(APPEND cflags ${includes})
18 list(APPEND cflags ${defs})
20 cmake_parse_arguments(
24 # Single value arguments
25 "OUTPUTS;SETTINGS_CXX"
26 # Multi-value arguments
28 # Start parsing after the known arguments
32 find_program(RUBY_EXECUTABLE ruby)
33 if (NOT RUBY_EXECUTABLE)
34 message(FATAL_ERROR "Could not find ruby")
37 if(host STREQUAL TOOLCHAIN)
38 set(USE_HOST_GCC "-g")
40 set(output ${dir}/${SETTINGS_GENERATED_H} ${dir}/${SETTINGS_GENERATED_C})
44 ${CMAKE_COMMAND} -E env CFLAGS="${cflags}" TARGET=${name} PATH="$ENV{PATH}" SETTINGS_CXX=${args_SETTINGS_CXX}
45 ${RUBY_EXECUTABLE} ${SETTINGS_GENERATOR} ${MAIN_DIR} ${SETTINGS_FILE} -o "${dir}" ${USE_HOST_GCC}
46 DEPENDS ${SETTINGS_GENERATOR} ${SETTINGS_FILE}
48 set(${args_OUTPUTS} ${output} PARENT_SCOPE)