1 # Spacenav Demo Qt |
1 # Spacenav lib hack |
2 # Copyright © 2018 František Kučera (Frantovo.cz, GlobalCode.info) |
2 # Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info) |
3 # |
3 # |
4 # This program is free software: you can redistribute it and/or modify |
4 # This program is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License as published by |
5 # it under the terms of the GNU General Public License as published by |
6 # the Free Software Foundation, either version 3 of the License, or |
6 # the Free Software Foundation, either version 3 of the License, or |
7 # (at your option) any later version. |
7 # (at your option) any later version. |
12 # GNU General Public License for more details. |
12 # GNU General Public License for more details. |
13 # |
13 # |
14 # You should have received a copy of the GNU General Public License |
14 # You should have received a copy of the GNU General Public License |
15 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 |
16 |
17 set(EXECUTABLE_FILE "spacenav-demo-qt") |
17 set(LIBRARY_FILE spnav-lib-hack) |
18 |
|
19 # Qt libraries: |
|
20 set(CMAKE_INCLUDE_CURRENT_DIR ON) # Find includes in corresponding build directories |
|
21 set(CMAKE_AUTOMOC ON) # Instruct CMake to run moc automatically when needed |
|
22 set(CMAKE_AUTOUIC ON) # Create code from a list of Qt designer ui files |
|
23 find_package(Qt5Widgets CONFIG REQUIRED) # Find the QtWidgets library |
|
24 # find_package(Qt5Charts CONFIG REQUIRED) |
|
25 |
18 |
26 # Add ASan AddressSanitizer |
19 # Add ASan AddressSanitizer |
27 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") |
20 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") |
28 set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") |
21 set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") |
29 # From ASan wiki: "To get nicer stack traces in error messages add -fno-omit-frame-pointer." |
22 # From ASan wiki: "To get nicer stack traces in error messages add -fno-omit-frame-pointer." |
30 |
23 |
31 # Executable output: |
24 # Executable output: |
32 add_executable( |
25 add_library( |
33 ${EXECUTABLE_FILE} |
26 ${LIBRARY_FILE} SHARED |
34 # QObjects must be listed here (including them from other files is not enough) |
27 spacenav-lib-hack.h |
35 spacenav-demo-qt.cpp |
28 spacenav-lib-hack.c |
36 ) |
29 ) |
37 |
30 |
38 # Link libraries: |
31 # Link libraries: |
39 target_link_libraries(${EXECUTABLE_FILE} -lX11 -lm -lspnav) |
32 target_link_libraries(${LIBRARY_FILE} -ldl -lX11 -lm -lspnav) |
40 target_link_libraries(${EXECUTABLE_FILE} Qt5::Widgets) |
|
41 # target_link_libraries(${EXECUTABLE_FILE} Qt5::Charts) |
|
42 set_property(TARGET ${EXECUTABLE_FILE} PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE) |
|
43 |
33 |
44 install(TARGETS ${EXECUTABLE_FILE} DESTINATION bin) |
|
45 |
|
46 # Print all variables: |
|
47 #macro(print_all_variables) |
|
48 # message(STATUS "print_all_variables------------------------------------------{") |
|
49 # get_cmake_property(_variableNames VARIABLES) |
|
50 # foreach (_variableName ${_variableNames}) |
|
51 # message(STATUS "${_variableName}=${${_variableName}}") |
|
52 # endforeach() |
|
53 # message(STATUS "print_all_variables------------------------------------------}") |
|
54 #endmacro() |
|
55 # |
|
56 #print_all_variables() |
|