-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
72 lines (54 loc) · 1.76 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
cmake_minimum_required(VERSION 3.15)
project(db_soci_orm_cpp VERSION 0.0.2 LANGUAGES CXX)
option(ENABLE_PCH "Enable Precompiled Headers" False)
option(ENABLE_TESTS "Enable tests" False)
set(SOURCES src/main.cpp)
add_executable(${PROJECT_NAME} ${SOURCES})
## Compiler options
include(cmake/CompilerOptions.cmake)
set_project_options(${PROJECT_NAME})
## Setup Conan
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_check(REQUIRED)
conan_cmake_autodetect(settings)
conan_cmake_run(
CONANFILE conanfile.txt
BASIC_SETUP
NO_OUTPUT_DIRS
BUILD missing
SETTINGS ${settings}
)
## Find third-party packages
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_BINARY_DIR})
find_package(fmt REQUIRED)
find_package(soci REQUIRED)
## Target
target_link_libraries(${PROJECT_NAME}
PRIVATE
fmt::fmt
soci::soci
)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
#target_include_directories(${PROJECT_NAME} PRIVATE include)
## Check custom options
if (ENABLE_PCH) # Since CMake 3.15
target_precompile_headers(${PROJECT_NAME} INTERFACE <vector> <string> <map> <utility>)
message("PCH enabled")
endif ()
if (ENABLE_TESTS)
message(STATUS "Tests enabled")
enable_testing() # Must be placed before add_subdirectory
add_subdirectory(test)
endif ()
## Install commands
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION "/opt/${PROJECT_NAME}"
)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Juan Jose Castellanos <juancho.312@hotmail.com>")
include(CPack)