Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>CMake honors the environment variables <code>CC</code> and <code>CXX</code> upon detecting the C and C++ compiler to use:</p> <pre><code>$ export CC=/usr/bin/clang $ export CXX=/usr/bin/clang++ $ cmake .. -- The C compiler identification is Clang -- The CXX compiler identification is Clang </code></pre> <p>The compiler specific flags can be overridden by putting them into a system wide CMake file and pointing the <a href="https://cmake.org/cmake/help/latest/variable/CMAKE_USER_MAKE_RULES_OVERRIDE.html" rel="noreferrer">CMAKE_USER_MAKE_RULES_OVERRIDE</a> variable to it. Create a file <code>~/ClangOverrides.txt</code> with the following contents:</p> <pre><code>SET (CMAKE_C_FLAGS_INIT "-Wall -std=c99") SET (CMAKE_C_FLAGS_DEBUG_INIT "-g") SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") SET (CMAKE_C_FLAGS_RELEASE_INIT "-O4 -DNDEBUG") SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") SET (CMAKE_CXX_FLAGS_INIT "-Wall") SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g") SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-O4 -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") </code></pre> <p>The suffix _INIT will make CMake initialize the corresponding <code>*_FLAGS</code> variable with the given value. Then invoke cmake in the following way:</p> <pre><code>$ cmake -DCMAKE_USER_MAKE_RULES_OVERRIDE=~/ClangOverrides.txt .. </code></pre> <p>Finally to force the use of the LLVM binutils, set the internal variable <code>_CMAKE_TOOLCHAIN_PREFIX</code>. This variable is honored by the <code>CMakeFindBinUtils</code> module:</p> <pre><code>$ cmake -D_CMAKE_TOOLCHAIN_PREFIX=llvm- .. </code></pre> <p>Putting this all together you can write a shell wrapper which sets up the environment variables <code>CC</code> and <code>CXX</code> and then invokes cmake with the mentioned variable overrides. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload