Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ execute_process(COMMAND uname -n OUTPUT_VARIABLE BUILD_MACHINE OUTPUT_STRIP_TRAI

# Options
set(DEFAULT_STACK_SIZE 1048576 CACHE STRING "Default stack size (default 1048576)")
option(ENABLE_POSIX_CAP
"Use POSIX capabilities, turn OFF to use id switching. (default ON)"
ON
)
option(ENABLE_JEMALLOC "Use jemalloc (default OFF)")
option(ENABLE_MIMALLOC "Use mimalloc (default OFF)")
option(ENABLE_PROFILER "Use gperftools profiler (default OFF)")
Expand Down Expand Up @@ -102,6 +106,21 @@ if(brotli_FOUND)
set(HAVE_BROTLI_ENCODE_H TRUE)
endif()

if(ENABLE_POSIX_CAP)
find_package(cap REQUIRED)
set(TS_USE_POSIX_CAP ${cap_FOUND})
find_path(PRCTL_HEADER NAMES sys/prctl.h)
# just making sure
if(NOT PRCTL_HEADER)
message(FATAL_ERROR "Have cap but sys/prctl.h not found.")
endif()
set(HAVE_SYS_PRCTL_H TRUE)
unset(PRCTL_HEADER)
else()
find_package(cap QUIET)
endif()
set(HAVE_SYS_CAPABILITY_H ${cap_FOUND})

find_package(hwloc)
if(hwloc_FOUND)
set(TS_USE_HWLOC TRUE)
Expand Down
49 changes: 49 additions & 0 deletions cmake/Findcap.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#######################
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor license
# agreements. See the NOTICE file distributed with this work for additional information regarding
# copyright ownership. The ASF licenses this file to you 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.
#
#######################

# Findcap.cmake
#
# This will define the following variables
#
# cap_FOUND
# cap_LIBRARY
# cap_INCLUDE_DIRS
#
# and the following imported targets
#
# cap::cap
#

find_library(cap_LIBRARY NAMES cap)
find_path(cap_INCLUDE_DIR NAMES sys/capability.h)

mark_as_advanced(cap_FOUND cap_LIBRARY cap_INCLUDE_DIR)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(cap
REQUIRED_VARS cap_LIBRARY cap_INCLUDE_DIR
)

if(cap_FOUND)
set(cap_INCLUDE_DIRS ${cap_INCLUDE_DIR})
endif()

if(cap_FOUND AND NOT TARGET cap::cap)
add_library(cap::cap INTERFACE IMPORTED)
target_include_directories(cap::cap INTERFACE ${cap_INCLUDE_DIRS})
target_link_libraries(cap::cap INTERFACE ${cap_LIBRARY})
endif()
7 changes: 5 additions & 2 deletions include/tscore/ink_config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
#cmakedefine HAVE_LINUX_MAJOR_H 1
#cmakedefine HAVE_SYS_DISK_H 1
#cmakedefine HAVE_SYS_DISKLABEL_H 1
#cmakedefine HAVE_SYS_CAPABILITY_H 1
#cmakedefine HAVE_SYS_IOCTL_H 1
#cmakedefine HAVE_SYS_PRCTL_H 1
#cmakedefine HAVE_SYS_TYPES_H 1
#cmakedefine HAVE_SYS_STAT_H 1
#cmakedefine HAVE_SYS_STATVFS_H 1
Expand Down Expand Up @@ -114,15 +116,16 @@ const int DEFAULT_STACKSIZE = @DEFAULT_STACK_SIZE@;
#cmakedefine01 TS_HAS_JEMALLOC
#cmakedefine01 TS_HAS_TCMALLOC
#cmakedefine01 TS_HAS_PROFILER
#cmakedefine01 TS_USE_DIAGS
#cmakedefine01 TS_USE_EPOLL
#cmakedefine01 TS_USE_GET_DH_2048_256
#cmakedefine01 TS_USE_HWLOC
#cmakedefine01 TS_USE_KQUEUE
#cmakedefine01 TS_USE_LINUX_IO_URING
#cmakedefine01 TS_USE_LINUX_NATIVE_AIO
#cmakedefine01 TS_USE_POSIX_CAP
#cmakedefine01 TS_USE_SET_RBIO
#cmakedefine01 TS_USE_TLS13
#cmakedefine01 TS_USE_DIAGS
#cmakedefine01 TS_USE_GET_DH_2048_256

#define TS_BUILD_CANONICAL_HOST "@CMAKE_HOST@"

Expand Down
5 changes: 4 additions & 1 deletion iocore/net/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ add_library(inknet STATIC
SSLDynlock.cc
SNIActionPerformer.cc
)
target_link_libraries(inknet inkevent records_p)
target_link_libraries(inknet PUBLIC inkevent records_p)
target_compile_options(inknet PUBLIC -Wno-deprecated-declarations)
target_include_directories(inknet PRIVATE
${CMAKE_SOURCE_DIR}/iocore/eventsystem
Expand All @@ -85,6 +85,9 @@ target_include_directories(inknet PRIVATE
${OPENSSL_INCLUDE_DIRS}
${YAML_INCLUDE_DIRS}
)
if(TS_USE_POSIX_CAP)
target_link_libraries(inknet PUBLIC cap::cap)
endif()

# Fails to link because of circular dep with proxy (ParentSelection)
# add_executable(test_net unit_tests/test_ProxyProtocol.cc)
Expand Down
3 changes: 3 additions & 0 deletions src/tscore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ endif()
if(TS_HAS_128BIT_CAS AND TS_NEEDS_MCX16_FOR_CAS)
target_compile_options(tscore PUBLIC "-mcx16")
endif()
if(TS_USE_POSIX_CAP)
target_link_libraries(tscore PUBLIC cap::cap)
endif()

add_executable(test_tscore
unit_tests/test_AcidPtr.cc
Expand Down