Cmake Set C Version
Sets the name of the project and stores it in the variable project name when called from the top level cmakelists txt also stores the project name in the variable cmake project name.
Cmake set c version. These will add the needed compile options on targets e g. I have multiple versions of visual studio installed 2010 2012 2015 trial. Also sets the variables. How can i force cmake to generate the makefiles for a specific vs version.
The version can be made a requirement by setting to on the variables cmake c standard required and cmake cxx standard required respectively. This property is initialized by the value of the cmake cxx standard variable if it is set when a target is created. To use a different compiler e g. We recommend using the cmake tools extension alongside the c c extension for visual studio code for intellisense configuration and a full fidelity c c development experience.
Happily with features added in cmake 3 1 it is trivial to handle this. Then we ll use cmake s add definitions function to set the corresponding preprocessor flag in our c program. Make sure you don t accidentally overwrite the contents of cmake cxx flags later on. Option use debug enter debug mode off now we can set this option to on when running cmake.
See the cmake compile features 7 manual for information on compile features and a list of supported compilers. Read moreenabling c 11 and later in cmake. Intel compiler clang or pgi or a different version then cmake uses by default one can either set environment variables or modify the cmakelists txt file. Compiler and standard set cmake c standard 99 set cmake cxx standard 17 set cmake c compiler clang 8 set cmake cxx compiler clang 8 i prefer to set the global project name in a variable and use that all over the rest of the file so that file is readable.
By default it generates for vs2015. The following screenshot of the extension shows a logical view of the open source cmake project bullet3 organized by target left and several cmake specific commands. Further variables are set by the optional arguments described in the following. Cmake evaluates the environment variables cc for the c compiler cxx for the c compiler and fc for the fortran compiler.
If your project targets multiple platforms and compilers this can be a headache to set up. The set cmake cxx flags std c 0x works fine for me so there is probably a problem somewhere else in the cmakelists file.