Skip to content

Commit

Permalink
launcherlib: Fix "different visibility" warning including GenerateExp…
Browse files Browse the repository at this point in the history
…ortHeader

This commit is an attempt to "different visibility" warning [1]. By including
"GenerateExportHeader" header, it automatically run the try_compile checking
if compiler support "visibility" flags and set option "USE_COMPILER_HIDDEN_VISIBILITY"
to ON if it makes sense.

[...]
-- Checking to see if CXX compiler accepts flag -fvisibility=hidden
-- Checking to see if CXX compiler accepts flag -fvisibility=hidden - yes
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
[...]

[1] Slicer/Slicer#727 (comment)
  • Loading branch information
jcfr committed May 25, 2017
1 parent 714ef57 commit 53935a2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 29 deletions.
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

0 comments on commit 53935a2

Please sign in to comment.