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

**URL:** https://discourse.cmake.org/t/compiler-is-not-using-c-17-standard-even-though-i-configured-it-in-cmakelists-txt/9570
**Category:** Usage
**Created:** [December 6, 2023, 5:34pm UTC](https://discourse.cmake.org/t/compiler-is-not-using-c-17-standard-even-though-i-configured-it-in-cmakelists-txt/9570 "2023-12-06T17:34:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![FederalPoop](https://discourse.cmake.org/user_avatar/discourse.cmake.org/federalpoop/32/4057_2.png) [@FederalPoop](https://discourse.cmake.org/u/FederalPoop)
#### Post date: [December 6, 2023, 5:34pm UTC](https://discourse.cmake.org/t/compiler-is-not-using-c-17-standard-even-though-i-configured-it-in-cmakelists-txt/9570/1 "2023-12-06T17:34:10Z")

</div>

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).

 ![Even though I configured the c++17 standard in CMakeLists, the compiler is not using it](https://discourse.cmake.org/uploads/default/original/2X/6/677fbbe8b9c625971c770cd3c66e6c6d4161b576.png)  
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.

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [December 6, 2023, 5:46pm UTC](https://discourse.cmake.org/t/compiler-is-not-using-c-17-standard-even-though-i-configured-it-in-cmakelists-txt/9570/2 "2023-12-06T17:46:15Z")

</div>

Put the set() before add\_executable()

---

<div class="post-metadata">

### Author: ![FederalPoop](https://discourse.cmake.org/user_avatar/discourse.cmake.org/federalpoop/32/4057_2.png) [@FederalPoop](https://discourse.cmake.org/u/FederalPoop)
#### Post date: [December 6, 2023, 5:50pm UTC](https://discourse.cmake.org/t/compiler-is-not-using-c-17-standard-even-though-i-configured-it-in-cmakelists-txt/9570/3 "2023-12-06T17:50:42Z")

</div>

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.
