Skip to content

Commit 96c388a

Browse files
committed
Standardized on using CMAKE_CXX_STANDARD to control the cxx_std_ used.
1 parent 89ace4a commit 96c388a

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ if (VSG_SUPPORTS_Windowing)
9090
endif()
9191
endif()
9292

93-
set(VSG_CXX_TARGET 17 CACHE STRING "Set target C++ standard version, valid values are 17, 20 & 23")
94-
95-
9693
option(VSG_USE_dynamic_cast "Use dynamic_cast in vsg::Object::cast<T>(), default is OFF and uses VSG native casting which provides 2-3x faster than using dynamic_cast<>." OFF)
9794

9895
# this line needs to be after the call to setup_build_vars()

src/vsg/CMakeLists.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,20 @@ set_property(TARGET vsg PROPERTY VERSION ${VSG_VERSION_MAJOR}.${VSG_VERSION_MINO
412412
set_property(TARGET vsg PROPERTY SOVERSION ${VSG_SOVERSION})
413413
set_property(TARGET vsg PROPERTY POSITION_INDEPENDENT_CODE ON)
414414

415-
if (VSG_CXX_TARGET EQUAL 23)
416-
target_compile_features(vsg PUBLIC cxx_std_23)
417-
elseif (VSG_CXX_TARGET EQUAL 20)
418-
target_compile_features(vsg PUBLIC cxx_std_20)
419-
elseif (VSG_CXX_TARGET EQUAL 17)
415+
# set up the C++ Standard used
416+
if (NOT CMAKE_CXX_STANDARD)
417+
# no CMAKE_CXX_STANDARD explicitly defined so default to 17
420418
target_compile_features(vsg PUBLIC cxx_std_17)
421-
else()
422-
message("Warning: invalid VSG_CXX_TARGET setting of " ${VSG_CXX_TARGET} " valid settings are 17, 20 or 23")
419+
elseif (${CMAKE_CXX_STANDARD} EQUAL 17)
423420
target_compile_features(vsg PUBLIC cxx_std_17)
421+
elseif (${CMAKE_CXX_STANDARD} EQUAL 20)
422+
target_compile_features(vsg PUBLIC cxx_std_20) # CMake minimum version 3.12
423+
elseif (${CMAKE_CXX_STANDARD} EQUAL 23)
424+
target_compile_features(vsg PUBLIC cxx_std_23) # CMake minimum version 3.20
425+
elseif (${CMAKE_CXX_STANDARD} EQUAL 26)
426+
target_compile_features(vsg PUBLIC cxx_std_26) # CMake minimum version 3.30
427+
else()
428+
message(FATAL_ERROR "Invalid CMAKE_CXX_STANDARD value of " ${CMAKE_CXX_STANDARD} ", supported values are 17, 20 or 23.")
424429
endif()
425430

426431

0 commit comments

Comments
 (0)