Skip to content

Commit

Permalink
Merge branch 'cmake' into 'master'
Browse files Browse the repository at this point in the history
Port to CMake

See merge request mer-core/mkcal!57
  • Loading branch information
pvuorela committed Jun 9, 2021
2 parents 7dbd0f3 + 9536c24 commit 40f1205
Show file tree
Hide file tree
Showing 19 changed files with 206 additions and 178 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -11,3 +11,4 @@ doxygen.*
*~
*.so*
plugins/defaultinvitationplugin/libdefaultinvitationplugin.so
build
76 changes: 76 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,76 @@
cmake_minimum_required(VERSION 3.11.4)

project(mkcal
VERSION 0.5.35
DESCRIPTION "Mkcal calendar library")

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 11)

find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})

include(FeatureSummary)
include(GNUInstallDirs)
include(ECMGeneratePkgConfigFile)

option(BUILD_PLUGINS "Build plugin" ON)
option(BUILD_TESTS "Build tests" ON)
option(INSTALL_TESTS "Install the tests to the system" OFF)
option(BUILD_DOCUMENTATION "Build documentation" OFF)

find_package(PkgConfig REQUIRED)

set(QT_MIN_VERSION "5.6.0")
find_package(Qt5 ${QT_MIN_VERSION} COMPONENTS DBus Gui Test REQUIRED)
find_package(KF5 COMPONENTS CalendarCore REQUIRED)

pkg_check_modules(TIMED timed-qt5 IMPORTED_TARGET REQUIRED)
set_property(GLOBAL APPEND PROPERTY _CMAKE_timed-qt5_TYPE REQUIRED)
pkg_check_modules(SQLITE3 sqlite3 IMPORTED_TARGET REQUIRED)
set_property(GLOBAL APPEND PROPERTY _CMAKE_sqlite3_TYPE REQUIRED)

if(TIMED_FOUND)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND timed-qt5)
else()
set_property(GLOBAL APPEND PROPERTY PACKAGES_NOT_FOUND timed-qt5)
endif()
if(SQLITE3_FOUND)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND sqlite3)
else()
set_property(GLOBAL APPEND PROPERTY PACKAGES_NOT_FOUND sqlite3)
endif()

add_subdirectory(src)
add_subdirectory(tools)

if(BUILD_PLUGINS)
pkg_check_modules(QMF QmfClient IMPORTED_TARGET REQUIRED)
set_property(GLOBAL APPEND PROPERTY _CMAKE_QmfClient_TYPE REQUIRED)

if(QMF_FOUND)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND QmfClient)
else()
set_property(GLOBAL APPEND PROPERTY PACKAGES_NOT_FOUND QmfClient)
endif()

add_subdirectory(plugins)
endif()

if(BUILD_TESTS)
include(CTest)
add_subdirectory(tests)
endif()

if(BUILD_DOCUMENTATION)
find_package(Doxygen REQUIRED)
if(DOXYGEN_FOUND)
add_subdirectory(doc)
endif()
endif()

feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
7 changes: 7 additions & 0 deletions doc/CMakeLists.txt
@@ -0,0 +1,7 @@
find_program(DOXYGEN NAMES doxygen)
execute_process(
COMMAND ${DOXYGEN} ${CMAKE_CURRENT_SOURCE_DIR}/libmkcal.cfg; ${CMAKE_CURRENT_SOURCE_DIR}/doc/xmlize.pl;
)

install(DIRECTORY html
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/libmkcal-doc)
18 changes: 0 additions & 18 deletions doc/doc.pro

This file was deleted.

2 changes: 1 addition & 1 deletion doc/libmkcal.cfg
Expand Up @@ -69,7 +69,7 @@ GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_HEADER = doc/header.html
HTML_FOOTER = doc/footer.html
HTML_STYLESHEET = doc/libextendedkcal.css
HTML_STYLESHEET = doc/libmkcal.css
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO

Expand Down
15 changes: 0 additions & 15 deletions mkcal.pro

This file was deleted.

1 change: 1 addition & 0 deletions plugins/CMakeLists.txt
@@ -0,0 +1 @@
add_subdirectory(defaultinvitationplugin)
16 changes: 16 additions & 0 deletions plugins/defaultinvitationplugin/CMakeLists.txt
@@ -0,0 +1,16 @@
set(SRC
defaultinvitationplugin.cpp)
set(HEADERS
defaultinvitationplugin.h)

add_library(defaultinvitationplugin ${SRC} ${HEADERS})

target_include_directories(defaultinvitationplugin PRIVATE ${PROJECT_SOURCE_DIR}/src)

target_link_libraries(defaultinvitationplugin
KF5::CalendarCore
mkcal-qt5
PkgConfig::QMF)

install(TARGETS defaultinvitationplugin
DESTINATION ${CMAKE_INSTALL_LIBDIR}/mkcalplugins)
26 changes: 0 additions & 26 deletions plugins/defaultinvitationplugin/defaultinvitationplugin.pro

This file was deleted.

2 changes: 0 additions & 2 deletions plugins/plugins.pro

This file was deleted.

9 changes: 4 additions & 5 deletions rpm/mkcal-qt5.spec
Expand Up @@ -9,6 +9,8 @@ Source0: %{name}-%{version}.tar.bz2
Source1: %{name}.privileges
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: cmake
BuildRequires: extra-cmake-modules >= 5.75.0
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Gui)
BuildRequires: pkgconfig(Qt5DBus)
Expand Down Expand Up @@ -43,19 +45,16 @@ This package contains unit tests for extended KDE kcal calendar library.
%setup -q -n %{name}-%{version}

%build
%qmake5 VERSION=`echo %{version} | sed 's/+.*//'`
%cmake -DINSTALL_TESTS=ON
make %{?_smp_mflags}

%install
rm -rf %{buildroot}
%qmake5_install
%make_install

mkdir -p %{buildroot}%{_datadir}/mapplauncherd/privileges.d
install -m 644 -p %{SOURCE1} %{buildroot}%{_datadir}/mapplauncherd/privileges.d/

# Sailfish uses pkconfig(libmkcal-qt5)
mv %{buildroot}%{_libdir}/pkgconfig/{,lib}%{name}.pc

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig
Expand Down
58 changes: 58 additions & 0 deletions src/CMakeLists.txt
@@ -0,0 +1,58 @@
set(SRC
extendedcalendar.cpp
extendedstorage.cpp
notebook.cpp
sqliteformat.cpp
sqlitestorage.cpp
servicehandler.cpp
logging.cpp
semaphore_p.cpp)
set(HEADERS
extendedcalendar.h
extendedstorage.h
extendedstorageobserver.h
notebook.h
sqliteformat.h
sqlitestorage.h
servicehandlerif.h
servicehandler.h
dummystorage.h
mkcal_export.h
logging_p.h
semaphore_p.h
invitationhandlerif.h
config-mkcal.h)

add_library(mkcal-qt5 SHARED ${SRC} ${HEADERS})

target_link_libraries(mkcal-qt5
PRIVATE
Qt5::DBus
PkgConfig::SQLITE3
PkgConfig::TIMED
PUBLIC
Qt5::Gui
KF5::CalendarCore)

set_target_properties(mkcal-qt5 PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION})

add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden)
add_definitions(-DMKCALPLUGINDIR="${CMAKE_INSTALL_LIBDIR}/mkcalplugins")

# Install the library
install(TARGETS mkcal-qt5
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

# Install headers
install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mkcal-qt5
COMPONENT Devel)

ecm_generate_pkgconfig_file(
BASE_NAME libmkcal-qt5
LIB_NAME mkcal-qt5
INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/mkcal-qt5
DESCRIPTION ${PROJECT_DESCRIPTION}
INSTALL)
61 changes: 0 additions & 61 deletions src/src.pro

This file was deleted.

25 changes: 25 additions & 0 deletions tests/CMakeLists.txt
@@ -0,0 +1,25 @@
set(SRC
tst_storage.cpp)
set(HEADERS
tst_storage.h)

add_executable(tst_storage ${SRC} ${HEADERS})

target_include_directories(tst_storage PRIVATE ${PROJECT_SOURCE_DIR}/src)

target_link_libraries(tst_storage
Qt5::DBus
Qt5::Test
KF5::CalendarCore
PkgConfig::SQLITE3
PkgConfig::TIMED
mkcal-qt5)

add_test(tst_storage tst_storage)

if(INSTALL_TESTS)
install(TARGETS tst_storage
DESTINATION /opt/tests/mkcal)
install(FILES tests.xml
DESTINATION /opt/tests/mkcal)
endif()
27 changes: 0 additions & 27 deletions tests/tests.pro

This file was deleted.

1 change: 1 addition & 0 deletions tools/CMakeLists.txt
@@ -0,0 +1 @@
add_subdirectory(mkcaltool)

0 comments on commit 40f1205

Please sign in to comment.