diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index b881e43..a2723a4 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -15,12 +15,10 @@ 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 @@ -32,6 +30,8 @@ add_executable(${TARGET} ) # Add Dependencies +find_package(PkgConfig REQUIRED) +pkg_check_modules(LIBPQXX REQUIRED libpqxx) find_package(Boost 1.64 COMPONENTS system date_time REQUIRED) # Crow CPP @@ -40,24 +40,10 @@ CPMAddPackage( GITHUB_REPOSITORY CrowCpp/Crow GIT_TAG v1.1.0 ) - if(crowcpp_ADDED) target_include_directories(${TARGET} PUBLIC "${crowcpp_SOURCE_DIR}/include") endif() -# Lib Pqxx -CPMAddPackage( - NAME libpqxx - GITHUB_REPOSITORY jtv/libpqxx - GIT_TAG 7.9.0 -) - -if(libpqxx_ADDED) - target_include_directories(${TARGET} PUBLIC "${libpqxx_SOURCE_DIR}/include") - target_include_directories(${TARGET} PUBLIC "${libpqxx_BINARY_DIR}/include") - target_link_libraries(${TARGET} PRIVATE pqxx) -endif() - # Copying the ressource folder to the build add_custom_target(CopyRes ALL COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/res @@ -71,13 +57,7 @@ add_custom_target(CopyRes ALL add_dependencies(${TARGET} CopyRes) # Including the include folder -target_include_directories(${TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/include") - -# Compilation depending on the platform -if(MSVC) - target_compile_options(${TARGET} PUBLIC /W3 /WX /DEBUG ) -elseif(${CMAKE_CXX_COMPILER} STREQUAL "/usr/bin/x86_64-w64-mingw32-g++") - target_compile_options(${TARGET} PUBLIC -Wall -Wextra -Wpedantic -Werror -static-libgcc -static-libstdc++) -else() - target_compile_options(${TARGET} PUBLIC -Wall -Wextra -Wpedantic -Werror -Wno-unused-but-set-variable) -endif() +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)