mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
cmake: Include CTest
in all projects, honor BUILD_TESTING
setting
Including the `CTest` modules ensures that the `BUILD_TESTING` option is defined and automatically calls `enable_testing()` if needed. It does not change the default or introduce any dependencies on its own. This follows what Abseil already does in their top-level `CMakeLists.txt`. PiperOrigin-RevId: 443305646 Change-Id: If067c17470f497437c7748aab4aab5227c26e84f
This commit is contained in:
parent
8dd9d47ba7
commit
c0cfeed925
|
@ -19,6 +19,7 @@ if(POLICY CMP0083)
|
|||
endif()
|
||||
|
||||
project(SandboxedAPI C CXX ASM)
|
||||
include(CTest)
|
||||
|
||||
# TODO(cblichmann): Enable for Android once support lands
|
||||
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
@ -148,7 +149,7 @@ target_link_libraries(sapi_test_main INTERFACE
|
|||
sapi::base
|
||||
)
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
include(GoogleTest)
|
||||
# Setup tests to work like with Bazel
|
||||
create_directory_symlink("${SAPI_BINARY_DIR}" com_google_sandboxed_api)
|
||||
|
@ -157,6 +158,6 @@ endif()
|
|||
|
||||
add_subdirectory(sandboxed_api)
|
||||
|
||||
if(SAPI_ENABLE_TESTS AND SAPI_ENABLE_CONTRIB_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS AND SAPI_ENABLE_CONTRIB_TESTS)
|
||||
add_subdirectory(contrib)
|
||||
endif()
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
cmake_minimum_required(VERSION 3.13..3.22)
|
||||
|
||||
project(sapi_brotli CXX)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
@ -75,6 +76,6 @@ if(SAPI_ENABLE_EXAMPLES)
|
|||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
cmake_minimum_required(VERSION 3.13..3.22)
|
||||
|
||||
project(sapi_blosc CXX)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
@ -84,6 +85,6 @@ if (SAPI_ENABLE_EXAMPLES)
|
|||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
if (SAPI_ENABLE_TESTS)
|
||||
if (BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
cmake_minimum_required(VERSION 3.13..3.22)
|
||||
|
||||
project(sapi_hunspell CXX)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
@ -136,6 +137,6 @@ if(SAPI_ENABLE_EXAMPLES)
|
|||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.13..3.22)
|
||||
|
||||
project(jsonnet-sapi C CXX)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
@ -91,10 +93,7 @@ if(SAPI_ENABLE_EXAMPLES)
|
|||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
include(GoogleTest)
|
||||
enable_testing()
|
||||
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
# Create directories so the tests will be able to access them
|
||||
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/tests_input"
|
||||
"${PROJECT_BINARY_DIR}/tests_output"
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.13..3.22)
|
||||
|
||||
project(libidn2-sapi CXX C)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
@ -56,6 +58,6 @@ target_link_libraries(libidn2_sapi_wrapper
|
|||
PRIVATE idn2
|
||||
)
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
project(sapi_zip CXX)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
@ -90,6 +91,6 @@ if(SAPI_ENABLE_EXAMPLES)
|
|||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.13..3.22)
|
||||
|
||||
project(pffft CXX C)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.13..3.22)
|
||||
|
||||
project(turbojpeg-sapi CXX C)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
@ -39,6 +41,6 @@ target_include_directories(turbojpeg_sapi INTERFACE
|
|||
"${PROJECT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
cmake_minimum_required(VERSION 3.13..3.22)
|
||||
|
||||
project(sapi_uriparser CXX)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
@ -76,6 +77,6 @@ if(SAPI_ENABLE_EXAMPLES)
|
|||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.13..3.22)
|
||||
|
||||
project(woff2-sapi CXX C)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
@ -59,7 +61,7 @@ target_include_directories(woff2_sapi INTERFACE
|
|||
"${SAPI_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
enable_testing()
|
||||
add_executable(woff2_sapi_test
|
||||
woff2_sapi_test.cc
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
cmake_minimum_required(VERSION 3.13..3.22)
|
||||
|
||||
project(sapi_zopfli CXX)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
@ -67,6 +68,6 @@ if(SAPI_ENABLE_EXAMPLES)
|
|||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
project(sapi_zstd CXX)
|
||||
include(CTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
@ -95,6 +96,6 @@ if(SAPI_ENABLE_EXAMPLES)
|
|||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
|
|
@ -190,7 +190,7 @@ target_link_libraries(sapi_client
|
|||
PUBLIC glog::glog
|
||||
)
|
||||
|
||||
if(SAPI_ENABLE_TESTS AND NOT CMAKE_CROSSCOMPILING)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS AND NOT CMAKE_CROSSCOMPILING)
|
||||
# sandboxed_api:testing
|
||||
add_library(sapi_testing ${SAPI_LIB_TYPE}
|
||||
testing.cc
|
||||
|
|
|
@ -617,7 +617,7 @@ target_link_libraries(sandbox2_violation_proto PRIVATE
|
|||
sapi::base
|
||||
)
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
add_subdirectory(testcases)
|
||||
|
||||
# sandboxed_api/sandbox2:regs_test
|
||||
|
|
|
@ -61,7 +61,7 @@ target_link_libraries(sandbox2_network_proxy_client PRIVATE
|
|||
sapi::status
|
||||
)
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
# sandboxed_api/sandbox2/network_proxy:filtering_test
|
||||
add_executable(sandbox2_filtering_test
|
||||
filtering_test.cc
|
||||
|
|
|
@ -50,7 +50,7 @@ target_link_libraries(sandbox2_util_maps_parser
|
|||
PUBLIC absl::statusor
|
||||
)
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
# sandboxed_api/sandbox2/util:minielf_test
|
||||
add_executable(sandbox2_minielf_test
|
||||
minielf_test.cc
|
||||
|
|
|
@ -67,7 +67,7 @@ target_link_libraries(sapi_generator_tool PRIVATE
|
|||
sapi::generator
|
||||
)
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
add_executable(sapi_generator_test
|
||||
frontend_action_test_util.cc
|
||||
frontend_action_test_util.h
|
||||
|
|
|
@ -30,7 +30,7 @@ sapi_cc_embed_data(NAME filewrapper_embedded
|
|||
SOURCES testdata/filewrapper_embedded.bin
|
||||
)
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
# sandboxed_api/tools/filewrapper:filewrapper_test
|
||||
add_executable(sapi_filewrapper_test
|
||||
filewrapper_test.cc
|
||||
|
|
|
@ -148,7 +148,7 @@ target_link_libraries(sapi_util_temp_file
|
|||
absl::statusor
|
||||
)
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
|
||||
# sandboxed_api/util:file_base_test
|
||||
add_executable(sapi_file_base_test
|
||||
path_test.cc
|
||||
|
|
Loading…
Reference in New Issue
Block a user