diff --git a/IlmBase/config/LibraryDefine.cmake b/IlmBase/config/LibraryDefine.cmake index 98750fc19e..2e3a052704 100644 --- a/IlmBase/config/LibraryDefine.cmake +++ b/IlmBase/config/LibraryDefine.cmake @@ -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)) @@ -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() @@ -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}) diff --git a/OpenEXR/IlmImfExamples/CMakeLists.txt b/OpenEXR/IlmImfExamples/CMakeLists.txt index 334691149c..bb92cdd294 100644 --- a/OpenEXR/IlmImfExamples/CMakeLists.txt +++ b/OpenEXR/IlmImfExamples/CMakeLists.txt @@ -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() diff --git a/OpenEXR/config/LibraryDefine.cmake b/OpenEXR/config/LibraryDefine.cmake index 555b762bcd..9a5cce5456 100644 --- a/OpenEXR/config/LibraryDefine.cmake +++ b/OpenEXR/config/LibraryDefine.cmake @@ -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)) @@ -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() @@ -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}) diff --git a/OpenEXR/exr2aces/CMakeLists.txt b/OpenEXR/exr2aces/CMakeLists.txt index 74d9811dce..3943f6d255 100644 --- a/OpenEXR/exr2aces/CMakeLists.txt +++ b/OpenEXR/exr2aces/CMakeLists.txt @@ -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() diff --git a/OpenEXR/exrenvmap/CMakeLists.txt b/OpenEXR/exrenvmap/CMakeLists.txt index beb0225be1..1363b9356b 100644 --- a/OpenEXR/exrenvmap/CMakeLists.txt +++ b/OpenEXR/exrenvmap/CMakeLists.txt @@ -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() diff --git a/OpenEXR/exrheader/CMakeLists.txt b/OpenEXR/exrheader/CMakeLists.txt index 5df8904c05..7f8438e7de 100644 --- a/OpenEXR/exrheader/CMakeLists.txt +++ b/OpenEXR/exrheader/CMakeLists.txt @@ -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() diff --git a/OpenEXR/exrmakepreview/CMakeLists.txt b/OpenEXR/exrmakepreview/CMakeLists.txt index cfc9e9461b..b339b3171f 100644 --- a/OpenEXR/exrmakepreview/CMakeLists.txt +++ b/OpenEXR/exrmakepreview/CMakeLists.txt @@ -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() diff --git a/OpenEXR/exrmaketiled/CMakeLists.txt b/OpenEXR/exrmaketiled/CMakeLists.txt index 8b0443a1da..17ad42b0b5 100644 --- a/OpenEXR/exrmaketiled/CMakeLists.txt +++ b/OpenEXR/exrmaketiled/CMakeLists.txt @@ -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() diff --git a/OpenEXR/exrmultipart/CMakeLists.txt b/OpenEXR/exrmultipart/CMakeLists.txt index f997e66038..2a2b0eb7d1 100644 --- a/OpenEXR/exrmultipart/CMakeLists.txt +++ b/OpenEXR/exrmultipart/CMakeLists.txt @@ -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() diff --git a/OpenEXR/exrmultiview/CMakeLists.txt b/OpenEXR/exrmultiview/CMakeLists.txt index 6446e2276a..72a115a705 100644 --- a/OpenEXR/exrmultiview/CMakeLists.txt +++ b/OpenEXR/exrmultiview/CMakeLists.txt @@ -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() diff --git a/OpenEXR/exrstdattr/CMakeLists.txt b/OpenEXR/exrstdattr/CMakeLists.txt index c8c2158535..8b868ea0a0 100644 --- a/OpenEXR/exrstdattr/CMakeLists.txt +++ b/OpenEXR/exrstdattr/CMakeLists.txt @@ -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()