Mercurial > trustbridge
comparison CMakeLists.txt @ 26:cbd57d767dfa
Move layout around. Restructure CMakeLists
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 11 Mar 2014 19:00:35 +0100 |
parents | 92108a2120f1 |
children | bee7d274c4dc |
comparison
equal
deleted
inserted
replaced
25:92108a2120f1 | 26:cbd57d767dfa |
---|---|
1 cmake_minimum_required(VERSION 2.8.8) | 1 cmake_minimum_required(VERSION 2.8.8) |
2 project(m13) | 2 project(m13) |
3 | 3 |
4 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") | |
5 | |
4 include(CTest) | 6 include(CTest) |
5 | 7 include(GenerateCppcheck) |
6 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") | |
7 | 8 |
8 # Use cmake's automoc and make sure the generated files are included | 9 # Use cmake's automoc and make sure the generated files are included |
9 set(CMAKE_AUTOMOC ON) | 10 set(CMAKE_AUTOMOC ON) |
10 set(CMAKE_INCLUDE_CURRENT_DIR ON) | 11 set(CMAKE_INCLUDE_CURRENT_DIR ON) |
11 | 12 |
12 # Default to debug build | 13 # Default to debug build |
13 if (NOT CMAKE_BUILD_TYPE) | 14 if (NOT CMAKE_BUILD_TYPE) |
14 set (CMAKE_BUILD_TYPE Debug) | 15 set (CMAKE_BUILD_TYPE Debug) |
15 endif (NOT CMAKE_BUILD_TYPE) | 16 endif (NOT CMAKE_BUILD_TYPE) |
16 | 17 |
17 find_package(Qt5Widgets REQUIRED) | |
18 | |
19 include_directories(${Qt5Widgets_INCLUDE_DIRS}) | |
20 add_definitions(${Qt5Widgets_DEFINITIONS}) | |
21 | |
22 set(CERTIFICATELIST_SOURCES | |
23 ${CMAKE_SOURCE_DIR}/ui/certificatelist.cpp | |
24 ${CMAKE_SOURCE_DIR}/ui/certificate.cpp | |
25 ${CMAKE_SOURCE_DIR}/ui/certificate_win.cpp | |
26 ${CMAKE_SOURCE_DIR}/ui/certificate_linux.cpp | |
27 ${CMAKE_SOURCE_DIR}/common/listutil.c | |
28 ) | |
29 | |
30 set(M13UI_SOURCES | |
31 ${CMAKE_SOURCE_DIR}/ui/mainwindow.cpp | |
32 ${CMAKE_SOURCE_DIR}/ui/downloader.cpp | |
33 ${CMAKE_SOURCE_DIR}/ui/downloader_win.cpp | |
34 ${CMAKE_SOURCE_DIR}/ui/downloader_linux.cpp | |
35 ${CMAKE_SOURCE_DIR}/ui/main.cpp | |
36 ${CERTIFICATELIST_SOURCES} | |
37 ) | |
38 | |
39 # Seperated to make it easier to include the sources in tests | |
40 set(M13UI_RESOURCES | |
41 ${CMAKE_SOURCE_DIR}/ui/icons.qrc | |
42 ${CMAKE_SOURCE_DIR}/ui/certs.qrc | |
43 ) | |
44 | |
45 # Warn level to be used for privileged parts | 18 # Warn level to be used for privileged parts |
46 set(WARN_HARDENING_FLAGS " -Wextra -Wconversion -Wformat-security") | 19 set(WARN_HARDENING_FLAGS " -Wextra -Wconversion -Wformat-security") |
47 | 20 |
48 # Hardening flags | 21 # Hardening flags |
49 set(HARDENING_FLAGS " -Wall -Werror -fstack-protector-all -fno-exceptions") | 22 set(HARDENING_FLAGS " -Wall -Werror -fstack-protector-all -fno-exceptions") |
50 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wstack-protector") | 23 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wstack-protector") |
51 set(HARDENING_FLAGS " ${HARDENING_FLAGS} --param ssp-buffer-size=4") | 24 set(HARDENING_FLAGS " ${HARDENING_FLAGS} --param ssp-buffer-size=4") |
52 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -D_FORTIFY_SOURCE=2 -O0 -fprofile-arcs -ftest-coverage") | 25 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -D_FORTIFY_SOURCE=2 -O0") |
53 | 26 |
54 SET(CMAKE_EXE_LINKER_FLAGS="-fprofile-arcs -ftest-coverage") | 27 # Uncomment to enable profiling |
28 # set(PROFILING_FLAGS "-fprofile-arcs -ftest-coverage") | |
29 | |
30 SET(CMAKE_EXE_LINKER_FLAGS=${PROFILING_FLAGS}) | |
55 | 31 |
56 if(UNIX) | 32 if(UNIX) |
57 # See: https://bugreports.qt-project.org/browse/QTBUG-35918 | |
58 # XCB_EXTRA_LIBS should be gotten automatically. | |
59 # The following list is taken from the .pri file | |
60 get_target_property(_loc Qt5::Widgets LOCATION) | |
61 get_filename_component(_qtpath ${_loc} PATH) | |
62 set(XCB_EXTRA_LIBS -static -static-libgcc | |
63 -L${_qtpath} | |
64 -lX11 -lX11-xcb -lXi -lxcb-render-util -lXrender -lSM -lICE -lxcb-render -ldbus-1 | |
65 -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr | |
66 -lxcb-shape -lxcb-keysyms -lQt5PlatformSupport | |
67 -lfreetype -lQt5DBus -lQt5Gui -ljpeg -lpng -lQt5Core | |
68 -lz -lm -ldl -lrt -lpthread) | |
69 | |
70 set(EXTRA_STATIC_LIBS -lz -lpthread -ldl -lpng -ljpeg | |
71 Qt5::QXcbIntegrationPlugin ${XCB_EXTRA_LIBS}) | |
72 | |
73 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -pie -fPIE -ftrapv") | 33 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -pie -fPIE -ftrapv") |
74 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,-z,relro,-z,now") | 34 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,-z,relro,-z,now") |
75 elseif(WIN32) | 35 elseif(WIN32) |
76 get_target_property(_loc Qt5::Widgets LOCATION) | |
77 get_filename_component(_qtpath ${_loc} PATH) | |
78 set(WINDOWS_EXTRA_LIBS | |
79 -L${_qtpath} | |
80 -lwinspool -lshlwapi -lfreetype -lbz2 -lpng16 | |
81 -lQt5PlatformSupport -lQt5Gui -lcomdlg32 -loleaut32 -limm32 -lwinmm | |
82 -lglu32 -lopengl32 -lgdi32 -ljpeg -lpng -lQt5Core -lole32 -luuid -lws2_32 | |
83 -ladvapi32 -lshell32 -luser32 -lkernel32 -lz -lsicuin -lsicuuc -lsicudt -lpcre16) | |
84 | |
85 set(EXTRA_STATIC_LIBS Qt5::QWindowsIntegrationPlugin ${WINDOWS_EXTRA_LIBS} -lwinhttp -lcrypt32) | |
86 | |
87 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat") | 36 set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat") |
88 endif() | 37 endif() |
89 | 38 |
90 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") | |
91 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HARDENING_FLAGS}") | 39 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HARDENING_FLAGS}") |
92 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARN_HARDENING_FLAGS} ${HARDENING_FLAGS}") | 40 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARN_HARDENING_FLAGS} ${HARDENING_FLAGS}") |
93 | |
94 # Adding resources here in an extra variable to enable reuse of | |
95 # M13UI_SOURCES in the test subdirectory. | |
96 set(M13UI_SOURCES_WITH_RESOURCES ${M13UI_SOURCES}) | |
97 qt5_add_resources(M13UI_SOURCES_WITH_RESOURCES ${M13UI_RESOURCES}) | |
98 add_executable(m13ui ${M13UI_SOURCES_WITH_RESOURCES}) | |
99 | |
100 target_link_libraries(m13ui Qt5::Widgets ${EXTRA_STATIC_LIBS} gcov) | |
101 | |
102 add_custom_target(static_check) | |
103 | |
104 # CPPCheck | |
105 include(GenerateCppcheck) | |
106 generate_cppcheck(SOURCES ${CINST_SOURCES} ${M13UI_SOURCES} TARGET_NAME m13) | |
107 add_dependencies(static_check cppcheck) | |
108 | 41 |
109 # FlawFinder | 42 # FlawFinder |
110 find_program(FLAWFINDER_PATH flawfinder DOC "flawfinder path") | 43 find_program(FLAWFINDER_PATH flawfinder DOC "flawfinder path") |
111 if (FLAWFINDER_PATH) | 44 if (FLAWFINDER_PATH) |
112 add_custom_target(flawfinder COMMENT "FlawFinder" VERBATIM COMMAND ${FLAWFINDER_PATH} | 45 add_custom_target(flawfinder COMMENT "FlawFinder" VERBATIM COMMAND ${FLAWFINDER_PATH} |
115 ${CMAKE_SOURCE_DIR}/common | 48 ${CMAKE_SOURCE_DIR}/common |
116 ) | 49 ) |
117 add_dependencies(static_check flawfinder) | 50 add_dependencies(static_check flawfinder) |
118 endif (FLAWFINDER_PATH) | 51 endif (FLAWFINDER_PATH) |
119 | 52 |
120 # Tests | |
121 add_subdirectory(tests) | |
122 add_subdirectory(cinst) | 53 add_subdirectory(cinst) |
54 add_subdirectory(ui) | |
123 | 55 |
124 # Documentation | 56 # Documentation |
125 configure_file (doc/Doxyfile.in doc/Doxyfile) | 57 configure_file (doc/Doxyfile.in doc/Doxyfile) |
126 add_subdirectory(doc) | 58 add_subdirectory(doc) |