But, non-CACHE'd variables are meant to be transient, so I'm not sure why you would need them outside of a build environment anyway. If your variables are marked as INTERNAL or not CACHE'd at all, then there is no method within CMake to pull it out. And it will not show any that are cached INTERNAL, and will only show ADVANCED if -LA is used instead of -L. In order to avoid depending on any additional libraries and parsers, CMake was designed with only one major dependency, the C++ compiler (which we can. The issue though is that it will not show any variables that are not marked with CACHE. So, it does show variables from other files. Build files have been written to: /home/tgallagher/cmaketest-build Check for working CXX compiler: /usr/bin/c++ - works The cmake-variables(7) manual is printed in a human-readable text format. help-variables Print cmake-variables manual and exit.serverMode true if cmake supports server-mode and false. Check for working CXX compiler: /usr/bin/c++ version A JSON array whose elements are each a JSON object containing major and minor members specifying non-negative integer version components. Check for working C compiler: /usr/bin/gcc - works Check for working C compiler: /usr/bin/gcc Gives: - The C compiler identification is GNU The command (run from another directory): cmake -L. Of course, if you only want the value, you can do: cmake -L /path/to/CMakeLists.txt | grep MY_CMAKE_VARIABLE | cut -d "=" -f2įor example, with a CMakeLists.txt that is: cmake_minimum_required(VERSION 2.8)Īnd where otherFile.txt is: set(MY_OTHER_VAR "Hi" CACHE STRING "") If it is an advanced variable, add the -A flag to the same command and it will include advanced variables. CMAKEVSPLATFORMTOOLSET Visual Studio Platform Toolset name. The -id component appears in non-release versions and may be arbitrary text. Which will return to you something like := See variables CMAKEMAJORVERSION, CMAKEMINORVERSION, CMAKEPATCHVERSION, and CMAKETWEAKVERSION for individual version components. If you do not yet have a cache file and you want to see what options there are in a CMakeLists.txt file, you can do (in a different directory since this will write a cache file): cmake -L /path/to/CMakeLists.txt | grep MY_CMAKE_VARIABLE So, next build won't treat the file as updated and won't trigger the COMMAND re-run.If you have an existing cache file, you can do: grep MY_CMAKE_VARIABLE CMakeCache.txt That is, if the variable is set by a user to another value, then options_list_file will be updated, and this triggers re-running custom COMMAND on next build.īut if the variable's content is not changed, then configure_file wouldn't change the file options_list_file and its timestamp (this is important!). This is a main feature of configure_file. You can use this section in the same way that you might use the CMakeGUI to view a list of all the CMake variables available to edit. They're passed to CMake at build time, and override whatever values are in the CMakeLists.txt file. It is only different when a different version of CMake is run on a previously created cache file. These settings enable you to set CMake variables and save them in CMakeSettings.json. This stores the major version of CMake used to write a CMake cache file. Upon that re-run the configure_file will be called unconditionally.īut the file options_list_file will be updated only when its content would be changed. CMAKECACHEMAJORVERSION¶ Major version of CMake used to create the CMakeCache.txt file. This is so that you can set these on the command line and not have them overridden when the CMake file executes. The syntax for declaring a variable and setting it if it is not already set is: set(MYCACHEVARIABLE 'VALUE' CACHE STRING 'Description') This will not replace an existing value. # Configure file which will be updated on changing the variable's contentĬonfigure_file("options_list_file.in" "options_list_file")Īdd_custom_command(OUTPUT "File.c" "File.h"ĬOMMAND ruby generate_files.rb $/options_list_file" # dependency from the fileĬhanging the OPTIONS_LIST variable implies re-running CMake ( configuration stage). Some variables are already here, like CMAKEBUILDTYPE. Using configure_file one may convert "dependency from the variable" to "dependency from the file" which is naturally handled by custom target/command:ĬMakeLists.txt: # Variable which can be modified by a user
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |