Merge pull request #1883 from DarthGandalf/applecctz

Maybe fix build on macos
This commit is contained in:
Alexey Sokolov
2023-09-30 16:37:16 +01:00
committed by GitHub
13 changed files with 156 additions and 46 deletions

3
.github/build.sh vendored
View File

@@ -43,6 +43,9 @@ case "${CC:-gcc}" in
lcov --list lcov-coverage.txt
;;
clang)
if [[ x$(uname) == xDarwin ]]; then
export PATH=$PATH:/Library/Developer/CommandLineTools/usr/bin
fi
llvm-profdata merge unittest.profraw -o unittest.profdata
llvm-profdata merge inttest.profraw -o inttest.profdata
llvm-cov show -show-line-counts-or-regions -instr-profile=unittest.profdata test/unittest_bin > unittest-cmake-coverage.txt

View File

@@ -100,18 +100,22 @@ jobs:
#CXXFLAGS: "-fsanitize=undefined -O1 -fPIE -fno-sanitize-recover"
#LDFLAGS: "-fsanitize=undefined -pie -fno-sanitize-recover"
#macos:
#name: macOS
#runs-on: macos-latest
#steps:
#- uses: actions/checkout@v3
#with:
#submodules: true
#- run: |
#brew update
#brew install icu4c qt5 gettext pkg-config cpanminus boost
#- run: source .github/build.sh
#- uses: codecov/codecov-action@v3
macos:
name: macOS
runs-on: macos-latest
env:
# This doesn't make big difference, since it's the same compiler, but we also use this variable to select lcov vs llvm-cov
CXX: clang++
CC: clang
steps:
- uses: actions/checkout@v3
with:
submodules: true
- run: |
brew update
brew install icu4c qt5 gettext pkg-config cpanminus boost
- run: source .github/build.sh
- uses: codecov/codecov-action@v3
docker:
name: Docker push

View File

@@ -79,6 +79,9 @@ macro(tristate_option opt help)
endif()
endmacro()
set(ZNC_CMAKE_FIND_DEPS "")
set(zncpubdeps)
tristate_option(OPENSSL "Support SSL")
if(WANT_OPENSSL)
find_package(OpenSSL ${TRISTATE_OPENSSL_REQUIRED})
@@ -95,6 +98,9 @@ if(WANT_OPENSSL)
HAVE_SSL_SESSION_get0_cipher)
endfunction()
check_SSL_SESSION_get0_cipher()
set(ZNC_CMAKE_FIND_DEPS
"${ZNC_CMAKE_FIND_DEPS}\nfind_dependency(OpenSSL)")
list(APPEND zncpubdeps OpenSSL::SSL)
endif()
endif()
set(HAVE_LIBSSL "${OPENSSL_FOUND}")
@@ -110,7 +116,7 @@ set(HAVE_ZLIB "${ZLIB_FOUND}")
tristate_option(CYRUS "Support authentication with Cyrus")
if(WANT_CYRUS)
pkg_check_modules(CYRUS libsasl2)
pkg_check_modules(CYRUS IMPORTED_TARGET libsasl2)
if(NOT CYRUS_FOUND)
# libsasl2.pc is missing on 2.1.25 which is on ubuntu 14.04
# next ubuntu version has 2.1.26 which has libsasl2.pc
@@ -126,7 +132,9 @@ if(WANT_CYRUS)
CYRUS_HARDCODED)
set(CMAKE_REQUIRED_LIBRARIES "${_old_cmake_required_libraries}")
if(CYRUS_HARDCODED)
set(CYRUS_LDFLAGS -lsasl2)
add_library(HardcodedCyrusDep INTERFACE)
add_library(PkgConfig::CYRUS ALIAS HardcodedCyrusDep)
target_link_libraries(HardcodedCyrusDep INTERFACE sasl2)
set(CYRUS_FOUND true)
endif()
endif()
@@ -143,9 +151,13 @@ set(ZNC_HAVE_ARGON "${ARGON_FOUND}")
tristate_option(ICU "Support character encodings")
if(WANT_ICU)
pkg_check_modules(ICU ${TRISTATE_ICU_REQUIRED} icu-uc)
pkg_check_modules(ICU ${TRISTATE_ICU_REQUIRED} IMPORTED_TARGET icu-uc)
endif()
set(HAVE_ICU "${ICU_FOUND}")
if(ICU_FOUND)
set(ZNC_CMAKE_FIND_DEPS "${ZNC_CMAKE_FIND_DEPS}\nfind_dependency_pc(ICU icu-uc)")
list(APPEND zncpubdeps PkgConfig::ICU)
endif()
set(WANT_PERL false CACHE BOOL "Support Perl modules")
set(WANT_PYTHON false CACHE BOOL "Support Python modules")
@@ -297,6 +309,10 @@ else()
add_library(cctz::cctz ALIAS cctz)
target_include_directories(cctz INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/cctz/include>)
if (APPLE)
find_library(CoreFoundation CoreFoundation REQUIRED)
target_link_libraries(cctz INTERFACE ${CoreFoundation})
endif()
endif()
check_cxx_symbol_exists(getopt_long "getopt.h" HAVE_GETOPT_LONG)
@@ -421,6 +437,8 @@ include(CMakePackageConfigHelpers)
write_basic_package_version_file("ZNCConfigVersion.cmake"
COMPATIBILITY AnyNewerVersion)
install(FILES
"${PROJECT_SOURCE_DIR}/cmake/CMakeFindDependencyMacroPC.cmake"
"${PROJECT_SOURCE_DIR}/cmake/use_homebrew.cmake"
"${PROJECT_BINARY_DIR}/ZNCConfig.cmake"
"${PROJECT_BINARY_DIR}/ZNCConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_DATADIR}/znc/cmake")

View File

@@ -14,6 +14,11 @@
# limitations under the License.
#
include(CMakeFindDependencyMacro)
include("${CMAKE_CURRENT_LIST_DIR}/CMakeFindDependencyMacroPC.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/use_homebrew.cmake")
@ZNC_CMAKE_FIND_DEPS@
include("${CMAKE_CURRENT_LIST_DIR}/znc_internal.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/znc_public.cmake")
include(CMakeParseArguments)

View File

@@ -0,0 +1,99 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
CMakeFindDependencyMacro
------------------------
.. command:: find_dependency
The ``find_dependency()`` macro wraps a :command:`find_package` call for
a package dependency::
find_dependency(<dep> [...])
It is designed to be used in a
:ref:`Package Configuration File <Config File Packages>`
(``<PackageName>Config.cmake``). ``find_dependency`` forwards the correct
parameters for ``QUIET`` and ``REQUIRED`` which were passed to
the original :command:`find_package` call. Any additional arguments
specified are forwarded to :command:`find_package`.
If the dependency could not be found it sets an informative diagnostic
message and calls :command:`return` to end processing of the calling
package configuration file and return to the :command:`find_package`
command that loaded it.
.. note::
The call to :command:`return` makes this macro unsuitable to call
from :ref:`Find Modules`.
Package Dependency Search Optimizations
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If ``find_dependency`` is called with arguments identical to a previous
call in the same directory, perhaps due to diamond-shaped package
dependencies, the underlying call to :command:`find_package` is optimized
out. This optimization is important to support large package dependency
graphs while avoiding a combinatorial explosion of repeated searches.
However, the heuristic cannot account for ambient variables that
affect package behavior, such as ``<PackageName>_USE_STATIC_LIBS``,
offered by some packages. Therefore package configuration files should
avoid setting such variables before their calls to ``find_dependency``.
.. versionchanged:: 3.15
Previously, the underlying call to :command:`find_package` was always
optimized out if the package had already been found. CMake 3.15
removed the optimization to support cases in which ``find_dependency``
call arguments request different components.
.. versionchanged:: 3.26
The pre-3.15 optimization was restored, but with the above-described
heuristic to account for varying ``find_dependency`` call arguments.
#]=======================================================================]
macro(find_dependency_pc dep)
find_dependency(PkgConfig)
string(SHA256 cmake_fd_call_hash "${dep};${ARGN};${${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED}")
if(_CMAKE_${dep}_${cmake_fd_call_hash}_FOUND)
unset(cmake_fd_call_hash)
else()
list(APPEND _CMAKE_${dep}_HASH_STACK ${cmake_fd_call_hash})
set(cmake_fd_quiet_arg)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
set(cmake_fd_quiet_arg QUIET)
endif()
set(cmake_fd_required_arg)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
set(cmake_fd_required_arg REQUIRED)
endif()
get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY
_CMAKE_${dep}_TRANSITIVE_DEPENDENCY
)
pkg_check_modules(${dep}
${cmake_fd_quiet_arg}
${cmake_fd_required_arg}
IMPORTED_TARGET ${ARGN}
)
list(POP_BACK _CMAKE_${dep}_HASH_STACK cmake_fd_call_hash)
set("_CMAKE_${dep}_${cmake_fd_call_hash}_FOUND" "${${dep}_FOUND}")
if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive)
set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE)
endif()
unset(cmake_fd_alreadyTransitive)
unset(cmake_fd_call_hash)
unset(cmake_fd_quiet_arg)
unset(cmake_fd_required_arg)
if (NOT ${dep}_FOUND)
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.")
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
return()
endif()
endif()
endmacro()

View File

@@ -14,7 +14,7 @@
# limitations under the License.
#
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.13)
project(cxx11check LANGUAGES CXX)
set(CMAKE_VERBOSE_MAKEFILE true)

View File

@@ -14,7 +14,7 @@
# limitations under the License.
#
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.13)
project(perl_check LANGUAGES CXX)
set(CMAKE_VERBOSE_MAKEFILE true)

View File

@@ -37,11 +37,7 @@ function(add_cxx_module mod modpath)
if(moddepend_${mod})
add_dependencies("module_${mod}" ${moddepend_${mod}})
endif()
# ${znclib_LIB_DEPENDS} is to overcome OSX's need for -undefined suppress
# when accessing symbols exported by dependencies of znclib (e.g.
# openssl), but not used in znclib itself
target_link_libraries("module_${mod}" PRIVATE ZNC ${modlink_${mod}}
${znclib_LIB_DEPENDS})
target_link_libraries("module_${mod}" PRIVATE ZNC ${modlink_${mod}})
set_target_properties("module_${mod}" PROPERTIES "" "" ${modprop_${mod}})
install(TARGETS "module_${mod}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/znc")
@@ -54,8 +50,7 @@ function(add_python_module mod modpath)
endfunction()
if(CYRUS_FOUND)
set(modcompile_cyrusauth PRIVATE ${CYRUS_CFLAGS})
set(modlink_cyrusauth ${CYRUS_LDFLAGS})
set(modlink_cyrusauth PkgConfig::CYRUS)
else()
set(moddisable_cyrusauth true)
endif()

View File

@@ -82,7 +82,7 @@ target_include_directories(modperl_lib PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}/.."
"${CMAKE_CURRENT_SOURCE_DIR}/.."
${PERL_INCLUDE_DIRS})
target_link_libraries(modperl_lib ${znc_link})
target_link_libraries(modperl_lib ZNC)
set_target_properties(modperl_lib PROPERTIES
PREFIX ""
SUFFIX ".${perl_ext}"

View File

@@ -75,7 +75,7 @@ target_include_directories(modpython_lib PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}/.."
"${CMAKE_CURRENT_SOURCE_DIR}/.."
${Python3_INCLUDE_DIRS})
target_link_libraries(modpython_lib ${znc_link} ${Python3_LDFLAGS})
target_link_libraries(modpython_lib ZNC ${Python3_LDFLAGS})
set_target_properties(modpython_lib PROPERTIES
PREFIX "_"
OUTPUT_NAME "znc_core"

View File

@@ -14,11 +14,6 @@
# limitations under the License.
#
if(CMAKE_VERSION VERSION_LESS 3.2)
# Since 3.2 it does this automatically from BYPRODUCTS
set_source_files_properties("versionc.cpp" PROPERTIES GENERATED true)
endif()
set(znc_cpp "ZNCString.cpp" "znc.cpp" "IRCNetwork.cpp" "Translation.cpp"
"IRCSock.cpp" "Client.cpp" "Chan.cpp" "Nick.cpp" "Server.cpp"
"Modules.cpp" "MD5.cpp" "Buffer.cpp" "Utils.cpp" "FileUtils.cpp"
@@ -66,25 +61,16 @@ set(znc_include_dirs
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>")
target_link_libraries(znclib PRIVATE ${CMAKE_DL_LIBS} Threads::Threads)
if(OPENSSL_FOUND)
target_link_libraries(znclib PUBLIC ${OPENSSL_LIBRARIES})
list(APPEND znc_include_dirs "${OPENSSL_INCLUDE_DIR}")
endif()
if(ZLIB_FOUND)
target_link_libraries(znclib PRIVATE ${ZLIB_LIBRARIES})
list(APPEND znc_include_dirs ${ZLIB_INCLUDE_DIRS})
endif()
if(ICU_FOUND)
target_link_libraries(znclib PUBLIC ${ICU_LDFLAGS})
list(APPEND znc_include_dirs ${ICU_INCLUDE_DIRS})
target_link_libraries(znclib PRIVATE ZLIB::ZLIB)
endif()
if(Boost_FOUND)
target_link_libraries(znclib PRIVATE ${Boost_LIBRARIES})
list(APPEND znc_include_dirs ${Boost_INCLUDE_DIRS})
target_link_libraries(znclib PRIVATE Boost::locale)
endif()
if(ZNC_HAVE_ARGON)
target_link_libraries(znclib PRIVATE PkgConfig::ARGON)
endif()
target_link_libraries(znclib PUBLIC ${zncpubdeps})
target_link_libraries(znclib PRIVATE cctz::cctz)
target_include_directories(znc PUBLIC ${znc_include_dirs})
target_include_directories(znclib PUBLIC ${znc_include_dirs})
@@ -109,7 +95,7 @@ target_compile_features(znc PUBLIC ${required_cxx11_features})
target_compile_features(znclib PUBLIC ${required_cxx11_features})
add_library(ZNC INTERFACE)
target_link_libraries(ZNC INTERFACE ${znc_link})
target_link_libraries(ZNC INTERFACE ${znc_link} ${zncpubdeps})
target_compile_definitions(ZNC INTERFACE "znc_export_lib_EXPORTS")
if(HAVE_I18N)

View File

@@ -14,7 +14,7 @@
# limitations under the License.
#
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.13)
project(ZNCIntegrationTest LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)

View File

@@ -56,7 +56,7 @@ args = parser.parse_args()
with tempfile.TemporaryDirectory() as cmdir:
with open(os.path.join(cmdir, 'CMakeLists.txt'), 'w') as cm:
print('cmake_minimum_required(VERSION 3.1)', file=cm)
print('cmake_minimum_required(VERSION 3.13)', file=cm)
print('project(ExternalModules LANGUAGES CXX)', file=cm)
print('find_package(ZNC @ZNC_VERSION_MAJOR@.@ZNC_VERSION_MINOR@ HINTS '
'@CMAKE_INSTALL_FULL_DATADIR@/znc REQUIRED)', file=cm)