Apply cmake-format

This commit is contained in:
Martchus 2019-02-09 21:25:11 +01:00
parent 39dcba215e
commit 1f6fade6c2
3 changed files with 144 additions and 159 deletions

View File

@ -15,8 +15,7 @@ set(HEADER_FILES
frontendaction.h frontendaction.h
consumer.h consumer.h
visitor.h visitor.h
clangversionabstraction.h clangversionabstraction.h)
)
set(SRC_FILES set(SRC_FILES
codegenerator.cpp codegenerator.cpp
serializationcodegenerator.cpp serializationcodegenerator.cpp
@ -27,32 +26,29 @@ set(SRC_FILES
consumer.cpp consumer.cpp
clangversionabstraction.cpp clangversionabstraction.cpp
visitor.cpp visitor.cpp
main.cpp main.cpp)
) set(TEST_HEADER_FILES tests/helper.h)
set(TEST_HEADER_FILES set(TEST_SRC_FILES tests/binarygenerator.cpp)
tests/helper.h
)
set(TEST_SRC_FILES
tests/binarygenerator.cpp
)
# add JSON-specific test cases # add JSON-specific test cases
if(RapidJSON_FOUND) if (RapidJSON_FOUND)
list(APPEND TEST_HEADER_FILES list(APPEND TEST_HEADER_FILES tests/structs.h tests/morestructs.h)
tests/structs.h list(APPEND TEST_SRC_FILES tests/jsongenerator.cpp)
tests/morestructs.h endif ()
)
list(APPEND TEST_SRC_FILES
tests/jsongenerator.cpp
)
endif()
# link against c++utilities # link against c++utilities
use_cpp_utilities() use_cpp_utilities()
# find Clang for LibTooling; adding clangTooling should be sufficient as it pulls all transitive dependencies # find Clang for LibTooling; adding clangTooling should be sufficient as it pulls all transitive dependencies
find_package(Clang REQUIRED) find_package(Clang REQUIRED)
list(APPEND PRIVATE_LIBRARIES clangTooling clangFrontend clangAST clangLex clangSema clangBasic LLVM) list(APPEND PRIVATE_LIBRARIES
clangTooling
clangFrontend
clangAST
clangLex
clangSema
clangBasic
LLVM)
# also add reflective_rapidjson which is header-only but might pull additional include dirs for RapidJSON # also add reflective_rapidjson which is header-only but might pull additional include dirs for RapidJSON
list(APPEND PRIVATE_LIBRARIES reflective_rapidjson) list(APPEND PRIVATE_LIBRARIES reflective_rapidjson)
@ -66,8 +62,9 @@ include(ShellCompletion)
include(Doxygen) include(Doxygen)
# trigger code generator for tests because the tests already contain structs to be (de)serialized # trigger code generator for tests because the tests already contain structs to be (de)serialized
if(TARGET reflective_rapidjson_generator_tests) if (TARGET reflective_rapidjson_generator_tests)
include(ReflectionGenerator) include(ReflectionGenerator)
# cmake-format: off
add_reflection_generator_invocation( add_reflection_generator_invocation(
INPUT_FILES INPUT_FILES
tests/structs.h # used by test cases tests/structs.h # used by test cases
@ -88,19 +85,20 @@ if(TARGET reflective_rapidjson_generator_tests)
JSON_VISIBILITY JSON_VISIBILITY
LIB_EXPORT # not required, just to test setting visibility LIB_EXPORT # not required, just to test setting visibility
) )
# cmake-format: on
list(APPEND TEST_HEADER_FILES ${TEST_GENERATED_HEADER_FILES}) list(APPEND TEST_HEADER_FILES ${TEST_GENERATED_HEADER_FILES})
target_sources(reflective_rapidjson_generator_tests PRIVATE ${TEST_GENERATED_HEADER_FILES}) target_sources(reflective_rapidjson_generator_tests PRIVATE ${TEST_GENERATED_HEADER_FILES})
endif() endif ()
# add paths for include dirs of c++utilities and RapidJSON to config header so test cases can use it # add paths for include dirs of c++utilities and RapidJSON to config header so test cases can use it
set(META_CUSTOM_CONFIG "#define CPP_UTILITIES_INCLUDE_DIRS \"${CPP_UTILITIES_INCLUDE_DIRS}\"\n") set(META_CUSTOM_CONFIG "#define CPP_UTILITIES_INCLUDE_DIRS \"${CPP_UTILITIES_INCLUDE_DIRS}\"\n")
if(RapidJSON_FOUND) if (RapidJSON_FOUND)
string(APPEND META_CUSTOM_CONFIG "#define RAPIDJSON_INCLUDE_DIRS \"${RAPIDJSON_INCLUDE_DIRS}\"\n") string(APPEND META_CUSTOM_CONFIG "#define RAPIDJSON_INCLUDE_DIRS \"${RAPIDJSON_INCLUDE_DIRS}\"\n")
endif() endif ()
# add path of Clang's resource dir to config header so test cases can use it # add path of Clang's resource dir to config header so test cases can use it
string(APPEND META_CUSTOM_CONFIG "#define REFLECTION_GENERATOR_CLANG_RESOURCE_DIR \"${REFLECTION_GENERATOR_CLANG_RESOURCE_DIR}\"\n") string(APPEND META_CUSTOM_CONFIG
"#define REFLECTION_GENERATOR_CLANG_RESOURCE_DIR \"${REFLECTION_GENERATOR_CLANG_RESOURCE_DIR}\"\n")
# make config header # make config header
include(ConfigHeader) include(ConfigHeader)

View File

@ -5,66 +5,53 @@ set(META_PROJECT_TYPE library)
set(META_HEADER_ONLY_LIB ON) set(META_HEADER_ONLY_LIB ON)
# add project files # add project files
set(HEADER_FILES set(HEADER_FILES traits.h)
traits.h set(SRC_FILES)
) set(TEST_HEADER_FILES)
set(SRC_FILES set(TEST_SRC_FILES)
) set(CMAKE_MODULE_FILES cmake/modules/ReflectionGenerator.cmake)
set(TEST_HEADER_FILES set(DOC_FILES README.md)
)
set(TEST_SRC_FILES
)
set(CMAKE_MODULE_FILES
cmake/modules/ReflectionGenerator.cmake
)
set(DOC_FILES
README.md
)
# add JSON-specific sources # add JSON-specific sources
if(RapidJSON_FOUND) if (RapidJSON_FOUND)
list(APPEND HEADER_FILES list(APPEND HEADER_FILES
json/reflector.h json/reflector.h
json/reflector-boosthana.h json/reflector-boosthana.h
json/reflector-chronoutilities.h json/reflector-chronoutilities.h
json/serializable.h json/serializable.h
json/errorhandling.h json/errorhandling.h)
)
list(APPEND TEST_SRC_FILES list(APPEND TEST_SRC_FILES
tests/jsonreflector.cpp tests/jsonreflector.cpp
tests/jsonreflector-boosthana.cpp tests/jsonreflector-boosthana.cpp
tests/jsonreflector-chronoutilities.cpp tests/jsonreflector-chronoutilities.cpp)
) endif ()
endif()
# add binary (de)serialization specific sources # add binary (de)serialization specific sources
list(APPEND HEADER_FILES list(APPEND HEADER_FILES
binary/reflector.h binary/reflector.h
binary/reflector-boosthana.h binary/reflector-boosthana.h
binary/reflector-chronoutilities.h binary/reflector-chronoutilities.h
binary/serializable.h binary/serializable.h)
)
list(APPEND TEST_SRC_FILES list(APPEND TEST_SRC_FILES
tests/traits.cpp tests/traits.cpp
tests/binaryreflector.cpp tests/binaryreflector.cpp
tests/binaryreflector-boosthana.cpp tests/binaryreflector-boosthana.cpp)
)
# add (only) the CMake module and include dirs for c++utilities because we're not depending on the actual library # add (only) the CMake module and include dirs for c++utilities because we're not depending on the actual library
list(APPEND CMAKE_MODULE_PATH ${CPP_UTILITIES_MODULE_DIRS}) list(APPEND CMAKE_MODULE_PATH ${CPP_UTILITIES_MODULE_DIRS})
if (CPP_UTILITIES_SOURCE_DIR) if (CPP_UTILITIES_SOURCE_DIR)
list(APPEND PUBLIC_SHARED_INCLUDE_DIRS "${CPP_UTILITIES_SOURCE_DIR}/..") list(APPEND PUBLIC_SHARED_INCLUDE_DIRS "${CPP_UTILITIES_SOURCE_DIR}/..")
list(APPEND PUBLIC_STATIC_INCLUDE_DIRS "${CPP_UTILITIES_SOURCE_DIR}/..") list(APPEND PUBLIC_STATIC_INCLUDE_DIRS "${CPP_UTILITIES_SOURCE_DIR}/..")
else() else ()
list(APPEND PUBLIC_SHARED_INCLUDE_DIRS "${CPP_UTILITIES_INCLUDE_DIRS}") list(APPEND PUBLIC_SHARED_INCLUDE_DIRS "${CPP_UTILITIES_INCLUDE_DIRS}")
list(APPEND PUBLIC_STATIC_INCLUDE_DIRS "${CPP_UTILITIES_INCLUDE_DIRS}") list(APPEND PUBLIC_STATIC_INCLUDE_DIRS "${CPP_UTILITIES_INCLUDE_DIRS}")
endif() endif ()
# find RapidJSON, also add only the include dirs because RapidJSON is a header-only library # find RapidJSON, also add only the include dirs because RapidJSON is a header-only library
if(RapidJSON_FOUND) if (RapidJSON_FOUND)
list(APPEND PUBLIC_SHARED_INCLUDE_DIRS ${RAPIDJSON_INCLUDE_DIRS}) list(APPEND PUBLIC_SHARED_INCLUDE_DIRS ${RAPIDJSON_INCLUDE_DIRS})
list(APPEND PUBLIC_STATIC_INCLUDE_DIRS ${RAPIDJSON_INCLUDE_DIRS}) list(APPEND PUBLIC_STATIC_INCLUDE_DIRS ${RAPIDJSON_INCLUDE_DIRS})
endif() endif ()
# include modules to apply configuration # include modules to apply configuration
include(BasicConfig) include(BasicConfig)

View File

@ -1,50 +1,55 @@
cmake_minimum_required(VERSION 3.3.0 FATAL_ERROR) cmake_minimum_required(VERSION 3.3.0 FATAL_ERROR)
# prevent multiple inclusion # prevent multiple inclusion
if(DEFINED REFLECTION_GENERATOR_MODULE_LOADED) if (DEFINED REFLECTION_GENERATOR_MODULE_LOADED)
return() return()
endif() endif ()
set(REFLECTION_GENERATOR_MODULE_LOADED YES) set(REFLECTION_GENERATOR_MODULE_LOADED YES)
# find code generator # find code generator
set(DEFAULT_REFLECTION_GENERATOR_EXECUTABLE "reflective_rapidjson_generator") set(DEFAULT_REFLECTION_GENERATOR_EXECUTABLE "reflective_rapidjson_generator")
set(REFLECTION_GENERATOR_EXECUTABLE "" CACHE FILEPATH "path to executable of reflection generator") set(REFLECTION_GENERATOR_EXECUTABLE "" CACHE FILEPATH "path to executable of reflection generator")
if(REFLECTION_GENERATOR_EXECUTABLE) if (REFLECTION_GENERATOR_EXECUTABLE)
# use custom generator executable # use custom generator executable
if(NOT EXISTS "${REFLECTION_GENERATOR_EXECUTABLE}" OR IS_DIRECTORY "${REFLECTION_GENERATOR_EXECUTABLE}") if (NOT EXISTS "${REFLECTION_GENERATOR_EXECUTABLE}" OR IS_DIRECTORY "${REFLECTION_GENERATOR_EXECUTABLE}")
message(FATAL_ERROR "The specified code generator executable \"${REFLECTION_GENERATOR_EXECUTABLE}\" is not a file.") message(FATAL_ERROR "The specified code generator executable \"${REFLECTION_GENERATOR_EXECUTABLE}\" is not a file.")
endif() endif ()
elseif(CMAKE_CROSSCOMPILING OR NOT TARGET "${DEFAULT_REFLECTION_GENERATOR_EXECUTABLE}") elseif (CMAKE_CROSSCOMPILING OR NOT TARGET "${DEFAULT_REFLECTION_GENERATOR_EXECUTABLE}")
# find native/external "reflective_rapidjson_generator" # find native/external "reflective_rapidjson_generator"
find_program(REFLECTION_GENERATOR_EXECUTABLE find_program(REFLECTION_GENERATOR_EXECUTABLE "${DEFAULT_REFLECTION_GENERATOR_EXECUTABLE}" PATHS "/usr/bin" "/bin")
"${DEFAULT_REFLECTION_GENERATOR_EXECUTABLE}" else ()
PATHS "/usr/bin" "/bin"
)
else()
# use "reflective_rapidjson_generator" target # use "reflective_rapidjson_generator" target
set(REFLECTION_GENERATOR_EXECUTABLE "${DEFAULT_REFLECTION_GENERATOR_EXECUTABLE}") set(REFLECTION_GENERATOR_EXECUTABLE "${DEFAULT_REFLECTION_GENERATOR_EXECUTABLE}")
endif() endif ()
if(NOT REFLECTION_GENERATOR_EXECUTABLE) if (NOT REFLECTION_GENERATOR_EXECUTABLE)
message(FATAL_ERROR "Unable to find executable of generator for reflection code. Set REFLECTION_GENERATOR_EXECUTABLE to specify the path.") message(
endif() FATAL_ERROR
"Unable to find executable of generator for reflection code. Set REFLECTION_GENERATOR_EXECUTABLE to specify the path."
)
endif ()
# determine Clang's resource directory # determine Clang's resource directory
set(REFLECTION_GENERATOR_CLANG_RESOURCE_DIR "" CACHE PATH "directory containing Clang's builtin headers, usually /usr/lib/clang/version") set(REFLECTION_GENERATOR_CLANG_RESOURCE_DIR ""
if(NOT REFLECTION_GENERATOR_CLANG_RESOURCE_DIR) CACHE PATH "directory containing Clang's builtin headers, usually /usr/lib/clang/version")
if(NOT REFLECTION_GENERATOR_CLANG_BIN) if (NOT REFLECTION_GENERATOR_CLANG_RESOURCE_DIR)
find_program(REFLECTION_GENERATOR_CLANG_BIN clang if (NOT REFLECTION_GENERATOR_CLANG_BIN)
NAMES clang++ find_program(REFLECTION_GENERATOR_CLANG_BIN clang NAMES clang++ PATHS "/usr/bin" "/bin")
PATHS "/usr/bin" "/bin" if (NOT REFLECTION_GENERATOR_CLANG_BIN)
)
if(NOT REFLECTION_GENERATOR_CLANG_BIN)
message(FATAL_ERROR "Unable to find the clang executable to determine Clang's resource directory") message(FATAL_ERROR "Unable to find the clang executable to determine Clang's resource directory")
endif() endif ()
endif() endif ()
exec_program(${REFLECTION_GENERATOR_CLANG_BIN} ARGS -print-resource-dir OUTPUT_VARIABLE REFLECTION_GENERATOR_CLANG_RESOURCE_DIR) exec_program(${REFLECTION_GENERATOR_CLANG_BIN}
endif() ARGS
if(NOT REFLECTION_GENERATOR_CLANG_RESOURCE_DIR OR NOT IS_DIRECTORY "${REFLECTION_GENERATOR_CLANG_RESOURCE_DIR}") -print-resource-dir
message(FATAL_ERROR "Unable to find Clang's resource directory. Set REFLECTION_GENERATOR_CLANG_RESOURCE_DIR manually to the corresponding path (usually /usr/lib/clang/\$version).") OUTPUT_VARIABLE
endif() REFLECTION_GENERATOR_CLANG_RESOURCE_DIR)
endif ()
if (NOT REFLECTION_GENERATOR_CLANG_RESOURCE_DIR OR NOT IS_DIRECTORY "${REFLECTION_GENERATOR_CLANG_RESOURCE_DIR}")
message(
FATAL_ERROR
"Unable to find Clang's resource directory. Set REFLECTION_GENERATOR_CLANG_RESOURCE_DIR manually to the corresponding path (usually /usr/lib/clang/\$version)."
)
endif ()
message(STATUS "Using ${REFLECTION_GENERATOR_CLANG_RESOURCE_DIR} as Clang's resource directory for Reflective RapidJSON") message(STATUS "Using ${REFLECTION_GENERATOR_CLANG_RESOURCE_DIR} as Clang's resource directory for Reflective RapidJSON")
# allow to specify a custom include paths (useful for cross-compilation when header files are under custom prefix) # allow to specify a custom include paths (useful for cross-compilation when header files are under custom prefix)
@ -55,67 +60,61 @@ set(REFLECTION_GENERATOR_TRIPLE "" CACHE STRING "platform triple for code genera
# define helper function to add a reflection generator invocation for a specified list of source files # define helper function to add a reflection generator invocation for a specified list of source files
include(CMakeParseArguments) include(CMakeParseArguments)
function(add_reflection_generator_invocation) function (add_reflection_generator_invocation)
# parse arguments # parse arguments
set(OPTIONAL_ARGS set(OPTIONAL_ARGS)
) set(ONE_VALUE_ARGS OUTPUT_DIRECTORY JSON_VISIBILITY)
set(ONE_VALUE_ARGS set(MULTI_VALUE_ARGS INPUT_FILES GENERATORS OUTPUT_LISTS CLANG_OPTIONS CLANG_OPTIONS_FROM_TARGETS JSON_CLASSES)
OUTPUT_DIRECTORY
JSON_VISIBILITY
)
set(MULTI_VALUE_ARGS
INPUT_FILES
GENERATORS
OUTPUT_LISTS
CLANG_OPTIONS
CLANG_OPTIONS_FROM_TARGETS
JSON_CLASSES)
cmake_parse_arguments(ARGS "${OPTIONAL_ARGS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN}) cmake_parse_arguments(ARGS "${OPTIONAL_ARGS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN})
# determine file name or file path if none specified # determine file name or file path if none specified
if(NOT ARGS_OUTPUT_DIRECTORY) if (NOT ARGS_OUTPUT_DIRECTORY)
set(ARGS_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/reflection") set(ARGS_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/reflection")
file(MAKE_DIRECTORY "${ARGS_OUTPUT_DIRECTORY}") file(MAKE_DIRECTORY "${ARGS_OUTPUT_DIRECTORY}")
endif() endif ()
# specify Clang's resource directory # specify Clang's resource directory
list(APPEND ARGS_CLANG_OPTIONS -resource-dir "${REFLECTION_GENERATOR_CLANG_RESOURCE_DIR}") list(APPEND ARGS_CLANG_OPTIONS -resource-dir "${REFLECTION_GENERATOR_CLANG_RESOURCE_DIR}")
# apply specified REFLECTION_GENERATOR_TRIPLET # apply specified REFLECTION_GENERATOR_TRIPLET
if(REFLECTION_GENERATOR_TRIPLE) if (REFLECTION_GENERATOR_TRIPLE)
list(APPEND ARGS_CLANG_OPTIONS list(APPEND ARGS_CLANG_OPTIONS
-Xclang -triple -Xclang
-Xclang "${REFLECTION_GENERATOR_TRIPLE}" -triple
) -Xclang
endif() "${REFLECTION_GENERATOR_TRIPLE}")
endif ()
# apply specified REFLECTION_GENERATOR_INCLUDE_DIRECTORIES # apply specified REFLECTION_GENERATOR_INCLUDE_DIRECTORIES
foreach(INCLUDE_DIR ${REFLECTION_GENERATOR_INCLUDE_DIRECTORIES}) foreach (INCLUDE_DIR ${REFLECTION_GENERATOR_INCLUDE_DIRECTORIES})
if(NOT IS_DIRECTORY "${INCLUDE_DIR}") if (NOT IS_DIRECTORY "${INCLUDE_DIR}")
message(FATAL_ERROR "Specified include directory \"${INCLUDE_DIR})\" for reflection generator doesn't exists.") message(FATAL_ERROR "Specified include directory \"${INCLUDE_DIR})\" for reflection generator doesn't exists.")
endif() endif ()
list(APPEND ARGS_CLANG_OPTIONS -I "${INCLUDE_DIR}") list(APPEND ARGS_CLANG_OPTIONS -I "${INCLUDE_DIR}")
endforeach() endforeach ()
# add workaround for cross compiling with mingw-w64 to prevent host stdlib.h being included # add workaround for cross compiling with mingw-w64 to prevent host stdlib.h being included (not sure why specifying
# (not sure why specifying REFLECTION_GENERATOR_INCLUDE_DIRECTORIES is not enough to let it find this particular header file) # REFLECTION_GENERATOR_INCLUDE_DIRECTORIES is not enough to let it find this particular header file)
if(MINGW) if (MINGW)
# find MinGW version of stdlib.h # find MinGW version of stdlib.h
find_file(MINGW_W64_STDLIB_H stdlib.h ${REFLECTION_GENERATOR_INCLUDE_DIRECTORIES}) find_file(MINGW_W64_STDLIB_H stdlib.h ${REFLECTION_GENERATOR_INCLUDE_DIRECTORIES})
if(NOT EXISTS "${MINGW_W64_STDLIB_H}") if (NOT EXISTS "${MINGW_W64_STDLIB_H}")
message(FATAL_ERROR "Unable to locate MinGW version of stdlib.h. Ensure it is in REFLECTION_GENERATOR_INCLUDE_DIRECTORIES.") message(
endif() FATAL_ERROR
"Unable to locate MinGW version of stdlib.h. Ensure it is in REFLECTION_GENERATOR_INCLUDE_DIRECTORIES.")
endif ()
# ensure libtooling includes the MinGW version of stdlib.h rather than the host version # ensure libtooling includes the MinGW version of stdlib.h rather than the host version
list(APPEND ARGS_CLANG_OPTIONS list(APPEND ARGS_CLANG_OPTIONS
-include "${MINGW_W64_STDLIB_H}" -include
-D_STDLIB_H # prevent processing of host stdlib.h "${MINGW_W64_STDLIB_H}"
) -D_STDLIB_H # prevent processing of host stdlib.h
endif() )
endif ()
# add options to be passed to clang from the specified targets # add options to be passed to clang from the specified targets
if(ARGS_CLANG_OPTIONS_FROM_TARGETS) if (ARGS_CLANG_OPTIONS_FROM_TARGETS)
foreach(TARGET_NAME ${ARGS_CLANG_OPTIONS_FROM_TARGETS}) foreach (TARGET_NAME ${ARGS_CLANG_OPTIONS_FROM_TARGETS})
# set c++ standard # set c++ standard
list(APPEND CLANG_TIDY_CXX_FLAGS "-std=c++$<TARGET_PROPERTY:${TARGET_NAME},CXX_STANDARD>") list(APPEND CLANG_TIDY_CXX_FLAGS "-std=c++$<TARGET_PROPERTY:${TARGET_NAME},CXX_STANDARD>")
# add compile flags # add compile flags
@ -127,11 +126,11 @@ function(add_reflection_generator_invocation)
# add include directories # add include directories
set(PROP "$<TARGET_PROPERTY:${TARGET_NAME},INCLUDE_DIRECTORIES>") set(PROP "$<TARGET_PROPERTY:${TARGET_NAME},INCLUDE_DIRECTORIES>")
list(APPEND ARGS_CLANG_OPTIONS "$<$<BOOL:${PROP}>:-I$<JOIN:${PROP},$<SEMICOLON>-I>>") list(APPEND ARGS_CLANG_OPTIONS "$<$<BOOL:${PROP}>:-I$<JOIN:${PROP},$<SEMICOLON>-I>>")
endforeach() endforeach ()
endif() endif ()
# create a custom command for each input file # create a custom command for each input file
foreach(INPUT_FILE ${ARGS_INPUT_FILES}) foreach (INPUT_FILE ${ARGS_INPUT_FILES})
# determine the output file # determine the output file
get_filename_component(OUTPUT_NAME "${INPUT_FILE}" NAME_WE) get_filename_component(OUTPUT_NAME "${INPUT_FILE}" NAME_WE)
set(OUTPUT_FILE "${ARGS_OUTPUT_DIRECTORY}/${OUTPUT_NAME}.h") set(OUTPUT_FILE "${ARGS_OUTPUT_DIRECTORY}/${OUTPUT_NAME}.h")
@ -139,34 +138,35 @@ function(add_reflection_generator_invocation)
# compose the CLI arguments and actually add the custom command # compose the CLI arguments and actually add the custom command
set(CLI_ARGUMENTS set(CLI_ARGUMENTS
--output-file "${OUTPUT_FILE}" --output-file
--input-file "${INPUT_FILE}" "${OUTPUT_FILE}"
--generators ${ARGS_GENERATORS} --input-file
--clang-opt ${ARGS_CLANG_OPTIONS} "${INPUT_FILE}"
--json-classes ${ARGS_JSON_CLASSES} --generators
) ${ARGS_GENERATORS}
if(ARGS_JSON_VISIBILITY) --clang-opt
${ARGS_CLANG_OPTIONS}
--json-classes
${ARGS_JSON_CLASSES})
if (ARGS_JSON_VISIBILITY)
list(APPEND CLI_ARGUMENTS --json-visibility "${ARGS_JSON_VISIBILITY}") list(APPEND CLI_ARGUMENTS --json-visibility "${ARGS_JSON_VISIBILITY}")
endif() endif ()
add_custom_command( add_custom_command(OUTPUT "${OUTPUT_FILE}"
OUTPUT "${OUTPUT_FILE}" COMMAND "${REFLECTION_GENERATOR_EXECUTABLE}" ARGS ${CLI_ARGUMENTS}
COMMAND "${REFLECTION_GENERATOR_EXECUTABLE}" DEPENDS "${INPUT_FILE}"
ARGS ${CLI_ARGUMENTS} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS "${INPUT_FILE}" COMMENT "Generating reflection code for ${INPUT_FILE}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" VERBATIM)
COMMENT "Generating reflection code for ${INPUT_FILE}"
VERBATIM
)
# prevent Qt's code generator to be executed on the files generated by this code generator # prevent Qt's code generator to be executed on the files generated by this code generator
set_property(SOURCE "${OUTPUT_FILE}" PROPERTY SKIP_AUTOGEN ON) set_property(SOURCE "${OUTPUT_FILE}" PROPERTY SKIP_AUTOGEN ON)
# append the output file to lists specified via OUTPUT_LISTS # append the output file to lists specified via OUTPUT_LISTS
if(ARGS_OUTPUT_LISTS) if (ARGS_OUTPUT_LISTS)
foreach(OUTPUT_LIST ${ARGS_OUTPUT_LISTS}) foreach (OUTPUT_LIST ${ARGS_OUTPUT_LISTS})
list(APPEND "${OUTPUT_LIST}" "${OUTPUT_FILE}") list(APPEND "${OUTPUT_LIST}" "${OUTPUT_FILE}")
set("${OUTPUT_LIST}" "${${OUTPUT_LIST}}" PARENT_SCOPE) set("${OUTPUT_LIST}" "${${OUTPUT_LIST}}" PARENT_SCOPE)
endforeach() endforeach ()
endif() endif ()
endforeach() endforeach ()
endfunction() endfunction ()