sandboxed-api/sandboxed_api/util/CMakeLists.txt
Anton D. Kachalov 0e8d16e011 Enable shared libraries build and cross-compilation
This allows resource-constrained environments to benefit from the
space savings of dynamic linking. This is not meant to be used in
the general case.

PiperOrigin-RevId: 347398828
Change-Id: Ia634959148a31159878f48c44255dd733424a2b8
2020-12-14 09:16:14 -08:00

127 lines
3.4 KiB
CMake

# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# sandboxed_api/util:status_proto
sapi_protobuf_generate_cpp(_sapi_util_status_pb_cc _sapi_util_status_pb_h
status.proto
)
add_library(sapi_util_status_proto ${SAPI_LIB_TYPE}
${_sapi_util_status_pb_cc}
${_sapi_util_status_pb_h}
)
add_library(sapi::status_proto ALIAS sapi_util_status_proto)
target_link_libraries(sapi_util_status_proto
PRIVATE sapi::base
PUBLIC protobuf::libprotobuf
)
# sandboxed_api/util:status
add_library(sapi_util_status ${SAPI_LIB_TYPE}
status.cc
status.h
status_macros.h
)
add_library(sapi::status ALIAS sapi_util_status)
target_link_libraries(sapi_util_status
PRIVATE absl::core_headers
absl::status
absl::strings
sapi::base
protobuf::libprotobuf
PUBLIC sapi::status_proto
)
# sandboxed_api/util:statusor
add_library(sapi_util_statusor ${SAPI_LIB_TYPE}
statusor.h
)
add_library(sapi::statusor ALIAS sapi_util_statusor)
target_link_libraries(sapi_util_statusor PRIVATE
absl::core_headers
absl::status
absl::statusor
sapi::base
)
# sandboxed_api/util:flag
file(WRITE ${SAPI_BINARY_DIR}/sapi_util_flags_force_cxx_linkage.cc "")
add_library(sapi_util_flags ${SAPI_LIB_TYPE}
flag.h
"${SAPI_BINARY_DIR}/sapi_util_flags_force_cxx_linkage.cc"
)
add_library(sapi::flags ALIAS sapi_util_flags)
target_link_libraries(sapi_util_flags PUBLIC
glog::glog
# gflags::gflags
)
# sandboxed_api/util:raw_logging
add_library(sapi_util_raw_logging ${SAPI_LIB_TYPE}
raw_logging.cc
raw_logging.h
)
add_library(sapi::raw_logging ALIAS sapi_util_raw_logging)
target_link_libraries(sapi_util_raw_logging PRIVATE
absl::str_format
absl::strings
sandbox2::strerror
sapi::base
)
if(SAPI_ENABLE_TESTS)
# sandboxed_api/util:status_matchers
add_library(sapi_util_status_matchers ${SAPI_LIB_TYPE}
status_matchers.h
)
add_library(sapi::status_matchers ALIAS sapi_util_status_matchers)
target_link_libraries(sapi_util_status_matchers
PRIVATE absl::optional
gmock
gtest
sapi::base
PUBLIC absl::status
sapi::status
)
# sandboxed_api/util:status_test
add_executable(sapi_status_test
status_test.cc
)
set_target_properties(sapi_status_test PROPERTIES OUTPUT_NAME status_test)
target_link_libraries(sapi_status_test PRIVATE
sapi::status
sapi::status_matchers
sapi::test_main
absl::status
absl::type_traits
)
gtest_discover_tests_xcompile(sapi_status_test)
# sandboxed_api/util:status_macros_test
add_executable(sapi_status_macros_test
status_macros_test.cc
)
set_target_properties(sapi_status_macros_test PROPERTIES
OUTPUT_NAME status_macros_test
)
target_link_libraries(sapi_status_macros_test PRIVATE
sapi::status_matchers
sapi::test_main
absl::status
absl::statusor
absl::type_traits
)
gtest_discover_tests_xcompile(sapi_status_macros_test)
endif()