Skip to content

Commit 51a36db

Browse files
cblichmanncopybara-github
authored andcommitted
CMake: Update to >= 3.25
- Update the minimum required CMake version to 3.25 - Use `cmake_path` for more robust path handling during header installation - Remove custom FetchContent macro - Switch the Zlib dependency to explicitly use ZLIB::ZLIBSTATIC - Disable building documentation for libunwind - Adjust policies to reflect the newer version Drive-by: Fix a copy-and-paste typo in `ubuntu-cmake.yml` PiperOrigin-RevId: 903803386 Change-Id: I73e798482156a53f24e79a66c14194747040537f
1 parent b8819fe commit 51a36db

9 files changed

Lines changed: 12 additions & 44 deletions

File tree

.github/workflows/ubuntu-cmake.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
clang-${{matrix.compiler-version}} \
5858
libclang-${{matrix.libclang-version}}-dev \
5959
libclang-rt-${{matrix.libclang-version}}-dev \
60-
llvm-${{matrix.libclang-version}}-dev \
60+
llvm-${{matrix.libclang-version}}-dev
6161
echo "CXX=clang++-${{matrix.compiler-version}}" >> $GITHUB_ENV
6262
echo "CC=clang-${{matrix.compiler-version}}" >> $GITHUB_ENV
6363
@@ -68,7 +68,7 @@ jobs:
6868
g++-${{matrix.compiler-version}} \
6969
libclang-${{matrix.libclang-version}}-dev \
7070
libclang-rt-${{matrix.libclang-version}}-dev \
71-
llvm-${{matrix.libclang-version}}-dev \
71+
llvm-${{matrix.libclang-version}}-dev
7272
echo "CXX=g++-${{matrix.compiler-version}}" >> $GITHUB_ENV
7373
echo "CC=gcc-${{matrix.compiler-version}}" >> $GITHUB_ENV
7474

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
cmake_minimum_required(VERSION 3.13..3.26)
15+
cmake_minimum_required(VERSION 3.25..4.2)
1616

1717
if(POLICY CMP0083)
1818
cmake_policy(SET CMP0083 NEW) # Add PIE flags when requested
1919
endif()
2020

21-
if(POLICY CMP0135)
22-
cmake_policy(SET CMP0135 NEW) # Set download timestamp to current time
21+
if(POLICY CMP0177)
22+
cmake_policy(SET CMP0177 NEW) # Normalize install() paths
2323
endif()
2424

2525
project(SandboxedAPI C CXX ASM)

cmake/SapiDeps.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function(sapi_check_target target)
1919
endif()
2020
endfunction()
2121

22-
include(SapiFetchContent)
22+
include(FetchContent)
2323

2424
# Use static libraries
2525
set(_sapi_saved_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
@@ -92,7 +92,7 @@ sapi_check_target(re2)
9292
if(SAPI_BUILD_EXAMPLES)
9393
if(SAPI_DOWNLOAD_ZLIB)
9494
include(cmake/zlib.cmake)
95-
sapi_check_target(ZLIB::ZLIB)
95+
sapi_check_target(ZLIB::ZLIBSTATIC)
9696
else()
9797
find_package(ZLIB REQUIRED)
9898
endif()

cmake/SapiFetchContent.cmake

Lines changed: 0 additions & 32 deletions
This file was deleted.

cmake/libunwind.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ if(NOT libunwind_POPULATED)
2727
message("-- Running ./configure for libunwind...")
2828
execute_process(
2929
COMMAND ./configure --disable-dependency-tracking
30+
--disable-documentation
3031
--disable-minidebuginfo
3132
--disable-shared
3233
--enable-ptrace

cmake/zlib.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ FetchContent_MakeAvailable(zlib)
2020

2121
set(ZLIB_FOUND TRUE)
2222
set(ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR})
23-
add_library(ZLIB::ZLIB ALIAS zlibstatic)

sandboxed_api/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ endforeach()
403403
file(GLOB_RECURSE _sapi_headers true ${CMAKE_CURRENT_LIST_DIR}/*.h)
404404
list(FILTER _sapi_headers EXCLUDE REGEX /\(tools|examples\)/)
405405
foreach(_file ${_sapi_headers})
406-
get_filename_component(_dir ${_file} DIRECTORY)
407-
string(REPLACE ${CMAKE_CURRENT_LIST_DIR} "" _dir ${_dir})
406+
cmake_path(GET _file PARENT_PATH _dir)
407+
cmake_path(RELATIVE_PATH _dir BASE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
408408
install(FILES ${_file}
409409
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sandboxed_api/${_dir})
410410
endforeach()

sandboxed_api/examples/zlib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ add_sapi_library(zlib-sapi
2424
)
2525
add_library(sapi::zlib_sapi ALIAS zlib-sapi)
2626
target_link_libraries(zlib-sapi PRIVATE
27-
ZLIB::ZLIB
27+
ZLIB::ZLIBSTATIC
2828
)
2929

3030
# sandboxed_api/examples/zlib:main_zlib

sandboxed_api/sandbox2/examples/zlib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ set_target_properties(sandbox2_zpipe PROPERTIES OUTPUT_NAME zpipe)
4545
add_executable(sandbox2::zpipe ALIAS sandbox2_zpipe)
4646
target_link_libraries(sandbox2_zpipe PRIVATE
4747
-static
48-
ZLIB::ZLIB
48+
ZLIB::ZLIBSTATIC
4949
)

0 commit comments

Comments
 (0)