Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
c87b080c
Unverified
Commit
c87b080c
authored
Aug 25, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
👷
new cmake file for test cases
parent
5b71bf09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
72 deletions
+40
-72
test/CMakeLists.txt
test/CMakeLists.txt
+40
-72
No files found.
test/CMakeLists.txt
View file @
c87b080c
#############################################################################
# Catch library with the main function to speed up build
#############################################################################
add_library
(
catch_main OBJECT
"src/unit.cpp"
)
set_target_properties
(
catch_main 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
(
catch_main PRIVATE
"thirdparty/catch"
)
# The unit test executable.
set
(
JSON_UNITTEST_TARGET_NAME
"json_unit"
)
add_executable
(
${
JSON_UNITTEST_TARGET_NAME
}
$<TARGET_OBJECTS:catch_main>
"../src/json.hpp"
"src/unit-algorithms.cpp"
"src/unit-allocator.cpp"
"src/unit-capacity.cpp"
"src/unit-cbor.cpp"
"src/unit-class_const_iterator.cpp"
"src/unit-class_iterator.cpp"
"src/unit-class_lexer.cpp"
"src/unit-class_parser.cpp"
"src/unit-comparison.cpp"
"src/unit-concepts.cpp"
"src/unit-constructor1.cpp"
"src/unit-constructor2.cpp"
"src/unit-convenience.cpp"
"src/unit-conversions.cpp"
"src/unit-deserialization.cpp"
"src/unit-element_access1.cpp"
"src/unit-element_access2.cpp"
"src/unit-inspection.cpp"
"src/unit-iterator_wrapper.cpp"
"src/unit-iterators1.cpp"
"src/unit-iterators2.cpp"
"src/unit-json_patch.cpp"
"src/unit-json_pointer.cpp"
"src/unit-meta.cpp"
"src/unit-modifiers.cpp"
"src/unit-msgpack.cpp"
"src/unit-noexcept.cpp"
"src/unit-pointer_access.cpp"
"src/unit-readme.cpp"
"src/unit-reference_access.cpp"
"src/unit-regression.cpp"
"src/unit-serialization.cpp"
"src/unit-testsuites.cpp"
"src/unit-udt.cpp"
"src/unit-unicode.cpp"
)
#############################################################################
# one executable for each unit test file
#############################################################################
set_target_properties
(
${
JSON_UNITTEST_TARGET_NAME
}
PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
file
(
GLOB files
"src/unit-*.cpp"
)
foreach
(
file
${
files
}
)
get_filename_component
(
file_basename
${
file
}
NAME_WE
)
string
(
REGEX REPLACE
"unit-([^$]+)"
"test-
\\
1"
testcase
${
file_basename
}
)
if
(
MSVC
)
set_target_properties
(
${
JSON_UNITTEST_TARGET_NAME
}
PROPERTIES
COMPILE_DEFINITIONS
"_SCL_SECURE_NO_WARNINGS"
COMPILE_OPTIONS
"/EHsc;$<$<CONFIG:Release>:/Od>"
add_executable
(
${
testcase
}
$<TARGET_OBJECTS:catch_main>
${
file
}
)
set_target_properties
(
${
testcase
}
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>>"
)
endif
()
target_include_directories
(
${
JSON_UNITTEST_TARGET_NAME
}
PRIVATE
"src"
"thirdparty/catch"
)
target_link_libraries
(
${
JSON_UNITTEST_TARGET_NAME
}
${
JSON_TARGET_NAME
}
)
target_compile_definitions
(
${
testcase
}
PRIVATE CATCH_CONFIG_FAST_COMPILE
)
target_include_directories
(
${
testcase
}
PRIVATE
"thirdparty/catch"
)
target_link_libraries
(
${
testcase
}
${
JSON_TARGET_NAME
}
)
if
(
NOT MSVC
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-deprecated -Wno-float-equal"
)
endif
()
include
(
cotire OPTIONAL
)
include
(
cotire OPTIONAL
)
if
(
COMMAND cotire
)
cotire
(
${
testcase
}
)
endif
()
if
(
COMMAND cotire
)
set_target_properties
(
${
JSON_UNITTEST_TARGET_NAME
}
PROPERTIES
COTIRE_ADD_UNITY_BUILD FALSE
COTIRE_CXX_PREFIX_HEADER_INIT
"src/prefix.hpp"
add_test
(
NAME
"
${
testcase
}
_default"
COMMAND
${
testcase
}
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
)
# HACK - CMAKE_INCLUDE_SYSTEM_FLAG_CXX has a trailing space, which Cotire doesn't strip
# Technically, this fix should go in cotire.cmake. TODO - submit a pull request upstream.
if
(
CMAKE_INCLUDE_SYSTEM_FLAG_CXX
)
string
(
STRIP
"
${
CMAKE_INCLUDE_SYSTEM_FLAG_CXX
}
"
CMAKE_INCLUDE_SYSTEM_FLAG_CXX
)
endif
()
cotire
(
${
JSON_UNITTEST_TARGET_NAME
}
)
endif
()
set_tests_properties
(
"
${
testcase
}
_default"
PROPERTIES LABELS
"default"
)
add_test
(
NAME
"
${
JSON_UNITTEST_TARGET_NAME
}
_default"
COMMAND
${
JSON_UNITTEST_TARGET_NAME
}
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
)
add_test
(
NAME
"
${
JSON_UNITTEST_TARGET_NAME
}
_all"
COMMAND
${
JSON_UNITTEST_TARGET_NAME
}
"*"
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
)
add_test
(
NAME
"
${
testcase
}
_all"
COMMAND
${
testcase
}
"*"
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
)
set_tests_properties
(
"
${
testcase
}
_all"
PROPERTIES LABELS
"all"
)
endforeach
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment