pica/CMakeLists.txt

75 lines
2.2 KiB
CMake
Raw Normal View History

2023-12-30 22:42:11 +00:00
#SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
#SPDX-License-Identifier: GPL-3.0-or-later
2023-11-21 22:19:08 +00:00
cmake_minimum_required(VERSION 3.5)
project(pica
VERSION 0.0.1
LANGUAGES CXX
)
set(PROJECT_LICENSE "GPL-3.0")
2023-11-21 14:24:12 +00:00
2023-12-07 20:32:43 +00:00
cmake_policy(SET CMP0076 NEW) #allow adding sources from subdir
cmake_policy(SET CMP0079 NEW) #allow linking from subdirs
2023-11-21 22:19:08 +00:00
include(GNUInstallDirs)
2023-11-21 22:19:08 +00:00
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
2023-12-11 23:29:55 +00:00
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
message("Build type: ${CMAKE_BUILD_TYPE}")
set(COMPILE_OPTIONS -fno-sized-deallocation)
if (CMAKE_BUILD_TYPE STREQUAL Release)
list(APPEND COMPILE_OPTIONS -O3)
elseif (CMAKE_BUILD_TYPE STREQUAL Debug)
list(APPEND COMPILE_OPTIONS -g)
list(APPEND COMPILE_OPTIONS -Wall)
list(APPEND COMPILE_OPTIONS -Wextra)
endif()
set(COMPILE_OPTIONS_STRING "")
foreach(element IN LISTS COMPILE_OPTIONS)
if(NOT COMPILE_OPTIONS_STRING STREQUAL "")
set(COMPILE_OPTIONS_STRING "${COMPILE_OPTIONS_STRING} ")
endif()
set(COMPILE_OPTIONS_STRING "${COMPILE_OPTIONS_STRING}${element}")
endforeach()
message("Compile options: " ${COMPILE_OPTIONS_STRING})
2023-11-21 22:19:08 +00:00
2023-11-23 19:57:32 +00:00
find_package(nlohmann_json REQUIRED)
find_package(FCGI REQUIRED)
2023-12-20 22:42:13 +00:00
find_package(Argon2 REQUIRED)
2023-12-29 17:40:00 +00:00
find_package(Threads REQUIRED)
2023-11-21 14:24:12 +00:00
2023-12-11 23:29:55 +00:00
add_executable(${PROJECT_NAME} main.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_compile_options(${PROJECT_NAME} PRIVATE ${COMPILE_OPTIONS})
2023-11-21 22:19:08 +00:00
add_subdirectory(server)
2023-12-13 20:33:11 +00:00
add_subdirectory(handler)
2023-11-21 22:19:08 +00:00
add_subdirectory(request)
add_subdirectory(response)
add_subdirectory(stream)
2023-12-07 20:32:43 +00:00
add_subdirectory(database)
add_subdirectory(utils)
2023-12-30 22:42:11 +00:00
add_subdirectory(taskmanager)
configure_file(config.h.in config.h @ONLY)
2023-12-28 20:26:08 +00:00
configure_file(run.sh.in run.sh @ONLY)
execute_process(COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/run.sh)
2023-11-21 22:19:08 +00:00
2023-12-11 23:29:55 +00:00
target_link_libraries(${PROJECT_NAME} PRIVATE
FCGI::FCGI
FCGI::FCGI++
2023-11-23 19:57:32 +00:00
nlohmann_json::nlohmann_json
2023-12-20 22:42:13 +00:00
Argon2::Argon2
2023-12-29 17:40:00 +00:00
Threads::Threads
2023-11-21 22:19:08 +00:00
)
2023-11-21 14:24:12 +00:00
2023-12-11 23:29:55 +00:00
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})