Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable building E57Format as a shared library #40

Merged
merged 3 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,30 @@ endif()
find_package( Threads REQUIRED )
find_package( XercesC REQUIRED )

option( E57_BUILD_SHARED
"Compile E57Format as a shared library"
OFF
)

if( BUILD_SHARED_LIBS )
set( E57_BUILD_SHARED ON )
endif()

set( revision_id "${PROJECT_NAME}-${PROJECT_VERSION}-${${PROJECT_NAME}_BUILD_TAG}" )
message( STATUS "[E57] Revison ID: ${revision_id}" )

add_library( E57Format STATIC )
# Target
if ( E57_BUILD_SHARED )
message( STATUS "[E57] Building shared library" )
add_library( E57Format SHARED )
else()
message( STATUS "[E57] Building static library" )
add_library( E57Format STATIC )
endif()

include( E57ExportHeader )

# Main sources and includes
add_subdirectory( extern/CRCpp )
add_subdirectory( include )
add_subdirectory( src )
Expand Down Expand Up @@ -114,6 +133,7 @@ install(
EXPORT
E57Format-export
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)

# CMake package files
Expand Down
35 changes: 35 additions & 0 deletions cmake/Modules/E57ExportHeader.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generate the export header file for E57Format

include( GenerateExportHeader )

set( comment "// NOTE: This is a generated file. Any changes will be overwritten." )

generate_export_header( E57Format
EXPORT_FILE_NAME E57Export.h
EXPORT_MACRO_NAME E57_DLL
CUSTOM_CONTENT_FROM_VARIABLE comment
)

unset( comment )

target_sources( E57Format
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/E57Export.h
)

target_include_directories( ${PROJECT_NAME}
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
)

target_compile_definitions( E57Format
PRIVATE
$<$<BOOL:E57_BUILD_SHARED>:E57Format_EXPORTS>
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/E57Export.h
DESTINATION
include/E57Format
)
1 change: 1 addition & 0 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ install(
target_include_directories( ${PROJECT_NAME}
PUBLIC
$<INSTALL_INTERFACE:include/E57Format>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)

8 changes: 5 additions & 3 deletions include/E57Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <iostream>
#include <string>

#include "E57Export.h"

namespace e57
{
//! @brief Numeric error identifiers used in E57Exception
Expand Down Expand Up @@ -93,7 +95,7 @@ namespace e57
E57_ERROR_INVARIANCE_VIOLATION = 50 //!< class invariance constraint violation in debug mode
};

class E57Exception : public std::exception
class E57_DLL E57Exception : public std::exception
{
public:
void report( const char *reportingFileName = nullptr, int reportingLineNumber = 0,
Expand Down Expand Up @@ -126,8 +128,8 @@ namespace e57
namespace Utilities
{
// Get latest version of ASTM standard supported, and library id string
void getVersions( int &astmMajor, int &astmMinor, std::string &libraryId );
E57_DLL void getVersions( int &astmMajor, int &astmMinor, std::string &libraryId );

std::string errorCodeToString( ErrorCode ecode );
E57_DLL std::string errorCodeToString( ErrorCode ecode );
}
}
26 changes: 13 additions & 13 deletions include/E57Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected:
class VectorNode;
class VectorNodeImpl;

class Node
class E57_DLL Node
{
public:
Node() = delete;
Expand Down Expand Up @@ -216,7 +216,7 @@ protected:
//! \endcond
};

class StructureNode
class E57_DLL StructureNode
{
public:
StructureNode() = delete;
Expand Down Expand Up @@ -257,7 +257,7 @@ protected:
//! \endcond
};

class VectorNode
class E57_DLL VectorNode
{
public:
VectorNode() = delete;
Expand Down Expand Up @@ -299,7 +299,7 @@ protected:
//! \endcond
};

class SourceDestBuffer
class E57_DLL SourceDestBuffer
{
public:
SourceDestBuffer() = delete;
Expand Down Expand Up @@ -344,7 +344,7 @@ protected:
//! \endcond
};

class CompressedVectorReader
class E57_DLL CompressedVectorReader
{
public:
CompressedVectorReader() = delete;
Expand All @@ -371,7 +371,7 @@ protected:
//! \endcond
};

class CompressedVectorWriter
class E57_DLL CompressedVectorWriter
{
public:
CompressedVectorWriter() = delete;
Expand All @@ -397,7 +397,7 @@ protected:
//! \endcond
};

class CompressedVectorNode
class E57_DLL CompressedVectorNode
{
public:
CompressedVectorNode() = delete;
Expand Down Expand Up @@ -441,7 +441,7 @@ protected:
//! \endcond
};

class IntegerNode
class E57_DLL IntegerNode
{
public:
IntegerNode() = delete;
Expand Down Expand Up @@ -478,7 +478,7 @@ protected:
//! \endcond
};

class ScaledIntegerNode
class E57_DLL ScaledIntegerNode
{
public:
ScaledIntegerNode() = delete;
Expand Down Expand Up @@ -526,7 +526,7 @@ protected:
//! \endcond
};

class FloatNode
class E57_DLL FloatNode
{
public:
FloatNode() = delete;
Expand Down Expand Up @@ -564,7 +564,7 @@ protected:
//! \endcond
};

class StringNode
class E57_DLL StringNode
{
public:
StringNode() = delete;
Expand Down Expand Up @@ -599,7 +599,7 @@ protected:
//! \endcond
};

class BlobNode
class E57_DLL BlobNode
{
public:
BlobNode() = delete;
Expand Down Expand Up @@ -640,7 +640,7 @@ protected:
//! \endcond
};

class ImageFile
class E57_DLL ImageFile
{
public:
ImageFile() = delete;
Expand Down