Mercurial > trustbridge
diff CMakeLists.txt @ 1264:3cd8dd706aaa
Add possibility to build with CLANG and document it.
This only works for now with the c parts of the code.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 26 Sep 2014 17:59:49 +0200 |
parents | 60927efa48cc |
children | a548dd9a5dbe |
line wrap: on
line diff
--- a/CMakeLists.txt Fri Sep 26 16:06:44 2014 +0200 +++ b/CMakeLists.txt Fri Sep 26 17:59:49 2014 +0200 @@ -11,6 +11,7 @@ option(DO_RELEASE_BUILD "Build for a public release." OFF) option(ENABLE_PROFILING "Set to enable profiling." OFF) option(USE_CURL "Use libcurl to download updates and certificate lists." ON) +option(USE_CLANG "Use clang to compile trustbridge." OFF) set(DOWNLOAD_SERVER "https://tb-devel.intevation.de:443" CACHE STRING "Used as download server" ) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") @@ -21,6 +22,10 @@ cmake_policy(SET CMP0020 OLD) endif() +if (USE_CLANG) + message (STATUS "Using clang options to build trustbridge.") +endif() + include(CTest) include(GenerateCppcheck) include(HGVersion) @@ -82,14 +87,16 @@ add_definitions (-DUSE_REAL_RESOURCES) endif() +if (NOT USE_CLANG) # Warn level to be used for privileged parts -set(WARN_HARDENING_FLAGS " -Wextra -Wconversion -Wformat-security") + set(WARN_HARDENING_FLAGS " -Wextra -Wconversion -Wformat-security") # Hardening flags -set(HARDENING_FLAGS " -Wall -fstack-protector-all -fno-exceptions") -set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wstack-protector") -set(HARDENING_FLAGS " ${HARDENING_FLAGS} --param ssp-buffer-size=4") -set(HARDENING_FLAGS " ${HARDENING_FLAGS} -D_FORTIFY_SOURCE=2 -O0") + set(HARDENING_FLAGS " -Wall -fstack-protector-all -fno-exceptions") + set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wstack-protector") + set(HARDENING_FLAGS " ${HARDENING_FLAGS} --param ssp-buffer-size=4") + set(HARDENING_FLAGS " ${HARDENING_FLAGS} -D_FORTIFY_SOURCE=2 -O0") +endif() if(ENABLE_PROFILING) set(PROFILING_FLAGS "-fprofile-arcs -ftest-coverage") @@ -102,10 +109,10 @@ add_definitions(-DMINGW_HAS_SECURE_API) # for _s functions endif(WIN32) -if(UNIX) +if(UNIX AND NOT USE_CLANG) set(HARDENING_FLAGS " ${HARDENING_FLAGS} -pie -fPIE -ftrapv") set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,-z,relro,-z,now") -elseif(WIN32) +elseif(WIN32 AND NOT USE_CLANG) set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat") endif()