CMake and Specified unknown feature "cxx_std_ 17"

I’m trying to learn CMake and I’m following the console app example. However I’m getting the following error:

CMake Error in CMakeLists.txt:
  Specified unknown feature "cxx_std_	17" for target "TaggerApp".

But I’m setting CMake to use C++ 20.

set(CMAKE_CXX_STANDARD 20)

Using CMake cmake version 3.21.3

Any ideas?

Are you using any custom modules, and do any of those set the C++ standard to 17 in their module metadata blocks? Perhaps there’s an unexpected character in there (a tab, by the looks of things) that the parsing code isn’t handling properly.

That was it, thanks. Is it possible to work around that in juceaide/cmake? Seems to be a pretty big limitation if you can’t use CMake if you save your source with tabs?

Yeah, it’s probably just a regex bug in the parser. I’ll take a look at it tomorrow.

The following fixed it for me, if you don’t want to have to change all the regexps

index 5f5f1de8c..f4b19baa7 100644
--- a/extras/Build/CMake/JUCEModuleSupport.cmake
+++ b/extras/Build/CMake/JUCEModuleSupport.cmake
@@ -119,6 +119,7 @@ function(_juce_extract_metadata_block delim_str file_with_block out_dict)
     set(append NO)
 
     foreach(line IN LISTS module_header_contents)
+        string(REPLACE "\t" " " line "${line}")
         if(NOT append)
             if(line MATCHES " *BEGIN_${delim_str} *")
                 set(append YES)

Thanks for reporting this issue. It should be fixed here:

2 Likes