Search code examples
c++cmakekdevelopkdevelop4

KDevelop4: Set environment variable when before CMake


Related to my other question here (CMake: Force to use optional include and library path), how do I set an environment variable in Kdevelop4 when debugging the project / executing CMake?

I need to set CMAKE_PREFIX_PATH in order to give certain duplicate libraries installed in another path priority over libraries installed in /usr.


Solution

  • Not specific to Kdevelop, but you could change your CMakeLists.txt to include another CMake file, if it exists. This file would contain your ad-hoc configuration. For example :

    # LocalConfig.cmake
    set(CMAKE_PREFIX_PATH "/opt/hhd/geos")
    
    # CMakeLists.txt
    include(LocalConfig.cmake OPTIONAL)
    
    find_package(geos)