Skip to content

Commit 6dd799d

Browse files
committed
Added macros for specific C standards
All the currently avialable C standards from C90 to C23.
1 parent 30abd2e commit 6dd799d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

c-standards.cmake

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Copyright (C) 2021 by George Cave - [email protected]
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
# use this file except in compliance with the License. You may obtain a copy of
6+
# the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
# License for the specific language governing permissions and limitations under
14+
# the License.
15+
16+
# Set the compiler standard to C89/90
17+
macro(c_90)
18+
set(CMAKE_C_STANDARD 90)
19+
set(CMAKE_C_STANDARD_REQUIRED ON)
20+
set(CMAKE_C_EXTENSIONS OFF)
21+
endmacro()
22+
23+
# Set the compiler standard to C99
24+
macro(c_99)
25+
set(CMAKE_C_STANDARD 99)
26+
set(CMAKE_C_STANDARD_REQUIRED ON)
27+
set(CMAKE_C_EXTENSIONS OFF)
28+
endmacro()
29+
30+
# Set the compiler standard to C11
31+
macro(c_11)
32+
set(CMAKE_C_STANDARD 11)
33+
set(CMAKE_C_STANDARD_REQUIRED ON)
34+
set(CMAKE_C_EXTENSIONS OFF)
35+
endmacro()
36+
37+
# Set the compiler standard to C17
38+
macro(c_17)
39+
set(CMAKE_C_STANDARD 17)
40+
set(CMAKE_C_STANDARD_REQUIRED ON)
41+
set(CMAKE_C_EXTENSIONS OFF)
42+
endmacro()
43+
44+
# Set the compiler standard to C23
45+
macro(c_23)
46+
set(CMAKE_C_STANDARD 23)
47+
set(CMAKE_C_STANDARD_REQUIRED ON)
48+
set(CMAKE_C_EXTENSIONS OFF)
49+
endmacro()

0 commit comments

Comments
 (0)