[CMake] Generator-independent incremental CMake run
Nagger
nagger at gmx.de
Wed Aug 13 15:40:34 EDT 2014
Hello,
For our Continuous Integration tests we need fast incremental builds
(only build what has changed).
This also includes that CMake only has to run if necessary (some
CMakeLists.txt changed).
It seems there is no beautiful/portable/generator-independent way to do
this?!
Fortunately we mainly use the VisualStudio2010 x64 Generator, so I wrote
this hard-coded batch script:
echo === %DATE% == %TIME% ========= CMake...
set BUILD_DIR=build
set SOURCE_DIR=%CD%
if not exist %BUILD_DIR% goto generate
if not exist %BUILD_DIR%\CMakeCache.txt goto generate
if not exist %BUILD_DIR%\*.sln goto generate
:update
echo Solution exists, only updating...
cmake --build %BUILD_DIR% --target ZERO_CHECK
if %errorlevel% == 0 goto build
:generate
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
pushd %BUILD_DIR%
echo Generating Solution...
cmake -G "Visual Studio 10 Win64" "%SOURCE_DIR%"
set el=%ERRORLEVEL%
popd
if %el% neq 0 exit /b %el%
:build
echo === %DATE% == %TIME% ========= Building...
cmake --build %BUILD_DIR% --config Release
exit /b %ERRORLEVEL%
This script works well, but I'm looking for a generator-independent way
for this script!
Does anyone already came up with a good solution? Isn't this a common
problem?
Some of my thoughts:
"cmake --build" returns "1" on every kind of error (no binary dir, no
solution, real build errors, ...). It would be nice to have a different
return value for cmake internal errors (every error prior starting the
actual build).
But what I really miss is an "--update" option for CMake which is doing
all the work (updating if possible, configuring if necessary)
internally. It would use the implementation of 'cmake --build' to
trigger a re-configure and if that is not possible it would start a
fresh configure&generate.
Any thoughts about that?
Thanks,
Marc
More information about the CMake
mailing list