Mercurial > trustbridge
annotate 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 |
rev | line source |
---|---|
0
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 cmake_minimum_required(VERSION 2.8.8) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 project(m13) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
3 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
4 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
5 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
6 # Use cmake's automoc and make sure the generated files are included |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
7 set(CMAKE_AUTOMOC ON) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 set(CMAKE_INCLUDE_CURRENT_DIR ON) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 find_package(Qt5Widgets REQUIRED) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
11 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
12 include_directories(${Qt5Widgets_INCLUDE_DIRS}) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
13 add_definitions(${Qt5Widgets_DEFINITIONS}) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
14 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
15 set(M13UI_SOURCES |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 ui/main.cpp |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
17 ui/mainwindow.cpp |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
18 ) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
19 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
20 set(M13UI_RESOURCES |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
21 ui/icons.qrc |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
22 ) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
23 |
1
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
24 # Warn level to be used for privileged parts |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
25 set(WARN_HARDENING_FLAGS " -Wall -Wextra -Wconversion -Wformat-security") |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
26 |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
27 # Hardening flags |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
28 set(HARDENING_FLAGS " -Werror -fstack-protector-all") |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
29 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wstack-protector") |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
30 set(HARDENING_FLAGS " ${HARDENING_FLAGS} --param ssp-buffer-size=4") |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
31 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -pie -fPIE -ftrapv") |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
32 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -D_FORTIFY_SOURCE=2 -O2") |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
33 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,-z,relro,-z,now") |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
34 |
0
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
35 if(UNIX) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
36 # See: https://bugreports.qt-project.org/browse/QTBUG-35918 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
37 # XCB_EXTRA_LIBS should be gotten automatically. |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
38 # The following list is taken from the .pri file |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
39 get_target_property(_loc Qt5::Widgets LOCATION) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
40 get_filename_component(_qtpath ${_loc} PATH) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
41 set(XCB_EXTRA_LIBS |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
42 -L${_qtpath} |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
43 -lX11 -lX11-xcb -lXi -lxcb-render-util -lXrender -lSM -lICE -lxcb-render -ldbus-1 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
44 -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
45 -lxcb-shape -lxcb-keysyms -lQt5PlatformSupport |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 -lfreetype -lQt5DBus -lQt5Gui -ljpeg -lpng -lQt5Core |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
47 -lz -lm -ldl -lrt -lpthread) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
48 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
49 set(EXTRA_STATIC_LIBS -lz -lpthread -ldl -lpng -ljpeg |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
50 Qt5::QXcbIntegrationPlugin ${XCB_EXTRA_LIBS}) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
51 elseif(WIN32) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
52 get_target_property(_loc Qt5::Widgets LOCATION) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
53 get_filename_component(_qtpath ${_loc} PATH) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
54 set(WINDOWS_EXTRA_LIBS |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
55 -L${_qtpath} |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
56 -lwinspool -lshlwapi -lfreetype -lbz2 -lpng16 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
57 -lQt5PlatformSupport -lQt5Gui -lcomdlg32 -loleaut32 -limm32 -lwinmm |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
58 -lglu32 -lopengl32 -lgdi32 -ljpeg -lpng -lQt5Core -lole32 -luuid -lws2_32 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
59 -ladvapi32 -lshell32 -luser32 -lkernel32 -lz -lsicuin -lsicuuc -lsicudt -lpcre16) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
60 set(EXTRA_STATIC_LIBS Qt5::QWindowsIntegrationPlugin ${WINDOWS_EXTRA_LIBS}) |
1
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
61 |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
62 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,dynamicbase -Wl,nxcompat") |
0
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
63 endif() |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
64 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
65 qt5_add_resources(M13UI_SOURCES ${M13UI_RESOURCES}) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
66 |
1
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
67 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
68 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HARDENING_FLAGS}") |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
69 |
0
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
70 add_executable(m13ui ${M13UI_SOURCES}) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
71 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
72 target_link_libraries(m13ui Qt5::Widgets ${EXTRA_STATIC_LIBS}) |
1
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
73 |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
74 add_custom_target(static_check) |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
75 |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
76 # CPPCheck |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
77 include(GenerateCppcheck) |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
78 generate_cppcheck(SOURCES ${M13UI_SOURCES} "" "" m13ui) |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
79 add_dependencies(static_check cppcheck) |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
80 |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
81 # FlawFinder |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
82 find_program(FLAWFINDER_PATH flawfinder DOC "flawfinder path") |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
83 if (FLAWFINDER_PATH) |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
84 add_custom_target(flawfinder COMMENT "FlawFinder" VERBATIM COMMAND ${FLAWFINDER_PATH} |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
85 ${CMAKE_SOURCE_DIR}/ui |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
86 ) |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
87 add_dependencies(static_check flawfinder) |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
88 endif (FLAWFINDER_PATH) |
524cd4908656
Build infrastructure
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
89 |