2021-01-07 21:01:47 +01:00
|
|
|
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
|
|
|
|
project(GeminiServer CXX)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
|
|
|
|
|
|
|
|
find_package(Boost REQUIRED COMPONENTS system)
|
|
|
|
find_package(OpenSSL REQUIRED)
|
2021-01-23 15:13:08 +01:00
|
|
|
find_package(OpenMP REQUIRED)
|
2021-01-07 21:01:47 +01:00
|
|
|
include_directories(${Boost_INCLUDE_DIR} ${OpenSSL_INCLUDE_DIR})
|
|
|
|
|
2021-01-23 15:13:08 +01:00
|
|
|
set(COMPILE_DEFINITIONS
|
|
|
|
$<$<CONFIG:DEBUG>:_GLIBCXX_DEBUG>
|
|
|
|
BOOST_ASIO_NO_DEPRECATED
|
|
|
|
BOOST_ASIO_NO_TS_EXECUTORS
|
|
|
|
#[[_FORTIFY_SOURCE=2]]
|
|
|
|
)
|
|
|
|
|
2021-01-07 21:01:47 +01:00
|
|
|
set(COMPILE_FLAGS
|
|
|
|
-pipe
|
|
|
|
-march=skylake # change to native or your architecture.
|
|
|
|
-mtune=skylake # same as above
|
2021-01-23 15:13:08 +01:00
|
|
|
-mrdseed # be careful about this, this is linked to the x86 architecture.
|
|
|
|
-mrdrnd # same as above
|
|
|
|
-stdlib=libc++
|
|
|
|
-Wpedantic
|
2021-01-07 21:01:47 +01:00
|
|
|
-Wall
|
|
|
|
-Wextra
|
2021-01-23 15:13:08 +01:00
|
|
|
-Wmove
|
|
|
|
-Wopenmp
|
2021-01-07 21:01:47 +01:00
|
|
|
-funroll-loops
|
|
|
|
-flto=thin -fwhole-program-vtables
|
|
|
|
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
|
|
|
|
)
|
|
|
|
set(LINKER_OPTIONS
|
|
|
|
PRIVATE -Wl,--sort-common,--as-needed
|
2021-01-23 15:13:08 +01:00
|
|
|
-stdlib=libc++
|
2021-01-07 21:01:47 +01:00
|
|
|
-flto=thin
|
|
|
|
-fwhole-program-vtables
|
|
|
|
-fuse-ld=gold
|
|
|
|
)
|
|
|
|
|
|
|
|
set(LINKER_FLAGS
|
|
|
|
jemalloc
|
2021-01-23 15:13:08 +01:00
|
|
|
${Boost_LIBRARIES}
|
|
|
|
OpenSSL::SSL
|
|
|
|
OpenMP::OpenMP_CXX
|
2021-01-07 21:01:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
file(GLOB HEADERS includes/*.hpp)
|
|
|
|
|
|
|
|
set(FILES
|
2021-01-23 15:13:08 +01:00
|
|
|
main.cpp
|
|
|
|
src/network.cpp
|
|
|
|
include/information.hpp
|
|
|
|
src/cache_files.cpp
|
|
|
|
include/cache_files.hpp
|
|
|
|
)
|
2021-01-07 21:01:47 +01:00
|
|
|
|
|
|
|
add_executable(GeminiServer ${FILES})
|
|
|
|
target_precompile_headers(GeminiServer PRIVATE ${HEADERS})
|
2021-01-23 15:13:08 +01:00
|
|
|
target_compile_definitions(GeminiServer PRIVATE ${COMPILE_DEFINITIONS})
|
2021-01-07 21:01:47 +01:00
|
|
|
target_compile_options(GeminiServer PRIVATE ${COMPILE_FLAGS})
|
|
|
|
target_link_options(GeminiServer ${LINKER_OPTIONS})
|
2021-01-23 15:13:08 +01:00
|
|
|
target_link_libraries(GeminiServer ${LINKER_FLAGS})
|