I wrote an CMakeLists.txt
to build a project with either g++
or clang++
.
To catch as many as possible bugs I use both libc++
I think you can safely just pass both defines for each library.
But if you really want to do this conditionally, I'd recommend using CheckCXXSourceCompiles module with following code:
#include <iostream>
int a =
#ifdef __GLIBCXX__
1;
#else
fgsfds;
#endif
int main(int argc, char* argv[])
{
return 0;
}
If that code compiles, then you are using libstdc++.