Skip to content

Commit

Permalink
Applies OPENEXR_DLL only to shared libraries and no longer to static …
Browse files Browse the repository at this point in the history
…libraries

Signed-off-by: Transporter <[email protected]>
  • Loading branch information
OgreTransporter authored and cary-ilm committed Jun 12, 2020
1 parent c8f2463 commit ccf91b9
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 6 deletions.
5 changes: 2 additions & 3 deletions IlmBase/config/LibraryDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ function(ILMBASE_DEFINE_LIBRARY libname)
# only do the object library mechanism in a few cases:
# - xcode doesn't handle "empty" targets (i.e. add_library with
# an object lib only)
# - under windows, we don't want the static library targets to
# have the export tags
# - if we're not compiling both, don't add the extra layer to prevent
# extra compiles since we aren't doing that anyway
if(ILMBASE_BUILD_BOTH_STATIC_SHARED AND NOT (APPLE OR WIN32))
Expand All @@ -39,7 +37,7 @@ function(ILMBASE_DEFINE_LIBRARY libname)
target_compile_features(${objlib} PUBLIC cxx_std_${OPENEXR_CXX_STANDARD})
if(ILMBASE_CURLIB_PRIV_EXPORT AND BUILD_SHARED_LIBS)
target_compile_definitions(${objlib} PRIVATE ${ILMBASE_CURLIB_PRIV_EXPORT})
if(WIN32)
if(WIN32 AND NOT ILMBASE_BUILD_BOTH_STATIC_SHARED)
target_compile_definitions(${objlib} PUBLIC OPENEXR_DLL)
endif()
endif()
Expand Down Expand Up @@ -113,6 +111,7 @@ function(ILMBASE_DEFINE_LIBRARY libname)
target_link_libraries(${libname}_static INTERFACE ${objlib})
else()
# have to build multiple times... but have different flags anyway (i.e. no dll)
target_compile_definitions(${libname} PRIVATE OPENEXR_DLL)
set(curlib ${libname}_static)
add_library(${curlib} STATIC ${ILMBASE_CURLIB_SOURCES})
target_compile_features(${curlib} PUBLIC cxx_std_${OPENEXR_CXX_STANDARD})
Expand Down
3 changes: 3 additions & 0 deletions OpenEXR/IlmImfExamples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ install(
DESTINATION
${CMAKE_INSTALL_DOCDIR}/examples
)
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(IlmImfExamples PRIVATE OPENEXR_DLL)
endif()
5 changes: 2 additions & 3 deletions OpenEXR/config/LibraryDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ function(OPENEXR_DEFINE_LIBRARY libname)
# only do the object library mechanism in a few cases:
# - xcode doesn't handle "empty" targets (i.e. add_library with
# an object lib only)
# - under windows, we don't want the static library targets to
# have the export tags
# - if we're not compiling both, don't add the extra layer to prevent
# extra compiles since we aren't doing that anyway
if(OPENEXR_BUILD_BOTH_STATIC_SHARED AND NOT (APPLE OR WIN32))
Expand All @@ -37,7 +35,7 @@ function(OPENEXR_DEFINE_LIBRARY libname)
target_compile_features(${objlib} PUBLIC cxx_std_${OPENEXR_CXX_STANDARD})
if(OPENEXR_CURLIB_PRIV_EXPORT AND BUILD_SHARED_LIBS)
target_compile_definitions(${objlib} PRIVATE ${OPENEXR_CURLIB_PRIV_EXPORT})
if(WIN32)
if(WIN32 AND NOT OPENEXR_BUILD_BOTH_STATIC_SHARED)
target_compile_definitions(${objlib} PUBLIC OPENEXR_DLL)
endif()
endif()
Expand Down Expand Up @@ -107,6 +105,7 @@ function(OPENEXR_DEFINE_LIBRARY libname)
target_link_libraries(${libname}_static INTERFACE ${objlib})
else()
# have to build multiple times... but have different flags anyway (i.e. no dll)
target_compile_definitions(${libname} PRIVATE OPENEXR_DLL)
set(curlib ${libname}_static)
add_library(${curlib} STATIC ${OPENEXR_CURLIB_SOURCES})
target_compile_features(${curlib} PUBLIC cxx_std_${OPENEXR_CXX_STANDARD})
Expand Down
3 changes: 3 additions & 0 deletions OpenEXR/exr2aces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ set_target_properties(exr2aces PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
install(TARGETS exr2aces DESTINATION ${CMAKE_INSTALL_BINDIR})
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(exr2aces PRIVATE OPENEXR_DLL)
endif()
3 changes: 3 additions & 0 deletions OpenEXR/exrenvmap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ set_target_properties(exrenvmap PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
install(TARGETS exrenvmap DESTINATION ${CMAKE_INSTALL_BINDIR})
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(exrenvmap PRIVATE OPENEXR_DLL)
endif()
3 changes: 3 additions & 0 deletions OpenEXR/exrheader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ set_target_properties(exrheader PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
install(TARGETS exrheader DESTINATION ${CMAKE_INSTALL_BINDIR})
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(exrheader PRIVATE OPENEXR_DLL)
endif()
3 changes: 3 additions & 0 deletions OpenEXR/exrmakepreview/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ set_target_properties(exrmakepreview PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
install(TARGETS exrmakepreview DESTINATION ${CMAKE_INSTALL_BINDIR})
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(exrmakepreview PRIVATE OPENEXR_DLL)
endif()
3 changes: 3 additions & 0 deletions OpenEXR/exrmaketiled/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ set_target_properties(exrmaketiled PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
install(TARGETS exrmaketiled DESTINATION ${CMAKE_INSTALL_BINDIR})
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(exrmaketiled PRIVATE OPENEXR_DLL)
endif()
3 changes: 3 additions & 0 deletions OpenEXR/exrmultipart/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ set_target_properties(exrmultipart PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
install(TARGETS exrmultipart DESTINATION ${CMAKE_INSTALL_BINDIR})
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(exrmultipart PRIVATE OPENEXR_DLL)
endif()
3 changes: 3 additions & 0 deletions OpenEXR/exrmultiview/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ set_target_properties(exrmultiview PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
install(TARGETS exrmultiview DESTINATION ${CMAKE_INSTALL_BINDIR})
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(exrmultiview PRIVATE OPENEXR_DLL)
endif()
3 changes: 3 additions & 0 deletions OpenEXR/exrstdattr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ set_target_properties(exrstdattr PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
install(TARGETS exrstdattr DESTINATION ${CMAKE_INSTALL_BINDIR})
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(exrstdattr PRIVATE OPENEXR_DLL)
endif()

0 comments on commit ccf91b9

Please sign in to comment.