Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CMake
CMake
Commits
93b7d3d2
Commit
93b7d3d2
authored
Feb 06, 2021
by
Raul Tambre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
C17 support
Implements
#17755
.
parent
58d95252
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
32 additions
and
4 deletions
+32
-4
Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
+3
-0
Help/prop_tgt/C_STANDARD.rst
Help/prop_tgt/C_STANDARD.rst
+1
-1
Help/release/dev/c-std.rst
Help/release/dev/c-std.rst
+6
-0
Modules/CMakeCCompiler.cmake.in
Modules/CMakeCCompiler.cmake.in
+1
-0
Modules/CMakeCCompilerId.c.in
Modules/CMakeCCompilerId.c.in
+2
-0
Modules/CMakeDetermineCompileFeatures.cmake
Modules/CMakeDetermineCompileFeatures.cmake
+6
-0
Modules/Compiler/CMakeCommonCompilerMacros.cmake
Modules/Compiler/CMakeCommonCompilerMacros.cmake
+3
-0
Source/cmStandardLevelResolver.cxx
Source/cmStandardLevelResolver.cxx
+3
-2
Source/cmake.h
Source/cmake.h
+1
-0
Tests/CompileFeatures/CMakeLists.txt
Tests/CompileFeatures/CMakeLists.txt
+1
-0
Tests/CompileFeatures/default_dialect.c
Tests/CompileFeatures/default_dialect.c
+5
-1
No files found.
Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
View file @
93b7d3d2
...
...
@@ -24,6 +24,9 @@ The features known to this version of CMake are:
``c_std_11``
Compiler mode is at least C 11.
``c_std_17``
Compiler mode is at least C 17.
``c_function_prototypes``
Function prototypes, as defined in ``ISO/IEC 9899:1990``.
...
...
Help/prop_tgt/C_STANDARD.rst
View file @
93b7d3d2
...
...
@@ -11,7 +11,7 @@ flag such as ``-std=gnu11`` to the compile line. For compilers that
have no notion of a C standard level, such as Microsoft Visual C++ before
VS 16.7, this property has no effect.
Supported values are ``90``, ``99``
and
``1
1
``.
Supported values are ``90``, ``99``
, ``11``,
``1
7
``.
If the value requested does not result in a compile flag being added for
the compiler in use, a previous standard flag will be added instead. This
...
...
Help/release/dev/c-std.rst
0 → 100644
View file @
93b7d3d2
c-std
-----
* :prop_tgt:`C_STANDARD` and the
:manual:`Compile Features <cmake-compile-features(7)>` functionality gained
support for C17.
Modules/CMakeCCompiler.cmake.in
View file @
93b7d3d2
...
...
@@ -9,6 +9,7 @@ set(CMAKE_C_COMPILE_FEATURES "@CMAKE_C_COMPILE_FEATURES@")
set(CMAKE_C90_COMPILE_FEATURES "@CMAKE_C90_COMPILE_FEATURES@")
set(CMAKE_C99_COMPILE_FEATURES "@CMAKE_C99_COMPILE_FEATURES@")
set(CMAKE_C11_COMPILE_FEATURES "@CMAKE_C11_COMPILE_FEATURES@")
set(CMAKE_C17_COMPILE_FEATURES "@CMAKE_C17_COMPILE_FEATURES@")
set(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@")
set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@")
...
...
Modules/CMakeCCompilerId.c.in
View file @
93b7d3d2
...
...
@@ -39,6 +39,8 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
# else
# define C_DIALECT
# endif
#elif __STDC_VERSION__ >= 201710L
# define C_DIALECT "17"
#elif __STDC_VERSION__ >= 201000L
# define C_DIALECT "11"
#elif __STDC_VERSION__ >= 199901L
...
...
Modules/CMakeDetermineCompileFeatures.cmake
View file @
93b7d3d2
...
...
@@ -10,6 +10,7 @@ function(cmake_determine_compile_features lang)
set
(
CMAKE_C90_COMPILE_FEATURES
)
set
(
CMAKE_C99_COMPILE_FEATURES
)
set
(
CMAKE_C11_COMPILE_FEATURES
)
set
(
CMAKE_C17_COMPILE_FEATURES
)
include
(
"
${
CMAKE_ROOT
}
/Modules/Internal/FeatureTesting.cmake"
)
...
...
@@ -20,6 +21,9 @@ function(cmake_determine_compile_features lang)
return
()
endif
()
if
(
CMAKE_C11_COMPILE_FEATURES AND CMAKE_C17_COMPILE_FEATURES
)
list
(
REMOVE_ITEM CMAKE_C17_COMPILE_FEATURES
${
CMAKE_C11_COMPILE_FEATURES
}
)
endif
()
if
(
CMAKE_C99_COMPILE_FEATURES AND CMAKE_C11_COMPILE_FEATURES
)
list
(
REMOVE_ITEM CMAKE_C11_COMPILE_FEATURES
${
CMAKE_C99_COMPILE_FEATURES
}
)
endif
()
...
...
@@ -32,6 +36,7 @@ function(cmake_determine_compile_features lang)
${
CMAKE_C90_COMPILE_FEATURES
}
${
CMAKE_C99_COMPILE_FEATURES
}
${
CMAKE_C11_COMPILE_FEATURES
}
${
CMAKE_C17_COMPILE_FEATURES
}
)
endif
()
...
...
@@ -39,6 +44,7 @@ function(cmake_determine_compile_features lang)
set
(
CMAKE_C90_COMPILE_FEATURES
${
CMAKE_C90_COMPILE_FEATURES
}
PARENT_SCOPE
)
set
(
CMAKE_C99_COMPILE_FEATURES
${
CMAKE_C99_COMPILE_FEATURES
}
PARENT_SCOPE
)
set
(
CMAKE_C11_COMPILE_FEATURES
${
CMAKE_C11_COMPILE_FEATURES
}
PARENT_SCOPE
)
set
(
CMAKE_C17_COMPILE_FEATURES
${
CMAKE_C17_COMPILE_FEATURES
}
PARENT_SCOPE
)
message
(
CHECK_PASS
"done"
)
...
...
Modules/Compiler/CMakeCommonCompilerMacros.cmake
View file @
93b7d3d2
...
...
@@ -64,6 +64,9 @@ endmacro()
# Define to allow compile features to be automatically determined
macro
(
cmake_record_c_compile_features
)
set
(
_result 0
)
if
(
_result EQUAL 0 AND DEFINED CMAKE_C17_STANDARD_COMPILE_OPTION
)
_has_compiler_features_c
(
17
)
endif
()
if
(
_result EQUAL 0 AND DEFINED CMAKE_C11_STANDARD_COMPILE_OPTION
)
if
(
CMAKE_C11_STANDARD__HAS_FULL_SUPPORT
)
_has_compiler_features_c
(
11
)
...
...
Source/cmStandardLevelResolver.cxx
View file @
93b7d3d2
...
...
@@ -308,8 +308,9 @@ struct StanardLevelComputer
std
::
unordered_map
<
std
::
string
,
StanardLevelComputer
>
StandardComputerMapping
=
{
{
"C"
,
StanardLevelComputer
{
"C"
,
std
::
vector
<
int
>
{
90
,
99
,
11
},
std
::
vector
<
std
::
string
>
{
"90"
,
"99"
,
"11"
}
}
},
StanardLevelComputer
{
"C"
,
std
::
vector
<
int
>
{
90
,
99
,
11
,
17
},
std
::
vector
<
std
::
string
>
{
"90"
,
"99"
,
"11"
,
"17"
}
}
},
{
"CXX"
,
StanardLevelComputer
{
"CXX"
,
std
::
vector
<
int
>
{
98
,
11
,
14
,
17
,
20
,
23
},
...
...
Source/cmake.h
View file @
93b7d3d2
...
...
@@ -739,6 +739,7 @@ private:
F(c_std_90) \
F(c_std_99) \
F(c_std_11) \
F(c_std_17) \
FOR_EACH_C90_FEATURE(F) \
FOR_EACH_C99_FEATURE(F) \
FOR_EACH_C11_FEATURE(F)
...
...
Tests/CompileFeatures/CMakeLists.txt
View file @
93b7d3d2
...
...
@@ -237,6 +237,7 @@ if (C_expected_features)
if
(
std_flag_idx EQUAL -1
)
add_executable
(
default_dialect_C default_dialect.c
)
target_compile_definitions
(
default_dialect_C PRIVATE
DEFAULT_C17=$<EQUAL:
${
CMAKE_C_STANDARD_DEFAULT
}
,17>
DEFAULT_C11=$<EQUAL:
${
CMAKE_C_STANDARD_DEFAULT
}
,11>
DEFAULT_C99=$<EQUAL:
${
CMAKE_C_STANDARD_DEFAULT
}
,99>
DEFAULT_C90=$<EQUAL:
${
CMAKE_C_STANDARD_DEFAULT
}
,90>
...
...
Tests/CompileFeatures/default_dialect.c
View file @
93b7d3d2
#if DEFAULT_C11
#if DEFAULT_C17
# if __STDC_VERSION__ < 201710L
# error Unexpected value for __STDC_VERSION__.
# endif
#elif DEFAULT_C11
# if __STDC_VERSION__ < 201112L
# error Unexpected value for __STDC_VERSION__.
# endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment