Make singleheader tests be test-only
This commit is contained in:
parent
02a8145b18
commit
843b73dedb
|
@ -13,8 +13,8 @@ set(SIMDJSON_LIB_SOVERSION "1" CACHE STRING "simdjson library soversion")
|
|||
set(SIMDJSON_GITHUB_REPOSITORY https://github.com/simdjson/simdjson)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(simdjson-flags.cmake)
|
||||
include(simdjson-user-cmakecache.cmake)
|
||||
include(cmake/simdjson-flags.cmake)
|
||||
include(cmake/simdjson-user-cmakecache.cmake)
|
||||
|
||||
if(SIMDJSON_JUST_LIBRARY)
|
||||
MESSAGE( STATUS "Building just the library, omitting all tests, tools and benchmarks." )
|
||||
|
|
|
@ -3,19 +3,23 @@
|
|||
# SOURCES defaults to testname.cpp if not specified.
|
||||
function(add_cpp_test TEST_NAME)
|
||||
# Parse arguments
|
||||
cmake_parse_arguments(PARSE_ARGV 1 ARGS "COMPILE_ONLY;WILL_FAIL" "" "SOURCES;LABELS")
|
||||
cmake_parse_arguments(PARSE_ARGV 1 ARGS "COMPILE_ONLY;LIBRARY;WILL_FAIL" "" "SOURCES;LABELS")
|
||||
if (NOT ARGS_SOURCES)
|
||||
list(APPEND ARGS_SOURCES ${TEST_NAME}.cpp)
|
||||
endif()
|
||||
if (COMPILE_ONLY)
|
||||
if (ARGS_COMPILE_ONLY)
|
||||
list(APPEND ${ARGS_LABELS} compile)
|
||||
endif()
|
||||
|
||||
# Add executable
|
||||
add_executable(${TEST_NAME} ${ARGS_SOURCES})
|
||||
# Add the compile target
|
||||
if (ARGS_LIBRARY)
|
||||
add_library(${TEST_NAME} STATIC ${ARGS_SOURCES})
|
||||
else(ARGS_LIBRARY)
|
||||
add_executable(${TEST_NAME} ${ARGS_SOURCES})
|
||||
endif(ARGS_LIBRARY)
|
||||
|
||||
# Add test
|
||||
if (ARGS_COMPILE_ONLY)
|
||||
if (ARGS_COMPILE_ONLY OR ARGS_LIBRARY)
|
||||
add_test(
|
||||
NAME ${TEST_NAME}
|
||||
COMMAND ${CMAKE_COMMAND} --build . --target ${TEST_NAME} --config $<CONFIGURATION>
|
||||
|
@ -34,3 +38,12 @@ function(add_cpp_test TEST_NAME)
|
|||
set_property(TEST ${TEST_NAME} PROPERTY WILL_FAIL TRUE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(add_compile_only_test TEST_NAME)
|
||||
add_test(
|
||||
NAME ${TEST_NAME}
|
||||
COMMAND ${CMAKE_COMMAND} --build . --target ${TEST_NAME} --config $<CONFIGURATION>
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
)
|
||||
set_target_properties(${TEST_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE EXCLUDE_FROM_DEFAULT_BUILD TRUE)
|
||||
endfunction()
|
|
@ -1,4 +1,5 @@
|
|||
option(SIMDJSON_JUST_LIBRARY "Build just the library, omit tests, tools and benchmarks" OFF)
|
||||
|
||||
#
|
||||
# Flags used by exes and by the simdjson library (project-wide flags)
|
||||
#
|
|
@ -1,3 +1,5 @@
|
|||
include(${PROJECT_SOURCE_DIR}/cmake/add_cpp_test.cmake)
|
||||
|
||||
#
|
||||
# Amalgamation
|
||||
#
|
||||
|
@ -122,6 +124,7 @@ install(FILES simdjson.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|||
|
||||
add_library(simdjson-singleheader STATIC "")
|
||||
target_link_libraries(simdjson-singleheader simdjson-singleheader-source simdjson-internal-flags)
|
||||
add_compile_only_test(simdjson-singleheader)
|
||||
|
||||
#
|
||||
# Test the existing simdjson.cpp/simdjson.h using the existing amalgamate_demo.cpp, using
|
||||
|
|
|
@ -37,7 +37,7 @@ endfunction()
|
|||
# Most tests need test data, and many need windows headers.
|
||||
link_libraries(simdjson-internal-flags test-data simdjson-windows-headers)
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/tests/add_cpp_test.cmake)
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/add_cpp_test.cmake)
|
||||
|
||||
#
|
||||
# These tests explicitly do #include "simdjson.cpp" so they can override stuff
|
||||
|
|
Loading…
Reference in New Issue