improved build when compiling shared libraries

This commit is contained in:
Ende! 2015-03-16 17:58:07 +01:00
parent c912af00f9
commit f845185fa1
2 changed files with 14 additions and 17 deletions

View File

@ -1,8 +1,9 @@
cmake_minimum_required(VERSION 2.8.12)
include(GenerateExportHeader)
project(VerteronDisassemblerEngine)
option(BUILD_SHARED "Build shared libraries rather than static ones" FALSE)
option(BUILD_SHARED_LIBS "Build shared libraries rather than static ones" FALSE)
option(BUILD_EXAMPLES "Build examples" TRUE)
option(BUILD_CPP_BINDINGS "Build C++ bindings" TRUE)
@ -38,12 +39,12 @@ set(vde_sources
"VerteronDisassemblerEngine/VXOpcodeTable.c"
"VerteronDisassemblerEngine/VXInstructionDecoder.c")
#if (BUILD_SHARED)
# add_definitions("-DVX_BUILD_SHARED")
# add_library("VerteronDisassemblerEngine" SHARED ${vde_headers} ${vde_sources})
#else ()
add_library("VerteronDisassemblerEngine" STATIC ${vde_headers} ${vde_sources})
#endif ()
add_library("VerteronDisassemblerEngine" ${vde_headers} ${vde_sources})
generate_export_header(
"VerteronDisassemblerEngine"
BASE_NAME "VX"
EXPORT_FILE_NAME "VXExportConfig.h")
include_directories(${PROJECT_BINARY_DIR})
# C++ bindings
if (BUILD_CPP_BINDINGS)

View File

@ -30,6 +30,12 @@
**************************************************************************************************/
/*
* Include CMake generated header defining macros im-/exporting functions statically or
* dynamically depending what the user requested from CMake.
*/
#include "VXExportConfig.h"
#ifndef _VDE_VXINTERNALCONFIG_H_
#define _VDE_VXINTERNALCONFIG_H_
@ -39,14 +45,4 @@
# define VX_INLINE extern inline
#endif
#ifdef VX_BUILD_SHARED /* set by CMake */
# if defined(_MSC_VER)
# define VX_EXPORT __declspec(dllexport)
# elif defined(__GNUC__) || defined(__clang__)
# define VX_EXPORT __attribute__((dllexport))
# endif
#else
# define VX_EXPORT
#endif
#endif /* _VDE_VXINTERNALCONFIG_H_ */