Discussion:
[CMake] New version forces rebuild all?
Andy
2018-12-01 08:32:10 UTC
Permalink
I have cmake project, I usuall call "cmake ." followed by make.
Now I have installed cmake 3.12.3 (was impossible install by apt-get)
I have following problem:
If I change one *.cpp file, in most cases make rebuilds all *.cpp files,
not related to this file. Sometimes is ok.
Eric Noulard
2018-12-04 11:01:30 UTC
Permalink
Problem are still.
Alone make also give me problems.
Do you have stripped down project example?
Ninja is replacement od cmake or make?
ninja (https://ninja-build.org/) is make replacement for which there is a
CMake generator.
https://cmake.org/cmake/help/v3.13/generator/Ninja.html
How work with ninja?
1) install ninja (on debian the package is called ninja-build)
2) cmake -G Ninja
3) ninja

this would rule out generator specific issue.
--
Eric
Andy
2018-12-05 21:19:19 UTC
Permalink
(previously I send this mail not to mail list, but user)
Maybe my cmake files are bad?
I have created test project
https://gitlab.com/andrzejbor/test_rebuild_all
after commit is rebuild whole project
what I might change?
I don't want moving all but .git to one directory src/
Cristian Adam
2018-12-05 22:54:24 UTC
Permalink
Post by Andy
(previously I send this mail not to mail list, but user)
Maybe my cmake files are bad?
I have created test project
https://gitlab.com/andrzejbor/test_rebuild_all
after commit is rebuild whole project
what I might change?
I don't want moving all but .git to one directory src/
The problem is that you add the GIT variables as compile time defines,
which means that after every commit you will have different compile command
lines, which trigger recompilation of whole project because you have used
add_definitions.

You should instead write those GIT variables in a file, like this:

file(WRITE ${CMAKE_BINARY_DIR}/git_version.h.in "
#define GIT_SHA1 \"@GIT_SHA@\"
#define GIT_TAG \"@GIT_TAG@\"
#define GIT_LOCAL_CHANGES \"@GIT_LOCAL_CHANGES@\""
)

configure_file(${CMAKE_BINARY_DIR}/git_version.h.in
${CMAKE_BINARY_DIR}/git_version.h @ONLY)

Make sure you have ${CURRENT_BINARY_DIR} as part of your target's include
directories. And then somewhere in your code do an #include "git_version.h".

Cheers,
Cristian.

Loading...