Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use and depend on system libraries. #108

Open
dreirund opened this issue Jan 5, 2023 · 5 comments
Open

Use and depend on system libraries. #108

dreirund opened this issue Jan 5, 2023 · 5 comments

Comments

@dreirund
Copy link

dreirund commented Jan 5, 2023

Ahoj,

thanks for the software!

Your build system fetches and uses dependencies on it's own (e.g. iMath, OpenEXR). This is undesirable on Unix-systems, where it is desirable and clean to use system libraries.

Can you update your build system to have an easy switch to to

  • use system libraries by default, and
  • switch on downloading and building and bundling libraries standalone?

Regards!

@wkjarosz
Copy link
Owner

wkjarosz commented Jan 6, 2023

HDRView uses CPM.cmake as I have found this dramatically reduces build issues.

If you want to check for system libraries first, I believe you can set an option to have CPM look for these first, but I haven't tested this.

@dreirund
Copy link
Author

dreirund commented Jan 6, 2023

If you want to check for system libraries first, I believe you can set an option to have CPM look for these first,

But this looks like it wants to have source code of the libraries, and compiled libraries + include files are not enough? Hm.

@wkjarosz
Copy link
Owner

wkjarosz commented Jan 6, 2023

No, I believe that if you set the CPM_USE_LOCAL_PACKAGES option, CPM will use find_package to find the prebuilt/installed libraries and include files. But again, I haven't actually tested this.

@dreirund
Copy link
Author

dreirund commented Jan 6, 2023

No, I believe that if you set the CPM_USE_LOCAL_PACKAGES option, CPM will use find_package to find the prebuilt/installed libraries and include files. But again, I haven't actually tested this.

This still will download openexr into _deps and builds it, although I have it installed on my system, including header files, and also other packages depend successfully on it.

And later it fails while linking:

[ 60%] Building CXX object _deps/openexr-build/src/lib/OpenEXR/CMakeFiles/OpenEXR.dir/ImfRgbaFile.cpp.o
[ 61%] Linking CXX executable force-random-dither
/usr/bin/ld: cannot find -lnlohmann_json: No such file or directory
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/force-random-dither.dir/build.make:100: force-random-dither] Error 1
make[1]: *** [CMakeFiles/Makefile2:387: CMakeFiles/force-random-dither.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

.. so maybe it uses the downloaded OpenEXR to build against it, and then tries to use the system OpenEXR to link against it? I don't know.

@wkjarosz
Copy link
Owner

wkjarosz commented Jan 6, 2023

I don't know either, as this is not a use case for me. One of the reasons I use CPM and download source is precisely to avoid such issues across platforms (previously I would use git submodules, but prefer CPM). This also allows me to use modified versions of libraries (by referencing specific forked github repos), which is sometimes necessary.

In case it's helpful for you, a test only partially worked on my end. It indicated that it used the locally installed version of e.g. imath (though i don't have installed versions of many of the other dependencies, so it fails to download those):

cmake -B build/cpm-test -G Ninja -DCPM_USE_LOCAL_PACKAGES=True
-- Saving build timestamp: 2023-01-06 08:48
-- Found Git: /usr/bin/git (found version "2.37.1 (Apple Git-137.1)") 
-- Version: 1.7.1
     Git tag:     [v1.7.1]
     Git hash:    []
     Decorated:   [v1.7.1-1-gf5f5ba1-dirty]
     Identifiers: []
     Metadata:    [2023-01-06-08:48:36]
     SemVer:      [1.7.1+2023-01-06-08:48:36]
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using sanitizer: 
-- Setting build type to 'Release' as none was specified.
-- Using C++17 standard
-- Performing Test HAS_LIBCPP
-- Performing Test HAS_LIBCPP - Success
-- HDRView: using libc++.
-- CPM: adding package filesystem@0 (5e0eb2a6160201de38d076c085641742ee86a8f6 at /Users/wjarosz/.cache/CPM/filesystem/b39e61be0349f6bf8972ab3b87cadb320dc25b51)
-- CPM: adding package stb@0 (a0a939058c579ddefd4c5671b046f29d12aeae01 at /Users/wjarosz/.cache/CPM/stb/1532208e8ba0d1cd421ca8a37564c1e9d5510f34)
-- CPM: adding package tinydir@0 (9f866c1ec09e62aa4df50d7209556ed705a4dd90 at /Users/wjarosz/.cache/CPM/tinydir/3796fa7f6715639287fe8c963fe7f2651f5c61ff)
-- CPM: adding package [email protected] (3.9.1 at /Users/wjarosz/.cache/CPM/nlohmann_json/da58edb2f54861722a77eb11ffdeecbeb52e1388)
-- CPM: adding package tinydng@0 (96eea08c8ff4b18cae2f10028acc1dcda76873a6 at /Users/wjarosz/.cache/CPM/tinydng/06c235e21d07e61e753d684a84e82a357e29190d)
-- CPM: adding package [email protected] (4.2.0 at /Users/wjarosz/.cache/CPM/platform_folders/a18e11ff10a8082d6c8bcab3ca6686658650ce61)
-- CPM: adding package [email protected] (2.2.0 at /Users/wjarosz/.cache/CPM/cli11/642cac8a0b1a528c7c982679b163f839c5530044)
-- Build spdlog: 1.9.2
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Build type: Release
-- CPM: adding package [email protected] (v1.9.2 at /Users/wjarosz/.cache/CPM/spdlog/cced5c35ec43466bb67ce80a52ac7dff03377357)
-- CPM: using local package [email protected]
-- Found ZLIB: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/lib/libz.tbd (found version "1.2.11") 
-- Found CONFIG for OpenEXR 3 (OPENEXR_VERSION=3.1.5)
-- OpenEXR is configuring as a cmake subproject
-- Using Imath from /opt/homebrew/lib/cmake/Imath
-- Performing Test OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN
-- Performing Test OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN - Success
-- Performing Test OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
-- Performing Test OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX - Failed
-- Looking for include file ucontext.h
-- Looking for include file ucontext.h - not found
-- Configure OpenEXR 3.2.0-dev, library API version: 29.0.0
-- CPM: adding package openexr@0 (71bffa3d7d89e46a37108732f5e63d554c10e018 at /Users/wjarosz/.cache/CPM/openexr/e7f03545963c8b6914b842e8a9ca58df5ade7606)
-- NanoGUI v0.1.4 
-- NanoGUI: using Metal backend.
-- NanoGUI: building static library.
-- Using Cocoa for window creation
-- NanoGUI: not building the Python plugin.
-- CPM: adding package nanogui@0 (cf8baf7c2a02a0e8443379a6b80f6709139f84a0 at /Users/wjarosz/.cache/CPM/nanogui/301823904d0d656230ec37c5e1c301d3b66e954b)
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/wjarosz/Documents/Work/Sandbox/hdrview/build/cpm-test
(base) wjarosz@weasel hdrview % cmake -B build/cpm-test -G Ninja -DCPM_LOCAL_PACKAGES_ONLY=True
-- Saving build timestamp: 2023-01-06 08:54
-- Version: 1.7.1
     Git tag:     [v1.7.1]
     Git hash:    []
     Decorated:   [v1.7.1-1-gf5f5ba1-dirty]
     Identifiers: []
     Metadata:    [2023-01-06-08:54:37]
     SemVer:      [1.7.1+2023-01-06-08:54:37]
-- Using sanitizer: 
-- Using C++17 standard
-- HDRView: using libc++.
CMake Error at /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:625 (message):
  CPM: filesystem not found via find_package(filesystem 0)
Call Stack (most recent call first):
  CMakeLists.txt:144 (cpmaddpackage)


-- CPM: adding package filesystem@0 (5e0eb2a6160201de38d076c085641742ee86a8f6 at /Users/wjarosz/.cache/CPM/filesystem/b39e61be0349f6bf8972ab3b87cadb320dc25b51)
CMake Error at /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:625 (message):
  CPM: stb not found via find_package(stb 0)
Call Stack (most recent call first):
  CMakeLists.txt:150 (cpmaddpackage)


-- CPM: adding package stb@0 (a0a939058c579ddefd4c5671b046f29d12aeae01 at /Users/wjarosz/.cache/CPM/stb/1532208e8ba0d1cd421ca8a37564c1e9d5510f34)
CMake Error at /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:625 (message):
  CPM: tinydir not found via find_package(tinydir 0)
Call Stack (most recent call first):
  CMakeLists.txt:156 (cpmaddpackage)


-- CPM: adding package tinydir@0 (9f866c1ec09e62aa4df50d7209556ed705a4dd90 at /Users/wjarosz/.cache/CPM/tinydir/3796fa7f6715639287fe8c963fe7f2651f5c61ff)
CMake Error at /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:625 (message):
  CPM: nlohmann_json not found via find_package(nlohmann_json 3.9.1)
Call Stack (most recent call first):
  CMakeLists.txt:162 (cpmaddpackage)


-- CPM: adding package [email protected] (3.9.1 at /Users/wjarosz/.cache/CPM/nlohmann_json/da58edb2f54861722a77eb11ffdeecbeb52e1388)
CMake Error at /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:625 (message):
  CPM: tinydng not found via find_package(tinydng 0)
Call Stack (most recent call first):
  CMakeLists.txt:178 (cpmaddpackage)


-- CPM: adding package tinydng@0 (96eea08c8ff4b18cae2f10028acc1dcda76873a6 at /Users/wjarosz/.cache/CPM/tinydng/06c235e21d07e61e753d684a84e82a357e29190d)
CMake Error at /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:625 (message):
  CPM: platform_folders not found via find_package(platform_folders 4.2.0)
Call Stack (most recent call first):
  CMakeLists.txt:184 (cpmaddpackage)


-- CPM: adding package [email protected] (4.2.0 at /Users/wjarosz/.cache/CPM/platform_folders/a18e11ff10a8082d6c8bcab3ca6686658650ce61)
CMake Error at /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:625 (message):
  CPM: cli11 not found via find_package(cli11 2.2.0)
Call Stack (most recent call first):
  CMakeLists.txt:189 (cpmaddpackage)


-- CPM: adding package [email protected] (2.2.0 at /Users/wjarosz/.cache/CPM/cli11/642cac8a0b1a528c7c982679b163f839c5530044)
CMake Error at /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:625 (message):
  CPM: spdlog not found via find_package(spdlog 1.9.2)
Call Stack (most recent call first):
  CMakeLists.txt:195 (cpmaddpackage)


-- Build spdlog: 1.9.2
-- Build type: Release
-- CPM: adding package [email protected] (v1.9.2 at /Users/wjarosz/.cache/CPM/spdlog/cced5c35ec43466bb67ce80a52ac7dff03377357)
-- CPM: using local package [email protected]
-- Found PkgConfig: /opt/homebrew/bin/pkg-config (found version "0.29.2") 
CMake Warning (dev) at /opt/homebrew/Cellar/cmake/3.25.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (OpenEXR)
  does not match the name of the calling package (openexr).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/Findopenexr.cmake:226 (find_package_handle_standard_args)
  /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:215 (find_package)
  /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:617 (cpm_find_package)
  CMakeLists.txt:209 (cpmaddpackage)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find OpenEXR (missing: ILMBASE_INCLUDE_PATH OPENEXR_ILMIMF_LIBRARY OPENEXR_HALF_LIBRARY) (found version "3.1.5")
CMake Error at /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:625 (message):
  CPM: openexr not found via find_package(openexr 0)
Call Stack (most recent call first):
  CMakeLists.txt:209 (cpmaddpackage)


-- OpenEXR is configuring as a cmake subproject
-- Using Imath from /opt/homebrew/lib/cmake/Imath
-- Configure OpenEXR 3.2.0-dev, library API version: 29.0.0
-- CPM: adding package openexr@0 (71bffa3d7d89e46a37108732f5e63d554c10e018 at /Users/wjarosz/.cache/CPM/openexr/e7f03545963c8b6914b842e8a9ca58df5ade7606)
CMake Error at /Users/wjarosz/.cache/CPM/cpm/CPM_0.35.1.cmake:625 (message):
  CPM: nanogui not found via find_package(nanogui 0)
Call Stack (most recent call first):
  CMakeLists.txt:223 (cpmaddpackage)


-- NanoGUI v0.1.4 
-- NanoGUI: using Metal backend.
-- NanoGUI: building static library.
-- Using Cocoa for window creation
-- NanoGUI: not building the Python plugin.
-- CPM: adding package nanogui@0 (cf8baf7c2a02a0e8443379a6b80f6709139f84a0 at /Users/wjarosz/.cache/CPM/nanogui/301823904d0d656230ec37c5e1c301d3b66e954b)
-- Configuring incomplete, errors occurred!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants