mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Ensure compatibility with CMake 3.10
This fixes some CMake-3.12+-isms, like `list(JOIN ...)` and setting link properties on OBJECT libraries. PiperOrigin-RevId: 265033725 Change-Id: I0ee1ec0e1b1097ea8226ad6fdeff794a97c2881b
This commit is contained in:
parent
c966f21109
commit
d91879f752
|
@ -1,5 +1,8 @@
|
|||
---
|
||||
tasks:
|
||||
ubuntu1804:
|
||||
shell_commands:
|
||||
- apt-get update && apt-get install libcap-dev
|
||||
- pip3 install absl-py clang
|
||||
build_targets:
|
||||
- "..."
|
||||
|
|
|
@ -38,7 +38,7 @@ configure_file(cmake/libcap_capability.h.in
|
|||
|
||||
# Library with basic project settings. The empty file is there to be able to
|
||||
# define header-only libraries without cumbersome target_sources() hacks.
|
||||
file(TOUCH ${SAPI_BINARY_DIR}/sapi_base_force_cxx_linkage.cc)
|
||||
file(WRITE ${SAPI_BINARY_DIR}/sapi_base_force_cxx_linkage.cc "")
|
||||
add_library(sapi_base STATIC
|
||||
"${SAPI_BINARY_DIR}/sapi_base_force_cxx_linkage.cc"
|
||||
)
|
||||
|
|
|
@ -102,7 +102,7 @@ function(add_sapi_library)
|
|||
set(_sapi_bin "${_sapi_NAME}.bin")
|
||||
set(_sapi_force_cxx_linkage
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${_sapi_bin}_force_cxx_linkage.cc")
|
||||
file(TOUCH "${_sapi_force_cxx_linkage}")
|
||||
file(WRITE "${_sapi_force_cxx_linkage}" "")
|
||||
add_executable("${_sapi_bin}" "${_sapi_force_cxx_linkage}")
|
||||
# TODO(cblichmann): Use target_link_options on CMake >= 3.13
|
||||
target_link_libraries("${_sapi_bin}" PRIVATE
|
||||
|
@ -123,12 +123,12 @@ function(add_sapi_library)
|
|||
endif()
|
||||
|
||||
# Interface
|
||||
list(JOIN _sapi_FUNCTIONS "," _sapi_funcs)
|
||||
list_join(_sapi_FUNCTIONS "," _sapi_funcs)
|
||||
foreach(src IN LISTS _sapi_INPUTS)
|
||||
get_filename_component(src "${src}" ABSOLUTE)
|
||||
list(APPEND _sapi_full_inputs "${src}")
|
||||
endforeach()
|
||||
list(JOIN _sapi_full_inputs "," _sapi_full_inputs)
|
||||
list_join(_sapi_full_inputs "," _sapi_full_inputs)
|
||||
if(NOT _sapi_NOEMBED)
|
||||
set(_sapi_embed_dir "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
set(_sapi_embed_name "${_sapi_NAME}")
|
||||
|
@ -152,7 +152,7 @@ function(add_sapi_library)
|
|||
if(NOT _sapi_SOURCES)
|
||||
set(_sapi_force_cxx_linkage
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${_sapi_NAME}_force_cxx_linkage.cc")
|
||||
file(TOUCH "${_sapi_force_cxx_linkage}")
|
||||
file(WRITE "${_sapi_force_cxx_linkage}" "")
|
||||
list(APPEND _sapi_SOURCES "${_sapi_force_cxx_linkage}")
|
||||
endif()
|
||||
add_library("${_sapi_NAME}" STATIC
|
||||
|
|
|
@ -35,6 +35,16 @@ function(create_directory_symlink SOURCE DESTINATION)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
# Implements list(JOIN ...) for CMake < 3.12.
|
||||
function(list_join LIST SEP OUTPUT)
|
||||
foreach(item IN LISTS ${LIST})
|
||||
set(_concat "${_concat}${SEP}${item}")
|
||||
endforeach()
|
||||
string(LENGTH "${SEP}" _len)
|
||||
string(SUBSTRING "${_concat}" ${_len} -1 _concat)
|
||||
set(${OUTPUT} "${_concat}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Helper function that behaves just like Protobuf's protobuf_generate_cpp(),
|
||||
# except that it strips import paths. This is necessary, because CMake's
|
||||
# protobuf rules don't work well with imports across different directories.
|
||||
|
|
|
@ -38,3 +38,5 @@ set(protobuf_WITH_ZLIB OFF CACHE BOOL "")
|
|||
|
||||
add_subdirectory("${CMAKE_BINARY_DIR}/protobuf-src/cmake"
|
||||
"${CMAKE_BINARY_DIR}/protobuf-build" EXCLUDE_FROM_ALL)
|
||||
get_property(Protobuf_INCLUDE_DIRS TARGET protobuf::libprotobuf
|
||||
PROPERTY INCLUDE_DIRECTORIES)
|
||||
|
|
|
@ -23,9 +23,8 @@ add_library(sapi_stringop_params_proto OBJECT
|
|||
${_sapi_stringop_params_pb_h}
|
||||
)
|
||||
add_library(sapi::stringop_params_proto ALIAS sapi_stringop_params_proto)
|
||||
target_link_libraries(sapi_stringop_params_proto
|
||||
PRIVATE sapi::base
|
||||
PUBLIC protobuf::libprotobuf
|
||||
target_include_directories(sapi_stringop_params_proto PUBLIC
|
||||
${Protobuf_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# sandboxed_api/examples/stringop/lib:stringop
|
||||
|
|
|
@ -23,9 +23,8 @@ add_library(sapi_sum_params_proto OBJECT
|
|||
${_sapi_sum_params_pb_h}
|
||||
)
|
||||
add_library(sapi::sum_params_proto ALIAS sapi_sum_params_proto)
|
||||
target_link_libraries(sapi_sum_params_proto
|
||||
PRIVATE sapi::base
|
||||
PUBLIC protobuf::libprotobuf
|
||||
target_include_directories(sapi_sum_params_proto PUBLIC
|
||||
${Protobuf_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# sandboxed_api/examples/sum/lib:sum
|
||||
|
|
Loading…
Reference in New Issue
Block a user