How to enable c++17 for CMake?

Now, I got this error when building using CMake:

error C2039: ‘string_view’: is not a member of ‘std’

string_view is a new feature of C++17 which must be enabled for CMake.

You can use the following command to configure your project to enable C++17 support:

cmake src -DCMAKE_CXX_STANDARD=17

Alternatively, you can set the CMAKE_CXX_STANDARD variable in CMakeLists.txt:

set(CMAKE_CXX_STANDARD 17)

You can also enable C++17 support for CMake by adding the following line to CMakeLists.txt:

target_compile_features(projectname PRIVATE cxx_std_17)

Did you like this?
Tip admin with Cryptocurrency

Donate Bitcoin to admin

Scan to Donate Bitcoin to admin
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to admin

Scan to Donate Bitcoin Cash to admin
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to admin

Scan to Donate Ethereum to admin
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to admin

Scan to Donate Litecoin to admin
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to admin

Scan to Donate Monero to admin
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to admin

Scan to Donate ZCash to admin
Scan the QR code or copy the address below into your wallet to send some ZCash:

Leave a Reply