aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-04-13 12:36:03 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-04-13 14:44:04 +0900
commitb68186efc5fcedad6980686c8a07bab3b47a874d (patch)
tree1aaf5de974996279ec7e82af199d65fc5a187a48 /CMakeLists.txt
parent44764f015f25db307811f2969c117b37133fc676 (diff)
parent7ca442a432994a19a86d43c917a1f537bcebb387 (diff)
downloadlibquotient-b68186efc5fcedad6980686c8a07bab3b47a874d.tar.gz
libquotient-b68186efc5fcedad6980686c8a07bab3b47a874d.zip
Merge branch 'master' into kitsune-gtad
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt141
1 files changed, 100 insertions, 41 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e5b191e..29171e7e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,9 +3,10 @@ cmake_minimum_required(VERSION 3.1)
project(qmatrixclient 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)
@@ -18,6 +19,18 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"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)
@@ -27,7 +40,7 @@ foreach (FLAG all "" pedantic extra error=return-type no-unused-parameter no-gnu
endif ()
endforeach ()
-find_package(Qt5 5.6 REQUIRED Network Gui)
+find_package(Qt5 5.5.1 REQUIRED Network Gui)
get_filename_component(Qt5_Prefix "${Qt5_DIR}/../../../.." ABSOLUTE)
message( STATUS )
@@ -49,33 +62,33 @@ message( STATUS )
# Set up source files
set(libqmatrixclient_SRCS
- networkaccessmanager.cpp
- connectiondata.cpp
- connection.cpp
- logging.cpp
- room.cpp
- user.cpp
- avatar.cpp
- settings.cpp
- networksettings.cpp
- events/event.cpp
- events/eventcontent.cpp
- events/roommessageevent.cpp
- events/roommemberevent.cpp
- events/roomavatarevent.cpp
- events/typingevent.cpp
- events/receiptevent.cpp
- events/directchatevent.cpp
- jobs/requestdata.cpp
- jobs/basejob.cpp
- jobs/checkauthmethods.cpp
- jobs/sendeventjob.cpp
- jobs/setroomstatejob.cpp
- jobs/joinroomjob.cpp
- jobs/roommessagesjob.cpp
- jobs/syncjob.cpp
- jobs/mediathumbnailjob.cpp
- jobs/downloadfilejob.cpp
+ lib/networkaccessmanager.cpp
+ lib/connectiondata.cpp
+ lib/connection.cpp
+ lib/logging.cpp
+ lib/room.cpp
+ lib/user.cpp
+ lib/avatar.cpp
+ lib/settings.cpp
+ lib/networksettings.cpp
+ lib/events/event.cpp
+ lib/events/eventcontent.cpp
+ lib/events/roommessageevent.cpp
+ lib/events/roommemberevent.cpp
+ lib/events/roomavatarevent.cpp
+ lib/events/typingevent.cpp
+ lib/events/receiptevent.cpp
+ lib/events/directchatevent.cpp
+ lib/jobs/requestdata.cpp
+ lib/jobs/basejob.cpp
+ lib/jobs/checkauthmethods.cpp
+ lib/jobs/sendeventjob.cpp
+ lib/jobs/setroomstatejob.cpp
+ lib/jobs/joinroomjob.cpp
+ lib/jobs/roommessagesjob.cpp
+ lib/jobs/syncjob.cpp
+ lib/jobs/mediathumbnailjob.cpp
+ lib/jobs/downloadfilejob.cpp
)
set(API_DEF_PATH ${MATRIX_DOC_PATH}/api/client-server/)
@@ -95,27 +108,73 @@ if (MATRIX_DOC_PATH AND GTAD_PATH)
notifications.yaml- peeking_events.yaml-
pushrules.yaml- rooms.yaml- search.yaml-
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
- SOURCES jobs/gtad.yaml
- jobs/{{base}}.h.mustache jobs/{{base}}.cpp.mustache
+ SOURCES lib/jobs/gtad.yaml
+ lib/jobs/{{base}}.h.mustache lib/jobs/{{base}}.cpp.mustache
${API_DEFS}
VERBATIM
)
endif()
-aux_source_directory(jobs/generated libqmatrixclient_job_SRCS)
+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_link_libraries(qmatrixclient Qt5::Core Qt5::Network Qt5::Gui)
+add_library(QMatrixClient ${libqmatrixclient_SRCS} ${libqmatrixclient_job_SRCS})
+set(API_VERSION "0.2")
+set_property(TARGET QMatrixClient PROPERTY VERSION "${API_VERSION}.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_link_libraries(QMatrixClient Qt5::Core Qt5::Network Qt5::Gui)
add_executable(qmc-example ${example_SRCS})
-target_link_libraries(qmc-example Qt5::Core qmatrixclient)
+target_link_libraries(qmc-example Qt5::Core QMatrixClient)
+
+# Installation
+
+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(PACKAGE QMatrixClient)
+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}
+)
+# Only available from CMake 3.7; reserved for future use
+#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})