svnversion-controlbuildcmaketweak

Processing additional CMake files with CMake


I have CMakeLists.txt file, which is under source control. However, to cross-compile I need to do a lot of tweaks, so that all the options like -DCMAKE_SYSTEM_PROCESSOR=armhf etc. do not fit the command line limit. To workaround, I just added all the options to the CMakeLists.txt file in the root directory. They look like

if(TWEAK_PROJECT_XXX)
    set(CMAKE_SYSTEM_PROCESSOR armhf CACHE STRING "")
...
endif()

Of course I cannot commit these tweaks to the source control. However, command line SVN does not let to exclude some files when making a patch like:

svn diff --diff-cmd=diff -x -U999999 > full.diff

And I need full diff, so I can't use TortoiseSVN GUI for making it (no such possibility in GUI, AFAIK). So I have to manually modify the diff each time to exclude the tweaks of CMakeLists.txt . This is inconvenient.

As a solution I am thinking of moving the tweaks to a separate file, not under source control (and ignore it in SVN) and pass some command-line option to CMake to process that file first of all. Is this possible? How?


Solution

  • CMake offers to load a file with variables and their values to use it as the basis of its cache.
    Use such a cache file and load it via

    cmake -C <cachefile>
    

    Documentation: cmake.org/cmake/help/v3.6/manual/cmake.1.html

    Similar, you could use load_cache but it would not fit the needs in your specific case.