[gdal-dev] Building with cmake

Even Rouault even.rouault at spatialys.com
Sun May 8 03:55:52 PDT 2022


Le 08/05/2022 à 12:37, Greg Troxel a écrit :
> Paul Harwood <runette at gmail.com> writes:
>
>> I get that error message when I try to use the source directory as the
>> build directory.
>>
>> With cmake, it is better to use a different folder structure for the build
>> - if I remember correctly something like running cmake in a clean version
>> of the repository but using ..
>>
>> cmake -S . -B ../build
> or
>
>    mkdir build
>    cd build
>    cmake ..
>
> While I completely agree that it's better to buse a build directory, I
> think it's a bug if cmake in the source dir fails, unless it is
> documented not to work and it bails out early with a nice error message.

In-tree CMake builds are only partly supported currently, because of the 
continued support of autoconf/nmake and conflicts between generated 
files of CMake with files used by autoconf/nmake. We should be able to 
fix that once support for autoconf/nmake is gone

Anyway out of tree builds are always recommended.

When doing "cmake ." you'll get the following warning at the end:


CMake Warning at gdal.cmake:872 (message):
   In-tree builds, that is running cmake from the top of the source tree are
   not recommended.  You are advised instead to 'mkdir build; cd build; 
cmake
   ..'.  Using 'make' with the Makefile generator will not work, as it will
   try the GNUmakefile of autoconf builds.  Use 'make -f Makefile' instead.
Call Stack (most recent call first):
   CMakeLists.txt:218 (include)


-- 
http://www.spatialys.com
My software is free, but my time generally not.



More information about the gdal-dev mailing list