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
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ include(CTest)

message("Configuring for ${HOST_OS}")

configure_file(include/tscore/ink_config.h.cmake.in include/tscore/ink_config.h)
configure_file(include/ts/apidefs.h.in include/ts/apidefs.h)

add_compile_definitions(${HOST_OS} PACKAGE_NAME="ats" PACKAGE_VERSION="${TS_VERSION_STRING}")
add_compile_options(-Wno-invalid-offsetof)

Expand All @@ -125,10 +122,24 @@ if (OPENSSL_FOUND)
endif(OPENSSL_FOUND)

add_subdirectory(lib)
include_directories(
${CMAKE_SOURCE_DIR}/lib/swoc/include
${YAML_CPP_SOURCE_DIR}/include
)

include(subproject_version)

subproject_version(YAML_CPP YAMLCPP_LIB_VERSION)

configure_file(include/tscore/ink_config.h.cmake.in include/tscore/ink_config.h)
configure_file(include/ts/apidefs.h.in include/ts/apidefs.h)

add_subdirectory(src/tscpp/util)
add_subdirectory(src/tscore)
add_subdirectory(src/records)
add_subdirectory(iocore)
add_subdirectory(proxy)
add_subdirectory(mgmt/utils)
add_subdirectory(mgmt/config)
add_subdirectory(mgmt/rpc)
add_subdirectory(src/traffic_server)
37 changes: 37 additions & 0 deletions cmake/subproject_version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#######################
#
# 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.
#
#######################

# subproject_version(<subproject-name> <result-variable>)
#
# Extract version of a sub-project, which was previously included with add_subdirectory().
function(subproject_version subproject_name VERSION_VAR)
# Read CMakeLists.txt for subproject and extract project() call(s) from it.
file(STRINGS "${${subproject_name}_SOURCE_DIR}/CMakeLists.txt" project_calls REGEX "[ \t]*project\\(")
# For every project() call try to extract its VERSION option
foreach(project_call ${project_calls})
string(REGEX MATCH "VERSION[ ]+([^ )]+)" version_param "${project_call}")
if(version_param)
set(version_value "${CMAKE_MATCH_1}")
endif()
endforeach()
if(version_value)
set(${VERSION_VAR} "${version_value}" PARENT_SCOPE)
message("INFO: ${subproject_name} version ${version_value}")
else()
message("WARNING: Cannot extract version for subproject '${subproject_name}'")
endif()
endfunction(subproject_version)
2 changes: 1 addition & 1 deletion include/tscore/ink_config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ const int DEFAULT_STACKSIZE = @DEFAULT_STACK_SIZE@;

#define TS_BUILD_CANONICAL_HOST "@CMAKE_HOST@"


#cmakedefine YAMLCPP_LIB_VERSION "@YAMLCPP_LIB_VERSION@"

1 change: 1 addition & 0 deletions iocore/eventsystem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ target_sources(inkevent PRIVATE
UnixEThread.cc
UnixEvent.cc
UnixEventProcessor.cc
ConfigProcessor.cc
)
target_include_directories(inkevent PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ add_compile_options(-Wno-shadow)
add_subdirectory(yamlcpp)
set(YAML_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/lib/yamlcpp/include PARENT_SCOPE)
add_subdirectory(fastlz)
add_subdirectory(swoc)
set(SWOC_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/lib/swoc/include PARENT_SCOPE)
132 changes: 132 additions & 0 deletions lib/swoc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
cmake_minimum_required(VERSION 3.11)

project(Lib-SWOC CXX)
set(LIBSWOC_VERSION "1.4.2")
set(CMAKE_CXX_STANDARD 17)
cmake_policy(SET CMP0087 NEW)
# override "lib64" to be "lib" unless the user explicitly sets it.
set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "directory for libraries" FORCE)
include(GNUInstallDirs)

cmake_dependent_option(LIBSWOC_INSTALL
"Enable generation of libswoc install targets" ON
"NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT" OFF)

set(HEADER_FILES
include/swoc/swoc_version.h
include/swoc/ArenaWriter.h
include/swoc/BufferWriter.h
include/swoc/bwf_base.h
include/swoc/bwf_ex.h
include/swoc/bwf_ip.h
include/swoc/bwf_std.h
include/swoc/DiscreteRange.h
include/swoc/Errata.h
include/swoc/IntrusiveDList.h
include/swoc/IntrusiveHashMap.h
include/swoc/swoc_ip.h
include/swoc/IPEndpoint.h
include/swoc/IPAddr.h
include/swoc/IPSrv.h
include/swoc/IPRange.h
include/swoc/Lexicon.h
include/swoc/MemArena.h
include/swoc/MemSpan.h
include/swoc/Scalar.h
include/swoc/TextView.h
include/swoc/swoc_file.h
include/swoc/swoc_meta.h
include/swoc/string_view.h
include/swoc/Vectray.h
)

# These are external but required.
set(EXTERNAL_HEADER_FILES
include/swoc/ext/HashFNV.h
)

set(CC_FILES
src/bw_format.cc
src/bw_ip_format.cc
src/ArenaWriter.cc
src/Errata.cc
src/swoc_ip.cc
src/MemArena.cc
src/RBTree.cc
src/swoc_file.cc
src/TextView.cc
src/string_view_util.cc
)

add_library(libswoc SHARED ${CC_FILES})
set_target_properties(libswoc PROPERTIES OUTPUT_NAME swoc-${LIBSWOC_VERSION})
if (CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(libswoc PRIVATE -fPIC -Wall -Wextra -Werror -Wnon-virtual-dtor -Wpedantic)
endif()

add_library(libswoc-static STATIC ${CC_FILES})
set_target_properties(libswoc-static PROPERTIES OUTPUT_NAME swoc-static-${LIBSWOC_VERSION})
if (CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(libswoc-static PRIVATE -fPIC -Wall -Wextra -Werror -Wnon-virtual-dtor -Wpedantic)
endif()

# Not quite sure how this works, but I think it generates one of two paths depending on the context.
# That is, the generator functions return non-empty strings only in the corresponding context.
target_include_directories(libswoc-static
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

target_include_directories(libswoc
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

if (LIBSWOC_INSTALL)
# These install target variables are created by GNUInstallDirs.
install(TARGETS libswoc-static
EXPORT libswoc-static-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # seems to have no effect.
)
install(TARGETS libswoc
EXPORT libswoc-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # seems to have no effect.
)
install(DIRECTORY include/swoc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

set(link-target libswoc.so)
set(link-src $<TARGET_FILE_NAME:libswoc>)
install(CODE
"execute_process(COMMAND bash -c \"echo Linking ${link-src} to ${link-target};cd ${CMAKE_INSTALL_FULL_LIBDIR} && (rm -f ${link-target};ln -s ${link-src} ${link-target})
\")"
)

install(EXPORT libswoc-static-config
NAMESPACE libswoc::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libswoc
)

install(EXPORT libswoc-config
NAMESPACE libswoc::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libswoc
)

# set(PKG_CONFIG_FILE libswoc.pc)
# set(PKG_STATIC_CONFIG_FILE libswoc-static.pc)
# configure_file("libswoc.pc.cmake" ${PKG_CONFIG_FILE} @ONLY)
#
# configure_file("libswoc.pc.cmake" libswoc.pc @ONLY)
# configure_file("libswoc-static.pc.cmake" libswoc-static.pc @ONLY)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to comment these configure_file lines out since the source files are missing. Otherwise this file is the same as swoc upstream.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. I might to put those back in so that the internal libswoc can generate accurate pkg-config files. That would make it easier for external consumption to switch.

# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libswoc.pc ${CMAKE_CURRENT_BINARY_DIR}/libswoc-static.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# install(FILES ${PKG_STATIC_CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()

# Alledgedly this makes the targets "importable from the build directory" but I see no evidence of that.
# AFAICT the file isn't created at all even with this enabled.
#export(TARGETS libswoc FILE libswoc-config.cmake)

set(CLANG_DIRS )

set_target_properties(libswoc-static PROPERTIES CLANG_FORMAT_DIRS "${PROJECT_SOURCE_DIR}/src;${PROJECT_SOURCE_DIR}/include")
32 changes: 32 additions & 0 deletions mgmt/config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#######################
#
# 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.
#
#######################

add_library(configmanager STATIC
FileManager.cc
AddConfigFilesHere.cc
)
include_directories(
${CMAKE_SOURCE_DIR}/mgmt
${CMAKE_SOURCE_DIR}/proxy
${CMAKE_SOURCE_DIR}/proxy/hdrs
${CMAKE_SOURCE_DIR}/proxy/http
${CMAKE_SOURCE_DIR}/iocore/eventsystem
${CMAKE_SOURCE_DIR}/iocore/net
${CMAKE_SOURCE_DIR}/iocore/cache
${CMAKE_SOURCE_DIR}/iocore/aio
${CMAKE_SOURCE_DIR}/iocore/dns
)
2 changes: 1 addition & 1 deletion mgmt/config/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ AM_CPPFLAGS += \
$(TS_INCLUDES) @SWOC_INCLUDES@ \
@YAMLCPP_INCLUDES@

# ^^ all the proxy/* is to include the PluginCallbacks.
# ^^ all the proxy is to include the PluginCallbacks.

noinst_LTLIBRARIES = libconfigmanager.la
#check_PROGRAMS = test_configfiles
Expand Down
54 changes: 54 additions & 0 deletions mgmt/rpc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#######################
#
# 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.
#
#######################

include_directories(
${CMAKE_SOURCE_DIR}/mgmt
${CMAKE_SOURCE_DIR}/mgmt/rpc
${CMAKE_SOURCE_DIR}/iocore/eventsystem
${CMAKE_SOURCE_DIR}/iocore/utils
${CMAKE_SOURCE_DIR}/iocore/cache
${CMAKE_SOURCE_DIR}/iocore/aio
${CMAKE_SOURCE_DIR}/iocore/net
${CMAKE_SOURCE_DIR}/iocore/dns
${CMAKE_SOURCE_DIR}/lib
${CMAKE_SOURCE_DIR}/proxy
${CMAKE_SOURCE_DIR}/proxy/hdrs
${CMAKE_SOURCE_DIR}/proxy/http

)

add_library(jsonrpc_protocol STATIC
jsonrpc/error/RPCError.cc
jsonrpc/JsonRPCManager.cc
jsonrpc/Context.cc
)

add_library(jsonrpc_server STATIC
server/RPCServer.cc
server/CommBase.cc
server/IPCSocketServer.cc
config/JsonRPCConfig.cc
)

add_library(rpcpublichandlers STATIC
handlers/common/RecordsUtils.cc
handlers/config/Configuration.cc
handlers/records/Records.cc
handlers/storage/Storage.cc
handlers/server/Server.cc
handlers/plugins/Plugins.cc
)
6 changes: 6 additions & 0 deletions src/records/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ add_library(records_lm STATIC
RecMutex.cc
RecRawStats.cc
RecUtils.cc
RecYAMLDecoder.cc
RecordsConfig.cc
RecordsConfigUtils.cc
)
target_include_directories(records_lm PRIVATE
${CMAKE_SOURCE_DIR}/mgmt
Expand All @@ -48,6 +51,9 @@ add_library(records_p STATIC
RecRawStats.cc
RecUtils.cc
RecProcess.cc
RecYAMLDecoder.cc
RecordsConfig.cc
RecordsConfigUtils.cc
)
target_include_directories(records_p PRIVATE
${CMAKE_SOURCE_DIR}/mgmt
Expand Down
7 changes: 6 additions & 1 deletion src/traffic_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ add_executable(traffic_server
InkIOCoreAPI.cc
SocksProxy.cc
traffic_server.cc
RpcAdminPubHandlers.cc
${CMAKE_SOURCE_DIR}/src/shared/overridable_txn_vars.cc
)
target_include_directories(traffic_server PRIVATE
Expand All @@ -38,8 +39,8 @@ target_link_libraries(traffic_server
http2
logging
hdrs
configmanager
diagsconfig
mgmt_p
utils_p
inkutils
inkdns
Expand All @@ -54,4 +55,8 @@ target_link_libraries(traffic_server
records_p
inkevent
yaml-cpp
libswoc
jsonrpc_protocol
jsonrpc_server
rpcpublichandlers
)
3 changes: 2 additions & 1 deletion src/tscpp/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ add_library(tscpputil SHARED
TextView.cc
YamlCfg.cc
)
target_link_libraries(tscpputil PRIVATE yaml-cpp libswoc)

add_executable(test_tscpputil
unit_tests/test_LocalBuffer.cc
Expand All @@ -29,5 +30,5 @@ add_executable(test_tscpputil
unit_tests/test_ts_meta.cc
unit_tests/unit_test_main.cc
)
target_link_libraries(test_tscpputil PRIVATE tscpputil)
target_link_libraries(test_tscpputil PRIVATE tscpputil libswoc)
target_include_directories(test_tscpputil PRIVATE ${CMAKE_SOURCE_DIR}/include ${CATCH_INCLUDE_DIR})