cmake: Rename build options to follow Abseil naming

`BUILD_TESTING` is a CMake provided option and we should use similar naming,
just like how Abseil does it.

- `SAPI_ENABLE_TESTS` -> `SAPI_BUILD_TESTING`
- `SAPI_ENABLE_CONTRIB_TESTS` -> `SAPI_CONTRIB_BUILD_TESTING`
- `SAPI_ENABLE_EXAMPLES` -> `SAPI_BUILD_EXAMPLES`

Drive-by:
- Fix option name in GitHub action
PiperOrigin-RevId: 443305932
Change-Id: Ice2b42be1229a0f9ae7c2ceda9ce87187baf22c4
This commit is contained in:
Christian Blichmann 2022-04-21 01:17:08 -07:00 committed by Copybara-Service
parent c0cfeed925
commit 839914d6dd
35 changed files with 70 additions and 69 deletions

View File

@ -68,8 +68,8 @@ jobs:
-B $GITHUB_WORKSPACE/build \
-G Ninja \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DSAPI_ENABLE_TEST=ON \
-DSAPI_ENABLE_EXAMPLES=ON
-DSAPI_BUILD_TESTING=ON \
-DSAPI_BUILD_EXAMPLES=ON
- name: Build
run: |

View File

@ -149,7 +149,7 @@ target_link_libraries(sapi_test_main INTERFACE
sapi::base
)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
include(GoogleTest)
# Setup tests to work like with Bazel
create_directory_symlink("${SAPI_BINARY_DIR}" com_google_sandboxed_api)
@ -158,6 +158,6 @@ endif()
add_subdirectory(sandboxed_api)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS AND SAPI_ENABLE_CONTRIB_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING AND SAPI_CONTRIB_BUILD_TESTING)
add_subdirectory(contrib)
endif()

View File

@ -41,7 +41,7 @@ endif()
set(_sapi_saved_BUILD_TESTING ${BUILD_TESTING})
set(BUILD_TESTING OFF) # No need to build test code of our deps
if(SAPI_ENABLE_TESTS)
if(SAPI_BUILD_TESTING)
if(SAPI_DOWNLOAD_GOOGLETEST)
include(cmake/googletest.cmake)
endif()
@ -99,7 +99,7 @@ if(SAPI_DOWNLOAD_PROTOBUF)
endif()
find_package(Protobuf REQUIRED)
if(SAPI_ENABLE_EXAMPLES)
if(SAPI_BUILD_EXAMPLES)
if(SAPI_DOWNLOAD_ZLIB)
include(cmake/zlib.cmake)
sapi_check_target(ZLIB::ZLIB)

View File

@ -38,19 +38,20 @@ option(SAPI_DOWNLOAD_LIBCAP "Download libcap at config time" ON)
option(SAPI_DOWNLOAD_LIBFFI "Download libffi at config time" ON)
# Options for building examples
option(SAPI_ENABLE_EXAMPLES
"Build example code" ${_sapi_enable_tests_examples_default}
option(SAPI_BUILD_EXAMPLES
"If ON, build example code" ${_sapi_enable_tests_examples_default}
)
option(SAPI_DOWNLOAD_ZLIB
"Download zlib at config time (only if SAPI_ENABLE_EXAMPLES is set)"
"Download zlib at config time (only if SAPI_BUILD_EXAMPLES is set)"
${_sapi_enable_tests_examples_default}
)
option(SAPI_ENABLE_TESTS
"Build unit tests" ${_sapi_enable_tests_examples_default}
option(SAPI_BUILD_TESTING
"If ON, this will build all of Sandboxed API's own tests"
${_sapi_enable_tests_examples_default}
)
# Disabled by default, as this will download a lot of extra content.
option(SAPI_ENABLE_CONTRIB_TESTS "Build tests for sandboxes in 'contrib'" OFF)
option(SAPI_CONTRIB_BUILD_TESTING "Build tests for sandboxes in 'contrib'" OFF)
option(SAPI_ENABLE_GENERATOR
"Build Clang based code generator from source" OFF

View File

@ -72,10 +72,10 @@ target_include_directories(sapi_brotli INTERFACE
"${SAPI_SOURCE_DIR}"
)
if(SAPI_ENABLE_EXAMPLES)
if(SAPI_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -81,10 +81,10 @@ target_include_directories(sapi_blosc INTERFACE
"${PROJECT_BINARY_DIR}"
)
if (SAPI_ENABLE_EXAMPLES)
if (SAPI_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
if (BUILD_TESTING AND SAPI_ENABLE_TESTS)
if (BUILD_TESTING AND SAPI_BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -133,10 +133,10 @@ target_include_directories(sapi_hunspell INTERFACE
"${PROJECT_BINARY_DIR}"
)
if(SAPI_ENABLE_EXAMPLES)
if(SAPI_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -89,11 +89,11 @@ target_link_libraries(jsonnet_sapi PUBLIC
sapi_contrib::jsonnet_helper
)
if(SAPI_ENABLE_EXAMPLES)
if(SAPI_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
# Create directories so the tests will be able to access them
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/tests_input"
"${PROJECT_BINARY_DIR}/tests_output"

View File

@ -53,7 +53,7 @@ in the `contrib/jsonnet` directory:
```
mkdir -p build && cd build
cmake .. -G Ninja -Wno-dev -DSAPI_ENABLE_TESTS=ON
cmake .. -G Ninja -Wno-dev -DSAPI_BUILD_TESTING=ON
ninja
```

View File

@ -58,6 +58,6 @@ target_link_libraries(libidn2_sapi_wrapper
PRIVATE idn2
)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_subdirectory(tests)
endif()

View File

@ -87,10 +87,10 @@ target_include_directories(sapi_zip INTERFACE
"${SAPI_SOURCE_DIR}"
)
if(SAPI_ENABLE_EXAMPLES)
if(SAPI_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -41,6 +41,6 @@ target_include_directories(turbojpeg_sapi INTERFACE
"${PROJECT_BINARY_DIR}"
)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_subdirectory(tests)
endif()

View File

@ -73,10 +73,10 @@ target_include_directories(sapi_uriparser INTERFACE
"${SAPI_SOURCE_DIR}"
)
if(SAPI_ENABLE_EXAMPLES)
if(SAPI_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -61,7 +61,7 @@ target_include_directories(woff2_sapi INTERFACE
"${SAPI_SOURCE_DIR}"
)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
enable_testing()
add_executable(woff2_sapi_test
woff2_sapi_test.cc

View File

@ -64,10 +64,10 @@ target_include_directories(sapi_zopfli INTERFACE
"${SAPI_SOURCE_DIR}"
)
if(SAPI_ENABLE_EXAMPLES)
if(SAPI_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -92,10 +92,10 @@ target_include_directories(sapi_zstd INTERFACE
"${SAPI_SOURCE_DIR}"
)
if(SAPI_ENABLE_EXAMPLES)
if(SAPI_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -35,8 +35,8 @@ add_subdirectory(curl_wrapper)
# Setup Sandboxed API
set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree")
set(SAPI_ENABLE_EXAMPLES ${SAPI_CURL_ENABLE_EXAMPLES} CACHE BOOL "" FORCE)
set(SAPI_ENABLE_TESTS ${SAPI_CURL_ENABLE_TESTS} CACHE BOOL "" FORCE)
set(SAPI_BUILD_EXAMPLES ${SAPI_CURL_ENABLE_EXAMPLES} CACHE BOOL "" FORCE)
set(SAPI_BUILD_TESTING ${SAPI_CURL_ENABLE_TESTS} CACHE BOOL "" FORCE)
add_subdirectory(
"${SAPI_ROOT}"
"${CMAKE_BINARY_DIR}/sandboxed-api-build"

View File

@ -99,7 +99,7 @@ website. More information about each example can be found in the examples'
[README](examples/README.md).
To build these examples when building the library, the cmake variable
`CURL_SAPI_ENABLE_EXAMPLES` must be set to `ON`. This enables Sandboxed API
`CURL_SAPI_BUILD_EXAMPLES` must be set to `ON`. This enables Sandboxed API
examples as well.
## Policy
@ -117,7 +117,7 @@ The `tests` folder contains some test cases created using Google Test. The class
including the setup of a mock local server on which test requests are performed.
To build these tests when building the library, the cmake variable
`CURL_SAPI_ENABLE_TESTS` must be set to `ON`. This enables Sandboxed API tests
`CURL_SAPI_BUILD_TESTING` must be set to `ON`. This enables Sandboxed API tests
as well.
## Callbacks

View File

@ -27,8 +27,8 @@ pkg_check_modules(proj REQUIRED IMPORTED_TARGET proj)
set(SAPI_ROOT "${PROJECT_SOURCE_DIR}/../.." CACHE PATH "Path to the Sandboxed API source tree")
# cmake .. -G Ninja -DSAPI_ROOT=$HOME/sapi_root
set(SAPI_ENABLE_EXAMPLES OFF CACHE BOOL "")
set(SAPI_ENABLE_TESTS OFF CACHE BOOL "")
set(SAPI_BUILD_EXAMPLES OFF CACHE BOOL "")
set(SAPI_BUILD_TESTING OFF CACHE BOOL "")
add_subdirectory("${SAPI_ROOT}"
"${CMAKE_BINARY_DIR}/sandboxed-api-build"
# Omit this to have the full Sandboxed API in IDE

View File

@ -27,11 +27,11 @@ set(SAPI_ROOT "" CACHE PATH "Path to the Sandboxed API source tree")
# mkdir -p build && cd build
# cmake .. -G Ninja -DSAPI_ROOT=/path/to/sapi_root
option(LIBPNG_SAPI_ENABLE_EXAMPLES "" OFF)
option(LIBPNG_SAPI_ENABLE_TESTS "" OFF)
option(LIBPNG_SAPI_BUILD_EXAMPLES "" OFF)
option(LIBPNG_SAPI_BUILD_TESTING "" OFF)
set(SAPI_ENABLE_EXAMPLES ${LIBPNG_SAPI_ENABLE_EXAMPLES} CACHE BOOL "" FORCE)
set(SAPI_ENABLE_TESTS ${LIBPNG_SAPI_ENABLE_TESTS} CACHE BOOL "" FORCE)
set(SAPI_BUILD_EXAMPLES ${LIBPNG_SAPI_BUILD_EXAMPLES} CACHE BOOL "" FORCE)
set(SAPI_BUILD_TESTING ${LIBPNG_SAPI_BUILD_TESTING} CACHE BOOL "" FORCE)
set (CMAKE_FIND_LIBRARY_SUFFIXES .a $ {CMAKE_FIND_LIBRARY_SUFFIXES})
find_package(PNG REQUIRED)
@ -102,11 +102,11 @@ target_include_directories(libpng_sapi INTERFACE
"${PROJECT_BINARY_DIR}" # To find the generated SAPI header
)
if (LIBPNG_SAPI_ENABLE_EXAMPLES)
if (LIBPNG_SAPI_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if (LIBPNG_SAPI_ENABLE_TESTS)
if (LIBPNG_SAPI_BUILD_TESTING)
add_subdirectory(tests)
endif()

View File

@ -16,7 +16,7 @@ make -j8
```
#### Example:
You should add `-DLIBPNG_SAPI_ENABLE_EXAMPLES=ON` to use the example.\
You should add `-DLIBPNG_SAPI_BUILD_EXAMPLES=ON` to use the example.\
run PNG to PNG:
```
./examples/pngtopng /absolute/path/to/input/image.png /absolute/path/to/output/image.png
@ -38,7 +38,7 @@ output: `images/rgbtobgr_red_ball.png`
#### Tests:
You should add `-DLIBPNG_SAPI_ENABLE_TESTS=ON` to use tests and do:
You should add `-DLIBPNG_SAPI_BUILD_TESTING=ON` to use tests and do:
```
cd tests
ctest .

View File

@ -27,11 +27,11 @@ set(SAPI_ROOT "" CACHE PATH "Path to the Sandboxed API source tree")
# mkdir -p build && cd build
# cmake .. -G Ninja -DSAPI_ROOT=$HOME/sapi_root
option(TIFF_SAPI_ENABLE_EXAMPLES "" ON)
option(TIFF_SAPI_ENABLE_TESTS "" ON)
option(TIFF_SAPI_BUILD_EXAMPLES "" ON)
option(TIFF_SAPI_BUILD_TESTING "" ON)
set(SAPI_ENABLE_EXAMPLES ${TIFF_SAPI_ENABLE_EXAMPLES} CACHE BOOL "" FORCE)
set(SAPI_ENABLE_TESTS ${TIFF_SAPI_ENABLE_TESTS} CACHE BOOL "" FORCE)
set(SAPI_BUILD_EXAMPLES ${TIFF_SAPI_BUILD_EXAMPLES} CACHE BOOL "" FORCE)
set(SAPI_BUILD_TESTING ${TIFF_SAPI_BUILD_TESTING} CACHE BOOL "" FORCE)
add_subdirectory(wrapper)
@ -121,10 +121,10 @@ target_include_directories(tiff_sapi INTERFACE
"${PROJECT_BINARY_DIR}" # To find the generated SAPI header
)
if (TIFF_SAPI_ENABLE_EXAMPLES)
if (TIFF_SAPI_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
if (TIFF_SAPI_ENABLE_TESTS)
if (TIFF_SAPI_BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -72,8 +72,8 @@ target_link_libraries(uv_wrapper_and_callbacks uv_a)
# Setup Sandboxed API
set(SAPI_ROOT "" CACHE PATH "Path to the Sandboxed API source tree")
set(SAPI_ENABLE_EXAMPLES ${SAPI_UV_ENABLE_EXAMPLES} CACHE BOOL "" FORCE)
set(SAPI_ENABLE_TESTS ${SAPI_UV_ENABLE_TESTS} CACHE BOOL "" FORCE)
set(SAPI_BUILD_EXAMPLES ${SAPI_UV_ENABLE_EXAMPLES} CACHE BOOL "" FORCE)
set(SAPI_BUILD_TESTING ${SAPI_UV_ENABLE_TESTS} CACHE BOOL "" FORCE)
# Generate SAPI header
add_sapi_library(uv_sapi

View File

@ -24,8 +24,8 @@ set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build OpenJPEG shared library and link exe
add_subdirectory(openjpeg)
set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree")
set(SAPI_ENABLE_EXAMPLES OFF CACHE BOOL "")
set(SAPI_ENABLE_TESTS OFF CACHE BOOL "")
set(SAPI_BUILD_EXAMPLES OFF CACHE BOOL "")
set(SAPI_BUILD_TESTING OFF CACHE BOOL "")
set(EXECUTABLE_OUTPUT_PATH "" CACHE PATH "" FORCE)
add_subdirectory("${SAPI_ROOT}"
"${CMAKE_BINARY_DIR}/sandboxed-api-build"

View File

@ -190,7 +190,7 @@ target_link_libraries(sapi_client
PUBLIC glog::glog
)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS AND NOT CMAKE_CROSSCOMPILING)
if(BUILD_TESTING AND SAPI_BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
# sandboxed_api:testing
add_library(sapi_testing ${SAPI_LIB_TYPE}
testing.cc

View File

@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if((SAPI_ENABLE_EXAMPLES OR SAPI_ENABLE_TESTS) AND NOT CMAKE_CROSSCOMPILING)
if((SAPI_BUILD_EXAMPLES OR SAPI_BUILD_TESTING) AND NOT CMAKE_CROSSCOMPILING)
# TODO(cblichmann): These are depended on by sapi::sapi_test
add_subdirectory(stringop)
add_subdirectory(sum)
endif()
if(SAPI_ENABLE_EXAMPLES AND SAPI_DOWNLOAD_ZLIB)
if(SAPI_BUILD_EXAMPLES AND SAPI_DOWNLOAD_ZLIB)
add_subdirectory(zlib)
endif()

View File

@ -28,8 +28,8 @@ set(SAPI_ROOT "${PROJECT_SOURCE_DIR}/../../.."
CACHE PATH "Path to the Sandboxed API source tree")
# Configure options and include Sandboxed API as a sub-directory.
set(SAPI_ENABLE_EXAMPLES OFF CACHE BOOL "")
set(SAPI_ENABLE_TESTS OFF CACHE BOOL "")
set(SAPI_BUILD_EXAMPLES OFF CACHE BOOL "")
set(SAPI_BUILD_TESTING OFF CACHE BOOL "")
add_subdirectory("${SAPI_ROOT}"
"${CMAKE_BINARY_DIR}/sandboxed-api-build" EXCLUDE_FROM_ALL)

View File

@ -65,7 +65,7 @@ target_link_libraries(stringop-sapi PRIVATE
sapi::base
)
if(SAPI_ENABLE_TESTS)
if(SAPI_BUILD_TESTING)
# sandboxed_api/examples/stringop:main_stringop
add_executable(sapi_main_stringop
main_stringop.cc

View File

@ -617,7 +617,7 @@ target_link_libraries(sandbox2_violation_proto PRIVATE
sapi::base
)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_subdirectory(testcases)
# sandboxed_api/sandbox2:regs_test

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if(SAPI_ENABLE_EXAMPLES)
if(SAPI_BUILD_EXAMPLES)
add_subdirectory(crc4)
add_subdirectory(custom_fork)
add_subdirectory(network)

View File

@ -61,7 +61,7 @@ target_link_libraries(sandbox2_network_proxy_client PRIVATE
sapi::status
)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
# sandboxed_api/sandbox2/network_proxy:filtering_test
add_executable(sandbox2_filtering_test
filtering_test.cc

View File

@ -50,7 +50,7 @@ target_link_libraries(sandbox2_util_maps_parser
PUBLIC absl::statusor
)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
# sandboxed_api/sandbox2/util:minielf_test
add_executable(sandbox2_minielf_test
minielf_test.cc

View File

@ -67,7 +67,7 @@ target_link_libraries(sapi_generator_tool PRIVATE
sapi::generator
)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_executable(sapi_generator_test
frontend_action_test_util.cc
frontend_action_test_util.h

View File

@ -30,7 +30,7 @@ sapi_cc_embed_data(NAME filewrapper_embedded
SOURCES testdata/filewrapper_embedded.bin
)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
# sandboxed_api/tools/filewrapper:filewrapper_test
add_executable(sapi_filewrapper_test
filewrapper_test.cc

View File

@ -148,7 +148,7 @@ target_link_libraries(sapi_util_temp_file
absl::statusor
)
if(BUILD_TESTING AND SAPI_ENABLE_TESTS)
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
# sandboxed_api/util:file_base_test
add_executable(sapi_file_base_test
path_test.cc