<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Tom,</p>
<p><span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">GDAL_LIBRARIES
and GDAL_INCLUDE_DIRS are indeed not defined. You have to use
the "GDAL::GDAL" target in a </span><br>
<span data-mce-style="font-family: 'courier new', courier, monaco,
monospace, sans-serif; font-size: 10pt;">target_link_libraries()
statement which propagates both include and linking requirements
and tends to be the modern CMake practice, although admitedly
not very clearly documented in target_link_libraries() official
documentation. I found
<a class="moz-txt-link-freetext" href="https://schneide.blog/2016/04/08/modern-cmake-with-target_link_libraries/">https://schneide.blog/2016/04/08/modern-cmake-with-target_link_libraries/</a>
which deal with that.<br>
</span></p>
<p><span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">So a typical
minimum CMakeLists.txt of a project using GDAL is (this is
actually
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/master/autotest/postinstall/test_c/CMakeLists.txt">https://github.com/OSGeo/gdal/blob/master/autotest/postinstall/test_c/CMakeLists.txt</a>
used in GDAL continuous integration to test usage of GDAL from a
third-party library/application)<br>
</span></p>
<p><span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">"""<br>
</span></p>
<p>cmake_minimum_required(VERSION 3.0)<br>
<br>
project(test_c C CXX) # CXX for properly linking GDAL<br>
<br>
find_package(GDAL CONFIG REQUIRED)<br>
<br>
add_executable(test_c test_c.c)<br>
target_link_libraries(test_c PRIVATE GDAL::GDAL)</p>
<p>"""</p>
<p>I've created <a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/issues/5875">https://github.com/OSGeo/gdal/issues/5875</a> to track
we need documenting that.</p>
<p>Note: If you really wanted to get the equivalent of <span
data-mce-style="font-family: 'courier new', courier, monaco,
monospace, sans-serif; font-size: 10pt;">GDAL_INCLUDE_DIRS and
GDAL_LIBRARIES, you could use the following expressions:<br>
</span></p>
<p>$<TARGET_PROPERTY:GDAL::GDAL,INTERFACE_INCLUDE_DIRECTORIES></p>
<p>$<TARGET_PROPERTY:GDAL::GDAL,INTERFACE_LINK_LIBRARIES></p>
<p><br>
</p>
<p>Even<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">Le 07/06/2022 à 02:02, Tom O'Reilly a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:1589859798.163134591.1654560169856.JavaMail.zimbra@mbari.org">
<div>
<div><span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">I've just
built and installed GDAL 3.5.0 on ubuntu 20.04, with cmake
3.5.0 and make. It appears that 'make install' installs
needed cmake config files for GDAL:</span></div>
<div>
<blockquote>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;">-- Installing:
/usr/local/lib/x86_64-linux-gnu/cmake/gdal/GDALConfigVersion.cmake</span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;">-- Installing:
/usr/local/lib/x86_64-linux-gnu/cmake/gdal/GDALConfig.cmake</span></div>
</blockquote>
</div>
<div><span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">I'm
building my own project that uses GDAL. The CMakelists.txt
invokes find_package() and prints out resulting variables:</span></div>
<div>
<blockquote>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;">find_package(GDAL CONFIG REQUIRED)</span></div>
<div><br>
</div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;">if (GDAL_FOUND)</span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;"> message("GDAL Found!")</span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;"> message("GDAL_INCLUDE_DIRS:
${GDAL_INCLUDE_DIRS}")</span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;"> message("GDAL_LIBRARIES: ${GDAL_LIBRARIES}")</span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;"> message("GDAL_VERSION: ${GDAL_VERSION}")</span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;">else()</span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;"> message("GDAL not found")</span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;">endif()</span></div>
</blockquote>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size: 10pt;">Running
cmake indicates that GDAL_FOUND is true, GDAL_VERSION is
set to the expected value(3.5.0), but GDAL_LIBRARIES and
GDAL_INCLUDE_DIRS are empty:</span></div>
<div>
<blockquote>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;">GDAL Found!</span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;">GDAL_INCLUDE_DIRS: </span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;">GDAL_LIBRARIES: </span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;">GDAL_LIBRARY: </span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size:
10pt;">GDAL_VERSION: 3.5.0</span></div>
</blockquote>
</div>
<div><span>Why are GDAL_LIBRARIES and GDAL_INCLUDE_DIR empty?</span><br>
</div>
<div><br>
</div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size: 10pt;">Thanks</span></div>
<div><span data-mce-style="font-family: 'courier new',
courier, monaco, monospace, sans-serif; font-size: 10pt;">Tom</span></div>
<div><br data-mce-bogus="1">
</div>
<blockquote>
<div><br data-mce-bogus="1">
</div>
</blockquote>
</div>
<div><br>
</div>
<div data-marker="__SIG_PRE__"><span
data-mce-style="font-family: 'courier new', courier, monaco,
monospace, sans-serif; font-size: 10pt;">--------------------------------------------------</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">Thomas C.
O'Reilly</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">Monterey
Bay Aquarium Research Institute</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">7700
Sandholdt Road</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">Moss
Landing, California 95039-9644</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">831-775-1766
(voice)</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">831-775-1620
(FAX)</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;"><a class="moz-txt-link-abbreviated" href="mailto:oreilly@mbari.org">oreilly@mbari.org</a>
(email)</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;"><a class="moz-txt-link-freetext" href="http://www.mbari.org">http://www.mbari.org</a>
(World-wide Web)</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;"> </span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;">"The
machine does not isolate us from the great mysteries</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;"> of nature,
but plunges us more deeply into them."</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;"> </span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;"> -
ANTOINE DE SAINT-EXUPERY</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;"> "Wind,
Sand, and Stars" (1939)</span><br>
<span data-mce-style="font-family: 'courier new', courier,
monaco, monospace, sans-serif; font-size: 10pt;"> </span></div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>