Relative Content

Tag Archive for c++cmake

CMake variable naming the C++ standard library implementation or path

CMake as used to compile C++ code has a variable CMAKE_CXX_COMPILER_ID that generally identifies the compiler in use as GCC, Clang, MSVC, Nvidia, etc. Is there a similar variable that identifies that C++ standard library implementation that will be referenced in the build? E.g. like “libstdc++” (from GCC), “libc++” (from LLVM), “MSVC++” (Microsoft), “stlport” (various ancient C++ implementations shipped with this).

Check if header has been generated using cmake

Let’s say I have two files main.cpp and generate_header.cpp. generate_header.cpp generates a header containing data that main.cpp needs to run. based on this answer, I can use the following code to run generate_header.cpp before building main.cpp:

C++: cc1plus: all warnings being treated as errors only in Debug mode

I recently migrated my C++ application from a native RHEL 7 application to a container (UBI9.4) running for now on RHEL 9 and I get some warnings when compiling. For some reason this causes the compilation to fail with cc1plus: all warnings being treated as errors. What´s strange is that it only happens when I set the build variant to Debug. With Release and RelWithDebInfo it works just fine.