]> jfr.im git - irc/weechat/weechat-relay.git/blame - CMakeLists.txt
Remove tests on macOS 11
[irc/weechat/weechat-relay.git] / CMakeLists.txt
CommitLineData
8ab2319d 1#
0def0350 2# Copyright (C) 2019-2024 Sébastien Helleu <flashcode@flashtux.org>
8ab2319d
SH
3#
4# This file is part of WeeChat Relay.
5#
6# WeeChat Relay is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# WeeChat Relay is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with WeeChat Relay. If not, see <https://www.gnu.org/licenses/>.
18#
19
f30b879b
SH
20cmake_minimum_required(VERSION 3.0)
21cmake_policy(VERSION 3.0)
8ab2319d
SH
22
23project(weechat-relay C)
24
25# CMake options
26set(CMAKE_VERBOSE_MAKEFILE OFF)
27set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
28set(CMAKE_SKIP_RPATH ON)
7136520e
SH
29
30# compiler options
31set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsigned-char -Wall -Wextra -Werror-implicit-function-declaration")
d532ed34 32set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char -Wall -Wextra")
7136520e
SH
33if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
34 # extra options specific to gcc/g++
35 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat-overflow=2 -Wformat-truncation=2")
36 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat-overflow=2 -Wformat-truncation=2")
37endif()
8ab2319d
SH
38
39# version
40execute_process(COMMAND ${CMAKE_SOURCE_DIR}/version.sh devel-full OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
41execute_process(COMMAND ${CMAKE_SOURCE_DIR}/version.sh devel-major OUTPUT_VARIABLE VERSION_MAJOR OUTPUT_STRIP_TRAILING_WHITESPACE)
42execute_process(COMMAND ${CMAKE_SOURCE_DIR}/version.sh devel-minor OUTPUT_VARIABLE VERSION_MINOR OUTPUT_STRIP_TRAILING_WHITESPACE)
43execute_process(COMMAND ${CMAKE_SOURCE_DIR}/version.sh devel-patch OUTPUT_VARIABLE VERSION_PATCH OUTPUT_STRIP_TRAILING_WHITESPACE)
44execute_process(COMMAND ${CMAKE_SOURCE_DIR}/version.sh devel-number OUTPUT_VARIABLE VERSION_NUMBER OUTPUT_STRIP_TRAILING_WHITESPACE)
45
56c7a96a 46# directories
8ab2319d
SH
47if(NOT DEFINED LIBDIR)
48 set(LIBDIR ${CMAKE_INSTALL_PREFIX}/lib)
49endif()
7bc9f09a
SH
50if(NOT DEFINED DATAROOTDIR)
51 set(DATAROOTDIR ${CMAKE_INSTALL_PREFIX}/share)
8ab2319d 52endif()
8ab2319d 53if(NOT DEFINED MANDIR)
7bc9f09a 54 set(MANDIR ${DATAROOTDIR}/man)
8ab2319d 55endif()
8ab2319d 56if(NOT DEFINED LOCALEDIR)
7bc9f09a 57 set(LOCALEDIR ${DATAROOTDIR}/locale)
8ab2319d 58endif()
8ab2319d
SH
59if(DEFINED INCLUDEDIR)
60 set(INCLUDEDIR ${INCLUDEDIR}/${PROJECT_NAME})
61else()
62 set(INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})
63endif()
64
56c7a96a 65# build options
8ab2319d 66option(BUILD_CLI "Build the testing CLI program" ON)
f4746881
SH
67option(BUILD_DOC "Enable build of documentation" OFF)
68option(BUILD_MAN "Enable build of man pages" OFF)
8ab2319d
SH
69option(BUILD_TESTS "Build tests" OFF)
70option(CODE_COVERAGE "Enable code coverage" OFF)
71
56c7a96a
SH
72# definitions
73add_definitions(-DPACKAGE_NAME="${PROJECT_NAME}")
8ab2319d 74
0e284dd7
SH
75set(LINK_LIBS)
76
56c7a96a
SH
77# code coverage
78add_library(coverage_config INTERFACE)
8ab2319d
SH
79if(CODE_COVERAGE)
80 target_compile_options(coverage_config INTERFACE -O0 -g --coverage)
81 target_link_libraries(coverage_config INTERFACE --coverage)
82endif()
83
56c7a96a 84# required libs
0e284dd7
SH
85find_package(GnuTLS REQUIRED)
86include_directories(${GNUTLS_INCLUDE_DIR})
87list(APPEND LINK_LIBS ${GNUTLS_LIBRARY})
88
56c7a96a 89# build weechat-relay.h
8ab2319d
SH
90configure_file(lib/weechat-relay.h.cmake lib/weechat-relay.h @ONLY)
91
56c7a96a 92# sub-directories
8ab2319d
SH
93add_subdirectory(lib)
94add_subdirectory(src)
95add_subdirectory(doc)
96
56c7a96a 97# tests
6db8082b
SH
98if(BUILD_TESTS)
99 find_package(CppUTest)
100 if(CPPUTEST_FOUND)
101 enable_testing()
102 add_subdirectory(tests)
103 else()
104 message(SEND_ERROR "CppUTest not found")
105 endif()
8ab2319d
SH
106endif()
107
108# set the git version in "config-git.h"
109add_custom_target(version_git ALL
8ec1849d 110 COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/set_git_version.sh" "${CMAKE_CURRENT_SOURCE_DIR}" "${VERSION}" "config-git.h"
8ab2319d
SH
111 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
112
56c7a96a 113# add target "dist"
8ab2319d
SH
114add_custom_target(dist
115 "${CMAKE_CURRENT_SOURCE_DIR}/tools/makedist.sh" "${VERSION}" "HEAD" "${CMAKE_CURRENT_BINARY_DIR}"
116 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
117
118# pkgconfig file
119set(prefix "${CMAKE_INSTALL_PREFIX}")
120set(exec_prefix "\${prefix}")
121set(libdir "\${exec_prefix}/lib")
122set(includedir "\${prefix}/include")
123configure_file(${CMAKE_CURRENT_SOURCE_DIR}/weechat-relay.pc.in ${CMAKE_CURRENT_BINARY_DIR}/weechat-relay.pc @ONLY)
124install(FILES ${CMAKE_CURRENT_BINARY_DIR}/weechat-relay.pc DESTINATION ${LIBDIR}/pkgconfig)
125
126# cygport file (used to build Cygwin packages)
127configure_file(${CMAKE_CURRENT_SOURCE_DIR}/weechat-relay.cygport.in
128 ${CMAKE_CURRENT_BINARY_DIR}/weechat-relay-${VERSION}-1.cygport @ONLY)
129
130# install some files (only on Cygwin)
131if(CYGWIN)
132 install(FILES
d519be37 133 ${CMAKE_CURRENT_SOURCE_DIR}/AUTHORS.md
59b97996 134 ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG.md
67e2c803 135 ${CMAKE_CURRENT_SOURCE_DIR}/CONTRIBUTING.md
36453225 136 ${CMAKE_CURRENT_SOURCE_DIR}/README.md
7bc9f09a 137 DESTINATION ${DATAROOTDIR}/doc/${PROJECT_NAME})
8ab2319d 138endif()