From ff4d2948c17b04052983825cf27e8212f995ae5c Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Thu, 23 Mar 2017 21:07:58 +0100 Subject: [PATCH 1/4] Implement the use of the generate_export_header cmake macro --- include/console_bridge/exportdecl.h | 84 ----------------------------- 1 file changed, 84 deletions(-) delete mode 100644 include/console_bridge/exportdecl.h diff --git a/include/console_bridge/exportdecl.h b/include/console_bridge/exportdecl.h deleted file mode 100644 index 594b8cc..0000000 --- a/include/console_bridge/exportdecl.h +++ /dev/null @@ -1,84 +0,0 @@ -/********************************************************************* -* Software License Agreement (BSD License) -* -* Copyright (c) 2008, Willow Garage, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of the Willow Garage nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -*********************************************************************/ - -/* Author: Thomas Moulard */ - -#ifndef CONSOLE_BRIDGE_EXPORTDECL_H -# define CONSOLE_BRIDGE_EXPORTDECL_H - -// Handle portable symbol export. -// Defining manually which symbol should be exported is required -// under Windows whether MinGW or MSVC is used. -// -// The headers then have to be able to work in two different modes: -// - dllexport when one is building the library, -// - dllimport for clients using the library. -// -// On Linux, set the visibility accordingly. If C++ symbol visibility -// is handled by the compiler, see: http://gcc.gnu.org/wiki/Visibility -# if defined _WIN32 || defined __CYGWIN__ -// On Microsoft Windows, use dllimport and dllexport to tag symbols. -# define CONSOLE_BRIDGE_DLLIMPORT __declspec(dllimport) -# define CONSOLE_BRIDGE_DLLEXPORT __declspec(dllexport) -# define CONSOLE_BRIDGE_DLLLOCAL -# else -// On Linux, for GCC >= 4, tag symbols using GCC extension. -# if __GNUC__ >= 4 -# define CONSOLE_BRIDGE_DLLIMPORT __attribute__ ((visibility("default"))) -# define CONSOLE_BRIDGE_DLLEXPORT __attribute__ ((visibility("default"))) -# define CONSOLE_BRIDGE_DLLLOCAL __attribute__ ((visibility("hidden"))) -# else -// Otherwise (GCC < 4 or another compiler is used), export everything. -# define CONSOLE_BRIDGE_DLLIMPORT -# define CONSOLE_BRIDGE_DLLEXPORT -# define CONSOLE_BRIDGE_DLLLOCAL -# endif // __GNUC__ >= 4 -# endif // defined _WIN32 || defined __CYGWIN__ - -# ifdef CONSOLE_BRIDGE_STATIC -// If one is using the library statically, get rid of -// extra information. -# define CONSOLE_BRIDGE_DLLAPI -# define CONSOLE_BRIDGE_LOCAL -# else -// Depending on whether one is building or using the -// library define DLLAPI to import or export. -# ifdef console_bridge_EXPORTS -# define CONSOLE_BRIDGE_DLLAPI CONSOLE_BRIDGE_DLLEXPORT -# else -# define CONSOLE_BRIDGE_DLLAPI CONSOLE_BRIDGE_DLLIMPORT -# endif // CONSOLE_BRIDGE_EXPORTS -# define CONSOLE_BRIDGE_LOCAL CONSOLE_BRIDGE_DLLLOCAL -# endif // CONSOLE_BRIDGE_STATIC -#endif //! CONSOLE_BRIDGE_EXPORTDECL_H From 8faa221742e6789b43f1833d0a45d331f43c866d Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Thu, 23 Mar 2017 21:19:25 +0100 Subject: [PATCH 2/4] Changes in build system and header file --- CMakeLists.txt | 5 ++++- include/console_bridge/console.h | 11 +---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d64bd17..b603e8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ set (CONSOLE_BRIDGE_VERSION ${CONSOLE_BRIDGE_MAJOR_VERSION}.${CONSOLE_BRIDGE_MIN message (STATUS "${PROJECT_NAME} version ${CONSOLE_BRIDGE_VERSION}") include(GNUInstallDirs) +include(GenerateExportHeader) if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) @@ -33,7 +34,7 @@ if(MSVC OR MSVC90 OR MSVC10) set(MSVC ON) endif (MSVC OR MSVC90 OR MSVC10) -include_directories(include) +include_directories(include ${PROJECT_BINARY_DIR}) if(NOT DEFINED BUILD_SHARED_LIBS) option(BUILD_SHARED_LIBS "Build dynamically-linked binaries" ON) @@ -47,6 +48,8 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}" add_library(${PROJECT_NAME} src/console.cpp) set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${CONSOLE_BRIDGE_MAJOR_VERSION}.${CONSOLE_BRIDGE_MINOR_VERSION}) +generate_export_header(${PROJECT_NAME} + EXPORT_MACRO_NAME CONSOLE_BRIDGE_DLLAPI) install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/include/console_bridge/console.h b/include/console_bridge/console.h index 40be25e..f72a211 100644 --- a/include/console_bridge/console.h +++ b/include/console_bridge/console.h @@ -39,16 +39,7 @@ #include -#include "exportdecl.h" - -#ifdef __GNUC__ -#define CONSOLE_BRIDGE_DEPRECATED __attribute__ ((deprecated)) -#elif defined(_MSC_VER) -#define CONSOLE_BRIDGE_DEPRECATED __declspec(deprecated) -#else -#pragma message("WARNING: You need to implement DEPRECATED for this compiler") -#define CONSOLE_BRIDGE_DEPRECATED -#endif +#include "console_bridge_export.h" static inline void CONSOLE_BRIDGE_DEPRECATED console_bridge_deprecated() {} From 495dec8f8faaaeb32110a098529bbe7bc24976be Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Thu, 23 Mar 2017 21:23:58 +0100 Subject: [PATCH 3/4] Include export file header in the installation --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b603e8d..bb780b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,9 @@ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h") +install(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}_export.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + set(PKG_NAME ${PROJECT_NAME}) set(PKG_LIBRARIES ${PROJECT_NAME}) set(cmake_conf_file "${PROJECT_NAME}-config.cmake") From c322c60ca6615ce272903ba545bf77e642266b19 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Wed, 29 Mar 2017 13:53:25 +0200 Subject: [PATCH 4/4] Update cmake version required --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb780b7..8cd7ea6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.6) project(console_bridge) set (CONSOLE_BRIDGE_MAJOR_VERSION 0)