view CMakeLists.txt @ 381:73bfc9cc22e7

Improved NSIS installer MUI script. Added sample images and icons.
author Emanuel Schuetze <emanuel@intevation.de>
date Tue, 15 Apr 2014 14:15:21 +0200
parents d10d9bc2e84f
children 35d6b371ba63
line wrap: on
line source
cmake_minimum_required(VERSION 2.8.8)
project(m13)

option(DO_RELEASE_BUILD "Build for a public release." OFF)
option(ENABLE_PROFILING "Set to enable profiling." OFF)

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

#Old qtmain linking behavior to be compatible with cmake versions < 2.8.11

if(POLICY CMP0020)
  cmake_policy(SET CMP0020 OLD)
endif()

include(CTest)
include(GenerateCppcheck)

find_package(PolarSSL)
include_directories(${POLARSSL_INCLUDE_DIR})

find_package(Qt5Widgets)

find_package(NSS)

# 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 (-DRELEASE_BUILD)
else()
# Default to debug build
   if (NOT CMAKE_BUILD_TYPE)
     set (CMAKE_BUILD_TYPE Debug)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
   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")

if(ENABLE_PROFILING)
   set(PROFILING_FLAGS "-fprofile-arcs -ftest-coverage")
   set(PROFILING_LIBS gcov)
endif()

if(WIN32)
   add_definitions(-D_WIN32_WINNT=0x0600) # Windows vista
   add_definitions(-DWINVER=0x0600)
   add_definitions(-DMINGW_HAS_SECURE_API) # for _s functions
endif(WIN32)

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} ${PROFILING_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARN_HARDENING_FLAGS} ${HARDENING_FLAGS} ${PROFILING_FLAGS}")

add_custom_target(static_check)

# 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)
if(Qt5Widgets_FOUND)
    add_subdirectory(ui)
else()
   message(STATUS "WARNING: Could not find qt. GUI parts will not be built.")
endif()

add_subdirectory(common)

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

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