[PATCH] [dunecontrol] Skip directories without CMake config files for module_DIR
authorMarkus Blatt <markus@dr-blatt.de>
Wed, 20 Nov 2024 10:39:10 +0000 (11:39 +0100)
committerMarkus Blatt <markus@dr-blatt.de>
Fri, 22 Nov 2024 14:28:16 +0000 (15:28 +0100)
find_package(module) will fail if the directory set with module_DIR
does not contain CMake configuration file.

Hence the current approach requires that there are pkgconfig files
installed and found for each module to be used.

With this change we fall back to installed modules if the directory
does not contain any Cmake configuration files.

This fixes problems with using OPM as DUNE modules (in Debian) which
stopped shipping broken pkgconf file 2023-09

Gbp-Pq: Name dunecontrol-Skip-directories-without-CMake-config-fi.patch

bin/dunecontrol

index 5b343338e310ce5373bffeac476f234217baec9b..35b6838fbfe186e15f6c4bf9b53c8671ffc22e4d 100755 (executable)
@@ -656,17 +656,20 @@ run_default_cmake () {
       name=$(eval "echo \$NAME_$m")
       local m_ABS_BUILDDIR=$(abs_builddir $m $BUILDDIR)
 
+      config_dir="$path"
+      for i in $MULTIARCH_LIBDIR lib lib64 lib32; do
+        if test -d "$path/$i/cmake/$name"; then
+          config_dir="$path/$i/cmake/$name"
+          break;
+        fi
+      done
       if test -d "$m_ABS_BUILDDIR"; then
-        CMAKE_PARAMS="$CMAKE_PARAMS \"-D""$name""_DIR=$m_ABS_BUILDDIR\""
-      else
-        TMP_PARAMS="\"-D""$name""_DIR=$path\""
-        for i in $MULTIARCH_LIBDIR lib lib64 lib32; do
-          if test -d "$path/$i/cmake/$name"; then
-            TMP_PARAMS="\"-D""$name""_DIR=$path/$i/cmake/$name\""
-            break;
-          fi
-        done
-        CMAKE_PARAMS="$CMAKE_PARAMS $TMP_PARAMS"
+        config_dir="$m_ABS_BUILDDIR"
+      fi
+      # Only add directories with CMake config files to -Dmodule_DIR
+      # Then there is at least a chance to find packages in default locations
+      if ls "$config_dir"/*onfig.cmake 1> /dev/null 2>&1; then
+        CMAKE_PARAMS="$CMAKE_PARAMS \"-D""$name""_DIR=$config_dir\""
       fi
     fi
   done