I am using Websocketpp that requires C++11 to be compiled (I don't want to setup boost). I want to use some C++20 features (Smart Pointers mainly) for the rest of my project. I tried looking through the CMake documentation and didn't find something that can help. Unfortunately, I am still not familiar with advance CMake features. Any help will be appreciated.
Asked
Active
Viewed 44 times
0
-
2"Websocketpp that **requires** C++11" Why bold requires? Where is it documented? What happens if you use C++20? – n. m. could be an AI Jan 20 '22 at 09:28
-
There is already a [question](https://stackoverflow.com/questions/10851247/how-do-i-activate-c-11-in-cmake) on Stack Overflow about setting C++ standard in CMake. Among its answers choose ones which works through the **target properties** instead of *variables*. E.g. [this one](https://stackoverflow.com/a/30251215/3440745) or [that one](https://stackoverflow.com/a/20165519/3440745). Setting different properties for different libraries will activate different C++ standards for them. – Tsyvarev Jan 20 '22 at 09:39
-
1C++11 code works fine with C++20 (with small corner cases which will not happen) , so just build everything as C++20. Do not make this over complicated. When someone says `requires C++11` it means `requires at least C++11`. – Marek R Jan 20 '22 at 09:41
-
1Other ways to approach this is to build dependency separately and install it in a system. Then in your code just do `find_package` to find dependency and use preferred C++ standard. – Marek R Jan 20 '22 at 09:44
-
Linking libraries that were compiled with different compiler or language versions (any combination) is... fraught. You should endeavor to compile Websocketpp as C++20. – Alex Reinking Jan 20 '22 at 19:18
-
@n.1.8e9-where's-my-sharem. post C++11 it requires boost to work. I don't want to setup another dependency that I'll barely use. [Here's a where I read that](https://stackoverflow.com/questions/33662788/undefined-reference-to-stderrcoperation-canceled-when-compiling-websocketp) – Ackker Jan 22 '22 at 09:42
-
"post C++11 it requires boost" From my cursory reading of the code this doesn't seem to be the case. It requires boost for certain older compilers, not for newer ones. – n. m. could be an AI Jan 22 '22 at 10:02