don't build tests in CMake by default

This commit is contained in:
Dmitry Arkhipov 2024-05-14 22:14:04 +03:00
parent 5db44182b6
commit 0b410ea466
3 changed files with 30 additions and 5 deletions

View File

@ -70,10 +70,17 @@ cd ../../
mkdir __build_static && cd __build_static
cmake -DBoost_VERBOSE=1 !CMAKE_BUILD_TESTING! -DCMAKE_INSTALL_PREFIX=iprefix ^
-DBOOST_INCLUDE_LIBRARIES=!SELF! !CMAKE_OPTIONS! ..
cmake --build . --target install --config Debug
if NOT "!CMAKE_BUILD_TESTING!" == "" (
cmake --build . --target tests --config Debug
)
ctest --output-on-failure --no-tests=error -R boost_!SELF! -C Debug
cmake --build . --target install --config Release
if NOT "!CMAKE_BUILD_TESTING!" == "" (
cmake --build . --target tests --config Release
)
ctest --output-on-failure --no-tests=error -R boost_!SELF! -C Release
cd ..
@ -86,12 +93,19 @@ if "!CMAKE_SHARED_LIBS!" == "1" (
mkdir __build_shared && cd __build_shared
cmake -DBoost_VERBOSE=1 !CMAKE_BUILD_TESTING! -DCMAKE_INSTALL_PREFIX=iprefix ^
-DBOOST_INCLUDE_LIBRARIES=!SELF! -DBUILD_SHARED_LIBS=ON !CMAKE_OPTIONS! ..
cmake --build . --config Debug
cmake --build . --target install --config Debug
if NOT "!CMAKE_BUILD_TESTING!" == "" (
cmake --build . --target tests --config Debug
)
ctest --output-on-failure --no-tests=error -R boost_!SELF! -C Debug
cmake --build . --config Release
cmake --build . --target install --config Release
if NOT "!CMAKE_BUILD_TESTING!" == "" (
cmake --build . --target tests --config Release
)
ctest --output-on-failure --no-tests=error -R boost_!SELF! -C Release
)

View File

@ -173,6 +173,9 @@ mkdir __build_static
cd __build_static
cmake -DBoost_VERBOSE=1 ${CMAKE_BUILD_TESTING} -DCMAKE_INSTALL_PREFIX=iprefix \
-DBOOST_INCLUDE_LIBRARIES=$SELF ${CMAKE_OPTIONS} ..
if [ -n "${CMAKE_BUILD_TESTING}" ]; then
cmake --build . --target tests
fi
cmake --build . --target install
ctest --output-on-failure --no-tests=$CMAKE_NO_TESTS -R boost_$SELF
cd ..
@ -183,6 +186,9 @@ mkdir __build_shared
cd __build_shared
cmake -DBoost_VERBOSE=1 ${CMAKE_BUILD_TESTING} -DCMAKE_INSTALL_PREFIX=iprefix \
-DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=ON ${CMAKE_OPTIONS} ..
if [ -n "${CMAKE_BUILD_TESTING}" ]; then
cmake --build . --target tests
fi
cmake --build . --target install
ctest --output-on-failure --no-tests=$CMAKE_NO_TESTS -R boost_$SELF

View File

@ -8,9 +8,14 @@
# Official repository: https://github.com/boostorg/json
#
if(BOOST_JSON_IS_ROOT)
set(EXCLUDE_TESTS_FROM_ALL)
else()
set(EXCLUDE_TESTS_FROM_ALL EXCLUDE_FROM_ALL)
endif()
if(NOT TARGET tests)
add_custom_target(tests)
add_custom_target(tests ${EXCLUDE_TESTS_FROM_ALL})
set_property(TARGET tests PROPERTY FOLDER _deps)
endif()
@ -23,7 +28,7 @@ list(FILTER BOOST_JSON_TESTS_FILES EXCLUDE REGEX limits\.cpp$)
list(FILTER BOOST_JSON_TESTS_FILES EXCLUDE REGEX no_exceptions\.cpp$)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "" FILES ${BOOST_JSON_TESTS_FILES})
add_executable(boost_json-tests ${BOOST_JSON_TESTS_FILES})
add_executable(boost_json-tests ${EXCLUDE_TESTS_FROM_ALL} ${BOOST_JSON_TESTS_FILES})
target_include_directories(boost_json-tests PRIVATE .)
target_link_libraries(boost_json-tests PRIVATE Boost::json)
target_compile_options(boost_json-tests PRIVATE
@ -35,7 +40,7 @@ add_dependencies(tests boost_json-tests)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "" FILES limits.cpp main.cpp intrusive_macros.cpp)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/../src PREFIX "" FILES ../src/src.cpp)
add_executable(boost_json-limits limits.cpp main.cpp ../src/src.cpp Jamfile)
add_executable(boost_json-limits ${EXCLUDE_TESTS_FROM_ALL} limits.cpp main.cpp ../src/src.cpp Jamfile)
boost_json_setup_properties(boost_json-limits)
target_compile_definitions(boost_json-limits PRIVATE
@ -48,7 +53,7 @@ target_compile_definitions(boost_json-limits PRIVATE
add_test(NAME boost_json-limits COMMAND boost_json-limits)
add_dependencies(tests boost_json-limits)
add_executable(boost_json-no_exceptions no_exceptions.cpp main.cpp ../src/src.cpp Jamfile)
add_executable(boost_json-no_exceptions ${EXCLUDE_TESTS_FROM_ALL} no_exceptions.cpp main.cpp ../src/src.cpp Jamfile)
boost_json_setup_properties(boost_json-no_exceptions)
target_compile_definitions(boost_json-no_exceptions PRIVATE
@ -63,7 +68,7 @@ target_compile_options(boost_json-no_exceptions PRIVATE
add_test(NAME boost_json-no_exceptions COMMAND boost_json-no_exceptions)
add_dependencies(tests boost_json-no_exceptions)
add_executable(boost_json-intrusive-macro-tests intrusive_macros.cpp main.cpp Jamfile)
add_executable(boost_json-intrusive-macro-tests ${EXCLUDE_TESTS_FROM_ALL} intrusive_macros.cpp main.cpp Jamfile)
boost_json_setup_properties(boost_json-intrusive-macro-tests)
target_compile_definitions(boost_json-intrusive-macro-tests PRIVATE
BOOST_JSON_NO_LIB=1