-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
73 lines (60 loc) · 1.89 KB
/
CMakeLists.txt
File metadata and controls
73 lines (60 loc) · 1.89 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
62
63
64
65
66
67
68
69
70
71
72
73
cmake_minimum_required(VERSION 3.20)
project(rconcli
VERSION 0.1.0
LANGUAGES CXX
DESCRIPTION "RCON CLI tool for Source game servers"
)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Generate compile_commands.json for clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Build type defaults to Debug if not specified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
# Output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Source directories
set(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
find_package(Threads REQUIRED)
# Dependencies via FetchContent
include(FetchContent)
FetchContent_Declare(cli11
GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git
GIT_TAG v2.4.1
)
FetchContent_MakeAvailable(cli11)
set(SPDLOG_USE_STD_FORMAT ON CACHE BOOL "" FORCE)
FetchContent_Declare(spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.14.1
)
FetchContent_MakeAvailable(spdlog)
FetchContent_Declare(tomlpp
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
GIT_TAG v3.4.0
)
FetchContent_MakeAvailable(tomlpp)
set(BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
FetchContent_Declare(rconpp
GIT_REPOSITORY https://github.com/Jaskowicz1/rconpp.git
GIT_TAG main
)
FetchContent_MakeAvailable(rconpp)
add_subdirectory(${SRC_DIR})
# Symlink compile_commands.json to project root so CLion/clangd can find it
# (dependencies are in build/_deps; IDE needs the compilation database)
if(CMAKE_EXPORT_COMPILE_COMMANDS)
execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_SOURCE_DIR}/compile_commands.json
OUTPUT_QUIET
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif()