view CMakeLists.txt @ 34:bee7d274c4dc

Check for polarssl. Add release option to build with other certificates
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 14 Mar 2014 08:58:18 +0100
parents cbd57d767dfa
children 00aa5fa3c2fb
line wrap: on
line source
cmake_minimum_required(VERSION 2.8.8)
project(m13)

option(DO_RELEASE_BUILD "Build for a public release." OFF)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

include(CTest)
include(GenerateCppcheck)

find_package(PolarSSL)

# Use cmake's automoc and make sure the generated files are included
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

if(DO_RELEASE_BUILD)
   if (NOT CMAKE_BUILD_TYPE)
      set (CMAKE_BUILD_TYPE RELEASE)
   endif (NOT CMAKE_BUILD_TYPE)
   add_definitions (RELEASE_BUILD)
else()
# Default to debug build
   if (NOT CMAKE_BUILD_TYPE)
     set (CMAKE_BUILD_TYPE Debug)
   endif (NOT CMAKE_BUILD_TYPE)
endif()

# Warn level to be used for privileged parts
set(WARN_HARDENING_FLAGS " -Wextra -Wconversion -Wformat-security")

# Hardening flags
set(HARDENING_FLAGS " -Wall -Werror -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")

# Uncomment to enable profiling
# set(PROFILING_FLAGS "-fprofile-arcs -ftest-coverage")
# set(PROFILING_LIBS gcov)

SET(CMAKE_EXE_LINKER_FLAGS=${PROFILING_FLAGS})

if(UNIX)
   set(HARDENING_FLAGS " ${HARDENING_FLAGS} -pie -fPIE -ftrapv")
   set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,-z,relro,-z,now")
elseif(WIN32)
   set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HARDENING_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARN_HARDENING_FLAGS} ${HARDENING_FLAGS}")

# FlawFinder
find_program(FLAWFINDER_PATH flawfinder DOC "flawfinder path")
if (FLAWFINDER_PATH)
    add_custom_target(flawfinder COMMENT "FlawFinder" VERBATIM COMMAND ${FLAWFINDER_PATH}
       ${CMAKE_SOURCE_DIR}/ui
       ${CMAKE_SOURCE_DIR}/cinst
       ${CMAKE_SOURCE_DIR}/common
    )
    add_dependencies(static_check flawfinder)
endif (FLAWFINDER_PATH)

add_subdirectory(cinst)
add_subdirectory(ui)

# Documentation
configure_file (doc/Doxyfile.in doc/Doxyfile)
add_subdirectory(doc)

http://wald.intevation.org/projects/trustbridge/