-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Try linking from gphoto2 from package config #18864
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
base: master
Are you sure you want to change the base?
Conversation
If gphoto2 was found in package config, but was _not_ found via the normal `find_path` / `find_library` calls, try looking again but with the paths supplied by pkg-config
Looks good to me but I'll prefer a CMake expert look at this, @kmilos can you review ? |
This looks very contorted and unnecessary to me... What is the exact problem you're trying to solve, can you provide some output when trying to link to libghpoto2 in a custom location? |
I've installed libgphoto2 to If I specify
AFAICT the Here is the script I'm using to build: begin
set -lx DEVELOPER_DIR "/Applications/Xcode.app/Contents/Developer"
set -lx CC cc
set -lx CXX c++
set -lx MACOSX_DEPLOYMENT_TARGET 14.0
set -lx SRC_DIR $HOME/git/darktable
set -lx BUILD_DIR $SRC_DIR/build
set -lx INSTALL_PREFIX $BUILD_DIR/macosx
set -lx ECO "-DBINARY_PACKAGE_BUILD=ON -DBUILD_CURVE_TOOLS=ON -DBUILD_NOISE_TOOLS=ON -DUSE_GRAPHICSMAGICK=OFF -DUSE_IMAGEMAGICK=ON"
set -lx CMAKE_BUILD_TYPE Release
set -lx GENERATOR Ninja
set -lx TARGET skiptest
set -lx PKG_CONFIG_PATH $HOME/.local/lib/pkgconfig
pushd $SRC_DIR
git submodule init
git config submodule.src/tests/integration.update none
git submodule update
popd
pushd $SRC_DIR
cmake -E make_directory $BUILD_DIR
cmake -E make_directory $INSTALL_PREFIX
$SRC_DIR/.ci/ci-script.sh
$SRC_DIR/packaging/macosx/3_make_hb_darktable_package.sh
popd
end Here is the logfile made by building on master. Here is the logfile made from building on my branch. On master:
On my branch:
I think this PR could be rewritten like this: diff --git a/cmake/modules/FindGphoto2.cmake b/cmake/modules/FindGphoto2.cmake
index 936122c75d..e1d3726cdf 100644
--- a/cmake/modules/FindGphoto2.cmake
+++ b/cmake/modules/FindGphoto2.cmake
@@ -19,19 +19,21 @@
include(LibFindMacros)
-find_path(Gphoto2_INCLUDE_DIR gphoto2/gphoto2.h)
-mark_as_advanced(Gphoto2_INCLUDE_DIR)
set(Gphoto2_NAMES ${Gphoto2_NAMES} gphoto2 libgphoto2)
set(Gphoto2_PORT_NAMES ${Gphoto2_PORT_NAMES} gphoto2_port libgphoto2_port)
-find_library(Gphoto2_LIBRARY NAMES ${Gphoto2_NAMES} )
-find_library(Gphoto2_PORT_LIBRARY NAMES ${Gphoto2_PORT_NAMES} )
-mark_as_advanced(Gphoto2_LIBRARY)
-mark_as_advanced(Gphoto2_PORT_LIBRARY)
# Detect libgphoto2 version
libfind_pkg_check_modules(Gphoto2_PKGCONF libgphoto2)
if(Gphoto2_PKGCONF_FOUND)
+ find_path(Gphoto2_INCLUDE_DIR gphoto2/gphoto2.h PATHS ${Gphoto2_PKGCONF_INCLUDE_DIRS} )
+ mark_as_advanced(Gphoto2_INCLUDE_DIR)
+
+ find_library(Gphoto2_LIBRARY NAMES ${Gphoto2_NAMES} PATHS ${Gphoto2_PKGCONF_LIBRARY_DIRS} )
+ find_library(Gphoto2_PORT_LIBRARY NAMES ${Gphoto2_PORT_NAMES} PATHS ${Gphoto2_PKGCONF_LIBRARY_DIRS} )
+ mark_as_advanced(Gphoto2_LIBRARY)
+ mark_as_advanced(Gphoto2_PORT_LIBRARY)
+
set(Gphoto2_VERSION_STRING "${Gphoto2_PKGCONF_VERSION}")
endif() But I'm not a CMake expert. Also I suspect I could manually pass CFLAGS etc, but since the build scripts require gphoto2 to be available via pkg-config, it seems like we should use the paths Hope this makes sense. Thank you for your patience. |
Yep, the Btw, are we sure gphoto2 ships a .pc file on all platforms? (It does for me on MSYS2 at least.) |
@tenderlove Can you please give #18875 a go instead? |
If gphoto2 was found in package config, but was not found via the normal
find_path
/find_library
calls, try looking again but with the paths supplied by pkg-configThis is probably a niche usecase, but tethering wasn't working with my OM-1 Mkii. I tracked the problem to a bug in libgphoto2, and sent a PR to fix libgphoto2. I was able to confirm that gphoto2 could control my camera, but I wanted to test darktable integration. I installed a development version of libgphoto2 to a special directory, and even though I could get CMake to find my pkg-config files, it wouldn't compile / link against them. I added the code in this PR to try compiling and linking against gphoto2 found in pkg-config so I could verify my changes fixed darktable too.
Here's a screenshot of darktable tethering with my OM-1 Mkii:
I know this is a niche usecase, so it's fine if my PR is rejected. But I wanted to send it in case someone else is trying to test edge versions of dependencies (or maybe there's an easier way I don't know).
Thanks!