Don't use variable for the test target name

I'm not sure that using a variable for target names really helps
with clarity. Unlike paths, target names aren't really something
you change. In a sense, targets are themselves a sort of variable,
so having a variable to name a variable seems just a bit gnarly.
This commit is contained in:
Chris Kitching 2016-05-11 01:12:56 +01:00
parent bf7b6d15c7
commit b6becce8fb
No known key found for this signature in database
GPG Key ID: 332E9EC8C8C33B2D

View File

@ -7,7 +7,6 @@ option(BuildTests "Build the unit tests" ON)
# define project variables
set(JSON_TARGET_NAME ${PROJECT_NAME})
set(JSON_UNITTEST_TARGET_NAME "json_unit")
set(JSON_PACKAGE_NAME ${JSON_TARGET_NAME})
set(JSON_TARGETS_FILENAME "${JSON_PACKAGE_NAME}Targets.cmake")
set(JSON_CONFIG_FILENAME "${JSON_PACKAGE_NAME}Config.cmake")
@ -23,17 +22,17 @@ target_include_directories(${JSON_TARGET_NAME} INTERFACE
# create and configure the unit test target
if (BuildTests)
add_executable(${JSON_UNITTEST_TARGET_NAME}
add_executable(json_unit
"test/catch.hpp"
"test/unit.cpp"
)
set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES
set_target_properties(json_unit PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>")
target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "test")
target_link_libraries(${JSON_UNITTEST_TARGET_NAME} ${JSON_TARGET_NAME})
target_include_directories(json_unit PRIVATE "test")
target_link_libraries(json_unit ${JSON_TARGET_NAME})
endif()
# generate a config and config version file for the package