cmake_minimum_required(VERSION 3.5) project(pica VERSION 0.0.1 LANGUAGES CXX ) set(PROJECT_LICENSE "GPL-3.0") cmake_policy(SET CMP0076 NEW) #allow adding sources from subdir cmake_policy(SET CMP0079 NEW) #allow linking from subdirs include(GNUInstallDirs) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") 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}) find_package(nlohmann_json REQUIRED) find_package(FCGI REQUIRED) 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}) add_subdirectory(server) add_subdirectory(request) add_subdirectory(response) add_subdirectory(stream) add_subdirectory(database) add_subdirectory(utils) configure_file(config.h.in config.h @ONLY) target_link_libraries(${PROJECT_NAME} PRIVATE FCGI::FCGI FCGI::FCGI++ nlohmann_json::nlohmann_json ) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})