use meson

This commit is contained in:
Thomas Lindner 2022-12-14 22:34:26 +01:00
parent 107633f8ee
commit aaf6836654
8 changed files with 36 additions and 90 deletions

2
.gitignore vendored
View file

@ -1,3 +1,3 @@
*.swp
*.core
/Build/
/builddir/

View file

@ -1,13 +0,0 @@
cmake_minimum_required(VERSION 3.20)
project(kappachat LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(deltachat-core REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
include(AddAutoformatTarget)
include(GNUInstallDirs)
qt_standard_project_setup()
add_subdirectory(src)

View file

@ -1,2 +0,0 @@
[ -f Build/build.ninja ] || cmake -G Ninja -B Build
exec ninja -C Build "$@"

View file

@ -1,28 +0,0 @@
find_program(clang-format_EXECUTABLE clang-format)
mark_as_advanced(clang-format_EXECUTABLE)
if(clang-format_EXECUTABLE)
add_executable(clang-format IMPORTED)
set_target_properties(clang-format PROPERTIES
IMPORTED_LOCATION ${clang-format_EXECUTABLE})
endif()
function(add_autoformat_target target)
get_target_property(source_dir ${target} SOURCE_DIR)
get_target_property(sources ${target} SOURCES)
foreach(source ${sources})
get_property(generated SOURCE ${source} PROPERTY GENERATED)
if(NOT ${generated})
list(APPEND non_generated_sources ${source})
endif()
endforeach()
add_custom_target(autoformat_${target}
COMMAND clang-format -i -- ${non_generated_sources}
WORKING_DIRECTORY ${source_dir}
COMMENT "Autoformating sources of target ${target}"
VERBATIM)
if(NOT TARGET autoformat)
add_custom_target(autoformat)
endif()
add_dependencies(autoformat autoformat_${target})
endfunction()

View file

@ -1,16 +0,0 @@
find_path(libdeltachat_INCLUDE_DIR deltachat.h)
mark_as_advanced(libdeltachat_INCLUDE_DIR)
find_library(libdeltachat_LIBRARY deltachat)
mark_as_advanced(libdeltachat_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
deltachat-core DEFAULT_MSG libdeltachat_LIBRARY libdeltachat_INCLUDE_DIR)
if(deltachat-core_FOUND AND NOT TARGET deltachat-core::libdeltachat)
add_library(deltachat-core::libdeltachat SHARED IMPORTED)
set_target_properties(deltachat-core::libdeltachat PROPERTIES
IMPORTED_LOCATION ${libdeltachat_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${libdeltachat_INCLUDE_DIR})
endif()

10
meson.build Normal file
View file

@ -0,0 +1,10 @@
project('kappachat', 'cpp',
license : 'ISC',
default_options : ['buildtype=debugoptimized',
'warning_level=3',
'cpp_std=c++20'])
deltachat_dep = dependency('deltachat')
qt6_dep = dependency('qt6', modules: ['Core', 'Widgets'])
subdir('src')

View file

@ -1,30 +0,0 @@
add_executable(${PROJECT_NAME}
deltachat_context.cc
deltachat_context.hh
login_dialog.cc
login_dialog.hh
main.cc
main.hh
main_window.cc
main_window.hh
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
deltachat-core::libdeltachat
Qt6::Widgets
)
target_compile_features(${PROJECT_NAME}
PRIVATE
cxx_std_20
)
target_compile_options(${PROJECT_NAME}
PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:-Wall -Wextra>
)
set_target_properties(${PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON
)
install(TARGETS ${PROJECT_NAME})
add_autoformat_target(${PROJECT_NAME})

25
src/meson.build Normal file
View file

@ -0,0 +1,25 @@
qt6 = import('qt6')
moc_files = qt6.compile_moc(headers : [
'deltachat_context.hh',
'login_dialog.hh',
'main.hh',
'main_window.hh',
],
dependencies : [
deltachat_dep,
qt6_dep,
])
executable('kappachat',
sources : [
'deltachat_context.cc',
'login_dialog.cc',
'main.cc',
'main_window.cc',
moc_files,
],
dependencies : [
deltachat_dep,
qt6_dep,
],
gui_app : true,
install : true)