I use cmake 3.22 and presets to configure and build my project. I have a few presets for different compilers defined like below.
How can I get the compiler libraries dir in the CMakeLists.txt file?
I can get ${CMAKE_CXX_COMPILER}
- full path to the compiler, but is it possible to retrieve the path to its libs?
Why can't I read ${GCC_DIR}
at least?
...
"configurePresets": [
{
"name": "tools",
"hidden": true,
"environment": {
"BINUTILS": "/gnu/binutils/binutils-2.37",
"GCC_DIR": "/gnu/gcc/gcc-11.2.0-rh6",
"LLVM_DIR": "/llvm/llvm-14.0",
"NINJA_DIR": "/ninja/ninja-1.7.2"
},
"generator": "Ninja"
},
...
{
"name": "gcc",
"hidden": true,
"inherits": ["tools", "common_settings"],
"environment": {
"PATH": "$env{BINUTILS}/bin:$env{GCC_DIR}/bin:$env{NINJA_DIR}/bin",
"LD_LIBRARY_PATH": "$env{GCC_DIR}/lib64",
"CC": "gcc",
"CXX": "g++"
}
},
...
"buildPresets": [
{
"name": "gcc_debug",
"configurePreset": "gcc_debug"
},
...