-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
151 lines (142 loc) · 5.17 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
cmake_minimum_required(VERSION 3.19)
option(VCPKG "Build dependencies with vcpkg" OFF)
if (VCPKG)
include("${CMAKE_SOURCE_DIR}/cmake/vcpkg.cmake")
endif ()
project("Easy Audio Sync"
VERSION 1.1.2
DESCRIPTION "Audio library syncing and conversion utility"
HOMEPAGE_URL "https://github.com/complexlogic/EasyAudioSync"
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 20)
set(EXECUTABLE_NAME "easyaudiosync")
set(RDNS_NAME "io.github.complexlogic.EasyAudioSync")
include_directories(${PROJECT_BINARY_DIR})
add_compile_definitions("$<$<CONFIG:DEBUG>:DEBUG>")
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}")
set(VS_STARTUP_PROJECT ${EXECUTABLE_NAME})
# Configure options
if (WIN32 OR APPLE)
set(QT_VERSION "6")
else ()
set(QT_VERSION "5" CACHE STRING "Qt major version to use (5 or 6).")
if (NOT (QT_VERSION STREQUAL "5" OR QT_VERSION STREQUAL "6"))
message(FATAL_ERROR "Unsupported Qt version '${QT_VERSION}'. Only 5 and 6 are supported")
endif ()
endif ()
if (APPLE)
option(DMG "Make deployable DMG" OFF)
endif ()
if (UNIX)
option(STRIP_BINARY "Run strip on the binary" OFF)
endif ()
option(PERSIST_GEOMETRY "Make window size and position persistent between runs" ON)
if (PERSIST_GEOMETRY)
add_compile_definitions(PERSIST_GEOMETRY)
endif ()
option(FFDEBUG "FFmpeg debug messages" OFF)
if (FFDEBUG)
add_compile_definitions("FFDEBUG")
endif ()
option(EXTRA_WARNINGS "Enable extra compiler warnings" OFF)
if (EXTRA_WARNINGS)
if (MSVC)
add_compile_options(/W4 /WX)
else ()
add_compile_options(-Wall -Wextra -Wpedantic -Wconversion)
endif ()
endif ()
if (WIN32)
option(NSIS_INSTALLER "Enable NSIS installer target" OFF)
endif ()
# Qt setup
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
if (QT_VERSION STREQUAL "5")
set(QT_VERSION_REQUIREMENT "5.15...<6")
endif ()
find_package(Qt${QT_VERSION} ${QT_VERSION_REQUIREMENT} REQUIRED COMPONENTS Core Gui Widgets LinguistTools)
if (UNIX)
find_package(PkgConfig MODULE REQUIRED)
find_package(Threads REQUIRED)
pkg_check_modules(LIBAVFORMAT REQUIRED IMPORTED_TARGET libavformat>=59.27)
pkg_check_modules(LIBAVCODEC REQUIRED IMPORTED_TARGET libavcodec>=59.37)
pkg_check_modules(LIBSWRESAMPLE REQUIRED IMPORTED_TARGET libswresample>=4.7)
pkg_check_modules(LIBAVFILTER REQUIRED IMPORTED_TARGET libavfilter>=8.44)
pkg_check_modules(LIBAVUTIL REQUIRED IMPORTED_TARGET libavutil>=57.28)
pkg_check_modules(FMT REQUIRED IMPORTED_TARGET fmt)
pkg_check_modules(SPDLOG REQUIRED IMPORTED_TARGET spdlog)
pkg_check_modules(TAGLIB REQUIRED IMPORTED_TARGET taglib>=1.12)
if (STRIP_BINARY)
find_program(STRIP strip REQUIRED)
endif ()
if (APPLE AND DMG)
find_program(MACDEPLOYQT macdeployqt PATHS "${VCPKG_INSTALLED_DIR}/x64-osx/tools/Qt${QT_VERSION}/bin" REQUIRED)
endif ()
elseif (WIN32)
find_path(FFMPEG_INCLUDE_DIR "libavformat/avformat.h" REQUIRED)
find_library(LIBAVFORMAT avformat REQUIRED)
find_library(LIBAVCODEC avcodec REQUIRED)
find_library(LIBAVFILTER avfilter REQUIRED)
find_library(LIBSWRESAMPLE swresample REQUIRED)
find_library(LIBAVUTIL avutil REQUIRED)
find_path(TAGLIB_INCLUDE_DIR "taglib/taglib.h" REQUIRED)
find_library(TAGLIB tag REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_program(WINDEPLOYQT windeployqt.exe REQUIRED)
if (NSIS_INSTALLER)
find_program(NSIS makensis.exe REQUIRED)
endif ()
endif ()
# Embed Git information
find_package(Git QUIET)
if (Git_FOUND)
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --long --tags
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_OUTPUT
RESULT_VARIABLE GIT_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (GIT_RESULT EQUAL 0)
string(REPLACE "-" ";" GIT_LIST "${GIT_OUTPUT}")
list(GET GIT_LIST 1 COMMITS_SINCE_TAG)
if (NOT COMMITS_SINCE_TAG STREQUAL "0")
list(GET GIT_LIST 2 COMMIT_HASH)
string(REPLACE "g" "" COMMIT_HASH "${COMMIT_HASH}")
set(PROJECT_VERSION_GIT "${PROJECT_VERSION}-r${COMMITS_SINCE_TAG}-${COMMIT_HASH}")
add_compile_definitions(PROJECT_VERSION_GIT=\"${PROJECT_VERSION_GIT}\")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_GIT}")
endif ()
endif ()
endif ()
# Generate Windows application manifest and resource file
if (WIN32)
set(VERSION_M ${PROJECT_VERSION_MAJOR})
set(VERSION_N ${PROJECT_VERSION_MINOR})
if (PROJECT_VERSION_PATCH)
set(VERSION_O ${PROJECT_VERSION_PATCH})
else ()
set(VERSION_O 0)
endif()
if (PROJECT_VERSION_TWEAK)
set(VERSION_P ${PROJECT_VERSION_TWEAK})
else ()
set(VERSION_P 0)
endif()
configure_file(${PROJECT_SOURCE_DIR}/config/${EXECUTABLE_NAME}.manifest.in ${PROJECT_BINARY_DIR}/${EXECUTABLE_NAME}.manifest)
endif()
# Linux desktop and appstream
if (UNIX AND NOT APPLE)
configure_file("${PROJECT_SOURCE_DIR}/config/${EXECUTABLE_NAME}.desktop.in" "${PROJECT_BINARY_DIR}/${RDNS_NAME}.desktop")
endif ()
add_subdirectory(src)
configure_file("${PROJECT_SOURCE_DIR}/config/easync.hpp.in" "${PROJECT_BINARY_DIR}/easync.hpp")
if (UNIX)
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${PROJECT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${PROJECT_BINARY_DIR}/cmake_uninstall.cmake)
endif ()