2023-07-15 10:37:19 +01:00
|
|
|
#
|
|
|
|
# InspIRCd -- Internet Relay Chat Daemon
|
|
|
|
#
|
|
|
|
# Copyright (C) 2019 Robby <robby@chatbelgie.be>
|
2024-07-14 11:58:57 +01:00
|
|
|
# Copyright (C) 2018-2019, 2021-2024 Sadie Powell <sadie@witchery.services>
|
2023-07-15 10:37:19 +01:00
|
|
|
# Copyright (C) 2013-2014 Attila Molnar <attilamolnar@hush.com>
|
2024-06-07 10:37:56 +01:00
|
|
|
# Copyright (C) 2013-2014 Adam <Adam@anope.org>
|
2023-07-15 10:37:19 +01:00
|
|
|
#
|
|
|
|
# This file is part of InspIRCd. InspIRCd is free software: you can
|
|
|
|
# redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
# License as published by the Free Software Foundation, version 2.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
2023-07-15 08:44:58 +01:00
|
|
|
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
|
2013-03-14 15:19:41 -04:00
|
|
|
|
2023-07-15 08:44:58 +01:00
|
|
|
project("InspIRCd" CXX)
|
2013-03-14 15:19:41 -04:00
|
|
|
|
2023-07-13 13:27:14 +01:00
|
|
|
if(NOT WIN32)
|
|
|
|
message(FATAL_ERROR "CMake can only be used on Windows!")
|
|
|
|
endif()
|
|
|
|
|
2023-07-15 08:44:58 +01:00
|
|
|
set(CONFIG_DIR "conf" CACHE PATH "Configuration path")
|
2014-07-22 16:33:07 -04:00
|
|
|
set(MODULE_DIR "modules" CACHE PATH "Module path")
|
|
|
|
set(DATA_DIR "data" CACHE PATH "Data path")
|
2023-07-15 08:44:58 +01:00
|
|
|
set(LOG_DIR "logs" CACHE PATH "Log path")
|
2013-03-23 22:47:25 -05:00
|
|
|
|
2023-07-15 08:44:58 +01:00
|
|
|
# Find the root of the source directory
|
|
|
|
cmake_path(GET CMAKE_CURRENT_SOURCE_DIR PARENT_PATH INSPIRCD_BASE)
|
2013-03-14 15:19:41 -04:00
|
|
|
|
2013-06-11 00:33:31 +02:00
|
|
|
# Build with multiple processes
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
|
|
|
|
2013-03-14 15:19:41 -04:00
|
|
|
# Use our own NSIS template
|
|
|
|
set(CMAKE_MODULE_PATH "${INSPIRCD_BASE}/win")
|
|
|
|
|
2021-06-07 06:59:23 +01:00
|
|
|
# Require C++17
|
|
|
|
set(CMAKE-CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_CXX_STANDARD "17")
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
2022-04-30 18:50:10 +01:00
|
|
|
# Put modules in their own folder
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
2022-09-03 14:26:31 +01:00
|
|
|
add_compile_definitions(
|
|
|
|
"_WIN32_WINNT=0x0A00" # Set the minimum OS to Windows 10
|
2023-06-19 17:41:04 +01:00
|
|
|
"FD_SETSIZE=24000" # Increase the default socket limit to something reasonable
|
2022-09-23 22:12:30 +01:00
|
|
|
"NOMINMAX" # Avoid the Windows API breaking std::{min,max}
|
2022-09-03 14:26:31 +01:00
|
|
|
"NTDDI_VERSION=0x0A000005" # Set the minimum OS to Windows 10 1803 "Redstone 4"
|
|
|
|
"WIN32_LEAN_AND_MEAN" # Trim down the size of the included headers.
|
|
|
|
)
|
|
|
|
|
2024-07-02 22:33:50 +01:00
|
|
|
add_compile_options("/utf-8")
|
|
|
|
|
2023-07-15 08:44:58 +01:00
|
|
|
include_directories("${INSPIRCD_BASE}/win" "${INSPIRCD_BASE}/include")
|
|
|
|
include_directories(SYSTEM "${INSPIRCD_BASE}/vendor")
|
|
|
|
|
|
|
|
# win32memory is statically linked into every target later
|
|
|
|
add_library("win32memory" STATIC "${INSPIRCD_BASE}/win/win32memory.cpp")
|
|
|
|
|
2013-03-14 15:19:41 -04:00
|
|
|
# Grab version info from version.sh
|
|
|
|
file(STRINGS "${INSPIRCD_BASE}/src/version.sh" VERSIONSH)
|
2014-07-22 16:33:07 -04:00
|
|
|
string(REGEX REPLACE ".*InspIRCd-([0-9]*).*" "\\1" VERSION_MAJOR "${VERSIONSH}")
|
|
|
|
string(REGEX REPLACE ".*InspIRCd-[0-9]*\\.([0-9]*).*" "\\1" VERSION_MINOR "${VERSIONSH}")
|
|
|
|
string(REGEX REPLACE ".*InspIRCd-[0-9]*\\.[0-9]*\\.([0-9]*).*" "\\1" VERSION_PATCH "${VERSIONSH}")
|
2018-02-17 17:12:26 +00:00
|
|
|
string(REGEX REPLACE ".*InspIRCd-([^\"]+).*" "\\1" VERSION_FULL "${VERSIONSH}")
|
2013-03-14 15:19:41 -04:00
|
|
|
|
2023-07-15 08:44:58 +01:00
|
|
|
# Preconfigure files that the InspIRCd build needs.
|
|
|
|
configure_file("${INSPIRCD_BASE}/make/template/config.h" "${INSPIRCD_BASE}/include/config.h")
|
|
|
|
configure_file("${INSPIRCD_BASE}/win/inspircd.rc.cmake" "${INSPIRCD_BASE}/win/inspircd.rc")
|
|
|
|
|
|
|
|
file(GLOB INSPIRCD_HEADERS
|
|
|
|
"${INSPIRCD_BASE}/include/*.h"
|
|
|
|
"${INSPIRCD_BASE}/include/modules/*.h"
|
|
|
|
"${INSPIRCD_BASE}/include/utility/*.h"
|
|
|
|
)
|
|
|
|
list(SORT INSPIRCD_HEADERS)
|
|
|
|
|
|
|
|
file(GLOB INSPIRCD_SOURCES
|
2022-09-03 14:26:31 +01:00
|
|
|
"${INSPIRCD_BASE}/src/*.cpp"
|
|
|
|
"${INSPIRCD_BASE}/src/socketengines/select.cpp"
|
2023-07-15 08:18:05 +01:00
|
|
|
"${INSPIRCD_BASE}/win/win32wrapper.cpp"
|
2022-09-03 14:26:31 +01:00
|
|
|
"${INSPIRCD_BASE}/win/win32service.cpp"
|
2019-05-15 16:22:24 +01:00
|
|
|
)
|
2013-03-14 15:19:41 -04:00
|
|
|
list(SORT INSPIRCD_SOURCES)
|
|
|
|
|
2023-07-15 08:44:58 +01:00
|
|
|
# The main server executable
|
|
|
|
add_executable("inspircd" ${INSPIRCD_HEADERS} ${INSPIRCD_SOURCES} "${INSPIRCD_BASE}/win/inspircd.rc")
|
|
|
|
add_dependencies("inspircd" "win32memory")
|
|
|
|
target_compile_definitions("inspircd" PRIVATE "FMT_LIB_EXPORT" "INSPIRCD_CORE")
|
|
|
|
set_target_properties("inspircd" PROPERTIES "ENABLE_EXPORTS" ON)
|
|
|
|
target_link_libraries("inspircd" "win32memory")
|
|
|
|
install(TARGETS "inspircd" RUNTIME DESTINATION ".")
|
2013-03-14 15:19:41 -04:00
|
|
|
|
2023-07-15 08:44:58 +01:00
|
|
|
# Also build modules
|
|
|
|
add_subdirectory("modules")
|
2013-03-14 15:19:41 -04:00
|
|
|
|
2023-07-15 08:44:58 +01:00
|
|
|
# Package any DLLs from Conan
|
|
|
|
file(GLOB EXTRA_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/*.dll")
|
|
|
|
install(FILES ${EXTRA_DLLS} DESTINATION ".")
|
2013-03-14 15:19:41 -04:00
|
|
|
|
|
|
|
# Install example configs
|
2022-04-24 19:27:35 +01:00
|
|
|
install(DIRECTORY "${INSPIRCD_BASE}/docs/conf/" DESTINATION "${CONFIG_DIR}/examples")
|
|
|
|
install(DIRECTORY "${INSPIRCD_BASE}/docs/sql/" DESTINATION "${CONFIG_DIR}/sql")
|
2013-03-14 15:19:41 -04:00
|
|
|
|
|
|
|
# Create an empty data and logs directory and install them
|
2014-07-22 16:33:07 -04:00
|
|
|
file(MAKE_DIRECTORY ${DATA_DIR})
|
|
|
|
install(DIRECTORY ${DATA_DIR} DESTINATION .)
|
|
|
|
file(MAKE_DIRECTORY ${LOG_DIR})
|
|
|
|
install(DIRECTORY ${LOG_DIR} DESTINATION .)
|
2013-03-14 15:19:41 -04:00
|
|
|
|
|
|
|
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
2023-07-15 08:44:58 +01:00
|
|
|
# Place runtime libraries next to the InspIRCd binary
|
|
|
|
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ".")
|
|
|
|
include("InstallRequiredSystemLibraries")
|
2013-03-14 15:19:41 -04:00
|
|
|
|
2023-07-15 08:44:58 +01:00
|
|
|
set(CPACK_PACKAGE_NAME "InspIRCd -- Internet Relay Chat Daemon")
|
|
|
|
set(CPACK_PACKAGE_VENDOR "InspIRCd Team")
|
2014-07-22 16:33:07 -04:00
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
|
2023-07-15 08:44:58 +01:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "InspIRCd-${VERSION_FULL}")
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${INSPIRCD_BASE}/docs/LICENSE.txt")
|
2013-03-14 15:19:41 -04:00
|
|
|
|
|
|
|
set(CPACK_GENERATOR "NSIS")
|
|
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "InspIRCd")
|
|
|
|
# NSIS has a bug with full nix paths, so this must contain at least one backslash
|
|
|
|
set(CPACK_PACKAGE_ICON "${INSPIRCD_BASE}/win\\\\inspircd.ico")
|
|
|
|
set(CPACK_NSIS_MUI_ICON "${INSPIRCD_BASE}/win\\\\inspircd.ico")
|
|
|
|
set(CPACK_NSIS_MUI_UNIICON "${INSPIRCD_BASE}/win\\\\inspircd.ico")
|
|
|
|
set(CPACK_NSIS_INSTALLED_ICON_NAME "inspircd.exe")
|
2019-03-12 15:37:18 +01:00
|
|
|
set(CPACK_NSIS_URL_INFO_ABOUT "https://www.inspircd.org")
|
2014-04-13 16:08:49 +02:00
|
|
|
set(CPACK_NSIS_COMPRESSOR "/SOLID zlib")
|
2013-03-14 15:19:41 -04:00
|
|
|
|
2023-07-15 08:44:58 +01:00
|
|
|
include("CPack")
|
2022-04-24 20:59:55 +01:00
|
|
|
endif()
|