Fix build with custom target suffix
This commit is contained in:
parent
c68d9ea384
commit
891b96a38f
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
|||
|
||||
# set metadata
|
||||
project(reflective_rapidjson)
|
||||
set(META_PROJECT_NAME ${PROJECT_NAME})
|
||||
set(META_PROJECT_NAME reflective_rapidjson)
|
||||
set(META_APP_NAME "Reflection for RapidJSON")
|
||||
set(META_APP_AUTHOR "Martchus")
|
||||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/reflective-rapidjson")
|
||||
|
@ -16,9 +16,6 @@ set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_
|
|||
set(META_CXX_STANDARD 17)
|
||||
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
|
||||
|
||||
# set project name for IDEs like Qt Creator
|
||||
project(${META_PROJECT_NAME})
|
||||
|
||||
# ensure testing is enabled at this level (and not only for particular sub directories)
|
||||
enable_testing()
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ else ()
|
|||
endif ()
|
||||
|
||||
# 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_TARGET_NAME}")
|
||||
|
||||
# include modules to apply configuration
|
||||
include(BasicConfig)
|
||||
|
@ -69,7 +69,7 @@ include(ShellCompletion)
|
|||
include(Doxygen)
|
||||
|
||||
# trigger code generator for tests because the tests already contain structs to be (de)serialized
|
||||
if (TARGET reflective_rapidjson_generator_tests)
|
||||
if (TARGET "${META_TARGET_NAME}_tests")
|
||||
include(ReflectionGenerator)
|
||||
# cmake-format: off
|
||||
add_reflection_generator_invocation(
|
||||
|
@ -85,7 +85,7 @@ if (TARGET reflective_rapidjson_generator_tests)
|
|||
CLANG_OPTIONS
|
||||
-std=c++17
|
||||
CLANG_OPTIONS_FROM_TARGETS
|
||||
reflective_rapidjson_generator_tests
|
||||
"${META_TARGET_NAME}_tests"
|
||||
JSON_CLASSES
|
||||
OtherNotJsonSerializable # test specifying classes for JSON (de)serialization manually
|
||||
SomeOtherClassName # specifying a class that does not exist should not cause any problems
|
||||
|
@ -94,7 +94,7 @@ if (TARGET reflective_rapidjson_generator_tests)
|
|||
)
|
||||
# cmake-format: on
|
||||
list(APPEND TEST_HEADER_FILES ${TEST_GENERATED_HEADER_FILES})
|
||||
target_sources(reflective_rapidjson_generator_tests PRIVATE ${TEST_GENERATED_HEADER_FILES})
|
||||
target_sources("${META_TARGET_NAME}_tests" PRIVATE ${TEST_GENERATED_HEADER_FILES})
|
||||
endif ()
|
||||
|
||||
# add paths for include dirs of c++utilities and RapidJSON to config header so test cases can use it
|
||||
|
|
|
@ -51,3 +51,6 @@ include(LibraryTarget)
|
|||
include(TestTarget)
|
||||
include(Doxygen)
|
||||
include(ConfigHeader)
|
||||
|
||||
# export target name so the generator can link against it
|
||||
set(${META_PROJECT_VARNAME_UPPER}_TARGET_NAME "${META_TARGET_NAME}" PARENT_SCOPE)
|
||||
|
|
|
@ -7,7 +7,7 @@ endif ()
|
|||
set(REFLECTION_GENERATOR_MODULE_LOADED YES)
|
||||
|
||||
# find code generator
|
||||
set(DEFAULT_REFLECTION_GENERATOR_EXECUTABLE "reflective_rapidjson_generator")
|
||||
set(DEFAULT_REFLECTION_GENERATOR_EXECUTABLE "${TARGET_PREFIX}reflective_rapidjson_generator${TARGET_SUFFIX}")
|
||||
set(REFLECTION_GENERATOR_EXECUTABLE
|
||||
""
|
||||
CACHE FILEPATH "path to executable of reflection generator")
|
||||
|
|
Loading…
Reference in New Issue