improved project files
This commit is contained in:
parent
b7553ada41
commit
5e78178fb2
|
@ -1,37 +1,77 @@
|
||||||
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
||||||
|
|
||||||
|
# add project files
|
||||||
|
set(HEADER_FILES
|
||||||
|
ffmpeglauncher.h
|
||||||
|
playerwatcher.h
|
||||||
|
)
|
||||||
|
set(SRC_FILES
|
||||||
|
ffmpeglauncher.cpp
|
||||||
|
main.cpp
|
||||||
|
playerwatcher.cpp
|
||||||
|
)
|
||||||
|
set(DBUS_FILES
|
||||||
|
org.freedesktop.DBus.Properties.xml
|
||||||
|
org.mpris.MediaPlayer2.xml
|
||||||
|
org.mpris.MediaPlayer2.Player.xml
|
||||||
|
)
|
||||||
|
|
||||||
# meta data
|
# meta data
|
||||||
set(META_PROJECT_NAME dbus-soundrecorder)
|
set(META_PROJECT_NAME dbus-soundrecorder)
|
||||||
set(META_APP_NAME "D-Bus Sound Recorder")
|
set(META_APP_NAME "D-Bus Sound Recorder")
|
||||||
set(META_APP_AUTHOR "Martchus")
|
set(META_APP_AUTHOR "Martchus")
|
||||||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||||
set(META APP_DESCRIPTION "Records sound from Pulse Audio with ffmpeg while watching D-Bus to determine tracks and meta information.")
|
set(META_APP_DESCRIPTION "Records sound from Pulse Audio with ffmpeg while watching D-Bus to determine tracks and meta information.")
|
||||||
set(META_VERSION_MAJOR 1)
|
set(META_VERSION_MAJOR 1)
|
||||||
set(META_VERSION_MINOR 1)
|
set(META_VERSION_MINOR 1)
|
||||||
set(META_VERSION_PATCH 0)
|
set(META_VERSION_PATCH 0)
|
||||||
|
|
||||||
# define project
|
|
||||||
project(${META_PROJECT_NAME})
|
|
||||||
|
|
||||||
# stringification of meta data
|
# stringification of meta data
|
||||||
set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"")
|
set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"")
|
||||||
set(META_APP_NAME_STR "\"${META_APP_NAME}\"")
|
set(META_APP_NAME_STR "\"${META_APP_NAME}\"")
|
||||||
set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"")
|
set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"")
|
||||||
set(META_APP_URL_STR "\"${META_APP_URL}\"")
|
set(META_APP_URL_STR "\"${META_APP_URL}\"")
|
||||||
set(APP_DESCRIPTION_STR "\"${APP_DESCRIPTION}\"")
|
set(META_APP_DESCRIPTION_STR "\"${META_APP_DESCRIPTION}\"")
|
||||||
set(META_APP_VERSION_STR "\"${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}\"")
|
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||||
|
set(META_APP_VERSION_STR "\"${META_APP_VERSION}\"")
|
||||||
|
|
||||||
|
# define project
|
||||||
|
project(${META_PROJECT_NAME})
|
||||||
|
|
||||||
# add configuration header
|
# add configuration header
|
||||||
configure_file (
|
configure_file(
|
||||||
"${PROJECT_SOURCE_DIR}/config.h.in"
|
"${PROJECT_SOURCE_DIR}/resources/config.h.in"
|
||||||
"${PROJECT_BINARY_DIR}/config.h"
|
"${PROJECT_BINARY_DIR}/resources/config.h"
|
||||||
)
|
)
|
||||||
include_directories("${PROJECT_BINARY_DIR}")
|
include_directories("${PROJECT_BINARY_DIR}")
|
||||||
|
|
||||||
# add source and header files
|
# add windows resource file
|
||||||
file(GLOB_RECURSE SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
|
if(MINGW)
|
||||||
file(GLOB_RECURSE HEADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
# creation windows icon from png with ffmpeg if available
|
||||||
file(GLOB_RECURSE DBUS_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "org.*.xml")
|
find_program(FFMPEG_BIN ffmpeg avconv)
|
||||||
|
if(FFMPEG_BIN)
|
||||||
|
set(PNG_ICON_PATH "${PROJECT_SOURCE_DIR}/resources/icons/hicolor/128x128/apps/${META_PROJECT_NAME}.png")
|
||||||
|
if(EXISTS ${PNG_ICON_PATH})
|
||||||
|
set(WINDOWS_ICON_PATH "${PROJECT_BINARY_DIR}/${META_PROJECT_NAME}.ico")
|
||||||
|
set(WINDOWS_ICON_RC_ENTRY "IDI_ICON1 ICON DISCARDABLE \"${WINDOWS_ICON_PATH}\"")
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${WINDOWS_ICON_PATH}"
|
||||||
|
COMMAND ${FFMPEG_BIN} -y -i "${PNG_ICON_PATH}" -vf crop=iw-20:ih-20:10:10,scale=64:64 "${WINDOWS_ICON_PATH}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif(FFMPEG_BIN)
|
||||||
|
# create windows rc file from template
|
||||||
|
set(WINDOWS_EXT "exe")
|
||||||
|
configure_file(
|
||||||
|
"${PROJECT_SOURCE_DIR}/resources/windows.rc.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/resources/windows.rc"
|
||||||
|
)
|
||||||
|
# set windres as resource compiler
|
||||||
|
set(RES_FILES "${PROJECT_BINARY_DIR}/resources/windows.rc")
|
||||||
|
set(CMAKE_RC_COMPILER_INIT windres)
|
||||||
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
||||||
|
enable_language(RC)
|
||||||
|
endif(MINGW)
|
||||||
|
|
||||||
# check required Qt 5 modules
|
# check required Qt 5 modules
|
||||||
find_package(Qt5Core REQUIRED)
|
find_package(Qt5Core REQUIRED)
|
||||||
|
@ -46,15 +86,28 @@ qt5_add_dbus_interfaces(SRC_FILES ${DBUS_FILES})
|
||||||
add_definitions(-DCMAKE_BUILD)
|
add_definitions(-DCMAKE_BUILD)
|
||||||
|
|
||||||
# executable and linking
|
# executable and linking
|
||||||
add_executable(${META_PROJECT_NAME} ${HEADER_FILES} ${SRC_FILES})
|
add_executable(${META_PROJECT_NAME} ${HEADER_FILES} ${SRC_FILES} ${RES_FILES} ${WINDOWS_ICON_PATH})
|
||||||
target_link_libraries(${META_PROJECT_NAME} c++utilities Qt5::Core Qt5::DBus)
|
target_link_libraries(${META_PROJECT_NAME} c++utilities Qt5::Core Qt5::DBus)
|
||||||
|
set_target_properties(${META_PROJECT_NAME} PROPERTIES
|
||||||
# enable C++11
|
CXX_STANDARD 11
|
||||||
set_property(TARGET ${META_PROJECT_NAME} PROPERTY CXX_STANDARD 11)
|
)
|
||||||
|
|
||||||
# add install target
|
# add install target
|
||||||
install(TARGETS ${META_PROJECT_NAME}
|
install(TARGETS ${META_PROJECT_NAME}
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
LIBRARY DESTINATION lib
|
COMPONENT binary
|
||||||
ARCHIVE DESTINATION lib
|
)
|
||||||
|
add_custom_target(install-binary
|
||||||
|
DEPENDS ${META_PROJECT_NAME}
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=binary -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
||||||
|
)
|
||||||
|
add_custom_target(install-mingw-w64
|
||||||
|
DEPENDS install-binary
|
||||||
|
)
|
||||||
|
add_custom_target(install-binary-strip
|
||||||
|
DEPENDS ${META_PROJECT_NAME}
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_COMPONENT=binary -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
||||||
|
)
|
||||||
|
add_custom_target(install-mingw-w64-strip
|
||||||
|
DEPENDS install-binary-strip
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
#ifndef APP_METADATA_AVAIL
|
|
||||||
#define APP_METADATA_AVAIL
|
|
||||||
#define PROJECT_NAME @META_PROJECT_NAME_STR@
|
|
||||||
#define APP_NAME @META_APP_NAME_STR@
|
|
||||||
#define APP_VERSION @META_APP_VERSION_STR@
|
|
||||||
#define APP_AUTHOR @META_APP_AUTHOR_STR@
|
|
||||||
#define APP_URL @META_APP_URL_STR@
|
|
||||||
#define APP_DESCRIPTION @META_APP_DESCRIPTION_STR@
|
|
||||||
#endif // APP_METADATA_AVAIL
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# meta data
|
||||||
projectname = dbus-soundrecorder
|
projectname = dbus-soundrecorder
|
||||||
appname = "D-Bus Sound Recorder"
|
appname = "D-Bus Sound Recorder"
|
||||||
appauthor = Martchus
|
appauthor = Martchus
|
||||||
|
@ -12,28 +13,32 @@ VERSION = 1.1.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# basic configuration: console application
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
|
||||||
CONFIG += console
|
CONFIG += console
|
||||||
|
|
||||||
QT += core dbus
|
QT += core dbus
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
# add project files
|
||||||
playerwatcher.cpp \
|
|
||||||
ffmpeglauncher.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
playerwatcher.h \
|
playerwatcher.h \
|
||||||
ffmpeglauncher.h
|
ffmpeglauncher.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
main.cpp \
|
||||||
|
playerwatcher.cpp \
|
||||||
|
ffmpeglauncher.cpp
|
||||||
|
|
||||||
DBUS_INTERFACES += \
|
DBUS_INTERFACES += \
|
||||||
org.freedesktop.DBus.Properties.xml \
|
org.freedesktop.DBus.Properties.xml \
|
||||||
org.mpris.MediaPlayer2.xml \
|
org.mpris.MediaPlayer2.xml \
|
||||||
org.mpris.MediaPlayer2.Player.xml
|
org.mpris.MediaPlayer2.Player.xml
|
||||||
|
|
||||||
DISTFILES += \
|
OTHER_FILES += \
|
||||||
README.md \
|
README.md \
|
||||||
LICENSE
|
LICENSE \
|
||||||
|
CMakeLists.txt \
|
||||||
|
resources/config.h.in \
|
||||||
|
resources/windows.rc.in
|
||||||
|
|
||||||
# libs and includepath
|
# libs and includepath
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
|
|
56
general.pri
56
general.pri
|
@ -1,28 +1,12 @@
|
||||||
#dirs
|
# specify build directories for moc, object and rcc files
|
||||||
MOC_DIR = ./moc
|
MOC_DIR = ./moc
|
||||||
OBJECTS_DIR = ./obj
|
OBJECTS_DIR = ./obj
|
||||||
RCC_DIR = ./res
|
RCC_DIR = ./res
|
||||||
# compiler flags
|
|
||||||
|
# compiler flags: enable C++11
|
||||||
QMAKE_CXXFLAGS += -std=c++11
|
QMAKE_CXXFLAGS += -std=c++11
|
||||||
QMAKE_LFLAGS += -std=c++11
|
QMAKE_LFLAGS += -std=c++11
|
||||||
# prefix
|
|
||||||
targetprefix = $$(TARGET_PREFIX)
|
|
||||||
message("Using target prefix \"$${targetprefix}\".")
|
|
||||||
# print install root
|
|
||||||
message("Using install root \"$$(INSTALL_ROOT)\".")
|
|
||||||
# target
|
|
||||||
CONFIG(debug, debug|release) {
|
|
||||||
TARGET = $${targetprefix}$${projectname}d
|
|
||||||
} else {
|
|
||||||
TARGET = $${targetprefix}$${projectname}
|
|
||||||
}
|
|
||||||
# add defines
|
|
||||||
DEFINES += "APP_METADATA_AVAIL"
|
|
||||||
DEFINES += "'PROJECT_NAME=\"$${projectname}\"'"
|
|
||||||
DEFINES += "'APP_NAME=\"$${appname}\"'"
|
|
||||||
DEFINES += "'APP_AUTHOR=\"$${appauthor}\"'"
|
|
||||||
DEFINES += "'APP_URL=\"$${appurl}\"'"
|
|
||||||
DEFINES += "'APP_VERSION=\"$${VERSION}\"'"
|
|
||||||
# variables to check target architecture
|
# variables to check target architecture
|
||||||
win32-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
|
win32-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
|
||||||
win32-g++-32:QMAKE_TARGET.arch = x86
|
win32-g++-32:QMAKE_TARGET.arch = x86
|
||||||
|
@ -30,7 +14,30 @@ win32-g++-64:QMAKE_TARGET.arch = x86_64
|
||||||
linux-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
|
linux-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
|
||||||
linux-g++-32:QMAKE_TARGET.arch = x86
|
linux-g++-32:QMAKE_TARGET.arch = x86
|
||||||
linux-g++-64:QMAKE_TARGET.arch = x86_64
|
linux-g++-64:QMAKE_TARGET.arch = x86_64
|
||||||
# configuration
|
|
||||||
|
# determine and print target prefix
|
||||||
|
targetprefix = $$(TARGET_PREFIX)
|
||||||
|
message("Using target prefix \"$${targetprefix}\".")
|
||||||
|
|
||||||
|
# print install root
|
||||||
|
message("Using install root \"$$(INSTALL_ROOT)\".")
|
||||||
|
|
||||||
|
# set target
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
TARGET = $${targetprefix}$${projectname}d
|
||||||
|
} else {
|
||||||
|
TARGET = $${targetprefix}$${projectname}
|
||||||
|
}
|
||||||
|
|
||||||
|
# add defines for meta data
|
||||||
|
DEFINES += "APP_METADATA_AVAIL"
|
||||||
|
DEFINES += "'PROJECT_NAME=\"$${projectname}\"'"
|
||||||
|
DEFINES += "'APP_NAME=\"$${appname}\"'"
|
||||||
|
DEFINES += "'APP_AUTHOR=\"$${appauthor}\"'"
|
||||||
|
DEFINES += "'APP_URL=\"$${appurl}\"'"
|
||||||
|
DEFINES += "'APP_VERSION=\"$${VERSION}\"'"
|
||||||
|
|
||||||
|
# configure Qt modules and defines
|
||||||
mobile {
|
mobile {
|
||||||
DEFINES += CONFIG_MOBILE
|
DEFINES += CONFIG_MOBILE
|
||||||
} else:desktop {
|
} else:desktop {
|
||||||
|
@ -61,7 +68,7 @@ no-gui {
|
||||||
}
|
}
|
||||||
guiqtquick {
|
guiqtquick {
|
||||||
message("Configured for Qt Quick GUI support.")
|
message("Configured for Qt Quick GUI support.")
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += quick
|
QT += quick
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
CONFIG += qml_debug
|
CONFIG += qml_debug
|
||||||
}
|
}
|
||||||
|
@ -69,11 +76,12 @@ guiqtquick {
|
||||||
}
|
}
|
||||||
guiqtwidgets {
|
guiqtwidgets {
|
||||||
message("Configured for Qt widgets GUI support.")
|
message("Configured for Qt widgets GUI support.")
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
QT += widgets
|
||||||
DEFINES += GUI_QTWIDGETS
|
DEFINES += GUI_QTWIDGETS
|
||||||
DEFINES += MODEL_UNDO_SUPPORT
|
DEFINES += MODEL_UNDO_SUPPORT
|
||||||
}
|
}
|
||||||
# Windows stuff: configuration for cross compliation with mingw-w64
|
|
||||||
|
# configuration for cross compliation with mingw-w64
|
||||||
win32 {
|
win32 {
|
||||||
QMAKE_TARGET_PRODUCT = "$${appname}"
|
QMAKE_TARGET_PRODUCT = "$${appname}"
|
||||||
QMAKE_TARGET_COPYRIGHT = "by $${appauthor}"
|
QMAKE_TARGET_COPYRIGHT = "by $${appauthor}"
|
||||||
|
|
2
main.cpp
2
main.cpp
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
// include configuration from separate header file when building with CMake
|
// include configuration from separate header file when building with CMake
|
||||||
#ifndef APP_METADATA_AVAIL
|
#ifndef APP_METADATA_AVAIL
|
||||||
#include "config.h"
|
#include "resources/config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <c++utilities/application/argumentparser.h>
|
#include <c++utilities/application/argumentparser.h>
|
||||||
|
|
Loading…
Reference in New Issue