cmake detect which library libc++ or libstdc++ is configured to be used against g++ or clang++

前端 未结 1 570
孤城傲影
孤城傲影 2021-01-21 10:29

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++

相关标签:
1条回答
  • 2021-01-21 11:08

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

    0 讨论(0)
提交回复
热议问题