Skip to content

Commit

Permalink
Use generate_export_header cmake macro (#43)
Browse files Browse the repository at this point in the history
* Implement the use of the generate_export_header cmake macro

* Changes in build system and header file

* Include export file header in the installation

* Update cmake version required
  • Loading branch information
j-rivero authored and scpeters committed Apr 7, 2017
1 parent 148df7e commit 9ef664d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 96 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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}
Expand All @@ -58,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")
Expand Down
11 changes: 1 addition & 10 deletions include/console_bridge/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,7 @@

#include <string>

#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() {}

Expand Down
84 changes: 0 additions & 84 deletions include/console_bridge/exportdecl.h

This file was deleted.

0 comments on commit 9ef664d

Please sign in to comment.