diff options
| author | Linus Jahn <lnj@kaidan.im> | 2022-12-29 19:53:26 +0100 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2022-12-29 20:48:08 +0100 |
| commit | 608fe34edb4b4d70a2ba6eca6a925f58fee52074 (patch) | |
| tree | 895e8289780b88ec37799b092f2b0ee9f9214229 /src | |
| parent | 6fcc1444b23e974a5a6731ef3081f5dfc4d581e9 (diff) | |
| download | qxmpp-608fe34edb4b4d70a2ba6eca6a925f58fee52074.tar.gz | |
cmake: Use generate_export_header() instead of doing manually
This is going to make it easier for us to maintain things. It's also
consistent with the new QXmppOmemo module.
This requires CMake 3.7 now.
Closes #523.
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 34 | ||||
| -rw-r--r-- | src/base/QXmppBuildConstants.h.in | 33 | ||||
| -rw-r--r-- | src/base/QXmppGlobal.h | 32 | ||||
| -rw-r--r-- | src/omemo/CMakeLists.txt | 2 |
4 files changed, 45 insertions, 56 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index daecf712..a73b1d5e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,8 @@ # # SPDX-License-Identifier: CC0-1.0 +include(GenerateExportHeader) + option(BUILD_SHARED "Build SHARED library" ON) add_definitions(-DQXMPP_BUILD) @@ -10,18 +12,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/base) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/client) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/server) -# Configure QXmppBuildConstants.h.in -if(BUILD_SHARED) - set(QXMPP_BUILD_SHARED true) -else() - set(QXMPP_BUILD_SHARED false) -endif() -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/base/QXmppBuildConstants.h.in ${CMAKE_CURRENT_BINARY_DIR}/base/QXmppBuildConstants.h @ONLY) -include_directories(${CMAKE_CURRENT_BINARY_DIR}/base) - set(INSTALL_HEADER_FILES - ${CMAKE_CURRENT_BINARY_DIR}/base/QXmppBuildConstants.h - # Base base/QXmppArchiveIq.h base/QXmppBindIq.h @@ -317,6 +308,23 @@ set_target_properties(qxmpp PROPERTIES EXPORT_NAME QXmpp ) +if(BUILD_SHARED) + set(QXMPP_BUILD_SHARED true) +else() + set(QXMPP_BUILD_SHARED false) +endif() + +set(QXMPP_CUSTOM_EXPORT_CONTENT " +#define QXMPP_BUILD_SHARED ${QXMPP_BUILD_SHARED} +#define QXMPP_VERSION_MAJOR ${PROJECT_VERSION_MAJOR} +#define QXMPP_VERSION_MINOR ${PROJECT_VERSION_MINOR} +#define QXMPP_VERSION_PATCH ${PROJECT_VERSION_PATCH} +") + +generate_export_header(qxmpp + CUSTOM_CONTENT_FROM_VARIABLE QXMPP_CUSTOM_EXPORT_CONTENT +) + target_include_directories(qxmpp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/base> @@ -327,6 +335,8 @@ target_include_directories(qxmpp ${GLIB2_INCLUDE_DIR} ${GOBJECT_INCLUDE_DIR} ${GSTREAMER_INCLUDE_DIRS} + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} ) target_link_libraries(qxmpp @@ -372,7 +382,7 @@ export( ) install( - FILES ${INSTALL_HEADER_FILES} + FILES ${INSTALL_HEADER_FILES} ${CMAKE_CURRENT_BINARY_DIR}/qxmpp_export.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qxmpp" ) diff --git a/src/base/QXmppBuildConstants.h.in b/src/base/QXmppBuildConstants.h.in deleted file mode 100644 index 787752da..00000000 --- a/src/base/QXmppBuildConstants.h.in +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-FileCopyrightText: 2010 Manjeet Dahiya <manjeetdahiya@gmail.com> -// SPDX-FileCopyrightText: 2017 Niels Ole Salscheider <niels_ole@salscheider-online.de> -// SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im> -// -// SPDX-License-Identifier: LGPL-2.1-or-later - -#ifndef QXMPPBUILDCONSTANTS_H -#define QXMPPBUILDCONSTANTS_H - -#include <QString> - -#define QXMPP_BUILD_SHARED @QXMPP_BUILD_SHARED@ - -/// -/// This macro expands a numeric value of the form 0xMMNNPP (MM = -/// major, NN = minor, PP = patch) that specifies QXmpp's version -/// number. For example, if you compile your application against -/// QXmpp 1.2.3, the QXMPP_VERSION macro will expand to 0x010203. -/// -/// You can use QXMPP_VERSION to use the latest QXmpp features where -/// available. -/// -#define QXMPP_VERSION QT_VERSION_CHECK(@PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@) - -/// -/// Returns the version of QXmpp used at compile time as a string. -/// -inline QLatin1String QXmppVersion() -{ - return QLatin1String("@PROJECT_VERSION@"); -} - -#endif // QXMPPBUILDCONSTANTS_H diff --git a/src/base/QXmppGlobal.h b/src/base/QXmppGlobal.h index 95867a2c..74f2b599 100644 --- a/src/base/QXmppGlobal.h +++ b/src/base/QXmppGlobal.h @@ -8,20 +8,32 @@ #ifndef QXMPPGLOBAL_H #define QXMPPGLOBAL_H -#include "QXmppBuildConstants.h" +#include "qxmpp_export.h" -#if QXMPP_BUILD_SHARED -#if defined(QXMPP_BUILD) -#define QXMPP_EXPORT Q_DECL_EXPORT -#else -#define QXMPP_EXPORT Q_DECL_IMPORT -#endif -#else -#define QXMPP_EXPORT -#endif +#include <QString> #define QXMPP_AUTOTEST_EXPORT +/// +/// This macro expands a numeric value of the form 0xMMNNPP (MM = +/// major, NN = minor, PP = patch) that specifies QXmpp's version +/// number. For example, if you compile your application against +/// QXmpp 1.2.3, the QXMPP_VERSION macro will expand to 0x010203. +/// +/// You can use QXMPP_VERSION to use the latest QXmpp features where +/// available. +/// +#define QXMPP_VERSION QT_VERSION_CHECK(QXMPP_VERSION_MAJOR, QXMPP_VERSION_MINOR, QXMPP_VERSION_PATCH) + +/// +/// Returns the version of QXmpp used at compile time as a string. +/// +inline QLatin1String QXmppVersion() +{ + return QLatin1String( + QT_STRINGIFY(QXMPP_VERSION_MAJOR) "." QT_STRINGIFY(QXMPP_VERSION_MINOR) "." QT_STRINGIFY(QXMPP_VERSION_PATCH)); +} + // This sets which deprecated functions should still be usable // It works exactly like QT_DISABLE_DEPRECATED_BEFORE #ifndef QXMPP_DISABLE_DEPRECATED_BEFORE diff --git a/src/omemo/CMakeLists.txt b/src/omemo/CMakeLists.txt index 3c6e403e..0ec3c0f0 100644 --- a/src/omemo/CMakeLists.txt +++ b/src/omemo/CMakeLists.txt @@ -3,7 +3,6 @@ # SPDX-License-Identifier: CC0-1.0 include(CMakePackageConfigHelpers) -include(GenerateExportHeader) set(OMEMO_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/QXmppOmemo") set(OMEMO_HEADER_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/qxmpp/omemo") @@ -37,6 +36,7 @@ target_include_directories(QXmppOmemo PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_BINARY_DIR} + ${PROJECT_BINARY_DIR}/src ) generate_export_header(QXmppOmemo) |
