mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
CMake build: Skip examples/tests when used via add_subdirectory
PiperOrigin-RevId: 422512365 Change-Id: I38c6b23d1b33b89346ccf6c6692d50f88c82212b
This commit is contained in:
parent
066af80c8b
commit
baa1e570b4
|
@ -47,6 +47,11 @@ endif()
|
|||
set(SAPI_BINARY_DIR "${PROJECT_BINARY_DIR}" CACHE INTERNAL "" FORCE)
|
||||
set(SAPI_SOURCE_DIR "${PROJECT_SOURCE_DIR}" CACHE INTERNAL "" FORCE)
|
||||
|
||||
get_directory_property(_sapi_has_parent PARENT_DIRECTORY)
|
||||
if(PROJECT_IS_TOP_LEVEL OR NOT _sapi_has_parent)
|
||||
set(SAPI_PROJECT_IS_TOP_LEVEL ON)
|
||||
endif()
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
# Sapi CMake modules, order matters
|
||||
|
|
|
@ -12,6 +12,14 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# If Sandboxed API is built from a plain checkout, built everything.
|
||||
# Otherwise, skip tests and examples.
|
||||
if(SAPI_PROJECT_IS_TOP_LEVEL)
|
||||
set(_sapi_enable_tests_examples_default ON)
|
||||
else()
|
||||
set(_sapi_enable_tests_examples_default OFF)
|
||||
endif()
|
||||
|
||||
# These options determine whether CMake should download the libraries that
|
||||
# Sandboxed API depends on at configure time.
|
||||
# The CMake script SapiDeps.cmake checks for the presence of certain build
|
||||
|
@ -30,16 +38,27 @@ 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" ON)
|
||||
option(SAPI_DOWNLOAD_ZLIB "Download zlib at config time (only if SAPI_ENABLE_EXAMPLES is set)" ON)
|
||||
option(SAPI_ENABLE_EXAMPLES
|
||||
"Build example code" ${_sapi_enable_tests_examples_default}
|
||||
)
|
||||
option(SAPI_DOWNLOAD_ZLIB
|
||||
"Download zlib at config time (only if SAPI_ENABLE_EXAMPLES is set)"
|
||||
${_sapi_enable_tests_examples_default}
|
||||
)
|
||||
|
||||
option(SAPI_ENABLE_TESTS "Build unit tests" ON)
|
||||
option(SAPI_ENABLE_GENERATOR "Build Clang based code generator from source" OFF)
|
||||
option(SAPI_ENABLE_TESTS
|
||||
"Build unit tests" ${_sapi_enable_tests_examples_default}
|
||||
)
|
||||
option(SAPI_ENABLE_GENERATOR
|
||||
"Build Clang based code generator from source" OFF
|
||||
)
|
||||
|
||||
# This flag should be only enabled for embedded and resource-constrained
|
||||
# environments
|
||||
# environments.
|
||||
option(SAPI_ENABLE_SHARED_LIBS "Build SAPI shared libs" OFF)
|
||||
|
||||
option(SAPI_HARDENED_SOURCE "Build with hardening compiler options" OFF)
|
||||
|
||||
option(SAPI_FORCE_COLOR_OUTPUT "Force colored compiler diagnostics when using Ninja" ON)
|
||||
option(SAPI_FORCE_COLOR_OUTPUT
|
||||
"Force colored compiler diagnostics when using Ninja" ON
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user