Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] launcherlib: Fix "different visibility" warning including GenerateExportHeader #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Base/ctkAppLauncherSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <QObject>
#include <QHash>

// CTK includes
#include "CTKAppLauncherLibExport.h"

class ctkAppLauncherSettingsPrivate;

///
Expand Down Expand Up @@ -129,7 +132,7 @@ class ctkAppLauncherSettingsPrivate;
/// qDebug() << appLauncherSettings.envVars().value("FOO");
/// \endcode
///
class ctkAppLauncherSettings : public QObject
class CTKAPPLAUNCHERLIB_EXPORT ctkAppLauncherSettings : public QObject
{
Q_OBJECT
public:
Expand Down
15 changes: 11 additions & 4 deletions Base/ctkSettingsHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,30 @@
#include <QHash>
#include <QString>

// CTK includes
#include "CTKAppLauncherLibExport.h"

class QSettings;
class QStringList;

namespace ctk {

/// Read list of value stored in an array into a QStringList
QStringList readArrayValues(QSettings& settings, const QString& arrayName, const QString fieldName);
QStringList CTKAPPLAUNCHERLIB_EXPORT readArrayValues(
QSettings& settings, const QString& arrayName, const QString fieldName);

/// Read list of value stored in a group into a QHash<QString, QString>
QHash<QString, QString> readKeyValuePairs(QSettings& settings, const QString& groupName);
QHash<QString, QString> CTKAPPLAUNCHERLIB_EXPORT readKeyValuePairs(
QSettings& settings, const QString& groupName);

/// Write QStringList
void writeArrayValues(QSettings& settings, const QStringList& values,
void CTKAPPLAUNCHERLIB_EXPORT writeArrayValues(
QSettings& settings, const QStringList& values,
const QString& arrayName, const QString fieldName);

/// Write QHash<QString, QString>
void writeKeyValuePairs(QSettings& settings,
void CTKAPPLAUNCHERLIB_EXPORT writeKeyValuePairs(
QSettings& settings,
const QHash<QString, QString>& map, const QString& groupName);

} // end of ctk namespace
Expand Down
35 changes: 11 additions & 24 deletions CMake/ctkMacroBuildLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@
#
###########################################################################

#
# Depends on:
# <SOURCE>/CMake/ctkMacroParseArguments.cmake
#
include(GenerateExportHeader)

macro(ctkMacroBuildLib)
set(prefix ${PROJECT_NAME})
if(prefix STREQUAL "")
message(SEND_ERROR "prefix should NOT be empty !")
endif()
set(options)
set(oneValueArgs NAME EXPORT_DIRECTIVE LIBRARY_TYPE LABEL)
set(oneValueArgs NAME LIBRARY_TYPE LABEL)
set(multiValueArgs
SRCS
MOC_SRCS
Expand All @@ -51,30 +48,11 @@ macro(ctkMacroBuildLib)
if(NOT DEFINED ${prefix}_LABEL)
set(${prefix}_LABEL ${${prefix}_NAME})
endif()
if(NOT DEFINED ${prefix}_EXPORT_DIRECTIVE)
if(${prefix}_LIBRARY_TYPE STREQUAL "SHARED")
message(SEND_ERROR "EXPORT_DIRECTIVE is mandatory")
endif()
endif()

# Define library name
set(lib_name ${${prefix}_NAME})

# --------------------------------------------------------------------------
set(dynamicHeaders)
if(${prefix}_LIBRARY_TYPE STREQUAL "SHARED")
set(MY_LIBRARY_EXPORT_DIRECTIVE ${${prefix}_EXPORT_DIRECTIVE})
set(MY_EXPORT_HEADER_PREFIX ${${prefix}_NAME})
set(MY_LIBNAME ${lib_name})

configure_file(
${CTK_SOURCE_DIR}/Libs/CTKExport.h.in
${CMAKE_CURRENT_BINARY_DIR}/${MY_EXPORT_HEADER_PREFIX}Export.h
)
set(dynamicHeaders
"${dynamicHeaders};${CMAKE_CURRENT_BINARY_DIR}/${MY_EXPORT_HEADER_PREFIX}Export.h")
endif()

# Make sure variable are cleared
set(${prefix}_MOC_CXX)
set(${prefix}_UI_CXX)
Expand Down Expand Up @@ -130,6 +108,15 @@ macro(ctkMacroBuildLib)
)
endforeach()

# Export header
generate_export_header(${lib_name}
BASE_NAME ${lib_name}
EXPORT_FILE_NAME ${lib_name}Export.h
)
set(dynamicHeaders
${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Export.h
)

# Install headers
if(CTKAppLauncher_INSTALL_LauncherLibrary)
file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
Expand Down