aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml13
-rw-r--r--CMakeLists.txt73
-rw-r--r--cmake/QMatrixClientConfig.cmake1
-rw-r--r--examples/CMakeLists.txt69
-rw-r--r--libqmatrixclient.pri131
5 files changed, 192 insertions, 95 deletions
diff --git a/.travis.yml b/.travis.yml
index c0008af0..45db175a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,15 +25,20 @@ before_install:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then VALGRIND="valgrind $VALGRIND_OPTIONS"; . /opt/qt56/bin/qt56-env.sh; fi
script:
-- mkdir build && cd build
+# Build and install with CMake
+- mkdir build && pushd build
- cmake -DCMAKE_INSTALL_PREFIX=../install ..
- cmake --build . --target all
- cmake --build . --target install
-- cd ../examples
-- $CC qmc-example.cpp -I../install/include -l../install/lib/libqmatrixclient.a -o qmc-example-lib-installed
-- cd ..
+# Build qmc-example with the installed library
+- popd && mkdir build-example && pushd build-example
+- cmake -DCMAKE_PREFIX_PATH=../install ../examples
+- cmake --build . --target all
+- popd
+# Build and install with qmake
- qmake qmc-example.pro "CONFIG += debug" "CONFIG -= app_bundle" "QMAKE_CC = $CC" "QMAKE_CXX = $CXX"
- make all
+# Run the qmake-compiled qmc-example under valgrind
- if [ "$QMC_TEST_USER" != "" ]; then $VALGRIND ./qmc-example "$QMC_TEST_USER" "$QMC_TEST_PWD" qmc-example-travis '#qmc-test:matrix.org' "Travis CI job $TRAVIS_JOB_NUMBER"; fi
notifications:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aca82c49..956c9a1f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,8 +7,6 @@ if (NOT WIN32)
include(GNUInstallDirs)
endif(NOT WIN32)
-# Find includes in corresponding build directories
-#set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
@@ -92,38 +90,61 @@ aux_source_directory(lib/jobs/generated libqmatrixclient_job_SRCS)
set(example_SRCS examples/qmc-example.cpp)
-add_library(qmatrixclient ${libqmatrixclient_SRCS} ${libqmatrixclient_job_SRCS})
-set_property(TARGET qmatrixclient PROPERTY VERSION "0.2.0")
-set_property(TARGET qmatrixclient PROPERTY SOVERSION 0 )
-
-target_include_directories(qmatrixclient PUBLIC
- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib>
- $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+add_library(QMatrixClient ${libqmatrixclient_SRCS} ${libqmatrixclient_job_SRCS})
+set(API_VERSION 2)
+set_property(TARGET QMatrixClient PROPERTY VERSION "0.2.0")
+set_property(TARGET QMatrixClient PROPERTY SOVERSION 0 )
+set_property(TARGET QMatrixClient PROPERTY
+ INTERFACE_QMatrixClient_MAJOR_VERSION ${API_VERSION})
+set_property(TARGET QMatrixClient APPEND PROPERTY
+ COMPATIBLE_INTERFACE_STRING QMatrixClient_MAJOR_VERSION)
+
+target_include_directories(QMatrixClient PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
-target_include_directories(qmatrixclient PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lib)
-target_link_libraries(qmatrixclient Qt5::Core Qt5::Network Qt5::Gui)
+target_link_libraries(QMatrixClient Qt5::Core Qt5::Network Qt5::Gui)
add_executable(qmc-example ${example_SRCS})
-target_include_directories(qmc-example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lib)
-target_link_libraries(qmc-example Qt5::Core qmatrixclient)
+target_link_libraries(qmc-example Qt5::Core QMatrixClient)
# Installation
-install (TARGETS qmatrixclient EXPORT QMatrixClient
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-install (DIRECTORY lib/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
- FILES_MATCHING PATTERN "*.h")
-
-install (TARGETS qmc-example RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+install(TARGETS QMatrixClient EXPORT QMatrixClientTargets
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+)
+install(DIRECTORY lib/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ FILES_MATCHING PATTERN "*.h")
+
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/QMatrixClient/QMatrixClientConfigVersion.cmake"
+ VERSION ${API_VERSION}
+ COMPATIBILITY AnyNewerVersion
+)
-#export(TARGETS qmatrixclient FILE QMatrixClientConfig.cmake EXPORT_LINK_INTERFACE_LIBRARIES)
-export(EXPORT QMatrixClient)
export(PACKAGE QMatrixClient)
-install (EXPORT QMatrixClient DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
+export(EXPORT QMatrixClientTargets
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/QMatrixClient/QMatrixClientTargets.cmake")
+configure_file(cmake/QMatrixClientConfig.cmake
+ "${CMAKE_CURRENT_BINARY_DIR}/QMatrixClient/QMatrixClientConfig.cmake"
+ COPYONLY
+)
+
+set(ConfigFilesLocation "${CMAKE_INSTALL_LIBDIR}/cmake/QMatrixClient")
+install(EXPORT QMatrixClientTargets
+ FILE QMatrixClientTargets.cmake DESTINATION ${ConfigFilesLocation})
+
+install(FILES cmake/QMatrixClientConfig.cmake
+ "${CMAKE_CURRENT_BINARY_DIR}/QMatrixClient/QMatrixClientConfigVersion.cmake"
+ DESTINATION ${ConfigFilesLocation}
+)
+install(EXPORT_ANDROID_MK QMatrixClientTargets DESTINATION share/ndk-modules)
if (WIN32)
- install (FILES mime/packages/freedesktop.org.xml
- DESTINATION mime/packages)
+ install(FILES mime/packages/freedesktop.org.xml DESTINATION mime/packages)
endif (WIN32)
+
+install(TARGETS qmc-example RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cmake/QMatrixClientConfig.cmake b/cmake/QMatrixClientConfig.cmake
new file mode 100644
index 00000000..900038a5
--- /dev/null
+++ b/cmake/QMatrixClientConfig.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/QMatrixClientTargets.cmake")
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 00000000..49e0089a
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,69 @@
+cmake_minimum_required(VERSION 3.1)
+
+# This CMakeLists file assumes that the library is installed to CMAKE_INSTALL_PREFIX
+# and ignores the in-tree library code. You can use this to start work on your own client.
+
+project(qmc-example CXX)
+
+include(CheckCXXCompilerFlag)
+if (NOT WIN32)
+ include(GNUInstallDirs)
+endif(NOT WIN32)
+
+# Find includes in corresponding build directories
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+# Instruct CMake to run moc automatically when needed.
+set(CMAKE_AUTOMOC ON)
+
+# Set a default build type if none was specified
+if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+ message(STATUS "Setting build type to 'Debug' as none was specified")
+ set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build" FORCE)
+ # Set the possible values of build type for cmake-gui
+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
+ "MinSizeRel" "RelWithDebInfo")
+endif()
+
+if (NOT CMAKE_INSTALL_LIBDIR)
+ set(CMAKE_INSTALL_LIBDIR ".")
+endif()
+
+if (NOT CMAKE_INSTALL_BINDIR)
+ set(CMAKE_INSTALL_BINDIR ".")
+endif()
+
+if (NOT CMAKE_INSTALL_INCLUDEDIR)
+ set(CMAKE_INSTALL_INCLUDEDIR "include")
+endif()
+
+set(CMAKE_CXX_STANDARD 14)
+
+foreach (FLAG all "" pedantic extra error=return-type no-unused-parameter no-gnu-zero-variadic-macro-arguments)
+ CHECK_CXX_COMPILER_FLAG("-W${FLAG}" WARN_${FLAG}_SUPPORTED)
+ if ( WARN_${FLAG}_SUPPORTED AND NOT CMAKE_CXX_FLAGS MATCHES "(^| )-W?${FLAG}($| )")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W${FLAG}")
+ endif ()
+endforeach ()
+
+find_package(Qt5 5.6 REQUIRED Network Gui)
+get_filename_component(Qt5_Prefix "${Qt5_DIR}/../../../.." ABSOLUTE)
+
+find_package(QMatrixClient REQUIRED)
+get_filename_component(QMC_Prefix "${QMatrixClient_DIR}/../.." ABSOLUTE)
+
+message( STATUS "qmc-example configuration:" )
+if (CMAKE_BUILD_TYPE)
+ message( STATUS " Build type: ${CMAKE_BUILD_TYPE}")
+endif(CMAKE_BUILD_TYPE)
+message( STATUS " Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" )
+message( STATUS " Qt: ${Qt5_VERSION} at ${Qt5_Prefix}" )
+message( STATUS " QMatrixClient: ${QMatrixClient_VERSION} at ${QMC_Prefix}" )
+
+set(example_SRCS qmc-example.cpp)
+
+add_executable(qmc-example ${example_SRCS})
+target_link_libraries(qmc-example Qt5::Core QMatrixClient)
+
+# Installation
+
+install (TARGETS qmc-example RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/libqmatrixclient.pri b/libqmatrixclient.pri
index 646af4b1..edba623e 100644
--- a/libqmatrixclient.pri
+++ b/libqmatrixclient.pri
@@ -7,72 +7,73 @@ win32-msvc* {
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-parameter
}
-INCLUDEPATH += $$PWD/lib
+SRCPATH = $$PWD/lib
+INCLUDEPATH += $$SRCPATH
HEADERS += \
- $$PWD/lib/connectiondata.h \
- $$PWD/lib/connection.h \
- $$PWD/lib/room.h \
- $$PWD/lib/user.h \
- $$PWD/lib/avatar.h \
- $$PWD/lib/util.h \
- $$PWD/lib/events/event.h \
- $$PWD/lib/events/eventcontent.h \
- $$PWD/lib/events/roommessageevent.h \
- $$PWD/lib/events/simplestateevents.h \
- $$PWD/lib/events/roommemberevent.h \
- $$PWD/lib/events/roomavatarevent.h \
- $$PWD/lib/events/typingevent.h \
- $$PWD/lib/events/receiptevent.h \
- $$PWD/lib/events/accountdataevents.h \
- $$PWD/lib/events/directchatevent.h \
- $$PWD/lib/events/redactionevent.h \
- $$PWD/lib/jobs/requestdata.h \
- $$PWD/lib/jobs/basejob.h \
- $$PWD/lib/jobs/checkauthmethods.h \
- $$PWD/lib/jobs/passwordlogin.h \
- $$PWD/lib/jobs/sendeventjob.h \
- $$PWD/lib/jobs/postreceiptjob.h \
- $$PWD/lib/jobs/joinroomjob.h \
- $$PWD/lib/jobs/roommessagesjob.h \
- $$PWD/lib/jobs/syncjob.h \
- $$PWD/lib/jobs/mediathumbnailjob.h \
- $$PWD/lib/jobs/setroomstatejob.h \
- $$PWD/lib/jobs/downloadfilejob.h \
- $$PWD/lib/jobs/postreadmarkersjob.h \
- $$files($$PWD/lib/jobs/generated/*.h, false) \
- $$PWD/lib/logging.h \
- $$PWD/lib/settings.h \
- $$PWD/lib/networksettings.h \
- $$PWD/lib/networkaccessmanager.h
+ $$SRCPATH/connectiondata.h \
+ $$SRCPATH/connection.h \
+ $$SRCPATH/room.h \
+ $$SRCPATH/user.h \
+ $$SRCPATH/avatar.h \
+ $$SRCPATH/util.h \
+ $$SRCPATH/events/event.h \
+ $$SRCPATH/events/eventcontent.h \
+ $$SRCPATH/events/roommessageevent.h \
+ $$SRCPATH/events/simplestateevents.h \
+ $$SRCPATH/events/roommemberevent.h \
+ $$SRCPATH/events/roomavatarevent.h \
+ $$SRCPATH/events/typingevent.h \
+ $$SRCPATH/events/receiptevent.h \
+ $$SRCPATH/events/accountdataevents.h \
+ $$SRCPATH/events/directchatevent.h \
+ $$SRCPATH/events/redactionevent.h \
+ $$SRCPATH/jobs/requestdata.h \
+ $$SRCPATH/jobs/basejob.h \
+ $$SRCPATH/jobs/checkauthmethods.h \
+ $$SRCPATH/jobs/passwordlogin.h \
+ $$SRCPATH/jobs/sendeventjob.h \
+ $$SRCPATH/jobs/postreceiptjob.h \
+ $$SRCPATH/jobs/joinroomjob.h \
+ $$SRCPATH/jobs/roommessagesjob.h \
+ $$SRCPATH/jobs/syncjob.h \
+ $$SRCPATH/jobs/mediathumbnailjob.h \
+ $$SRCPATH/jobs/setroomstatejob.h \
+ $$SRCPATH/jobs/downloadfilejob.h \
+ $$SRCPATH/jobs/postreadmarkersjob.h \
+ $$files($$SRCPATH/jobs/generated/*.h, false) \
+ $$SRCPATH/logging.h \
+ $$SRCPATH/settings.h \
+ $$SRCPATH/networksettings.h \
+ $$SRCPATH/networkaccessmanager.h
SOURCES += \
- $$PWD/lib/connectiondata.cpp \
- $$PWD/lib/connection.cpp \
- $$PWD/lib/room.cpp \
- $$PWD/lib/user.cpp \
- $$PWD/lib/avatar.cpp \
- $$PWD/lib/events/event.cpp \
- $$PWD/lib/events/eventcontent.cpp \
- $$PWD/lib/events/roommessageevent.cpp \
- $$PWD/lib/events/roommemberevent.cpp \
- $$PWD/lib/events/typingevent.cpp \
- $$PWD/lib/events/receiptevent.cpp \
- $$PWD/lib/events/directchatevent.cpp \
- $$PWD/lib/jobs/requestdata.cpp \
- $$PWD/lib/jobs/basejob.cpp \
- $$PWD/lib/jobs/checkauthmethods.cpp \
- $$PWD/lib/jobs/passwordlogin.cpp \
- $$PWD/lib/jobs/sendeventjob.cpp \
- $$PWD/lib/jobs/postreceiptjob.cpp \
- $$PWD/lib/jobs/joinroomjob.cpp \
- $$PWD/lib/jobs/roommessagesjob.cpp \
- $$PWD/lib/jobs/syncjob.cpp \
- $$PWD/lib/jobs/mediathumbnailjob.cpp \
- $$PWD/lib/jobs/setroomstatejob.cpp \
- $$PWD/lib/jobs/downloadfilejob.cpp \
- $$files($$PWD/lib/jobs/generated/*.cpp, false) \
- $$PWD/lib/logging.cpp \
- $$PWD/lib/settings.cpp \
- $$PWD/lib/networksettings.cpp \
- $$PWD/lib/networkaccessmanager.cpp
+ $$SRCPATH/connectiondata.cpp \
+ $$SRCPATH/connection.cpp \
+ $$SRCPATH/room.cpp \
+ $$SRCPATH/user.cpp \
+ $$SRCPATH/avatar.cpp \
+ $$SRCPATH/events/event.cpp \
+ $$SRCPATH/events/eventcontent.cpp \
+ $$SRCPATH/events/roommessageevent.cpp \
+ $$SRCPATH/events/roommemberevent.cpp \
+ $$SRCPATH/events/typingevent.cpp \
+ $$SRCPATH/events/receiptevent.cpp \
+ $$SRCPATH/events/directchatevent.cpp \
+ $$SRCPATH/jobs/requestdata.cpp \
+ $$SRCPATH/jobs/basejob.cpp \
+ $$SRCPATH/jobs/checkauthmethods.cpp \
+ $$SRCPATH/jobs/passwordlogin.cpp \
+ $$SRCPATH/jobs/sendeventjob.cpp \
+ $$SRCPATH/jobs/postreceiptjob.cpp \
+ $$SRCPATH/jobs/joinroomjob.cpp \
+ $$SRCPATH/jobs/roommessagesjob.cpp \
+ $$SRCPATH/jobs/syncjob.cpp \
+ $$SRCPATH/jobs/mediathumbnailjob.cpp \
+ $$SRCPATH/jobs/setroomstatejob.cpp \
+ $$SRCPATH/jobs/downloadfilejob.cpp \
+ $$files($$SRCPATH/jobs/generated/*.cpp, false) \
+ $$SRCPATH/logging.cpp \
+ $$SRCPATH/settings.cpp \
+ $$SRCPATH/networksettings.cpp \
+ $$SRCPATH/networkaccessmanager.cpp