I use SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -lstdc++") and target_link_libraries(stdc++) with cmake.