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.
parent bf7b6d15
...@@ -7,7 +7,6 @@ option(BuildTests "Build the unit tests" ON) ...@@ -7,7 +7,6 @@ option(BuildTests "Build the unit tests" ON)
# define project variables # define project variables
set(JSON_TARGET_NAME ${PROJECT_NAME}) set(JSON_TARGET_NAME ${PROJECT_NAME})
set(JSON_UNITTEST_TARGET_NAME "json_unit")
set(JSON_PACKAGE_NAME ${JSON_TARGET_NAME}) set(JSON_PACKAGE_NAME ${JSON_TARGET_NAME})
set(JSON_TARGETS_FILENAME "${JSON_PACKAGE_NAME}Targets.cmake") set(JSON_TARGETS_FILENAME "${JSON_PACKAGE_NAME}Targets.cmake")
set(JSON_CONFIG_FILENAME "${JSON_PACKAGE_NAME}Config.cmake") set(JSON_CONFIG_FILENAME "${JSON_PACKAGE_NAME}Config.cmake")
...@@ -23,17 +22,17 @@ target_include_directories(${JSON_TARGET_NAME} INTERFACE ...@@ -23,17 +22,17 @@ target_include_directories(${JSON_TARGET_NAME} INTERFACE
# create and configure the unit test target # create and configure the unit test target
if (BuildTests) if (BuildTests)
add_executable(${JSON_UNITTEST_TARGET_NAME} add_executable(json_unit
"test/catch.hpp" "test/catch.hpp"
"test/unit.cpp" "test/unit.cpp"
) )
set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES set_target_properties(json_unit PROPERTIES
CXX_STANDARD 11 CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON CXX_STANDARD_REQUIRED ON
COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>" COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>") COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>")
target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "test") target_include_directories(json_unit PRIVATE "test")
target_link_libraries(${JSON_UNITTEST_TARGET_NAME} ${JSON_TARGET_NAME}) target_link_libraries(json_unit ${JSON_TARGET_NAME})
endif() endif()
# generate a config and config version file for the package # generate a config and config version file for the package
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment