Adding include directories to CMake when calling it from the command line

I have the same problem. I found two solutions:

  1. The one proposed by sakra in a previous answer, i.e. setting an environment variable with C++ flags:

    export CXXFLAGS=-isystem\ /path/to/my/include
    cmake <path to my sources>
    

    OR the same thing, but environment variable are set only for this CMake call:

    CXXFLAGS=-isystem\ /path/to/my/include cmake <path to my sources>
    

    IMPORTANT: you must clean your build directory (i.e. clean the CMake cache) before launching any of this form. Without cleaning the cache, CMake will continue using your cached CMAKE_CXX_FLAGS from the previous run.

  2. Directly setting CMAKE_CXX_FLAGS in cmake string:

    cmake -DCMAKE_CXX_FLAGS=-isystem\ /path/to/my/include <path to my sources>
    

I believe that it can be done by a more ‘native’ way, but I didn’t find a variable responsible for paths to headers in CMake.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)