From 1a7a550bfe48528abf7a7e0fc6989b2b4ff0cdb7 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 17 Apr 2023 14:17:48 -0600 Subject: [PATCH] Use globally set CMAKE_CXX_STANDARD if it is set (#620) --- cmake/ftxui_set_options.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmake/ftxui_set_options.cmake b/cmake/ftxui_set_options.cmake index d608980..90acde4 100644 --- a/cmake/ftxui_set_options.cmake +++ b/cmake/ftxui_set_options.cmake @@ -43,9 +43,17 @@ function(ftxui_set_options library) $ ) + # Play nicely if we are being consumed by another project + # and use their CMAKE_CXX_STANDARD. Otherwise, fall back to 17 # C++17 is used. We require fold expression at least. + if (DEFINED CMAKE_CXX_STANDARD) + set(CXX_STANDARD ${CMAKE_CXX_STANDARD}) + else() + set(CXX_STANDARD 17) + endif() + set_target_properties(${library} PROPERTIES - CXX_STANDARD 17 + CXX_STANDARD ${CXX_STANDARD} CXX_EXTENSIONS OFF )