Skip to content

Commit 6a3fcab

Browse files
committed
Updated C++ standards macros
Each C++ version macro now uses version-specific variables instead of one general, to help prevent issues when changing versions and the variable being accidentally being used for a different version across configurations/generations.
1 parent 749aef6 commit 6a3fcab

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

c++-standards.cmake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2018-2021 by George Cave - gcave@stablecoder.ca
2+
# Copyright (C) 2018-2024 by George Cave - gcave@stablecoder.ca
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
55
# use this file except in compliance with the License. You may obtain a copy of
@@ -21,8 +21,8 @@ macro(cxx_11)
2121

2222
if(MSVC_VERSION GREATER_EQUAL "1900" AND CMAKE_VERSION LESS 3.10)
2323
include(CheckCXXCompilerFlag)
24-
check_cxx_compiler_flag("/std:c++11" _cpp_latest_flag_supported)
25-
if(_cpp_latest_flag_supported)
24+
check_cxx_compiler_flag("/std:c++11" _cpp_11_flag_supported)
25+
if(_cpp_11_flag_supported)
2626
add_compile_options("/std:c++11")
2727
endif()
2828
endif()
@@ -36,8 +36,8 @@ macro(cxx_14)
3636

3737
if(MSVC_VERSION GREATER_EQUAL "1900" AND CMAKE_VERSION LESS 3.10)
3838
include(CheckCXXCompilerFlag)
39-
check_cxx_compiler_flag("/std:c++14" _cpp_latest_flag_supported)
40-
if(_cpp_latest_flag_supported)
39+
check_cxx_compiler_flag("/std:c++14" _cpp_14_flag_supported)
40+
if(_cpp_14_flag_supported)
4141
add_compile_options("/std:c++14")
4242
endif()
4343
endif()
@@ -51,8 +51,8 @@ macro(cxx_17)
5151

5252
if(MSVC_VERSION GREATER_EQUAL "1900" AND CMAKE_VERSION LESS 3.10)
5353
include(CheckCXXCompilerFlag)
54-
check_cxx_compiler_flag("/std:c++17" _cpp_latest_flag_supported)
55-
if(_cpp_latest_flag_supported)
54+
check_cxx_compiler_flag("/std:c++17" _cpp_17_flag_supported)
55+
if(_cpp_17_flag_supported)
5656
add_compile_options("/std:c++17")
5757
endif()
5858
endif()

0 commit comments

Comments
 (0)