CMake: Fixed issues with libpqxx for non-cmake based libpqxx install.
This commit is contained in:
parent
42c487006c
commit
590105490a
1 changed files with 6 additions and 26 deletions
|
@ -15,12 +15,10 @@ set(TARGET app)
|
||||||
# CPM Setup
|
# CPM Setup
|
||||||
set(CPM_DOWNLOAD_VERSION 0.38.7)
|
set(CPM_DOWNLOAD_VERSION 0.38.7)
|
||||||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||||
|
|
||||||
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
|
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
|
||||||
message(STATUS "Downloading CPM.cmake")
|
message(STATUS "Downloading CPM.cmake")
|
||||||
file(DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION})
|
file(DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(${CPM_DOWNLOAD_LOCATION})
|
include(${CPM_DOWNLOAD_LOCATION})
|
||||||
|
|
||||||
# Source files
|
# Source files
|
||||||
|
@ -32,6 +30,8 @@ add_executable(${TARGET}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add Dependencies
|
# Add Dependencies
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(LIBPQXX REQUIRED libpqxx)
|
||||||
find_package(Boost 1.64 COMPONENTS system date_time REQUIRED)
|
find_package(Boost 1.64 COMPONENTS system date_time REQUIRED)
|
||||||
|
|
||||||
# Crow CPP
|
# Crow CPP
|
||||||
|
@ -40,24 +40,10 @@ CPMAddPackage(
|
||||||
GITHUB_REPOSITORY CrowCpp/Crow
|
GITHUB_REPOSITORY CrowCpp/Crow
|
||||||
GIT_TAG v1.1.0
|
GIT_TAG v1.1.0
|
||||||
)
|
)
|
||||||
|
|
||||||
if(crowcpp_ADDED)
|
if(crowcpp_ADDED)
|
||||||
target_include_directories(${TARGET} PUBLIC "${crowcpp_SOURCE_DIR}/include")
|
target_include_directories(${TARGET} PUBLIC "${crowcpp_SOURCE_DIR}/include")
|
||||||
endif()
|
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
|
# Copying the ressource folder to the build
|
||||||
add_custom_target(CopyRes ALL
|
add_custom_target(CopyRes ALL
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/res
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/res
|
||||||
|
@ -71,13 +57,7 @@ add_custom_target(CopyRes ALL
|
||||||
add_dependencies(${TARGET} CopyRes)
|
add_dependencies(${TARGET} CopyRes)
|
||||||
|
|
||||||
# Including the include folder
|
# Including the include folder
|
||||||
target_include_directories(${TARGET} PUBLIC "${PROJECT_SOURCE_DIR}/include")
|
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 depending on the platform
|
# Compilation only on Linux
|
||||||
if(MSVC)
|
target_compile_options(${TARGET} PUBLIC -Wall -Wextra -Wpedantic -Werror -Wno-unused-but-set-variable)
|
||||||
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()
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue