[CMake] CMAKE internal variables, files and scope
Kishore
kitts.mailinglists at gmail.com
Mon Jun 13 05:52:52 EDT 2011
I would like to know if there is a list of all variables defined by cmake
internally. ie. variables created by the various cmake supplied platform files
etc. and internal to the application but not by the various find modules etc.
that are explicitly invoked.
I would like to know for each variable:
1) When does it get created?
2) Is it a cache variable?
3) Where it gets modified and why/how.
4) Is there anything special about the variable (like it's scope for example)
To my knowledge some files inside modules/platform/ and the toolchain file are
the files that get invoked. In addition some files get invoked with PROJECT() or
ENABLE_LANGUAGE() commands. If these files can be listed as well it would
helpful.
So far, the only thing i know for sure is that the files
1) modules/platform/<CMAKE_SYSTEM_NAME>.cmake
2) modules/platform/<CMAKE_SYSTEM_NAME>-<CMAKE_COMPILER_SUITE>.cmake
3) modules/platform/<CMAKE_SYSTEM_NAME>-<CMAKE_COMPILER_SUITE>-
<CMAKE_SYSTEM_PROCESSOR>.cmake
get invoked in nested scope. ie. variables defined in 1 can be seen in 2 and 3
and variables defined in 2 can be seen in 3.
Also, it seems that these files are invoked when encountering the first call to
PROJECT() (or ENABLE_LANGUAGE()) in the projects CMakeLists.txt files.
Further, I think the toolchain file is invoked even before the top level
CMakeLists.txt and is executed in independent scope. ie. All non cache
variables declared in it are limited to the file itself.
Example: Despite the above knowledge i am often surprised. For example, i use
the following line of code in Modules/Platform/Generic-gcc.cmake
LIST(APPEND CMAKE_C_SOURCE_FILE_EXTENSIONS S)
As expected in my embedded system projects, all ASM files with a ".S" extension
get compiled by "gcc" instead of "as". However, putting the same line fo code
in either the toolchain file or the top level CMakeLists.txt (either before or
after PROJECT()) does no good.
Placing the code just before the PROJECT() call causes it to be overwritten to
include just "c" when checked after PROJECT() call. This whole thing is very
confusing and some documentation would help.
--
Cheers!
Kishore
More information about the CMake
mailing list