-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
59 lines (46 loc) · 2.49 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
# Minimum cmake version
cmake_minimum_required(VERSION 3.10)
# Project name
project(Efs VERSION 1.0 LANGUAGES CXX)
# Setting contants
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") # This line needed to generate the comopile_commands.json for lower cmake versions
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
# --------------------------------------------------------------------------------
# Locate files (change as needed).
# --------------------------------------------------------------------------------
file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
# Add external subdir
add_subdirectory(external)
# Find packages
set(OPENSSL_USE_STATIC_LIBS TRUE)
find_package(OpenSSL REQUIRED)
# Default name for the library built from src/*.cpp (change if you wish)
set(LIBRARY_NAME Efs)
# --------------------------------------------------------------------------------
# Build! (Change as needed)
# --------------------------------------------------------------------------------
# Compile all sources into a library.
add_library(${LIBRARY_NAME} ${headers} ${sources})
# Add submodules from external folder
set(EXTERNAL_LIB_HEADERS
external/nlohmann_json/single_include
)
target_include_directories(${LIBRARY_NAME} PRIVATE ${EXTERNAL_LIB_HEADERS})
# Lib needs its header files, and users of the library must also see these (PUBLIC). (No change needed)
target_include_directories(${LIBRARY_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include)
# Add an executable for the file app/main.cpp.
# If you add more executables, copy these lines accordingly.
add_executable(fileserver app/main.cpp) # Name of exec. and location of file.
target_link_libraries(fileserver PRIVATE OpenSSL::SSL) # Link executable with OPENSSL
target_link_libraries(fileserver PRIVATE nlohmann_json::nlohmann_json) # Link with nlohmann:json
target_link_libraries(fileserver PRIVATE ${LIBRARY_NAME} -static-libgcc -static-libstdc++ -lrt -pthread) # Link the executable to library (if it uses it).
# Set the properties you require, e.g. what C++ standard to use. Here applied to library and main (change as needed).
set_target_properties(
${LIBRARY_NAME} fileserver
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)