summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-14 13:57:10 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-14 13:57:10 +0100
commit1dd5531694205465a43232b1fa9aa3fa60b4982a (patch)
tree35a91f98ea5a41bbf0309a026c91c3816c69278c /CMakeLists.txt
parent99a6e4a1e3065292214cc7f95d3b987932418b8d (diff)
downloadrspamd-1dd5531694205465a43232b1fa9aa3fa60b4982a.tar.gz
rspamd-1dd5531694205465a43232b1fa9aa3fa60b4982a.zip
[Fix] Further fixes for lto and static linking
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt23
1 files changed, 18 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d126659d..b3df8a7bb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -649,7 +649,7 @@ ProcessPackage(GLIB2 LIBRARY glib-2.0 INCLUDE glib.h
ROOT ${GLIB_ROOT_DIR} MODULES glib-2.0>=2.28)
ProcessPackage(GMODULE2 LIBRARY gmodule-2.0 INCLUDE glib.h
INCLUDE_SUFFIXES include/glib
- ROOT ${GLIB_ROOT_DIR} MODULES gmodule-2.0>=2.28)
+ ROOT ${GLIB_ROOT_DIR} MODULES gmodule-no-export-2.0>=2.28 gmodule-2.0>=2.28)
IF(ENABLE_PCRE2 MATCHES "ON")
ProcessPackage(PCRE LIBRARY pcre2 INCLUDE pcre2.h INCLUDE_SUFFIXES include/pcre2
@@ -793,13 +793,26 @@ ENDIF(SUPPORT_FPIC)
# Optimization flags
IF(NOT CMAKE_C_OPT_FLAGS)
IF(ENABLE_OPTIMIZATION MATCHES "ON")
- CHECK_C_COMPILER_FLAG(-flto SUPPORT_FLTO)
- IF(SUPPORT_FLTO)
+ CHECK_C_COMPILER_FLAG(-flto SUPPORT_FLTO)
+ IF(SUPPORT_FLTO)
+ IF(NOT CMAKE_GCC_AR OR NOT CMAKE_GCC_RANLIB)
+ FIND_PROGRAM(CMAKE_GCC_AR NAMES "gcc-ar")
+ FIND_PROGRAM(CMAKE_GCC_AR NAMES "gcc-ranlib")
+ MARK_AS_ADVANCED(CMAKE_GCC_AR CMAKE_GCC_RANLIB)
+ ENDIF()
+ IF(CMAKE_GCC_AR AND CMAKE_GCC_RANLIB)
SET(CMAKE_C_OPT_FLAGS "-O3 -fstrict-aliasing -flto")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
- ELSE()
- SET(CMAKE_C_OPT_FLAGS "-O3 -fstrict-aliasing")
+ SET(CMAKE_C_ARCHIVE_CREATE "${CMAKE_GCC_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ SET(CMAKE_C_ARCHIVE_APPEND_IPO "${CMAKE_GCC_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>")
+ SET(CMAKE_C_ARCHIVE_FINISH_IPO "${CMAKE_GCC_RANLIB} <TARGET>")
+ SET(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_GCC_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ SET(CMAKE_CXX_ARCHIVE_APPEND_IPO "${CMAKE_GCC_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>")
+ SET(CMAKE_CXX_ARCHIVE_FINISH_IPO "${CMAKE_GCC_RANLIB} <TARGET>")
ENDIF()
+ ELSE()
+ SET(CMAKE_C_OPT_FLAGS "-O3 -fstrict-aliasing")
+ ENDIF()
ELSE(ENABLE_OPTIMIZATION MATCHES "ON")
IF(DEBUG_MODE MATCHES "ON")
SET(CMAKE_C_OPT_FLAGS "-g -O0 -fstrict-aliasing")