author | František Kučera <franta-hg@frantovo.cz> |
Thu, 29 Aug 2019 19:21:45 +0200 | |
branch | v_0 |
changeset 13 | 52d92c1b340e |
parent 12 | cf77c218b0b1 |
permissions | -rw-r--r-- |
0
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
set(EXECUTABLE_FILE "cadMousePro") |
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
|
12 | 3 |
# Qt libraries: |
4 |
set(CMAKE_INCLUDE_CURRENT_DIR ON) # Find includes in corresponding build directories |
|
5 |
set(CMAKE_AUTOMOC ON) # Instruct CMake to run moc automatically when needed |
|
6 |
set(CMAKE_AUTOUIC ON) # Create code from a list of Qt designer ui files |
|
7 |
find_package(Qt5 CONFIG REQUIRED Core DBus) |
|
8 |
||
13
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
9 |
# USB libraries: |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
10 |
INCLUDE(FindPkgConfig) |
0
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
pkg_check_modules (USB_LIBS hidapi-hidraw) |
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
include_directories(${USB_LIBS_INCLUDE_DIRS}) |
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
link_directories(${USB_LIBS_LIBRARY_DIRS}) |
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
|
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
# Add ASan AddressSanitizer |
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") |
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") |
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
13
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
19 |
# Generate C++ interface classes from D-Bus XML: |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
20 |
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated-sources/) |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
21 |
set(DBUS_XML ${CMAKE_CURRENT_SOURCE_DIR}/../../d-bus/info.globalcode.mouse.cadMousePro.xml) |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
22 |
set(GENERATED_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/generated-sources/) |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
23 |
add_custom_command( |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
24 |
DEPENDS ${DBUS_XML} |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
25 |
OUTPUT ${GENERATED_SOURCES}/DBusAdaptor.h |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
26 |
OUTPUT ${GENERATED_SOURCES}/DBusAdaptor.cpp |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
27 |
COMMAND qdbusxml2cpp -a DBusAdaptor.h:DBusAdaptor.cpp -c DBusAdaptor -l Daemon -i Daemon.h ${DBUS_XML} |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
28 |
WORKING_DIRECTORY ${GENERATED_SOURCES} |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
29 |
) |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
30 |
cmake_policy(SET CMP0071 NEW) # Let AUTOMOC and AUTOUIC process GENERATED files. |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
31 |
|
0
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
# Executable output: |
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
add_executable( |
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
${EXECUTABLE_FILE} |
12 | 35 |
Daemon.h |
13
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
36 |
${CMAKE_CURRENT_BINARY_DIR}/generated-sources/DBusAdaptor.h |
52d92c1b340e
generate C++ classes from D-Bus XML using cmake instead of a custom script
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
37 |
${CMAKE_CURRENT_BINARY_DIR}/generated-sources/DBusAdaptor.cpp |
0
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
cadMousePro.cpp |
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
) |
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
|
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
# Link libraries: |
12 | 42 |
target_link_libraries(${EXECUTABLE_FILE} ${USB_LIBS_LIBRARIES} Qt5::DBus) |
0
6ff501639c23
project skeleton, open USB HID device
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
set_property(TARGET ${EXECUTABLE_FILE} PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE) |