Browse Source

Yet another attempt to use CMake

master
Alexey Sokolov 5 years ago
parent
commit
561a18054c
51 changed files with 2204 additions and 77 deletions
  1. +22
    -4
      .appveyor.yml
  2. +25
    -11
      .travis.yml
  3. +333
    -0
      CMakeLists.txt
  4. +6
    -4
      Makefile.in
  5. +2
    -0
      NOTICE
  6. +29
    -1
      README.md
  7. +51
    -0
      ZNCConfig.cmake.in
  8. +40
    -0
      cmake/CMakeFindFrameworks_fixed.cmake
  9. +94
    -0
      cmake/FindPerlLibs.cmake
  10. +39
    -0
      cmake/TestCXX11.cmake
  11. +12
    -0
      cmake/TestFileOffsetBits.c
  12. +26
    -0
      cmake/TestLargeFiles.c.cmakein
  13. +122
    -0
      cmake/TestLargeFiles.cmake
  14. +12
    -0
      cmake/TestWindowsFSeek.c
  15. +26
    -0
      cmake/copy_csocket.cmake
  16. +20
    -0
      cmake/copy_csocket_cmd.cmake
  17. +23
    -0
      cmake/cxx11check/CMakeLists.txt
  18. +58
    -0
      cmake/cxx11check/main.cpp
  19. +76
    -0
      cmake/gen_version.cmake
  20. +30
    -0
      cmake/perl_check/CMakeLists.txt
  21. +29
    -0
      cmake/perl_check/main.cpp
  22. +42
    -0
      cmake/render_framed_multiline.cmake
  23. +63
    -0
      cmake/use_homebrew.cmake
  24. +2
    -2
      configure.ac
  25. +128
    -0
      configure.py
  26. +17
    -0
      include/CMakeLists.txt
  27. +34
    -0
      include/znc/CMakeLists.txt
  28. +19
    -15
      include/znc/Modules.h
  29. +4
    -1
      include/znc/version.h
  30. +53
    -0
      include/znc/zncconfig.h.cmake.in
  31. +12
    -9
      make-tarball.sh
  32. +111
    -0
      modules/CMakeLists.txt
  33. +107
    -0
      modules/modperl/CMakeLists.txt
  34. +3
    -3
      modules/modperl/Makefile.gen
  35. +8
    -2
      modules/modperl/Makefile.inc
  36. +3
    -9
      modules/modperl/module.h
  37. +97
    -0
      modules/modpython/CMakeLists.txt
  38. +3
    -3
      modules/modpython/Makefile.gen
  39. +8
    -2
      modules/modpython/Makefile.inc
  40. +3
    -10
      modules/modpython/module.h
  41. +18
    -0
      modules/modtcl/CMakeLists.txt
  42. +100
    -0
      src/CMakeLists.txt
  43. +18
    -0
      src/version.cpp.in
  44. +6
    -0
      src/znc.cpp
  45. +97
    -0
      test/CMakeLists.txt
  46. +46
    -0
      test/integration/CMakeLists.txt
  47. +0
    -0
      test/integration/main.cpp
  48. +78
    -0
      znc-buildmod.cmake.in
  49. +20
    -0
      znc.pc.cmake.in
  50. +1
    -1
      znc.service.in
  51. +28
    -0
      zz_msg/CMakeLists.txt

+ 22
- 4
.appveyor.yml View File

@ -9,23 +9,41 @@ cache:
environment:
matrix:
- cygwin_url: https://cygwin.com/setup-x86_64.exe
build_with: cmake
- cygwin_url: https://cygwin.com/setup-x86.exe
build_with: cmake
- cygwin_url: https://cygwin.com/setup-x86_64.exe
build_with: autoconf
- cygwin_url: https://cygwin.com/setup-x86.exe
build_with: autoconf
install:
- ps: Invoke-WebRequest $env:cygwin_url -OutFile c:\cygwin-setup.exe
# libcrypt-devel is needed only on x86_64 and only for modperl... probably some dependency problem.
- c:\cygwin-setup.exe --quiet-mode --no-shortcuts --no-startmenu --no-desktop --upgrade-also --only-site --site http://cygwin.mirror.constant.com/ --root c:\cygwin-root --local-package-dir c:\cygwin-setup-cache --packages automake,gcc-g++,make,pkg-config,wget,openssl-devel,libicu-devel,zlib-devel,libcrypt-devel,perl,python3,swig,libsasl2-devel,libQt5Core-devel
- c:\cygwin-setup.exe --quiet-mode --no-shortcuts --no-startmenu --no-desktop --upgrade-also --only-site --site http://cygwin.mirror.constant.com/ --root c:\cygwin-root --local-package-dir c:\cygwin-setup-cache --packages automake,gcc-g++,make,pkg-config,wget,openssl-devel,libicu-devel,zlib-devel,libcrypt-devel,perl,python3,swig,libsasl2-devel,libQt5Core-devel,cmake
- c:\cygwin-root\bin\sh -lc "echo Hi"
- c:\cygwin-root\bin\sh -lc "uname -a"
- c:\cygwin-root\bin\sh -lc "cat /proc/cpuinfo"
- c:\cygwin-root\bin\sh -lc "cat /proc/meminfo"
- c:\cygwin-root\bin\sh -lc "cygcheck -s -v > $APPVEYOR_BUILD_FOLDER/cygcheck.log 2>&1"
- ps: Push-AppveyorArtifact cygcheck.log
- ps: |
if ($env:build_with -eq "cmake") {
$env:cfg_suffix = ".py"
$env:unittest = "unittest"
$env:inttest = "inttest"
} else {
$env:cfg_suffix = ""
$env:unittest = "test"
$env:inttest = "test2"
}
# stdin is broken at AppVeyor, so we open it explicitly as /dev/null
build_script:
- git submodule update --init
- c:\cygwin-root\bin\sh -lc "cd $APPVEYOR_BUILD_FOLDER; ./autogen.sh < /dev/null"
- mkdir build
- c:\cygwin-root\bin\sh -lc "cd $APPVEYOR_BUILD_FOLDER/build; ../configure --enable-charset --enable-zlib --enable-openssl --enable-perl --enable-python --enable-cyrus < /dev/null; appveyor PushArtifact config.log"
- c:\cygwin-root\bin\sh -lc "cd $APPVEYOR_BUILD_FOLDER/build; ../configure$cfg_suffix --enable-charset --enable-zlib --enable-openssl --enable-perl --enable-python --enable-cyrus < /dev/null"
- c:\cygwin-root\bin\sh -lc "cd $APPVEYOR_BUILD_FOLDER/build; if [[ $build_with == cmake ]]; then cmake --system-information > config.log; fi"
- c:\cygwin-root\bin\sh -lc "cd $APPVEYOR_BUILD_FOLDER/build; appveyor PushArtifact config.log"
- c:\cygwin-root\bin\sh -lc "cd $APPVEYOR_BUILD_FOLDER/build; make VERBOSE=1 -j2 < /dev/null"
- c:\cygwin-root\bin\sh -lc "cd $APPVEYOR_BUILD_FOLDER/build; make install < /dev/null"
- c:\cygwin-root\bin\sh -lc "znc --version"
@ -33,5 +51,5 @@ build_script:
- c:\cygwin-root\bin\sh -lc "find /usr/local/lib/znc -iname '*.dll' -o -iname '*.so' | tee /tmp/files-to-rebase"
- c:\cygwin-root\bin\sh -lc "rebaseall -v -T /tmp/files-to-rebase"
test_script:
- c:\cygwin-root\bin\sh -lc "cd $APPVEYOR_BUILD_FOLDER/build; make VERBOSE=1 test < /dev/null"
- c:\cygwin-root\bin\sh -lc "cd $APPVEYOR_BUILD_FOLDER/build; make VERBOSE=1 test2 < /dev/null"
- c:\cygwin-root\bin\sh -lc "cd $APPVEYOR_BUILD_FOLDER/build; make VERBOSE=1 $unittest < /dev/null"
- c:\cygwin-root\bin\sh -lc "cd $APPVEYOR_BUILD_FOLDER/build; make VERBOSE=1 $inttest < /dev/null"

+ 25
- 11
.travis.yml View File

@ -8,22 +8,31 @@ matrix:
include:
- os: linux
compiler: gcc
env: BUILD_TYPE=normal
env: BUILD_TYPE=normal BUILD_WITH=cmake
- os: linux
compiler: gcc
env: BUILD_TYPE=coverage
env: BUILD_TYPE=normal BUILD_WITH=autoconf
- os: linux
compiler: gcc
env: BUILD_TYPE=coverage BUILD_WITH=autoconf
- os: linux
compiler: clang
env: BUILD_TYPE=asan
env: BUILD_TYPE=asan BUILD_WITH=cmake
- os: linux
compiler: clang
env: BUILD_TYPE=tsan
env: BUILD_TYPE=tsan BUILD_WITH=cmake
- os: osx
compiler: clang
env: BUILD_TYPE=normal BUILD_WITH=cmake
- os: osx
compiler: clang
env: BUILD_TYPE=normal
env: BUILD_TYPE=normal BUILD_WITH=autoconf
- os: linux
compiler: gcc
env: BUILD_TYPE=tarball BUILD_WITH=cmake
- os: linux
compiler: gcc
env: BUILD_TYPE=tarball
env: BUILD_TYPE=tarball BUILD_WITH=autoconf
before_install:
- "echo os: [$TRAVIS_OS_NAME] build: [$BUILD_TYPE]"
- if [[ "$BUILD_TYPE" == "normal" ]]; then export CFGFLAGS= MYCXXFLAGS= MYLDFLAGS=; fi
@ -31,6 +40,7 @@ before_install:
- if [[ "$BUILD_TYPE" == "asan" ]]; then export CFGFLAGS=--enable-debug MYCXXFLAGS="-fsanitize=address -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fPIE" MYLDFLAGS="-fsanitize=address -pie"; fi
- if [[ "$BUILD_TYPE" == "tsan" ]]; then export CFGFLAGS=--enable-debug MYCXXFLAGS="-fsanitize=thread -O1 -fPIE" MYLDFLAGS="-fsanitize=thread -pie"; fi
- if [[ "$BUILD_TYPE" == "coverage" ]]; then export CFGFLAGS="--enable-debug --disable-perl --disable-python" MYCXXFLAGS=--coverage MYLDFLAGS=--coverage DISABLED_ZNC_PERL_PYTHON_TEST=1; fi
- if [[ "$BUILD_WITH" == "cmake" ]]; then export CFGSUFFIX=.py UNITTEST=unittest INTTEST=inttest; else export CFGSUFFIX= UNITTEST=test INTTEST=test2; fi
# UBSan randomly crashes clang, and very often :(
# CFGFLAGS=--enable-debug MYCXXFLAGS="-fsanitize=undefined -O1 -fPIE -fno-sanitize-recover" MYLDFLAGS="-fsanitize=undefined -pie -fno-sanitize-recover"
- if [[ "$TRAVIS_REPO_SLUG" == "znc/znc" && "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_BRANCH" == "master" ]]; then openssl aes-256-cbc -d -in .travis-github.enc -out ~/znc-github-key -k ${SECRET_KEY}; fi
@ -41,10 +51,12 @@ install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:teward/swig3.0; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:beineri/opt-qt551-trusty; fi # default qt5.2 from trusty doesn't support QByteArray::toStdString()
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$BUILD_TYPE" == "tarball" ]]; then sudo add-apt-repository -y ppa:ostogvin/tjo-develop; fi # gtest+gmock
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$BUILD_WITH" == "cmake" ]]; then sudo add-apt-repository -y ppa:george-edison55/cmake-3.x; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libperl-dev python3-dev tcl-dev libsasl2-dev libicu-dev swig3.0 doxygen graphviz qt55base python3-yaml; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$BUILD_TYPE" == "tarball" ]]; then sudo apt-get install -y google-mock libgtest-dev; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then source /opt/qt55/bin/qt55-env.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$BUILD_WITH" == "cmake" ]]; then sudo apt-get install -y cmake; fi
- |
if [[ "$TRAVIS_OS_NAME" == "linux" && "$BUILD_TYPE" == "coverage" ]]; then
sudo apt-get install -y lcov
@ -58,6 +70,7 @@ install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew list --versions; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install swig python3 icu4c jq openssl qt5; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" && "$BUILD_WITH" == "cmake" ]]; then brew upgrade cmake; fi # preinstalled cmake on travis is too old
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew info --json=v1 --installed | jq .; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PKG_CONFIG_PATH="$(brew --prefix qt5)/lib/pkgconfig:$PKG_CONFIG_PATH"; fi
- "echo pkg-config path: [$PKG_CONFIG_PATH]"
@ -65,16 +78,17 @@ script:
- if [[ "$BUILD_TYPE" == "tarball" ]]; then ./make-tarball.sh --nightly znc-git-2015-01-16 /tmp/znc-tarball.tar.gz; fi
- if [[ "$BUILD_TYPE" == "tarball" ]]; then cd /tmp; tar xvf znc-tarball.tar.gz; fi
- if [[ "$BUILD_TYPE" == "tarball" ]]; then cd /tmp/znc-git-2015-01-16; fi
- if [[ "$BUILD_TYPE" != "tarball" ]]; then ./bootstrap.sh; fi
- if [[ "$BUILD_TYPE" != "tarball" && "$BUILD_WITH" != "cmake" ]]; then ./bootstrap.sh; fi
- mkdir build
- cd build
- ../configure --enable-perl --enable-python --enable-tcl --enable-cyrus --enable-charset $CFGFLAGS CXXFLAGS="$CXXFLAGS $MYCXXFLAGS" LDFLAGS="$LDFLAGS $MYLDFLAGS"
- cat config.log
- ../configure$CFGSUFFIX --enable-perl --enable-python --enable-tcl --enable-cyrus --enable-charset $CFGFLAGS CXXFLAGS="$CXXFLAGS $MYCXXFLAGS" LDFLAGS="$LDFLAGS $MYLDFLAGS"
- if [[ "$BUILD_WITH" == "cmake" ]]; then cmake --system-information; else cat config.log; fi
- make VERBOSE=1
- make VERBOSE=1 test
- make VERBOSE=1 $UNITTEST
- sudo make install
- make VERBOSE=1 test2
- make VERBOSE=1 $INTTEST
- cd ..
- /usr/local/bin/znc --version
after_success:
- test -r .travis_after_all.py && python .travis_after_all.py || echo No .travis_after_all.py found
- test -r .to_export_back && echo $(cat .to_export_back) || echo No .to_export_back found


+ 333
- 0
CMakeLists.txt View File

@ -0,0 +1,333 @@
#
# Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
#
# Licensed 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.
#
cmake_minimum_required(VERSION 3.0)
project(ZNC VERSION 1.7.0)
set(ZNC_VERSION 1.7.x)
set(append_git_version true)
set(alpha_version "") # e.g. "-rc1"
set(PROJECT_VERSION "${ZNC_VERSION}")
# https://cmake.org/pipermail/cmake/2010-September/039388.html
set(_all_targets "" CACHE INTERNAL "")
function(znc_add_library name)
add_library("${name}" ${ARGN})
set(_all_targets "${_all_targets};${name}" CACHE INTERNAL "")
endfunction()
function(znc_add_executable name)
add_executable("${name}" ${ARGN})
set(_all_targets "${_all_targets};${name}" CACHE INTERNAL "")
endfunction()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(TestCXX11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED true)
if(NOT CYGWIN)
# We don't want to use -std=gnu++11 instead of -std=c++11, but among other
# things, -std=c++11 on cygwin defines __STRICT_ANSI__ which makes cygwin
# not to compile: undefined references to strerror_r, to fdopen, to
# strcasecmp, etc (their declarations in system headers are between ifdef)
set(CMAKE_CXX_EXTENSIONS false)
endif()
include(CMakeFindFrameworks_fixed)
include(use_homebrew)
include(GNUInstallDirs)
include(CheckCXXSymbolExists)
include(copy_csocket)
set(CMAKE_THREAD_PREFER_PTHREAD true)
set(THREADS_PREFER_PTHREAD_FLAG true)
find_package(Threads REQUIRED)
if(NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "This compiler/OS doesn't seem to support pthreads.")
endif()
include(TestLargeFiles)
test_large_files(HAVE_LARGE_FILES_UNUSED_VAR)
find_package(PkgConfig)
macro(tristate_option opt help)
set(WANT_${opt} AUTO CACHE STRING ${help})
set_property(CACHE WANT_${opt} PROPERTY STRINGS AUTO YES NO)
if(WANT_${opt} STREQUAL "AUTO")
set(TRISTATE_${opt}_REQUIRED)
else()
set(TRISTATE_${opt}_REQUIRED REQUIRED)
endif()
endmacro()
tristate_option(OPENSSL "Support SSL")
if(WANT_OPENSSL)
find_package(OpenSSL ${TRISTATE_OPENSSL_REQUIRED})
endif()
set(HAVE_LIBSSL "${OPENSSL_FOUND}")
set(WANT_IPV6 true CACHE BOOL "Support IPv6")
set(HAVE_IPV6 "${WANT_IPV6}")
tristate_option(ZLIB "Compress HTTP traffic with Zlib")
if(WANT_ZLIB)
find_package(ZLIB ${TRISTATE_ZLIB_REQUIRED})
endif()
set(HAVE_ZLIB "${ZLIB_FOUND}")
tristate_option(CYRUS "Support authentication with Cyrus")
if(WANT_CYRUS)
pkg_check_modules(CYRUS 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
#
# osx (as of El Capitan) doesn't have it either...
set(_old_cmake_required_libraries "${CMAKE_REQUIRED_LIBRARIES}")
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -lsasl2)
check_cxx_symbol_exists(sasl_server_init "sasl/sasl.h" CYRUS_HARDCODED)
set(CMAKE_REQUIRED_LIBRARIES "${_old_cmake_required_libraries}")
if(CYRUS_HARDCODED)
set(CYRUS_LDFLAGS -lsasl2)
set(CYRUS_FOUND true)
endif()
endif()
if(TRISTATE_CYRUS_REQUIRED AND NOT CYRUS_FOUND)
message(FATAL_ERROR "Can't find Cyrus SASL 2")
endif()
endif()
tristate_option(ICU "Support character encodings")
if(WANT_ICU)
pkg_check_modules(ICU ${TRISTATE_ICU_REQUIRED} icu-uc)
endif()
set(HAVE_ICU "${ICU_FOUND}")
set(WANT_PERL false CACHE BOOL "Support Perl modules")
set(WANT_PYTHON false CACHE BOOL "Support Python modules")
set(WANT_PYTHON_VERSION "" CACHE STRING "Python version to use, or empty")
tristate_option(SWIG "Use SWIG to generate modperl and modpython")
set(search_swig false)
if(WANT_SWIG AND TRISTATE_SWIG_REQUIRED)
set(search_swig true)
endif()
if(WANT_PERL AND NOT EXISTS
"${PROJECT_SOURCE_DIR}/modules/modperl/generated.tar.gz")
if(WANT_SWIG)
set(search_swig true)
else()
message(FATAL_ERROR "Pregenerated modperl files are not available. "
"SWIG is required. Alternatively, build ZNC from tarball.")
endif()
endif()
if(WANT_PYTHON AND NOT EXISTS
"${PROJECT_SOURCE_DIR}/modules/modpython/generated.tar.gz")
if(WANT_SWIG)
set(search_swig true)
else()
message(FATAL_ERROR "Pregenerated modpython files are not available. "
"SWIG is required. Alternatively, build ZNC from tarball.")
endif()
endif()
if(search_swig)
find_package(SWIG 3.0.0)
if(NOT SWIG_FOUND)
message(FATAL_ERROR
"Can't find SWIG, therefore Perl and Python aren't supported. "
"Alternatively, build ZNC from tarball.")
endif()
endif()
if(WANT_PERL)
find_package(PerlLibs 5.10 REQUIRED)
endif()
if (WANT_PYTHON)
find_package(Perl 5.10 REQUIRED)
if(WANT_PYTHON_VERSION)
find_package(PythonLibs "${WANT_PYTHON_VERSION}" EXACT REQUIRED)
else()
find_package(PythonLibs 3 REQUIRED)
endif()
endif()
set(WANT_TCL false CACHE BOOL "Support Tcl modules")
if(WANT_TCL)
find_package(TCL QUIET)
if(NOT TCL_FOUND)
message(FATAL_ERROR "Can't find Tcl")
endif()
endif()
# poll() is broken on Mac OS, it fails with POLLNVAL for pipe()s.
if(APPLE)
set(CSOCK_USE_POLL false)
else()
set(CSOCK_USE_POLL true)
endif()
check_cxx_symbol_exists(getopt_long "getopt.h" HAVE_GETOPT_LONG)
check_cxx_symbol_exists(lstat "sys/types.h;sys/stat.h;unistd.h" HAVE_LSTAT)
check_cxx_symbol_exists(getpassphrase "stdlib.h" HAVE_GETPASSPHRASE)
check_cxx_symbol_exists(tcsetattr "termios.h;unistd.h" HAVE_TCSETATTR)
check_cxx_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
# Note that old broken systems, such as OpenBSD, NetBSD, which don't support
# AI_ADDRCONFIG, also have thread-unsafe getaddrinfo(). Gladly, they fixed
# thread-safety before support of AI_ADDRCONFIG, so this can be abused to
# detect the thread-safe getaddrinfo().
#
# TODO: drop support of blocking DNS at some point. OpenBSD supports
# AI_ADDRCONFIG since Nov 2014, and their getaddrinfo() is thread-safe since
# Nov 2013. NetBSD's one is thread-safe since ages ago.
check_cxx_symbol_exists(AI_ADDRCONFIG "sys/types.h;sys/socket.h;netdb.h"
HAVE_THREADED_DNS)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT CYGWIN)
# These enable some debug options in g++'s STL, e.g. invalid use of
# iterators, but they cause crashes on cygwin while loading modules
set(_GLIBCXX_DEBUG true)
set(_GLIBCXX_DEBUG_PEDANTIC true)
endif()
if(append_git_version)
find_package(Git)
endif()
file(GLOB csocket_files LIST_DIRECTORIES FALSE
"${PROJECT_SOURCE_DIR}/third_party/Csocket/Csocket.*")
if(csocket_files STREQUAL "")
message(FATAL_ERROR " It looks like git submodules are not initialized.\n"
" Run: git submodule update --init --recursive")
endif()
install(DIRECTORY webskins
DESTINATION "${CMAKE_INSTALL_DATADIR}/znc")
install(DIRECTORY man/
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
FILES_MATCHING PATTERN "znc*")
set(WANT_SYSTEMD false CACHE BOOL "Install znc.service to systemd")
if(WANT_SYSTEMD)
configure_file("znc.service.in" "znc.service")
set(SYSTEMD_DIR "" CACHE PATH "Path to systemd units")
if(SYSTEMD_DIR STREQUAL "" AND PKG_CONFIG_EXECUTABLE)
execute_process(COMMAND "${PKG_CONFIG_EXECUTABLE}"
--variable=systemdsystemunitdir systemd
OUTPUT_VARIABLE SYSTEMD_DIR)
endif()
if(SYSTEMD_DIR STREQUAL "")
message(FATAL_ERROR "Systemd is enabled, "
"but the unit dir can't be found.")
endif()
install(FILES "${PROJECT_BINARY_DIR}/znc.service"
DESTINATION "${SYSTEMD_DIR}")
endif()
# On cygwin, if to link modules against znc.exe directly, modperl can't call
# ZNC's functions very well. They do get called, but global variables have
# different addresses. That address actually is in modperl/ZNC.dll if to look
# at /proc/123/maps
# Example of such global variable is one returned by CZNC::Get()
# Modpython seems to work though with STATIC on cygwin... (I didn't test it
# too much though)
#
# Non-cygwin should link modules to /usr/bin/znc directly to prevent this:
# error while loading shared libraries: libznc.so: cannot open shared object file: No such file or directory
# Without need to touch LD_LIBRARY_PATH
if(CYGWIN)
set(znc_link "znclib")
set(lib_type "SHARED")
set(install_lib "znclib")
set(znclib_pc "-L${CMAKE_INSTALL_FULL_LIBDIR} -lznc")
else()
set(znc_link "znc")
set(lib_type "STATIC")
set(install_lib)
set(znclib_pc)
endif()
configure_file("include/znc/zncconfig.h.cmake.in" "include/znc/zncconfig.h")
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(modules)
add_subdirectory(test)
add_subdirectory(zz_msg)
add_custom_target(msg_after_all ALL
COMMAND "${CMAKE_COMMAND}" -E echo
COMMAND "${CMAKE_COMMAND}" -E echo " ZNC was successfully compiled."
COMMAND "${CMAKE_COMMAND}" -E echo
" Use 'make install' to install ZNC to '${CMAKE_INSTALL_PREFIX}'."
COMMAND "${CMAKE_COMMAND}" -E echo
VERBATIM)
add_dependencies(msg_after_all ${_all_targets})
# @echo ""
# @echo " ZNC was successfully compiled."
# @echo " Use '$(MAKE) install' to install ZNC to '$(prefix)'."
configure_file("ZNCConfig.cmake.in" "ZNCConfig.cmake" @ONLY)
include(CMakePackageConfigHelpers)
write_basic_package_version_file("ZNCConfigVersion.cmake"
COMPATIBILITY AnyNewerVersion)
install(FILES
"${PROJECT_BINARY_DIR}/ZNCConfig.cmake"
"${PROJECT_BINARY_DIR}/ZNCConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_DATADIR}/znc/cmake")
configure_file("znc-buildmod.cmake.in" "znc-buildmod" @ONLY)
install(PROGRAMS "${PROJECT_BINARY_DIR}/znc-buildmod"
DESTINATION "${CMAKE_INSTALL_BINDIR}")
configure_file("znc.pc.cmake.in" "znc.pc" @ONLY)
install(FILES "${PROJECT_BINARY_DIR}/znc.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
macro(summary_line text var)
if(${var})
list(APPEND summary_lines "${text} : yes")
else()
list(APPEND summary_lines "${text} : no")
endif()
endmacro()
set(summary_lines
"ZNC ${ZNC_VERSION}${alpha_version} configured"
" "
"Prefix : ${CMAKE_INSTALL_PREFIX}")
summary_line("SSL " "${OPENSSL_FOUND}")
summary_line("IPv6 " "${WANT_IPV6}")
summary_line("Async DNS" "${HAVE_THREADED_DNS}")
summary_line("Perl " "${PERLLIBS_FOUND}")
summary_line("Python " "${PYTHONLIBS_FOUND}")
summary_line("Tcl " "${TCL_FOUND}")
summary_line("Cyrus " "${CYRUS_FOUND}")
summary_line("Charset " "${ICU_FOUND}")
summary_line("Zlib " "${ZLIB_FOUND}")
include(render_framed_multiline)
render_framed_multiline("${summary_lines}")
message("")
message("Now you can run 'make' to compile ZNC")
message("")
# TODO
# ====
#
# readme: advice about cmake --system-information
# remove old configure.ac and Makefile.in
# consider mininum cmake version

+ 6
- 4
Makefile.in View File

@ -154,7 +154,7 @@ test/gmock-main.o: $(GMOCK_DIR)/src/gmock_main.cc Makefile
$(Q)$(CXX) $(CXXFLAGS) $(GTEST_FLAGS) -c -o $@ $< -MD -MF .depend/gmock-main.dep -MT $@
# Qt fails under TSAN, so CXXFLAGS/LDFLAGS can't be used.
test/Integration.o: test/Integration.cpp Makefile
test/Integration.o: test/integration/main.cpp Makefile
@mkdir -p .depend test
$(E) Building test object Integration...
$(Q)g++ $(qt_CFLAGS) $(GTEST_FLAGS) -c -o $@ $< -MD -MF .depend/Integration.test.dep -MT $@ '-DZNC_BIN_DIR="$(bindir)"' '-DZNC_SRC_DIR="$(realpath $(srcdir))"'
@ -179,7 +179,10 @@ src/version.cpp: Makefile version.sh $(shell if [ x`cat .version_extra 2> /dev/n
$(E) Building source file version.cpp...
$(Q)WRITE_OUTPUT=yes $(srcdir)/version.sh "$(GIT)" > .version_extra 2> /dev/null
CLEAN += src/version.cpp src/Csocket.cpp include/znc/Csocket.h
CLEAN += src/version.cpp
endif
CLEAN += src/Csocket.cpp include/znc/Csocket.h
src/Csocket.cpp: third_party/Csocket/Csocket.cc
@rm -f $@
@ -192,10 +195,9 @@ include/znc/Csocket.h: third_party/Csocket/Csocket.h
third_party/Csocket/Csocket.h third_party/Csocket/Csocket.cc:
@echo It looks like git submodules are not initialized. Run: git submodule update --init --recursive
@exit 1
endif
znc.service: znc.service.in
@sed -e "s:\@bindir\@:$(bindir):" $^ > $@
@sed -e "s:\@CMAKE_INSTALL_FULL_BINDIR\@:$(bindir):" $^ > $@
CLEAN += znc.service


+ 2
- 0
NOTICE View File

@ -14,6 +14,8 @@ ZNC includes modified code for SSL verification by Alban Diquet (https://github.
ZNC includes code from jQuery (http://jquery.com/), licensed under the MIT License.
ZNC includes code from jQuery UI (http://jqueryui.com/), licensed under the MIT License.
ZNC includes code from Selectize (http://brianreavis.github.io/selectize.js/), licensed under the Apache License 2.0.
ZNC includes modified code from CMakeFindFrameworks.cmake by Kitware, Inc., licensed under BSD License.
ZNC includes modified code from TestLargeFiles.cmake, licensed under Boost Software License, Version 1.0.
ZNC is developed by these people:


+ 29
- 1
README.md View File

@ -26,7 +26,9 @@ Core:
* GNU make
* pkg-config
* GCC 4.7 or clang 3.2
* autoconf and automake (if building from git)
* Either of:
* autoconf and automake (but only if building from git, not from tarball)
* CMake
## Optional Requirements
@ -53,6 +55,32 @@ Character Encodings:
## Installing ZNC
Currently there are 2 build systems in place: CMake and `./configure`.
`./configure` will eventually be removed.
There is also `configure.py` which should make migration to CMake easier:
it accepts the same parameters as `./configure`,
but calls CMake with CMake-style parameters.
### Installing with CMake
Installation from source code is performed using the CMake toolchain.
```shell
cmake .
make
make install
```
You can use `cmake-gui` or `ccmake` for more interactiveness.
Note for FreeBSD users:
By default base OpenSSL is selected.
If you want the one from ports, use `-DOPENSSL_ROOT_DIR=/usr/local`.
For troubleshooting, `cmake --system-information` will show you details.
### Installing with `./configure`
Installation from source code is performed using the `automake` toolchain.
If you are building from git, you will need to run `./autogen.sh` first to
produce the `configure` script.


+ 51
- 0
ZNCConfig.cmake.in View File

@ -0,0 +1,51 @@
#
# Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
#
# Licensed 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("${CMAKE_CURRENT_LIST_DIR}/znc.cmake")
include(CMakeParseArguments)
# For some reason cygwin fails to build modules if Threads::Threads
# is not found.
if(NOT CYGWIN)
set(ZNC_NO_INCLUDE_THREADS true)
endif()
if(NOT ZNC_NO_INCLUDE_THREADS)
set(CMAKE_THREAD_PREFER_PTHREAD true)
set(THREADS_PREFER_PTHREAD_FLAG true)
find_package(Threads REQUIRED)
if(NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "This compiler/OS doesn't seem "
"to support pthreads.")
endif()
endif()
function(znc_setup_module)
cmake_parse_arguments(znc_mod "" "TARGET;NAME" "" ${ARGN})
set_target_properties("${znc_mod_TARGET}" PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED true
OUTPUT_NAME "${znc_mod_NAME}"
PREFIX ""
SUFFIX ".so"
NO_SONAME true
CXX_VISIBILITY_PRESET "hidden"
COMPILE_DEFINITIONS "znc_export_lib_EXPORTS")
set(znc_link "@znc_link@")
target_link_libraries("${znc_mod_TARGET}" PUBLIC "znc_internal_${znc_link}")
endfunction()
message(STATUS "Found ZNC @ZNC_VERSION@")

+ 40
- 0
cmake/CMakeFindFrameworks_fixed.cmake View File

@ -0,0 +1,40 @@
# Modification from upstream CMakeFindFrameworks.cmake from version 3.3.1:
# - add support of ${fwk}_FRAMEWORKS_ADDITIONAL input variable
#.rst:
# CMakeFindFrameworks
# -------------------
#
# helper module to find OSX frameworks
#=============================================================================
# Copyright 2003-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED)
set(CMAKE_FIND_FRAMEWORKS_INCLUDED 1)
macro(CMAKE_FIND_FRAMEWORKS fwk)
set(${fwk}_FRAMEWORKS)
if(APPLE)
foreach(dir
${${fwk}_FRAMEWORKS_ADDITIONAL}
~/Library/Frameworks/${fwk}.framework
/Library/Frameworks/${fwk}.framework
/System/Library/Frameworks/${fwk}.framework
/Network/Library/Frameworks/${fwk}.framework)
if(EXISTS ${dir})
set(${fwk}_FRAMEWORKS ${${fwk}_FRAMEWORKS} ${dir})
endif()
endforeach()
endif()
endmacro()
endif()

+ 94
- 0
cmake/FindPerlLibs.cmake View File

@ -0,0 +1,94 @@
#
# Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
#
# Licensed 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.
#
# perl 5.20 will fix this warning:
# https://rt.perl.org/Public/Bug/Display.html?id=120670
set(PERL_CFLAGS -Wno-reserved-user-defined-literal -Wno-literal-suffix
CACHE STRING "Perl compiler flags")
if(PerlLibs_FIND_VERSION_EXACT)
set(_PerlLibs_exact EXACT)
else()
set(_PerlLibs_exact)
endif()
find_package(Perl ${PerlLibs_FIND_VERSION} ${PerlLibs_exact} QUIET)
if(PERL_FOUND)
if(PERL_INCLUDE_DIR AND PERL_LIBRARIES)
else()
execute_process(
COMMAND "${PERL_EXECUTABLE}" -MExtUtils::Embed -e perl_inc
OUTPUT_VARIABLE _PerlLibs_inc_output
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "^ *-I" "" _PerlLibs_include
"${_PerlLibs_inc_output}")
execute_process(
COMMAND "${PERL_EXECUTABLE}" -MExtUtils::Embed -e ldopts
OUTPUT_VARIABLE _PerlLibs_ld_output
OUTPUT_STRIP_TRAILING_WHITESPACE)
separate_arguments(_PerlLibs_ld_output)
set(_PerlLibs_ldflags)
set(_PerlLibs_libraries)
foreach(_PerlLibs_i ${_PerlLibs_ld_output})
if("${_PerlLibs_i}" MATCHES "^-l")
list(APPEND _PerlLibs_libraries "${_PerlLibs_i}")
else()
set(_PerlLibs_ldflags "${_PerlLibs_ldflags} ${_PerlLibs_i}")
endif()
endforeach()
get_filename_component(_PerlLibs_dir "${CMAKE_CURRENT_LIST_FILE}"
DIRECTORY)
try_compile(_PerlLibs_try
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/perl_check"
"${_PerlLibs_dir}/perl_check" perl_check
CMAKE_FLAGS
"-DPERL_INCLUDE_DIRS=${_PerlLibs_include}"
"-DPERL_LDFLAGS=${_PerlLibs_ldflags}"
"-DPERL_LIBRARIES=${_PerlLibs_libraries}"
"-DPERL_CFLAGS=${PERL_CFLAGS}"
OUTPUT_VARIABLE _PerlLibs_tryout)
if(_PerlLibs_try)
set(PERL_INCLUDE_DIR "${_PerlLibs_include}" CACHE PATH
"Perl include dir")
set(PERL_LDFLAGS "${_PerlLibs_ldflags}" CACHE STRING
"Perl linker flags")
set(PERL_LIBRARIES "${_PerlLibs_libraries}" CACHE STRING
"Perl libraries")
file(APPEND
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log"
"Output using Perl:\n${_PerlLibs_tryout}\n")
else()
set(_PerlLibs_failmsg FAIL_MESSAGE "Attempt to use Perl failed")
file(APPEND
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
"Error using Perl:\n${_PerlLibs_tryout}\n")
endif()
endif()
else()
set(_PerlLibs_failmsg FAIL_MESSAGE "Perl not found")
endif()
find_package_handle_standard_args(PerlLibs
REQUIRED_VARS PERL_INCLUDE_DIR PERL_LIBRARIES
VERSION_VAR PERL_VERSION_STRING
${_PerlLibs_failmsg})
set(PERL_INCLUDE_DIRS "${PERL_INCLUDE_DIR}")
mark_as_advanced(PERL_INCLUDE_DIR PERL_LDFLAGS PERL_LIBRARIES PERL_CFLAGS)

+ 39
- 0
cmake/TestCXX11.cmake View File

@ -0,0 +1,39 @@
#
# Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
#
# Licensed 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.
#
if(NOT DEFINED cxx11check)
message(STATUS "Checking for C++11 support")
get_filename_component(_CXX11Check_dir "${CMAKE_CURRENT_LIST_FILE}"
DIRECTORY)
try_compile(cxx11_supported
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cxx11check"
"${_CXX11Check_dir}/cxx11check" cxx11check
OUTPUT_VARIABLE _CXX11Check_tryout)
if(cxx11_supported)
message(STATUS "Checking for C++11 support - supported")
SET(cxx11check 1 CACHE INTERNAL "C++11 support")
file(APPEND
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log"
"Output of C++11 check:\n${_CXX11Check_tryout}\n")
else()
file(APPEND
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
"Error in C++11 check:\n${_CXX11Check_tryout}\n")
message(STATUS "Checking for C++11 support - not supported")
message(FATAL_ERROR " Upgrade your compiler.\n"
" GCC 4.7+ and Clang 3.2+ are known to work.")
endif()
endif()

+ 12
- 0
cmake/TestFileOffsetBits.c View File

@ -0,0 +1,12 @@
// See TestLargeFiles.cmake for the origin of this file
#include <sys/types.h>
int main(int argc, char **argv)
{
/* Cause a compile-time error if off_t is smaller than 64 bits */
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
return 0;
}

+ 26
- 0
cmake/TestLargeFiles.c.cmakein View File

@ -0,0 +1,26 @@
// See TestLargeFiles.cmake for the origin of this file
#cmakedefine _LARGEFILE_SOURCE
#cmakedefine _LARGEFILE64_SOURCE
#cmakedefine _LARGE_FILES
#cmakedefine _FILE_OFFSET_BITS ${_FILE_OFFSET_BITS}
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
/* Cause a compile-time error if off_t is smaller than 64 bits,
* and make sure we have ftello / fseeko.
*/
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];
FILE *fp = fopen(argv[0],"r");
off_t offset = ftello( fp );
fseeko( fp, offset, SEEK_CUR );
fclose(fp);
return 0;
}

+ 122
- 0
cmake/TestLargeFiles.cmake View File

@ -0,0 +1,122 @@
# Downloaded from https://panthema.net/2012/1119-eSAIS-Inducing-Suffix-and-LCP-Arrays-in-External-Memory/eSAIS-DC3-LCP-0.5.4/stxxl/misc/cmake/TestLargeFiles.cmake.html
# That project's license is Boost Software License, Version 1.0.
# - Define macro to check large file support
#
# TEST_LARGE_FILES(VARIABLE)
#
# VARIABLE will be set to true if off_t is 64 bits, and fseeko/ftello present.
# This macro will also set defines necessary enable large file support, for instance
# _LARGE_FILES
# _LARGEFILE_SOURCE
# _FILE_OFFSET_BITS 64
# HAVE_FSEEKO
#
# However, it is YOUR job to make sure these defines are set in a cmakedefine so they
# end up in a config.h file that is included in your source if necessary!
set(_test_large_files_dir "${CMAKE_CURRENT_LIST_DIR}")
MACRO(TEST_LARGE_FILES VARIABLE)
IF(NOT DEFINED ${VARIABLE})
# On most platforms it is probably overkill to first test the flags for 64-bit off_t,
# and then separately fseeko. However, in the future we might have 128-bit filesystems
# (ZFS), so it might be dangerous to indiscriminately set e.g. _FILE_OFFSET_BITS=64.
MESSAGE(STATUS "Checking for 64-bit off_t")
# First check without any special flags
TRY_COMPILE(FILE64_OK "${PROJECT_BINARY_DIR}"
"${_test_large_files_dir}/TestFileOffsetBits.c")
if(FILE64_OK)
MESSAGE(STATUS "Checking for 64-bit off_t - present")
endif(FILE64_OK)
if(NOT FILE64_OK)
# Test with _FILE_OFFSET_BITS=64
TRY_COMPILE(FILE64_OK "${PROJECT_BINARY_DIR}"
"${_test_large_files_dir}/TestFileOffsetBits.c"
COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" )
if(FILE64_OK)
MESSAGE(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64")
set(_FILE_OFFSET_BITS 64)
endif(FILE64_OK)
endif(NOT FILE64_OK)
if(NOT FILE64_OK)
# Test with _LARGE_FILES
TRY_COMPILE(FILE64_OK "${PROJECT_BINARY_DIR}"
"${_test_large_files_dir}/TestFileOffsetBits.c"
COMPILE_DEFINITIONS "-D_LARGE_FILES" )
if(FILE64_OK)
MESSAGE(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES")
set(_LARGE_FILES 1)
endif(FILE64_OK)
endif(NOT FILE64_OK)
if(NOT FILE64_OK)
# Test with _LARGEFILE_SOURCE
TRY_COMPILE(FILE64_OK "${PROJECT_BINARY_DIR}"
"${_test_large_files_dir}/TestFileOffsetBits.c"
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
if(FILE64_OK)
MESSAGE(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE")
set(_LARGEFILE_SOURCE 1)
endif(FILE64_OK)
endif(NOT FILE64_OK)
if(NOT FILE64_OK)
# now check for Windows stuff
TRY_COMPILE(FILE64_OK "${PROJECT_BINARY_DIR}"
"${_test_large_files_dir}/TestWindowsFSeek.c")
if(FILE64_OK)
MESSAGE(STATUS "Checking for 64-bit off_t - present with _fseeki64")
set(HAVE__FSEEKI64 1)
endif(FILE64_OK)
endif(NOT FILE64_OK)
if(NOT FILE64_OK)
MESSAGE(STATUS "Checking for 64-bit off_t - not present")
else(NOT FILE64_OK)
# Set the flags we might have determined to be required above
configure_file("${_test_large_files_dir}/TestLargeFiles.c.cmakein"
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
MESSAGE(STATUS "Checking for fseeko/ftello")
# Test if ftello/fseeko are available
TRY_COMPILE(FSEEKO_COMPILE_OK "${PROJECT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
if(FSEEKO_COMPILE_OK)
MESSAGE(STATUS "Checking for fseeko/ftello - present")
endif(FSEEKO_COMPILE_OK)
if(NOT FSEEKO_COMPILE_OK)
# glibc 2.2 neds _LARGEFILE_SOURCE for fseeko (but not 64-bit off_t...)
TRY_COMPILE(FSEEKO_COMPILE_OK "${PROJECT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c"
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" )
if(FSEEKO_COMPILE_OK)
MESSAGE(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE")
set(_LARGEFILE_SOURCE 1)
endif(FSEEKO_COMPILE_OK)
endif(NOT FSEEKO_COMPILE_OK)
endif(NOT FILE64_OK)
if(FSEEKO_COMPILE_OK)
SET(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
set(HAVE_FSEEKO 1)
else(FSEEKO_COMPILE_OK)
if (HAVE__FSEEKI64)
SET(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
SET(HAVE__FSEEKI64 1 CACHE INTERNAL "Windows 64-bit fseek" FORCE)
else (HAVE__FSEEKI64)
MESSAGE(STATUS "Checking for fseeko/ftello - not found")
SET(${VARIABLE} 0 CACHE INTERNAL "Result of test for large file support" FORCE)
endif (HAVE__FSEEKI64)
endif(FSEEKO_COMPILE_OK)
ENDIF(NOT DEFINED ${VARIABLE})
ENDMACRO(TEST_LARGE_FILES VARIABLE)

+ 12
- 0
cmake/TestWindowsFSeek.c View File

@ -0,0 +1,12 @@
// See TestLargeFiles.cmake for the origin of this file
#include <stdio.h>
int main()
{
__int64 off=0;
_fseeki64(NULL, off, SEEK_SET);
return 0;
}

+ 26
- 0
cmake/copy_csocket.cmake View File

@ -0,0 +1,26 @@
#
# Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
#
# Licensed 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.
#
function(copy_csocket tgt source destination)
add_custom_command(OUTPUT "${destination}"
COMMAND "${CMAKE_COMMAND}"
-D "source=${source}"
-D "destination=${destination}"
-P "${PROJECT_SOURCE_DIR}/cmake/copy_csocket_cmd.cmake"
DEPENDS "${source}" "${PROJECT_SOURCE_DIR}/cmake/copy_csocket_cmd.cmake"
VERBATIM)
add_custom_target("${tgt}" DEPENDS "${destination}")
endfunction()

+ 20
- 0
cmake/copy_csocket_cmd.cmake View File

@ -0,0 +1,20 @@
#
# Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
#
# Licensed 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.
#
file(READ "${source}" content)
string(REPLACE "#include \"defines.h\"" "#include <znc/defines.h>" content "${content}")
string(REPLACE "#include \"Csocket.h\"" "#include <znc/Csocket.h>" content "${content}")
file(WRITE "${destination}" "${content}")

+ 23
- 0
cmake/cxx11check/CMakeLists.txt View File

@ -0,0 +1,23 @@
#
# Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
#
# Licensed 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.
#
cmake_minimum_required(VERSION 3.0)
project(cxx11check)
set(CMAKE_VERBOSE_MAKEFILE true)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED true)
add_executable(main main.cpp)

+ 58
- 0
cmake/cxx11check/main.cpp View File

@ -0,0 +1,58 @@
// This file uses code from http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html (serial 5)
// Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
// Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
// Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
//
// Copying and distribution of this file, with or without modification, are
// permitted in any medium without royalty provided the copyright notice
// and this notice are preserved. This file is offered as-is, without any
// warranty.
template <typename T>
struct check {
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
struct Base {
virtual void f() {}
};
struct Child : public Base {
virtual void f() override {}
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);
auto d = a;
auto l = []() {};
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
// because of this
namespace test_template_alias_sfinae {
struct foo {};
template <typename T>
using member = typename T::member_type;
template <typename T>
void func(...) {}
template <typename T>
void func(member<T>*) {}
void test();
void test() { func<foo>(0); }
}
int main() { return 0; }

+ 76
- 0
cmake/gen_version.cmake View File

@ -0,0 +1,76 @@
#
# Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
#
# Licensed 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.
#
if(nightly)
set(git_info "${nightly}")
elseif(append_git_version)
set(git ${gitcmd} "--git-dir=${srcdir}/.git")
execute_process(COMMAND ${git} describe --abbrev=0 HEAD
RESULT_VARIABLE git_result
ERROR_QUIET
OUTPUT_VARIABLE latest_tag)
string(STRIP "${latest_tag}" latest_tag)
if(git_result EQUAL 0)
execute_process(COMMAND ${git} rev-parse --short HEAD
OUTPUT_VARIABLE short_id)
string(STRIP "${short_id}" short_id)
if(latest_tag STREQUAL "")
# shallow clone
set(git_info "-git-${short_id}")
else()
# One character "x" per commit, remove newlines from output
execute_process(COMMAND ${git} log --format=tformat:x
"${latest_tag}..HEAD"
OUTPUT_VARIABLE commits_since)
string(REGEX REPLACE "[^x]" "" commits_since "${commits_since}")
string(LENGTH "${commits_since}" commits_since)
if(commits_since EQUAL 0)
# If this commit is tagged, don't print anything
# (the assumption here is: this is a release)
set(git_info "")
# However, this shouldn't happen, as for releases
# append_git_version should be set to false
else()
set(git_info "-git-${commits_since}-${short_id}")
endif()
endif()
execute_process(COMMAND ${gitcmd} status
--ignore-submodules=dirty
--porcelain
-- third_party/Csocket
WORKING_DIRECTORY "${srcdir}"
OUTPUT_VARIABLE franken)
string(STRIP "${franken}" franken)
if(NOT franken STREQUAL "")
message(WARNING " Csocket submodule looks outdated.\n"
" Run: git submodule update --init --recursive")
set(git_info "${git_info}-frankenznc")
endif()
else()
# Probably .git/ or git isn't found, or something
set(git_info "-git-unknown")
endif()
else()
set(git_info "")
endif()
configure_file("${srcfile}" "${destfile}")

+ 30
- 0
cmake/perl_check/CMakeLists.txt View File

@ -0,0 +1,30 @@
#
# Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
#
# Licensed 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.
#
cmake_minimum_required(VERSION 3.0)
project(perl_check)
set(CMAKE_VERBOSE_MAKEFILE true)
if(APPLE)
set(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS
"${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
endif()
add_library(main MODULE main.cpp)
target_include_directories(main PRIVATE ${PERL_INCLUDE_DIRS})
target_compile_options(main PRIVATE "${PERL_CFLAGS}")
target_link_libraries(main PRIVATE ${PERL_LIBRARIES})
set_target_properties(main PROPERTIES LINK_FLAGS "${PERL_LDFLAGS}")