-
Notifications
You must be signed in to change notification settings - Fork 63
/
CMakeLists.txt
83 lines (66 loc) · 2.23 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
73
74
75
76
77
78
79
80
81
82
83
cmake_minimum_required(VERSION 3.20)
project(crud)
set(CMAKE_CXX_STANDARD 17)
add_library(crud-lib
src/controller/StaticController.hpp
src/controller/UserController.hpp
src/db/UserDb.hpp
src/dto/PageDto.hpp
src/dto/StatusDto.hpp
src/dto/UserDto.hpp
src/service/UserService.cpp
src/service/UserService.hpp
src/AppComponent.hpp
src/DatabaseComponent.hpp
src/SwaggerComponent.hpp
src/ErrorHandler.cpp
src/ErrorHandler.hpp)
## include directories
target_include_directories(crud-lib PUBLIC src)
## link libs
find_package(oatpp 1.4.0 REQUIRED)
find_package(oatpp-swagger 1.4.0 REQUIRED)
find_package(oatpp-sqlite 1.4.0 REQUIRED)
target_link_libraries(crud-lib
# Oat++
PUBLIC oatpp::oatpp
PUBLIC oatpp::oatpp-swagger
PUBLIC oatpp::oatpp-sqlite
)
# If CMake can't find SQLite3:
#
# 1. Make sure that you've built oatpp-sqlite with -DOATPP_SQLITE_AMALGAMATION=ON flag
# 2. If you are not willing to use SQLite amalgamation then uncomment the following lines:
#
#find_package(SQLite3 REQUIRED)
#
#target_link_libraries(crud-lib
# PUBLIC SQLite::SQLite3
#)
add_definitions(
## define path to swagger-ui static resources folder
-DOATPP_SWAGGER_RES_PATH="${oatpp-swagger_INCLUDE_DIRS}/../bin/oatpp-swagger/res"
## SQLite database file
-DDATABASE_FILE="${CMAKE_CURRENT_SOURCE_DIR}/db.sqlite"
## SQLite database test file
-DTESTDATABASE_FILE="${CMAKE_CURRENT_SOURCE_DIR}/test-db.sqlite"
## Path to database migration scripts
-DDATABASE_MIGRATIONS="${CMAKE_CURRENT_SOURCE_DIR}/sql"
)
if(CMAKE_SYSTEM_NAME MATCHES Linux)
find_package(Threads REQUIRED)
target_link_libraries(crud-lib INTERFACE Threads::Threads ${CMAKE_DL_LIBS})
endif()
## add executables
add_executable(crud-exe src/App.cpp)
target_link_libraries(crud-exe crud-lib)
add_executable(crud-test
test/tests.cpp
test/app/TestClient.hpp
test/app/TestDatabaseComponent.hpp
test/app/TestComponent.hpp
test/UserControllerTest.hpp
test/UserControllerTest.cpp)
target_link_libraries(crud-test crud-lib)
enable_testing()
add_test(project-tests crud-test)