Apply cmake-format 0.6.2
This commit is contained in:
parent
03563aafbf
commit
1192c2d74a
|
@ -14,28 +14,16 @@ 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-boosthana.h json/reflector-chronoutilities.h
|
||||||
json/reflector.h
|
json/serializable.h json/errorhandling.h)
|
||||||
json/reflector-boosthana.h
|
list(APPEND TEST_SRC_FILES tests/jsonreflector.cpp tests/jsonreflector-boosthana.cpp
|
||||||
json/reflector-chronoutilities.h
|
|
||||||
json/serializable.h
|
|
||||||
json/errorhandling.h)
|
|
||||||
list(APPEND TEST_SRC_FILES
|
|
||||||
tests/jsonreflector.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-boosthana.h binary/reflector-chronoutilities.h
|
||||||
binary/reflector.h
|
|
||||||
binary/reflector-boosthana.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/binaryreflector.cpp tests/binaryreflector-boosthana.cpp)
|
||||||
tests/traits.cpp
|
|
||||||
tests/binaryreflector.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})
|
||||||
|
|
|
@ -8,7 +8,9 @@ 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}")
|
||||||
|
@ -25,7 +27,7 @@ if (NOT REFLECTION_GENERATOR_EXECUTABLE)
|
||||||
message(
|
message(
|
||||||
FATAL_ERROR
|
FATAL_ERROR
|
||||||
"Unable to find executable of generator for reflection code. Set REFLECTION_GENERATOR_EXECUTABLE to specify the path."
|
"Unable to find executable of generator for reflection code. Set REFLECTION_GENERATOR_EXECUTABLE to specify the path."
|
||||||
)
|
)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# determine Clang's resource directory
|
# determine Clang's resource directory
|
||||||
|
@ -34,30 +36,34 @@ set(REFLECTION_GENERATOR_CLANG_RESOURCE_DIR
|
||||||
CACHE PATH "directory containing Clang's builtin headers, usually /usr/lib/clang/version")
|
CACHE PATH "directory containing Clang's builtin headers, usually /usr/lib/clang/version")
|
||||||
if (NOT REFLECTION_GENERATOR_CLANG_RESOURCE_DIR)
|
if (NOT REFLECTION_GENERATOR_CLANG_RESOURCE_DIR)
|
||||||
if (NOT REFLECTION_GENERATOR_CLANG_BIN)
|
if (NOT REFLECTION_GENERATOR_CLANG_BIN)
|
||||||
find_program(REFLECTION_GENERATOR_CLANG_BIN clang NAMES clang++ PATHS "/usr/bin" "/bin")
|
find_program(
|
||||||
|
REFLECTION_GENERATOR_CLANG_BIN clang
|
||||||
|
NAMES clang++
|
||||||
|
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}
|
exec_program(${REFLECTION_GENERATOR_CLANG_BIN} ARGS -print-resource-dir OUTPUT_VARIABLE
|
||||||
ARGS
|
|
||||||
-print-resource-dir
|
|
||||||
OUTPUT_VARIABLE
|
|
||||||
REFLECTION_GENERATOR_CLANG_RESOURCE_DIR)
|
REFLECTION_GENERATOR_CLANG_RESOURCE_DIR)
|
||||||
endif ()
|
endif ()
|
||||||
if (NOT REFLECTION_GENERATOR_CLANG_RESOURCE_DIR OR NOT IS_DIRECTORY "${REFLECTION_GENERATOR_CLANG_RESOURCE_DIR}")
|
if (NOT REFLECTION_GENERATOR_CLANG_RESOURCE_DIR OR NOT IS_DIRECTORY "${REFLECTION_GENERATOR_CLANG_RESOURCE_DIR}")
|
||||||
message(
|
message(
|
||||||
FATAL_ERROR
|
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)."
|
"Unable to find Clang's resource directory. Set REFLECTION_GENERATOR_CLANG_RESOURCE_DIR manually to the corresponding path (usually /usr/lib/clang/\$version)."
|
||||||
)
|
)
|
||||||
endif ()
|
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)
|
||||||
set(REFLECTION_GENERATOR_INCLUDE_DIRECTORIES "" CACHE FILEPATH "include directories for code generator")
|
set(REFLECTION_GENERATOR_INCLUDE_DIRECTORIES
|
||||||
|
""
|
||||||
|
CACHE FILEPATH "include directories for code generator")
|
||||||
|
|
||||||
# allow to specify a custom platform tiple (useful for cross-compilation to specify the target platform)
|
# allow to specify a custom platform tiple (useful for cross-compilation to specify the target platform)
|
||||||
set(REFLECTION_GENERATOR_TRIPLE "" CACHE STRING "platform triple for code generator")
|
set(REFLECTION_GENERATOR_TRIPLE
|
||||||
|
""
|
||||||
|
CACHE STRING "platform triple for code generator")
|
||||||
|
|
||||||
# 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)
|
||||||
|
@ -65,18 +71,8 @@ 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 OUTPUT_DIRECTORY JSON_VISIBILITY)
|
||||||
set(MULTI_VALUE_ARGS
|
set(MULTI_VALUE_ARGS INPUT_FILES GENERATORS OUTPUT_LISTS CLANG_OPTIONS CLANG_OPTIONS_FROM_TARGETS JSON_CLASSES)
|
||||||
INPUT_FILES
|
cmake_parse_arguments(ARGS "${OPTIONAL_ARGS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN})
|
||||||
GENERATORS
|
|
||||||
OUTPUT_LISTS
|
|
||||||
CLANG_OPTIONS
|
|
||||||
CLANG_OPTIONS_FROM_TARGETS
|
|
||||||
JSON_CLASSES)
|
|
||||||
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)
|
||||||
|
@ -89,11 +85,7 @@ function (add_reflection_generator_invocation)
|
||||||
|
|
||||||
# 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 "${REFLECTION_GENERATOR_TRIPLE}")
|
||||||
-Xclang
|
|
||||||
-triple
|
|
||||||
-Xclang
|
|
||||||
"${REFLECTION_GENERATOR_TRIPLE}")
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# apply specified REFLECTION_GENERATOR_INCLUDE_DIRECTORIES
|
# apply specified REFLECTION_GENERATOR_INCLUDE_DIRECTORIES
|
||||||
|
@ -116,11 +108,8 @@ function (add_reflection_generator_invocation)
|
||||||
endif ()
|
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}" -D_STDLIB_H # prevent processing of host stdlib.h
|
||||||
-include
|
)
|
||||||
"${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
|
||||||
|
@ -162,12 +151,13 @@ function (add_reflection_generator_invocation)
|
||||||
if (ARGS_JSON_VISIBILITY)
|
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(OUTPUT "${OUTPUT_FILE}"
|
add_custom_command(
|
||||||
COMMAND "${REFLECTION_GENERATOR_EXECUTABLE}" ARGS ${CLI_ARGUMENTS}
|
OUTPUT "${OUTPUT_FILE}"
|
||||||
DEPENDS "${INPUT_FILE}"
|
COMMAND "${REFLECTION_GENERATOR_EXECUTABLE}" 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)
|
||||||
|
@ -176,7 +166,9 @@ function (add_reflection_generator_invocation)
|
||||||
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 ()
|
||||||
|
|
Loading…
Reference in New Issue