Skip to content

Commit

Permalink
basic support for shared library
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkaneider authored and pstanczyk committed Apr 17, 2013
1 parent 3c2f7b9 commit 7dcffff
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 79 deletions.
11 changes: 11 additions & 0 deletions IlmBase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT ( ILMBase )

# Allow the developer to select if Dynamic or Static libraries are built
OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON)

IF ( NOT WIN32)
ADD_DEFINITIONS ( -pthread )
ENDIF ()
Expand Down Expand Up @@ -59,6 +62,14 @@ MACRO(GET_TARGET_PROPERTY_WITH_DEFAULT _variable _target _property _default_valu
INSTALL( FILES ${_laname} DESTINATION ${CMAKE_INSTALL_PREFIX}${_install_DIR})
ENDMACRO(CREATE_LIBTOOL_FILE)

SET (LIB_TYPE STATIC)
IF (BUILD_SHARED_LIBS)
# User wants to build Dynamic Libraries, so change the LIB_TYPE variable to CMake keyword 'SHARED'
SET (LIB_TYPE SHARED)
ADD_DEFINITIONS(-DOPENEXR_DLL)
ENDIF (BUILD_SHARED_LIBS)


ADD_SUBDIRECTORY ( Half )
ADD_SUBDIRECTORY ( Iex )
ADD_SUBDIRECTORY ( IexMath )
Expand Down
6 changes: 5 additions & 1 deletion IlmBase/Half/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ SET_SOURCE_FILES_PROPERTIES(
${CMAKE_CURRENT_SOURCE_DIR}/toFloat.h
)

ADD_LIBRARY ( Half STATIC
IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DHALF_EXPORTS)
ENDIF()

ADD_LIBRARY ( Half ${LIB_TYPE}
half.cpp
)

Expand Down
32 changes: 10 additions & 22 deletions IlmBase/Half/halfExport.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,16 @@
// This copyright notice does not imply publication.
//

#if defined(PLATFORM_WINDOWS)
# if defined(PLATFORM_BUILD_STATIC)
# define PLATFORM_EXPORT_DEFINITION
# define PLATFORM_IMPORT_DEFINITION
# else
# define PLATFORM_EXPORT_DEFINITION __declspec(dllexport)
# define PLATFORM_IMPORT_DEFINITION __declspec(dllimport)
# endif
#else // linux/macos
# if defined(PLATFORM_VISIBILITY_AVAILABLE)
# define PLATFORM_EXPORT_DEFINITION __attribute__((visibility("default")))
# define PLATFORM_IMPORT_DEFINITION
# else
# define PLATFORM_EXPORT_DEFINITION
# define PLATFORM_IMPORT_DEFINITION
# endif
#endif

#if defined(HALF_EXPORTS) // create library
# define HALF_EXPORT PLATFORM_EXPORT_DEFINITION
#else // use library
# define HALF_EXPORT PLATFORM_IMPORT_DEFINITION
#if defined(OPENEXR_DLL)
#if defined(HALF_EXPORTS)
#define HALF_EXPORT __declspec(dllexport)
#else
#define HALF_EXPORT __declspec(dllimport)
#endif
#define HALF_EXPORT_CONST
#else
#define HALF_EXPORT
#define HALF_EXPORT_CONST const
#endif

#endif // #ifndef HALFEXPORT_H
Expand Down
7 changes: 6 additions & 1 deletion IlmBase/Iex/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# yue.nicholas@gmail.com

ADD_LIBRARY ( Iex STATIC
IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DIEX_EXPORTS)
ENDIF()

ADD_LIBRARY ( Iex ${LIB_TYPE}
IexBaseExc.cpp
IexThrowErrnoExc.cpp
)


INSTALL ( TARGETS
Iex
DESTINATION
Expand Down
33 changes: 10 additions & 23 deletions IlmBase/Iex/IexExport.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,16 @@
//
///////////////////////////////////////////////////////////////////////////


#if defined(PLATFORM_WINDOWS)
# if defined(PLATFORM_BUILD_STATIC)
# define IEX_EXPORT_DEFINITION
# define IEX_IMPORT_DEFINITION
# else
# define IEX_EXPORT_DEFINITION __declspec(dllexport)
# define IEX_IMPORT_DEFINITION __declspec(dllimport)
# endif
#else // linux/macos
# if defined(PLATFORM_VISIBILITY_AVAILABLE)
# define IEX_EXPORT_DEFINITION __attribute__((visibility("default")))
# define IEX_IMPORT_DEFINITION
# else
# define IEX_EXPORT_DEFINITION
# define IEX_IMPORT_DEFINITION
# endif
#endif

#if defined(IEX_EXPORTS) // create library
# define IEX_EXPORT IEX_EXPORT_DEFINITION
#else // use library
# define IEX_EXPORT IEX_IMPORT_DEFINITION
#if defined(OPENEXR_DLL)
#if defined(IEX_EXPORTS)
#define IEX_EXPORT __declspec(dllexport)
#else
#define IEX_EXPORT __declspec(dllimport)
#endif
#define IEX_EXPORT_CONST
#else
#define IEX_EXPORT
#define IEX_EXPORT_CONST const
#endif

#endif // #ifndef IEXEXPORT_H
Expand Down
6 changes: 5 additions & 1 deletion IlmBase/IexMath/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# pstanczyk@ilm.com

ADD_LIBRARY ( IexMath STATIC
IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DIEXMATH_EXPORTS)
ENDIF()
ADD_LIBRARY ( IexMath ${LIB_TYPE}
IexMathFloatExc.cpp
IexMathFpu.cpp
)
TARGET_LINK_LIBRARIES(IexMath Iex)

INSTALL ( TARGETS
IexMath
Expand Down
19 changes: 11 additions & 8 deletions IlmBase/IexMath/IexMathFloatExc.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@

#ifndef IEXMATH_EXPORT_H
#define IEXMATH_EXPORT_H
#if defined(PLATFORM_WINDOWS) && !defined(ZENO_STATIC)
# ifdef IEXMATH_EXPORTS
# define IEXMATH_EXPORT __declspec(dllexport)
# else
# define IEXMATH_EXPORT __declspec(dllimport)
# endif

#if defined(OPENEXR_DLL)
#if defined(IEX_EXPORTS)
#define IEXMATH_EXPORT __declspec(dllexport)
#else
#define IEXMATH_EXPORT __declspec(dllimport)
#endif
#define IEXMATH_EXPORT_CONST
#else
# define IEXMATH_EXPORT
#endif
#define IEXMATH_EXPORT
#define IEXMATH_EXPORT_CONST const
#endif

#endif

#include "IexNamespace.h"
#include "IexMathExc.h"
Expand Down
37 changes: 16 additions & 21 deletions IlmBase/IlmThread/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
# yue.nicholas@gmail.com

SET( ILMTHREAD_LIBRARY_SOURCES
IlmThread.cpp
IlmThreadMutex.cpp
IlmThreadMutexPosix.cpp
IlmThreadPool.cpp
IlmThreadPosix.cpp
IlmThreadSemaphore.cpp
IlmThreadSemaphorePosixCompat.cpp
IlmThreadSemaphorePosix.cpp
)
IF (WIN32)
SET( ILMTHREAD_LIBRARY_SOURCES
IlmThread.cpp
IlmThreadMutex.cpp
IlmThreadMutexPosix.cpp
SET( ILMTHREAD_LIBRARY_SOURCES ${ILMTHREAD_LIBRARY_SOURCES}
IlmThreadMutexWin32.cpp
IlmThreadPool.cpp
IlmThreadPosix.cpp
IlmThreadSemaphore.cpp
IlmThreadSemaphorePosix.cpp
IlmThreadSemaphorePosixCompat.cpp
IlmThreadSemaphoreWin32.cpp
IlmThreadWin32.cpp
)
ELSE ()
ENDIF()

SET( ILMTHREAD_LIBRARY_SOURCES
IlmThread.cpp
IlmThreadMutex.cpp
IlmThreadMutexPosix.cpp
IlmThreadPool.cpp
IlmThreadPosix.cpp
IlmThreadSemaphore.cpp
IlmThreadSemaphorePosixCompat.cpp
IlmThreadSemaphorePosix.cpp
)

IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DILMTHREAD_EXPORTS)
ENDIF()

ADD_LIBRARY ( IlmThread STATIC
ADD_LIBRARY ( IlmThread ${LIB_TYPE}
${ILMTHREAD_LIBRARY_SOURCES}
)
TARGET_LINK_LIBRARIES(IlmThread Iex)

INSTALL ( TARGETS
IlmThread
Expand Down
8 changes: 7 additions & 1 deletion IlmBase/Imath/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# yue.nicholas@gmail.com

ADD_LIBRARY ( Imath STATIC
IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DIMATH_EXPORTS)
ENDIF()

ADD_LIBRARY ( Imath ${LIB_TYPE}
ImathBox.cpp
ImathRandom.cpp
ImathColorAlgo.cpp
Expand All @@ -9,6 +13,8 @@ ADD_LIBRARY ( Imath STATIC
ImathVec.cpp
ImathMatrixAlgo.cpp
)
TARGET_LINK_LIBRARIES(Imath Iex)


INSTALL ( TARGETS
Imath
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ SET ( ILMIMF_SRCS
ImfCompositeDeepScanLine.cpp
)

ADD_LIBRARY ( IlmImf STATIC
ADD_LIBRARY ( IlmImf ${LIB_TYPE}
${ILMIMF_SRCS}
)

Expand Down

0 comments on commit 7dcffff

Please sign in to comment.