Some variables are not documented
CMAKE_NM (and CMAKE_OBJDUMP, etc?)
There is https://cmake.org/cmake/help/latest/variable/CMAKE_AR.html and https://cmake.org/cmake/help/latest/variable/CMAKE_RANLIB.html.
But there is no documentation for CMAKE_NM. That makes you think cmake doesn't really "have" such a variable, which has implications for example when creating a toolchain file. But then you can see the variable in CMakeCache.txt.
Probably CMAKE_NM should be as documented as CMAKE_AR and CMAKE_RANLIB?
Others like https://cmake.org/cmake/help/latest/search.html?q=CMAKE_OBJDUMP are barely more documented.
CMAKE_<LANG>_COMPILE_OPTIONS_TARGET
Then we have https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_TARGET.html. It's a nice variable, cmake will automatically take care of using it as the compiler needs... until cmake stops taking care of it.
When using ExternalProject_Add()
I may pass CMAKE_C_COMPILER
, CMAKE_C_FLAGS
, etc. to the external build system. But in none of those variable I will see --target=XXXX
. AFAIK the --target=XXXX
that cmake generates and uses is not accessible to the CMakeLists.txt writer at all.
You can manually add --target=${CMAKE_C_COMPILER_TARGET}
but that supposed the argument is --target=
, which may not. The thing is that there is a CMAKE_<LANG>_COMPILE_OPTIONS_TARGET
variable (https://gitlab.kitware.com/cmake/cmake/-/blob/8d6b03644935ff54ee6045156e617d1f5991cadd/Modules/Compiler/Clang.cmake#L39) which can be used from a CMakeLists.txt. But it's not documented and I'm not even sure if it anybody was intending to make it public.
CMAKE_<LANG>_COMPILE_OPTIONS_SYSROOT
Similar case to CMAKE_<LANG>_COMPILE_OPTIONS_TARGET
.
Here the documentation of CMAKE_SYSROOT
actually says The CMAKE_SYSROOT content is passed to the compiler in the --sysroot flag
, which is not necessarily true. For example with the QCC compiler: https://gitlab.kitware.com/cmake/cmake/-/blob/8d6b03644935ff54ee6045156e617d1f5991cadd/Modules/Compiler/QCC.cmake#L15