-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
67 lines (58 loc) · 2.29 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# CMake minimum version
cmake_minimum_required(VERSION 3.7)
# Create project
project(WhistleDetector
VERSION 0.1
LANGUAGES CXX
)
# CMake options
option(VISUALIZE "Create a window to visualize frequencies" OFF)
# Set C++ standard and preprocessor macros
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_definitions(APP_NAME="${CMAKE_PROJECT_NAME}")
add_compile_definitions(APP_VERSION="${CMAKE_PROJECT_VERSION}")
# Find and configure Qt5 and fftw3
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 COMPONENTS Core Widgets Multimedia Network REQUIRED)
# Add executable
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/WhistleDetector)
add_executable(WhistleDetector
src/main.cpp
src/application.h src/application.cpp
src/detector.h src/detector.cpp
src/visualizer.h src/visualizer.cpp
src/settings.h src/settings.cpp
)
# Add and link dependencies
target_include_directories(WhistleDetector PRIVATE $ENV{CONDA_PREFIX}/include)
target_link_directories(WhistleDetector PRIVATE $ENV{CONDA_PREFIX}/lib)
target_link_libraries(WhistleDetector PRIVATE Qt5::Core Qt5::Multimedia Qt5::Network fftw3)
if (VISUALIZE)
target_link_libraries(WhistleDetector PRIVATE Qt5::Widgets)
target_compile_definitions(WhistleDetector PRIVATE VISUALIZE)
endif()
# Deploy dll's with executable on Windows
if (WIN32)
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
# Call windeployqt
add_custom_command(TARGET WhistleDetector POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E
env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
--verbose 1
--no-compiler-runtime # MSVC: vc_redist, GCC/MinGW: compiler dll's
--no-angle # Angle = portable OpenGL
--no-opengl-sw # No OpenGL was used!
"$<TARGET_FILE:WhistleDetector>"
)
endif()
# Deploy configuration and icons
add_custom_command(TARGET WhistleDetector POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_SOURCE_DIR}/resources/config.ini"
"$<TARGET_FILE_DIR:WhistleDetector>"
)