aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-04-13 11:35:02 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-04-13 11:35:02 +0300
commit6f2169ca6924100f309039efb502ae1af2d27113 (patch)
tree82efcb543cea648bf0e9c636947571d7e3ae85f9
parentFix old-style cast warnings (diff)
downloadsingleapplication-6f2169ca6924100f309039efb502ae1af2d27113.tar.xz
Add meson build support
Remove CMakeLists and qmake project files
-rw-r--r--CMakeLists.txt43
-rw-r--r--examples/basic/CMakeLists.txt15
-rwxr-xr-xexamples/basic/basic.pro5
-rw-r--r--examples/basic/meson.build4
-rw-r--r--examples/calculator/CMakeLists.txt20
-rw-r--r--examples/calculator/calculator.pro11
-rw-r--r--examples/calculator/meson.build5
-rw-r--r--examples/sending_arguments/CMakeLists.txt19
-rw-r--r--examples/sending_arguments/meson.build5
-rwxr-xr-xexamples/sending_arguments/sending_arguments.pro9
-rw-r--r--meson.build38
-rw-r--r--meson_options.txt1
-rw-r--r--singleapplication.pri20
13 files changed, 53 insertions, 142 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index d619230..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-cmake_minimum_required(VERSION 3.1.0)
-
-project(SingleApplication)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_AUTOMOC ON)
-
-# SingleApplication base class
-set(QAPPLICATION_CLASS QCoreApplication CACHE STRING "Inheritance class for SingleApplication")
-set_property(CACHE QAPPLICATION_CLASS PROPERTY STRINGS QApplication QGuiApplication QCoreApplication)
-
-# Libary target
-add_library(${PROJECT_NAME} STATIC
- singleapplication.cpp
- singleapplication_p.cpp
- )
-
-# Find dependencies
-find_package(Qt5Network)
-if(QAPPLICATION_CLASS STREQUAL QApplication)
- find_package(Qt5 COMPONENTS Widgets REQUIRED)
-elseif(QAPPLICATION_CLASS STREQUAL QGuiApplication)
- find_package(Qt5 COMPONENTS Gui REQUIRED)
-else()
- find_package(Qt5 COMPONENTS Core REQUIRED)
-endif()
-add_compile_definitions(QAPPLICATION_CLASS=${QAPPLICATION_CLASS})
-
-# Link dependencies
-target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Network)
-if(QAPPLICATION_CLASS STREQUAL QApplication)
- target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Widgets)
-elseif(QAPPLICATION_CLASS STREQUAL QGuiApplication)
- target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Gui)
-else()
- target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core)
-endif()
-
-if(WIN32)
- target_link_libraries(${PROJECT_NAME} PRIVATE advapi32)
-endif()
-
-target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/examples/basic/CMakeLists.txt b/examples/basic/CMakeLists.txt
deleted file mode 100644
index 4f1902b..0000000
--- a/examples/basic/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-cmake_minimum_required(VERSION 3.1.0)
-
-project(basic)
-
-# SingleApplication base class
-set(QAPPLICATION_CLASS QCoreApplication CACHE STRING "Inheritance class for SingleApplication")
-
-add_executable(basic
- main.cpp
- )
-
-find_package(Qt5 COMPONENTS Core REQUIRED)
-add_subdirectory(../.. SingleApplication)
-target_link_libraries(${PROJECT_NAME} Qt5::Core SingleApplication)
-
diff --git a/examples/basic/basic.pro b/examples/basic/basic.pro
deleted file mode 100755
index b7af16c..0000000
--- a/examples/basic/basic.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-# Single Application implementation
-include(../../singleapplication.pri)
-DEFINES += QAPPLICATION_CLASS=QCoreApplication
-
-SOURCES += main.cpp
diff --git a/examples/basic/meson.build b/examples/basic/meson.build
new file mode 100644
index 0000000..ba17a02
--- /dev/null
+++ b/examples/basic/meson.build
@@ -0,0 +1,4 @@
+executable('basic',
+ sources: 'main.cpp',
+ dependencies: [ SingleApplication_dep, dep_qt5 ]
+)
diff --git a/examples/calculator/CMakeLists.txt b/examples/calculator/CMakeLists.txt
deleted file mode 100644
index c90257a..0000000
--- a/examples/calculator/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-cmake_minimum_required(VERSION 3.1.0)
-
-project(calculator)
-
-set(CMAKE_AUTOMOC ON)
-
-# SingleApplication base class
-set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
-
-add_executable(${PROJECT_NAME}
- button.h
- calculator.h
- button.cpp
- calculator.cpp
- main.cpp
- )
-
-find_package(Qt5 COMPONENTS Widgets REQUIRED)
-add_subdirectory(../.. SingleApplication)
-target_link_libraries(${PROJECT_NAME} Qt5::Widgets SingleApplication)
diff --git a/examples/calculator/calculator.pro b/examples/calculator/calculator.pro
deleted file mode 100644
index 8f13260..0000000
--- a/examples/calculator/calculator.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets
-
-HEADERS = button.h \
- calculator.h
-SOURCES = button.cpp \
- calculator.cpp \
- main.cpp
-
-# Single Application implementation
-include(../../singleapplication.pri)
-DEFINES += QAPPLICATION_CLASS=QApplication
diff --git a/examples/calculator/meson.build b/examples/calculator/meson.build
new file mode 100644
index 0000000..66c177b
--- /dev/null
+++ b/examples/calculator/meson.build
@@ -0,0 +1,5 @@
+executable('calculator',
+ sources: [ 'button.cpp', 'calculator.cpp', 'main.cpp',
+ mod_qt5.preprocess(moc_headers: [ 'button.h', 'calculator.h' ], dependencies: dep_qt5) ],
+ dependencies: [ SingleApplication_dep, dep_qt5 ]
+)
diff --git a/examples/sending_arguments/CMakeLists.txt b/examples/sending_arguments/CMakeLists.txt
deleted file mode 100644
index bfdc5cc..0000000
--- a/examples/sending_arguments/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-cmake_minimum_required(VERSION 3.1.0)
-
-project(sending_arguments)
-
-set(CMAKE_AUTOMOC ON)
-
-# SingleApplication base class
-set(QAPPLICATION_CLASS QCoreApplication CACHE STRING "Inheritance class for SingleApplication")
-
-add_executable(${PROJECT_NAME}
- main.cpp
- messagereceiver.cpp
- messagereceiver.h
- main.cpp
- )
-
-find_package(Qt5 COMPONENTS Core REQUIRED)
-add_subdirectory(../.. SingleApplication)
-target_link_libraries(${PROJECT_NAME} Qt5::Core SingleApplication)
diff --git a/examples/sending_arguments/meson.build b/examples/sending_arguments/meson.build
new file mode 100644
index 0000000..856ec99
--- /dev/null
+++ b/examples/sending_arguments/meson.build
@@ -0,0 +1,5 @@
+executable('sending_arguments',
+ sources: [ 'main.cpp', 'messagereceiver.cpp',
+ mod_qt5.preprocess(moc_headers: 'messagereceiver.h', dependencies: dep_qt5) ],
+ dependencies: [ SingleApplication_dep, dep_qt5 ]
+)
diff --git a/examples/sending_arguments/sending_arguments.pro b/examples/sending_arguments/sending_arguments.pro
deleted file mode 100755
index 897636a..0000000
--- a/examples/sending_arguments/sending_arguments.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-# Single Application implementation
-include(../../singleapplication.pri)
-DEFINES += QAPPLICATION_CLASS=QCoreApplication
-
-SOURCES += main.cpp \
- messagereceiver.cpp
-
-HEADERS += \
- messagereceiver.h
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..c85b439
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,38 @@
+project('SingleApplication', ['cpp'],
+ version: '3.1.0b',
+ default_options: ['cpp_std=c++2a', 'warning_level=3'],
+ license: 'MIT',
+)
+
+mod_qt5 = import('qt5')
+dep_qt5 = dependency('qt5', modules: [ 'Core', 'Network', 'Gui', 'Widgets' ], include_type: 'system')
+
+SingleApplication_inc = include_directories('.')
+
+SingleApplication_moc = mod_qt5.preprocess(
+ moc_headers: [ 'singleapplication.h', 'singleapplication_p.h'],
+ moc_extra_arguments: ['-DQAPPLICATION_CLASS=QApplication'],
+ dependencies: dep_qt5
+)
+
+SingleApplication_lib = static_library('SingleApplication',
+ [ 'singleapplication.cpp', 'singleapplication_p.cpp', SingleApplication_moc ],
+ include_directories: SingleApplication_inc,
+ cpp_args: '-DQAPPLICATION_CLASS=QApplication',
+ dependencies: dep_qt5
+)
+
+SingleApplication_dep = declare_dependency(
+ include_directories: SingleApplication_inc,
+ link_with: SingleApplication_lib
+).as_system('system')
+
+# On windows, SingleApplication needs to be linked against advapi32. This is
+# done by adding 'advapi32' to cpp_winlibs, where it should be by default.
+
+if get_option('examples')
+ subdir('examples/basic')
+ subdir('examples/calculator')
+ subdir('examples/sending_arguments')
+endif
+
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..21e68e0
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('examples', description: 'Build examples', type: 'boolean', value: false)
diff --git a/singleapplication.pri b/singleapplication.pri
deleted file mode 100644
index ae81f59..0000000
--- a/singleapplication.pri
+++ /dev/null
@@ -1,20 +0,0 @@
-QT += core network
-CONFIG += c++11
-
-HEADERS += $$PWD/SingleApplication \
- $$PWD/singleapplication.h \
- $$PWD/singleapplication_p.h
-SOURCES += $$PWD/singleapplication.cpp \
- $$PWD/singleapplication_p.cpp
-
-INCLUDEPATH += $$PWD
-
-win32 {
- msvc:LIBS += Advapi32.lib
- gcc:LIBS += -ladvapi32
-}
-
-DISTFILES += \
- $$PWD/README.md \
- $$PWD/CHANGELOG.md \
- $$PWD/Windows.md