On Wed, Dec 5, 2018 at 10:19 PM Andy <borucki.andr...@gmail.com> wrote:
> (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.
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake