Search code examples
windowscmakecmake-gui

How to pass build directory and the toolchain file to cmake-gui?


I am using CMake on a Windows platform to cross-compile embedded applications. Now I would like to use the cmake-gui to configure the build. Is it possible to pass the build directory and the toolchain file to cmake-gui?

Some more background: I have a build script which will (1) call cmake and make to build the application or (2) call cmake-gui to configure the build. When the gui starts, the build directory and the toolchain should be configured.


Solution

  • When using make as build system, instead of calling cmake-gui directly, call:

    make edit_cache
    

    The edit_cache target is defined in the main Makefile. Its rule is something like this:

    edit_cache:
        <path to cmake-gui> -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
    

    Note how the source and build directories are passed to the cmake-gui program. The toolchain file will be read from the cache.