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 )
2021-03-23 21:50:51 +01:00
find_package ( Boost REQUIRED COMPONENTS system program_options )
2021-01-07 21:01:47 +01:00
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
2021-02-16 19:07:45 +01:00
$ < $ < C O N F I G : D E B U G > : _ L I B C P P _ D E B U G >
2021-01-23 15:13:08 +01:00
B O O S T _ A S I O _ N O _ D E P R E C A T E D
B O O S T _ A S I O _ N O _ T S _ E X E C U T O R S
#[[_FORTIFY_SOURCE=2]]
)
2021-01-07 21:01:47 +01:00
set ( COMPILE_FLAGS
- p i p e
- m a r c h = s k y l a k e # change to native or your architecture.
- m t u n e = s k y l a k e # same as above
2021-01-23 15:13:08 +01:00
- m r d s e e d # be careful about this, this is linked to the x86 architecture.
- m r d r n d # same as above
- s t d l i b = l i b c + +
- W p e d a n t i c
2021-01-07 21:01:47 +01:00
- W a l l
- W e x t r a
2021-01-23 15:13:08 +01:00
- W m o v e
- W o p e n m p
2021-01-07 21:01:47 +01:00
- f u n r o l l - l o o p s
2021-02-21 11:29:27 +01:00
- f l t o = t h i n
- f w h o l e - p r o g r a m - v t a b l e s
2021-01-07 21:01:47 +01:00
- f n o - b u i l t i n - m a l l o c - f n o - b u i l t i n - c a l l o c - f n o - b u i l t i n - r e a l l o c - f n o - b u i l t i n - f r e e
)
set ( LINKER_OPTIONS
2021-02-21 11:29:27 +01:00
- W l , - - s o r t - c o m m o n , - - a s - n e e d e d
2021-01-23 15:13:08 +01:00
- s t d l i b = l i b c + +
2021-01-07 21:01:47 +01:00
- f l t o = t h i n
- f w h o l e - p r o g r a m - v t a b l e s
- f u s e - l d = g o l d
)
set ( LINKER_FLAGS
j e m a l l o c
2021-01-23 15:13:08 +01:00
$ { B o o s t _ L I B R A R I E S }
O p e n S S L : : S S L
O p e n M P : : O p e n M P _ C X X
2021-01-07 21:01:47 +01:00
)
file ( GLOB HEADERS includes/*.hpp )
set ( FILES
2021-01-23 15:13:08 +01:00
m a i n . c p p
s r c / n e t w o r k . c p p
i n c l u d e / i n f o r m a t i o n . h p p
s r c / c a c h e _ f i l e s . c p p
i n c l u d e / c a c h e _ f i l e s . h p p
2021-01-24 21:05:11 +01:00
s r c / s i m d j s o n . c p p
i n c l u d e / s i m d j s o n . h
2021-02-21 11:29:27 +01:00
i n c l u d e / c o n f i g u r a t i o n . h p p s r c / c o n f i g u r a t i o n . c p p )
# options for spdlog
set ( SPDLOG_ENABLE_PCH ON CACHE BOOL "Build static or shared library using precompiled header to speed up compilation time" )
set ( SPDLOG_BUILD_WARNINGS ON CACHE BOOL "Enable compiler warnings" )
set ( SPDLOG_FMT_EXTERNAL ON CACHE BOOL "Use external fmt library instead of bundled" )
set ( SPDLOG_PREVENT_CHILD_FD ON CACHE BOOL "Prevent from child processes to inherit log file descriptors" )
set ( SPDLOG_NO_THREAD_ID ON CACHE BOOL "prevent spdlog from querying the thread id on each log call if thread id is not needed" )
set ( SPDLOG_NO_TLS ON CACHE BOOL "prevent spdlog from using thread local storage" )
set ( SPDLOG_NO_ATOMIC_LEVELS ON CACHE BOOL "prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently" )
add_subdirectory ( external/spdlog EXCLUDE_FROM_ALL )
target_compile_definitions ( spdlog PRIVATE ${ COMPILE_DEFINITIONS } )
target_compile_options ( spdlog PRIVATE ${ COMPILE_FLAGS } )
target_link_options ( spdlog PRIVATE ${ LINKER_OPTIONS } )
# end
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 } )
2021-02-21 11:29:27 +01:00
target_link_options ( GeminiServer PRIVATE ${ LINKER_OPTIONS } )
target_link_libraries ( GeminiServer ${ LINKER_FLAGS } spdlog )