Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't build tests in CMake by default #1006

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .drone/drone.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..

Expand All @@ -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

)
Expand Down
6 changes: 6 additions & 0 deletions .drone/drone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..
Expand All @@ -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

Expand Down
15 changes: 10 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading