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.
上级 bf7b6d15
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册