aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2019-09-08 18:27:12 +0200
committerToni Uhlig <matzeton@googlemail.com>2019-09-08 18:27:25 +0200
commite24eea1b24311a8973a063dd4a2941f52509f40e (patch)
tree5796fe53ea835a535a9e27d41a70d32c87c7e9e9
parentd19fb7b82d874de586a0af4984b28e32624d68ce (diff)
improved CMakeLists.txt
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r--CMakeLists.txt9
1 files changed, 8 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4967c8a..dc82f76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,13 @@
cmake_minimum_required(VERSION 2.8.9)
project(cpp-web)
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release ... FORCE)
+endif()
+
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
-set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fomit-frame-pointer -flto")
+set(CMAKE_CXX_FLAGS_RELEASE "-Os -fno-pic -fomit-frame-pointer -flto -fno-rtti -ffunction-sections -fdata-sections")
set(CPP_HTTPLIB_SRCDIR "${PROJECT_SOURCE_DIR}/deps/cpp-httplib" CACHE STRING "Path to the cpp-httplib source directory.")
if(NOT EXISTS "${CPP_HTTPLIB_SRCDIR}/httplib.h")
@@ -19,4 +23,7 @@ include_directories(${CPP_HTTPLIB_SRCDIR} ${INJA_SRCDIR}/single_include ${INJA_S
file(GLOB SOURCES "src/*.cpp")
add_executable(cpp-web ${SOURCES})
#target_compile_definitions(cpp-web PUBLIC CPPHTTPLIB_THREAD_POOL_COUNT=4)
+if(CMAKE_BUILD_TYPE MATCHES Release)
+ set_target_properties(cpp-web PROPERTIES LINK_FLAGS "-no-pie -flto -Wl,--gc-sections -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none")
+endif()
target_link_libraries(cpp-web pthread)