Skip to content

Commit

Permalink
Fix build with custom target suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
Martchus committed Jan 31, 2020
1 parent c68d9ea commit 891b96a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()

Expand Down
8 changes: 4 additions & 4 deletions generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion lib/cmake/modules/ReflectionGenerator.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 891b96a

Please sign in to comment.