Mercurial > trustbridge
comparison CMakeLists.txt @ 1:524cd4908656
Build infrastructure
Add hardening flags
Add static_check target for flawfinder and cppcheck
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 10 Feb 2014 16:14:55 +0000 |
parents | cb0cde2c5eb9 |
children | 9849250f50f2 |
comparison
equal
deleted
inserted
replaced
0:cb0cde2c5eb9 | 1:524cd4908656 |
---|---|
9 | 9 |
10 find_package(Qt5Widgets REQUIRED) | 10 find_package(Qt5Widgets REQUIRED) |
11 | 11 |
12 include_directories(${Qt5Widgets_INCLUDE_DIRS}) | 12 include_directories(${Qt5Widgets_INCLUDE_DIRS}) |
13 add_definitions(${Qt5Widgets_DEFINITIONS}) | 13 add_definitions(${Qt5Widgets_DEFINITIONS}) |
14 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") | |
15 | 14 |
16 set(M13UI_SOURCES | 15 set(M13UI_SOURCES |
17 ui/main.cpp | 16 ui/main.cpp |
18 ui/mainwindow.cpp | 17 ui/mainwindow.cpp |
19 ) | 18 ) |
20 | 19 |
21 set(M13UI_RESOURCES | 20 set(M13UI_RESOURCES |
22 ui/icons.qrc | 21 ui/icons.qrc |
23 ) | 22 ) |
23 | |
24 # Warn level to be used for privileged parts | |
25 set(WARN_HARDENING_FLAGS " -Wall -Wextra -Wconversion -Wformat-security") | |
26 | |
27 # Hardening flags | |
28 set(HARDENING_FLAGS " -Werror -fstack-protector-all") | |
29 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wstack-protector") | |
30 set(HARDENING_FLAGS " ${HARDENING_FLAGS} --param ssp-buffer-size=4") | |
31 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -pie -fPIE -ftrapv") | |
32 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -D_FORTIFY_SOURCE=2 -O2") | |
33 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,-z,relro,-z,now") | |
24 | 34 |
25 if(UNIX) | 35 if(UNIX) |
26 # See: https://bugreports.qt-project.org/browse/QTBUG-35918 | 36 # See: https://bugreports.qt-project.org/browse/QTBUG-35918 |
27 # XCB_EXTRA_LIBS should be gotten automatically. | 37 # XCB_EXTRA_LIBS should be gotten automatically. |
28 # The following list is taken from the .pri file | 38 # The following list is taken from the .pri file |
46 -lwinspool -lshlwapi -lfreetype -lbz2 -lpng16 | 56 -lwinspool -lshlwapi -lfreetype -lbz2 -lpng16 |
47 -lQt5PlatformSupport -lQt5Gui -lcomdlg32 -loleaut32 -limm32 -lwinmm | 57 -lQt5PlatformSupport -lQt5Gui -lcomdlg32 -loleaut32 -limm32 -lwinmm |
48 -lglu32 -lopengl32 -lgdi32 -ljpeg -lpng -lQt5Core -lole32 -luuid -lws2_32 | 58 -lglu32 -lopengl32 -lgdi32 -ljpeg -lpng -lQt5Core -lole32 -luuid -lws2_32 |
49 -ladvapi32 -lshell32 -luser32 -lkernel32 -lz -lsicuin -lsicuuc -lsicudt -lpcre16) | 59 -ladvapi32 -lshell32 -luser32 -lkernel32 -lz -lsicuin -lsicuuc -lsicudt -lpcre16) |
50 set(EXTRA_STATIC_LIBS Qt5::QWindowsIntegrationPlugin ${WINDOWS_EXTRA_LIBS}) | 60 set(EXTRA_STATIC_LIBS Qt5::QWindowsIntegrationPlugin ${WINDOWS_EXTRA_LIBS}) |
61 | |
62 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,dynamicbase -Wl,nxcompat") | |
51 endif() | 63 endif() |
52 | 64 |
53 qt5_add_resources(M13UI_SOURCES ${M13UI_RESOURCES}) | 65 qt5_add_resources(M13UI_SOURCES ${M13UI_RESOURCES}) |
54 | 66 |
67 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") | |
68 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HARDENING_FLAGS}") | |
69 | |
55 add_executable(m13ui ${M13UI_SOURCES}) | 70 add_executable(m13ui ${M13UI_SOURCES}) |
56 | 71 |
57 target_link_libraries(m13ui Qt5::Widgets ${EXTRA_STATIC_LIBS}) | 72 target_link_libraries(m13ui Qt5::Widgets ${EXTRA_STATIC_LIBS}) |
73 | |
74 add_custom_target(static_check) | |
75 | |
76 # CPPCheck | |
77 include(GenerateCppcheck) | |
78 generate_cppcheck(SOURCES ${M13UI_SOURCES} "" "" m13ui) | |
79 add_dependencies(static_check cppcheck) | |
80 | |
81 # FlawFinder | |
82 find_program(FLAWFINDER_PATH flawfinder DOC "flawfinder path") | |
83 if (FLAWFINDER_PATH) | |
84 add_custom_target(flawfinder COMMENT "FlawFinder" VERBATIM COMMAND ${FLAWFINDER_PATH} | |
85 ${CMAKE_SOURCE_DIR}/ui | |
86 ) | |
87 add_dependencies(static_check flawfinder) | |
88 endif (FLAWFINDER_PATH) | |
89 |