Comments (7)
I'm working on Windows. PkgConfig is not available.
Just as a side note - it is in theory via vcpkg (or chocolatey, or MSYS2).
But yeah, agree there is no reason not to try the direct CMake approach for newer libdeflate versions that supply the config files.
from openexr.
I'm in a Docker container with minimal dependencies. ;-)
from openexr.
I have made a patch to 3.1.4 that work for me to link to the shared version of libdeflate:
diff --git a/openexr_original/cmake/OpenEXRSetup.cmake b/openexr/cmake/OpenEXRSetup.cmake
index 425992d..fa80886 100644
--- a/openexr_original/cmake/OpenEXRSetup.cmake
+++ b/openexr/cmake/OpenEXRSetup.cmake
@@ -160,71 +160,79 @@ set(OPENEXR_DEFLATE_TAG "v1.18" CACHE STRING "Tag to use for libdeflate source r
if(NOT OPENEXR_FORCE_INTERNAL_DEFLATE)
#TODO: ^^ Release should not clone from main, this is a place holder
set(CMAKE_IGNORE_PATH "${CMAKE_CURRENT_BINARY_DIR}/_deps/deflate-src/config;${CMAKE_CURRENT_BINARY_DIR}/_deps/deflate-build/config")
- include(FindPkgConfig)
- pkg_check_modules(deflate IMPORTED_TARGET GLOBAL libdeflate)
- set(CMAKE_IGNORE_PATH)
- if (deflate_FOUND)
- message(STATUS "Using libdeflate from ${deflate_LINK_LIBRARIES}")
+ find_package(libdeflate CONFIG)
+ if(libdeflate_FOUND)
+ message(STATUS "Using libdeflate from ${libdeflate_DIR}")
+ else()
+ include(FindPkgConfig)
+ pkg_check_modules(deflate IMPORTED_TARGET GLOBAL libdeflate)
+ set(CMAKE_IGNORE_PATH)
+ if (deflate_FOUND)
+ message(STATUS "Using libdeflate from ${deflate_LINK_LIBRARIES}")
+ endif()
endif()
endif()
-if(NOT TARGET PkgConfig::deflate AND NOT deflate_FOUND)
- if(OPENEXR_FORCE_INTERNAL_DEFLATE)
- message(STATUS "libdeflate forced internal, installing from ${OPENEXR_DEFLATE_REPO} (${OPENEXR_DEFLATE_TAG})")
- else()
- message(STATUS "libdeflate was not found, installing from ${OPENEXR_DEFLATE_REPO} (${OPENEXR_DEFLATE_TAG})")
- endif()
- include(FetchContent)
- FetchContent_Declare(Deflate
- GIT_REPOSITORY "${OPENEXR_DEFLATE_REPO}"
- GIT_TAG "${OPENEXR_DEFLATE_TAG}"
- GIT_SHALLOW ON
- )
+if(libdeflate_FOUND)
+ set(EXR_DEFLATE_LIB libdeflate::libdeflate_shared)
+else()
+ if(NOT TARGET PkgConfig::deflate AND NOT deflate_FOUND)
+ if(OPENEXR_FORCE_INTERNAL_DEFLATE)
+ message(STATUS "libdeflate forced internal, installing from ${OPENEXR_DEFLATE_REPO} (${OPENEXR_DEFLATE_TAG})")
+ else()
+ message(STATUS "libdeflate was not found, installing from ${OPENEXR_DEFLATE_REPO} (${OPENEXR_DEFLATE_TAG})")
+ endif()
+ include(FetchContent)
+ FetchContent_Declare(Deflate
+ GIT_REPOSITORY "${OPENEXR_DEFLATE_REPO}"
+ GIT_TAG "${OPENEXR_DEFLATE_TAG}"
+ GIT_SHALLOW ON
+ )
- FetchContent_GetProperties(Deflate)
- if(NOT Deflate_POPULATED)
- FetchContent_Populate(Deflate)
- endif()
+ FetchContent_GetProperties(Deflate)
+ if(NOT Deflate_POPULATED)
+ FetchContent_Populate(Deflate)
+ endif()
- # Rather than actually compile something, just embed the sources
- # into exrcore. This could in theory cause issues when compiling as
- # a static library into another application which also uses
- # libdeflate but we switch the export symbol to hidden which should
- # hide the symbols when linking...
- set(EXR_DEFLATE_SOURCES
- lib/arm/cpu_features.c
- lib/x86/cpu_features.c
- lib/utils.c
- lib/deflate_compress.c
- lib/deflate_decompress.c
- lib/adler32.c
- lib/zlib_compress.c
- lib/zlib_decompress.c)
- # don't need these
- # lib/crc32.c
- # lib/gzip_compress.c
- # lib/gzip_decompress.c
- file(READ ${deflate_SOURCE_DIR}/lib/lib_common.h DEFLATE_HIDE)
- string(REPLACE "visibility(\"default\")" "visibility(\"hidden\")" DEFLATE_HIDE "${DEFLATE_HIDE}")
- string(REPLACE "__declspec(dllexport)" "/**/" DEFLATE_HIDE "${DEFLATE_HIDE}")
- file(WRITE ${deflate_SOURCE_DIR}/lib/lib_common.h "${DEFLATE_HIDE}")
+ # Rather than actually compile something, just embed the sources
+ # into exrcore. This could in theory cause issues when compiling as
+ # a static library into another application which also uses
+ # libdeflate but we switch the export symbol to hidden which should
+ # hide the symbols when linking...
+ set(EXR_DEFLATE_SOURCES
+ lib/arm/cpu_features.c
+ lib/x86/cpu_features.c
+ lib/utils.c
+ lib/deflate_compress.c
+ lib/deflate_decompress.c
+ lib/adler32.c
+ lib/zlib_compress.c
+ lib/zlib_decompress.c)
+ # don't need these
+ # lib/crc32.c
+ # lib/gzip_compress.c
+ # lib/gzip_decompress.c
+ file(READ ${deflate_SOURCE_DIR}/lib/lib_common.h DEFLATE_HIDE)
+ string(REPLACE "visibility(\"default\")" "visibility(\"hidden\")" DEFLATE_HIDE "${DEFLATE_HIDE}")
+ string(REPLACE "__declspec(dllexport)" "/**/" DEFLATE_HIDE "${DEFLATE_HIDE}")
+ file(WRITE ${deflate_SOURCE_DIR}/lib/lib_common.h "${DEFLATE_HIDE}")
- # cmake makes fetch content name lowercase for the properties (to deflate)
- list(TRANSFORM EXR_DEFLATE_SOURCES PREPEND ${deflate_SOURCE_DIR}/)
- set(EXR_DEFLATE_INCLUDE_DIR ${deflate_SOURCE_DIR})
- set(EXR_DEFLATE_LIB)
-else()
- set(EXR_DEFLATE_INCLUDE_DIR)
- set(EXR_DEFLATE_LIB ${deflate_LIBRARIES})
- # set EXR_DEFATE_LDFLAGS for OpenEXR.pc.in for static build
- if (BUILD_SHARED_LIBS)
- set(EXR_DEFLATE_LDFLAGS "")
+ # cmake makes fetch content name lowercase for the properties (to deflate)
+ list(TRANSFORM EXR_DEFLATE_SOURCES PREPEND ${deflate_SOURCE_DIR}/)
+ set(EXR_DEFLATE_INCLUDE_DIR ${deflate_SOURCE_DIR})
+ set(EXR_DEFLATE_LIB)
else()
- set(EXR_DEFLATE_LDFLAGS "-l${deflate_LIBRARIES}")
+ set(EXR_DEFLATE_INCLUDE_DIR)
+ set(EXR_DEFLATE_LIB ${deflate_LIBRARIES})
+ # set EXR_DEFATE_LDFLAGS for OpenEXR.pc.in for static build
+ if (BUILD_SHARED_LIBS)
+ set(EXR_DEFLATE_LDFLAGS "")
+ else()
+ set(EXR_DEFLATE_LDFLAGS "-l${deflate_LIBRARIES}")
+ endif()
+ set(EXR_DEFLATE_SOURCES)
endif()
- set(EXR_DEFLATE_SOURCES)
endif()
-
#######################################
# Find or install Imath
#######################################
If you ignore the indent changes its just:
diff --git a/openexr_original/cmake/OpenEXRSetup.cmake b/openexr/cmake/OpenEXRSetup.cmake
index 425992d..eaac6fa 100644
--- a/openexr_original/cmake/OpenEXRSetup.cmake
+++ b/openexr/cmake/OpenEXRSetup.cmake
@@ -160,14 +160,22 @@ set(OPENEXR_DEFLATE_TAG "v1.18" CACHE STRING "Tag to use for libdeflate source r
if(NOT OPENEXR_FORCE_INTERNAL_DEFLATE)
#TODO: ^^ Release should not clone from main, this is a place holder
set(CMAKE_IGNORE_PATH "${CMAKE_CURRENT_BINARY_DIR}/_deps/deflate-src/config;${CMAKE_CURRENT_BINARY_DIR}/_deps/deflate-build/config")
- include(FindPkgConfig)
- pkg_check_modules(deflate IMPORTED_TARGET GLOBAL libdeflate)
- set(CMAKE_IGNORE_PATH)
- if (deflate_FOUND)
- message(STATUS "Using libdeflate from ${deflate_LINK_LIBRARIES}")
+ find_package(libdeflate CONFIG)
+ if(libdeflate_FOUND)
+ message(STATUS "Using libdeflate from ${libdeflate_DIR}")
+ else()
+ include(FindPkgConfig)
+ pkg_check_modules(deflate IMPORTED_TARGET GLOBAL libdeflate)
+ set(CMAKE_IGNORE_PATH)
+ if (deflate_FOUND)
+ message(STATUS "Using libdeflate from ${deflate_LINK_LIBRARIES}")
+ endif()
endif()
endif()
+if(libdeflate_FOUND)
+ set(EXR_DEFLATE_LIB libdeflate::libdeflate_shared)
+else()
if(NOT TARGET PkgConfig::deflate AND NOT deflate_FOUND)
if(OPENEXR_FORCE_INTERNAL_DEFLATE)
message(STATUS "libdeflate forced internal, installing from ${OPENEXR_DEFLATE_REPO} (${OPENEXR_DEFLATE_TAG})")
@@ -224,7 +232,7 @@ else()
endif()
set(EXR_DEFLATE_SOURCES)
endif()
-
+endif()
#######################################
# Find or install Imath
#######################################
from openexr.
@bebuch are you planning to submit this as a pull request? We need the same thing for Blender. I can make a pull request too if that helps.
The one further change we need is to fall back to the static library if there is no shared one.
if(libdeflate::libdeflate_shared)
set(EXR_DEFLATE_LIB libdeflate::libdeflate_shared)
else()
set(EXR_DEFLATE_LIB libdeflate::libdeflate_static)
endif()
from openexr.
@brechtvl The patch is not a general solution, therefore I didn't make a PR. Please feel free to use it as part of your PR. ;-)
from openexr.
Following up on this, @brechtvl, will you submit a PR?
from openexr.
I submitted one now.
from openexr.
Related Issues (20)
- Bazel install target HOT 10
- fatal clang-format error on macOS can't upgrade/install via Homebrew HOT 13
- Cross-compiler target linking failure HOT 1
- Uninitialized sliceOptimizationData::type HOT 2
- [Usage recommendation request] Decompressing large EXRs in real-time. HOT 4
- OpenEXR.OutputFile Fails to Write to BytesIO Buffer HOT 1
- Install openexr 3.2.4 to macOS Big Sur 11.7.10 HOT 9
- Unit tests fail when building UB2 binaries on Mac. HOT 1
- CMP0107 issue
- OpenEXR static build not creating libIlmImf.a HOT 5
- Chromaticities should be a required attribute HOT 7
- terminate called after throwing an instance of `Iex_3_2::EioExc` in `OpenEXR.InputFile.channels` HOT 1
- AppleClang compiler warning with C++17
- std::atomic_*() overloads for shared_ptr are deprecated in C++20
- writing image from Python wrapper with xDensity gives "unknown attribute" warning
- Building OpenEXR with Python bindings HOT 1
- Add python support for the IDManifestAttribute
- Add proper python support for reading/writing header only
- Using openexr via cmake add_subdirectory HOT 1
- Fix formatting issues in OpenEXR File Layout Webpage HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openexr.