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 d1ec30c commit f7acbc5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 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
8 changes: 7 additions & 1 deletion IlmBase/Imath/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# [email protected]

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

0 comments on commit f7acbc5

Please sign in to comment.