-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
61 lines (47 loc) · 1.44 KB
/
CMakeLists.txt
File metadata and controls
61 lines (47 loc) · 1.44 KB
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
cmake_minimum_required(VERSION 3.10)
# Project name and language
project(MyApp LANGUAGES CXX)
# Path to PostgreSQL (use forward slashes)
set(POSTGRESQL_INCLUDE_DIR "C:/Program Files/PostgreSQL/17/include")
set(POSTGRESQL_LIB "C:/Program Files/PostgreSQL/17/lib/libpq.lib")
include(FetchContent)
FetchContent_Declare(
httplib
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
GIT_TAG master # or pick a release tag
)
FetchContent_MakeAvailable(httplib)
#ftxiu
# Sources
set(SOURCES
./src/Server.cpp
./src/windows_server.cpp
./src/config.cpp
./src/client_auth.cpp
./src/db_manager.cpp
./src/unix_server.cpp
./src/db_pool.cpp
)
# Create executable from main.cpp
add_executable(MyApp ${SOURCES})
# Include PostgreSQL headers
target_include_directories(MyApp PRIVATE ${POSTGRESQL_INCLUDE_DIR})
target_include_directories(MyApp PRIVATE ${CMAKE_SOURCE_DIR}/include)
# Link PostgreSQL library
target_link_libraries(MyApp PRIVATE ${POSTGRESQL_LIB})
target_link_libraries(MyApp PRIVATE httplib::httplib)
# Set C++ standard
set_target_properties(MyApp PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
# === nlohmann-json via FetchContent ===
include(FetchContent)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
)
FetchContent_MakeAvailable(nlohmann_json)
target_link_libraries(MyApp PRIVATE nlohmann_json::nlohmann_json)