Fixed export header for static/shared build.

This commit is contained in:
Vincent Richard 2013-05-13 11:16:31 +02:00
parent 1a53602555
commit 993f3bf56d
3 changed files with 57 additions and 9 deletions

3
.gitignore vendored
View File

@ -25,7 +25,8 @@ doc/html/*
/libvmime.a /libvmime.a
/vmime.pc /vmime.pc
/vmime/config.hpp /vmime/config.hpp
/vmime/export.hpp /vmime/export-static.hpp
/vmime/export-shared.hpp
/COPYING.txt /COPYING.txt
/build/ /build/

View File

@ -78,13 +78,15 @@ FILE(
vmime/* vmime/*
) )
LIST(APPEND VMIME_LIBRARY_GENERATED_INCLUDE_FILES "vmime/config.hpp") LIST(APPEND VMIME_LIBRARY_INCLUDE_FILES "vmime/config.hpp")
LIST(APPEND VMIME_LIBRARY_GENERATED_INCLUDE_FILES "vmime/export.hpp")
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
) )
INCLUDE(GenerateExportHeader)
ADD_COMPILER_EXPORT_FLAGS()
# Shared library # Shared library
OPTION( OPTION(
VMIME_BUILD_SHARED_LIBRARY VMIME_BUILD_SHARED_LIBRARY
@ -94,10 +96,6 @@ OPTION(
IF(VMIME_BUILD_SHARED_LIBRARY) IF(VMIME_BUILD_SHARED_LIBRARY)
INCLUDE(GenerateExportHeader)
ADD_COMPILER_EXPORT_FLAGS()
ADD_LIBRARY( ADD_LIBRARY(
${VMIME_LIBRARY_NAME} ${VMIME_LIBRARY_NAME}
SHARED SHARED
@ -108,14 +106,18 @@ IF(VMIME_BUILD_SHARED_LIBRARY)
GENERATE_EXPORT_HEADER( GENERATE_EXPORT_HEADER(
${VMIME_LIBRARY_NAME} ${VMIME_LIBRARY_NAME}
BASE_NAME VMIME BASE_NAME VMIME
EXPORT_FILE_NAME ${CMAKE_SOURCE_DIR}/vmime/export.hpp STATIC_DEFINE VMIME_STATIC
EXPORT_FILE_NAME ${CMAKE_SOURCE_DIR}/vmime/export-shared.hpp
) )
LIST(APPEND VMIME_LIBRARY_INCLUDE_FILES "vmime/export-shared.hpp")
SET_TARGET_PROPERTIES( SET_TARGET_PROPERTIES(
${VMIME_LIBRARY_NAME} ${VMIME_LIBRARY_NAME}
PROPERTIES PROPERTIES
VERSION "${VMIME_API_VERSION}" VERSION "${VMIME_API_VERSION}"
SOVERSION "${VMIME_API_VERSION_CURRENT}" SOVERSION "${VMIME_API_VERSION_CURRENT}"
COMPILE_FLAGS -DVMIME_SHARED
) )
ENDIF() ENDIF()
@ -139,11 +141,20 @@ IF(VMIME_BUILD_STATIC_LIBRARY)
${VMIME_LIBRARY_INCLUDE_FILES} ${VMIME_LIBRARY_INCLUDE_FILES}
) )
GENERATE_EXPORT_HEADER(
${VMIME_LIBRARY_NAME}-static
BASE_NAME VMIME
STATIC_DEFINE VMIME_STATIC
EXPORT_FILE_NAME ${CMAKE_SOURCE_DIR}/vmime/export-static.hpp
)
LIST(APPEND VMIME_LIBRARY_INCLUDE_FILES "vmime/export-static.hpp")
SET_TARGET_PROPERTIES( SET_TARGET_PROPERTIES(
${VMIME_LIBRARY_NAME}-static ${VMIME_LIBRARY_NAME}-static
PROPERTIES PROPERTIES
OUTPUT_NAME ${VMIME_LIBRARY_NAME} OUTPUT_NAME ${VMIME_LIBRARY_NAME}
COMPILE_FLAGS -DVMIME_STATIC_DEFINE COMPILE_FLAGS -DVMIME_STATIC
) )
ENDIF() ENDIF()

36
vmime/export.hpp Normal file
View File

@ -0,0 +1,36 @@
//
// VMime library (http://www.vmime.org)
// Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 3 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Linking this library statically or dynamically with other modules is making
// a combined work based on this library. Thus, the terms and conditions of
// the GNU General Public License cover the whole combination.
//
#ifndef VMIME_EXPORT_HPP_INCLUDED
#define VMIME_EXPORT_HPP_INCLUDED
// Define VMIME_STATIC if you are linking with the static library
#ifdef VMIME_STATIC
# include "vmime/export-static.hpp"
#else
# include "vmime/export-shared.hpp"
#endif
#endif // VMIME_EXPORT_HPP_INCLUDED