# Project Setup cmake_minimum_required(VERSION 3.21) project( projet VERSION 0.0.1 DESCRIPTION "api for etheryo blog" HOMEPAGE_URL "https://www.etheryo.fr/" LANGUAGES CXX C ) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(TARGET app) # CPM Setup set(CPM_DOWNLOAD_VERSION 0.38.7) set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) message(STATUS "Downloading CPM.cmake") file(DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION}) endif() include(${CPM_DOWNLOAD_LOCATION}) # Source files set(SOURCES "${PROJECT_SOURCE_DIR}/src") add_executable(${TARGET} ${SOURCES}/dotenv.cpp ${SOURCES}/json.cpp ${SOURCES}/main.cpp ) # Add Dependencies find_package(PkgConfig REQUIRED) pkg_check_modules(LIBPQXX REQUIRED libpqxx) find_package(Boost 1.64 COMPONENTS system date_time REQUIRED) # Crow CPP CPMAddPackage( NAME crowcpp GITHUB_REPOSITORY CrowCpp/Crow GIT_TAG v1.1.0 ) if(crowcpp_ADDED) target_include_directories(${TARGET} PUBLIC "${crowcpp_SOURCE_DIR}/include") endif() # Copying the ressource folder to the build add_custom_target(CopyRes ALL COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/res COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/res COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/res ${CMAKE_BINARY_DIR}/res COMMENT "Copying and deleting resources to build directory" VERBATIM ) add_dependencies(${TARGET} CopyRes) # Including the include folder target_include_directories(${TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/include" ${LIBPQXX_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) target_link_libraries(${TARGET} ${LIBPQXX_LIBRARIES} Boost::system Boost::date_time) # Compilation only on Linux target_compile_options(${TARGET} PUBLIC -Wall -Wextra -Wpedantic -Werror -Wno-unused-but-set-variable)