Compiler is not using c++17 standard even though I configured it in CMakeLists.txt

Hello,

I’m trying to use ROOT’s libraries in Visual Studio Community 2022 v17.8.3. Some of them need the c++17 standard to compile, so I configured it in CMakeLists.txt However, when I try building the project, the compiler gives me a warning because I’m not using the correct standard (obviously followed by a bunch of errors caused by undefined stuff).


I tried a lot of different things, like changing the cmake version, replacing True with ON in set(CMAKE_CXX_STANDARD_REQUIRED ON), manually linking the stdc++fs library (required for string_view, the library that’s giving me issues), and other things that I don’t even remember anymore.
What is causing this issue, and how can I solve it?

Thanks in advance.
Fede.

Put the set() before add_executable()

I changed the order and now it’s working, I had no idea the order of the instructions mattered (I learned how to use cmake literally yesterday).
Thank you so much for your help.