More options to CMake, Debug/Release connotation
FossilOrigin-Name: d522f2ca07348fd706ca32d175137b20cd8d244705ec57ae6d8c56e3402d1631
This commit is contained in:
parent
5b93813094
commit
fabd54e26d
1 changed files with 44 additions and 16 deletions
|
@ -1,6 +1,19 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(wormhole)
|
||||
|
||||
# files
|
||||
set(sources src/main.cpp
|
||||
src/database/database.cpp
|
||||
src/database/sqlite/sqlite.cpp
|
||||
src/http/httpserver.cpp
|
||||
src/http/microhttpd_server.cpp
|
||||
src/http/request.cpp
|
||||
src/http/response.cpp
|
||||
src/config/config_loader.cpp
|
||||
src/logger.cpp)
|
||||
|
||||
add_executable(wormhole ${sources})
|
||||
|
||||
# General includes
|
||||
include(CTest)
|
||||
|
||||
|
@ -14,9 +27,37 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||
# C++ settings
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
|
||||
target_compile_options(wormhole PRIVATE -Wall)
|
||||
|
||||
#
|
||||
# Config directories definition
|
||||
# TODO customizing
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message("Warning: Building in Debug mode... This is for development purposes only!\n")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
|
||||
target_compile_options(wormhole PRIVATE -Wall -g)
|
||||
enable_testing()
|
||||
if(NOT DEFINED CONFIG_DIR)
|
||||
message("CONFIG_DIR not set: Setting to empty")
|
||||
set(CONFIG_DIR "" CACHE PATH "Config directory e.g. YAML files")
|
||||
endif()
|
||||
if(NOT DEFINED DATA_DIR)
|
||||
message("DATA_DIR not set: Setting to \"data\"")
|
||||
set(DATA_DIR "data" CACHE PATH "Data directory e.g. SQLite3 database")
|
||||
endif()
|
||||
else()
|
||||
target_compile_options(wormhole PRIVATE -Wall -O2)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
if(NOT DEFINED CONFIG_DIR)
|
||||
message("CONFIG_DIR not set: Setting to \"/etc/wormhole/\"")
|
||||
set(CONFIG_DIR "/etc/wormhole/" CACHE PATH "Config directory e.g. YAML files")
|
||||
endif()
|
||||
if(NOT DEFINED DATA_DIR)
|
||||
message("DATA_DIR not set: Setting to \"/usr/share/wormhole\"")
|
||||
set(DATA_DIR "/usr/share/wormhole" CACHE PATH "Data directory e.g. SQLite3 database")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_definitions(-DCONFIG_DIR=${CONFIG_DIR} -DDATA_DIR=${DATA_DIR})
|
||||
|
||||
include_directories(wormhole
|
||||
${LIBMICROHTTPD_INCLUDE_DIRS}
|
||||
|
@ -25,24 +66,11 @@ include_directories(wormhole
|
|||
src/
|
||||
)
|
||||
|
||||
# files
|
||||
set(sources src/main.cpp
|
||||
src/database/database.cpp
|
||||
src/database/sqlite/sqlite.cpp
|
||||
src/http/httpserver.cpp
|
||||
src/http/microhttpd_server.cpp
|
||||
src/http/request.cpp
|
||||
src/http/response.cpp
|
||||
src/config/config_loader.cpp
|
||||
src/logger.cpp)
|
||||
|
||||
# automated tests
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
# files
|
||||
add_executable(wormhole ${sources})
|
||||
target_link_libraries(wormhole ${CMAKE_DL_LIBS}
|
||||
${LIBMICROHTTPD_LIBRARIES}
|
||||
${YAML_CPP_LIBRARIES}
|
||||
|
|
Loading…
Reference in a new issue