locked
Compiling with CMake & Clang from Visual Studio adds unwanted flags to the compiler call RRS feed

  • Question

  • In my CMakeSetting.json I define a configuration clang-cl-x64-Debug (see the configuration in question at the bottom) (relevant settings are: generator: Ninja, inheritEnviroments: clang_cl_x64 and CMAKE_CXX_FLAGS).

    The call generated (you find an example of an actual call in the excerpt of the build protocol below) for the clang compiler contains additional flags (the problematic flag is: -Werror=all).

    The flags I want are, what I set in CMAKE_CXX_FLAGS (CMAKE_CXX_FLAGS_DEBUG is left empty):
    -v -m64 -fdiagnostics-absolute-paths -fms-extensions -fdelayed-template-parsing -fms-compatibility -stdlib=libstdc++ -D_GLIBCXX_DEBUG /DWIN32 /D_WINDOWS /W3 /GR /EHsc -D_USE_MATH_DEFINES=ON -D_WIN32_WINNT=0x0601 -DBOOST_USE_WINDOWS_H=ON -DBOOST_ALL_DYN_LINK=ON -Wno-error=all

    What I get is:
    -v -m64 -fdiagnostics-absolute-paths -fms-extensions -fdelayed-template-parsing -fms-compatibility -stdlib=libstdc++ -D_GLIBCXX_DEBUG /DWIN32 /D_WINDOWS /W3 /GR /EHsc -D_USE_MATH_DEFINES=ON -D_WIN32_WINNT=0x0601 -DBOOST_USE_WINDOWS_H=ON -DBOOST_ALL_DYN_LINK=ON -Wno-error=all -Werror=all -Werror=extra -Werror=uninitialized -Werror=unreachable-code -Werror=unused-variable -Werror=unreachable-code -Wno-error=cpp -Wpedantic -Werror=strict-overflow=2 -Wno-error=unused-local-typedef -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fcolor-diagnostics -ftemplate-depth=1024 -Wno-unused-command-line-argument -std=c++14 /MDd /Zi /Ob0 /Od /RTC1 -fno-inline -fno-omit-frame-pointer -wd4996 -wd4068 -wd4715 -wd4351 -wd4503

    The additional flags prevent a third party open source framework (https://project-osrm.org/) from compiling. I do not want to change the source code to be compliant with the elevated warning generated by -Werror=all, because I do not want to change the code at all.

    Here are some examples of build errors, which I want to be warnings only:

    C:\Projects\OSRM\depend\osrm\include\extractor\intersection\node_based_graph_walker.hpp(60,39): error : private field 'barrier_nodes' is not used [-Werror,-Wunused-private-field]
          const std::unordered_set<NodeID> &barrier_nodes;
                                            ^
    C:\Projects\OSRM\depend\osrm\include\extractor\intersection\node_based_graph_walker.hpp(61,34): error : private field 'turn_lanes_data' is not used [-Werror,-Wunused-private-field]
          const TurnLanesIndexedArray &turn_lanes_data;
                                       ^
      75 warnings and 9 errors generated.
      [7/150] C:\PROGRA~2\MICROS~1\2019\ENTERP~1\VC\Tools\Llvm\bin\clang-cl.exe  /nologo -TP -DBOOST_ENABLE_ASSERT_HANDLER -DBOOST_FILESYSTEM_NO_DEPRECATED -DBOOST_RESULT_OF_USE_DECLTYPE -DBOOST_SPIRIT_USE_PHOENIX_V3 -DNOMINMAX -DOSRM_PROJECT_DIR=\"C:/Projects/OSRM/depend/osrm\" -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I..\..\..\include -I..\..\..\build\include -I..\..\..\third_party\flatbuffers\include -I..\..\..\third_party\sol2 -I..\..\..\third_party\variant\include -I..\..\..\third_party\rapidjson\include -I..\..\..\third_party\microtar\src -I..\..\..\third_party\geometry.hpp-0.9.2\include -I..\..\..\third_party\cheap-ruler-cpp-2.5.4\include -I..\..\..\third_party\protozero\include -I..\..\..\third_party\vtzero\include -I..\..\..\third_party\libosmium\include -IC:\Projects\OSRM\depend\boost\boost_1_70_0 -I"C:\Program Files\intel\TBB\include" -I..\..\..\osrm-deps\libs\include -v -m64 -fdiagnostics-absolute-paths -fms-extensions -fdelayed-template-parsing -fms-compatibility -stdlib=libstdc++ -D_GLIBCXX_DEBUG /DWIN32 /D_WINDOWS /W3 /GR /EHsc -D_USE_MATH_DEFINES=ON -D_WIN32_WINNT=0x0601 -DBOOST_USE_WINDOWS_H=ON -DBOOST_ALL_DYN_LINK=ON -Wno-error=all -Werror=all -Werror=extra  -Werror=uninitialized -Werror=unreachable-code -Werror=unused-variable -Werror=unreachable-code -Wno-error=cpp -Wpedantic -Werror=strict-overflow=2 -Wno-error=unused-local-typedef -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fcolor-diagnostics -ftemplate-depth=1024 -Wno-unused-command-line-argument -std=c++14 /MDd /Zi /Ob0 /Od /RTC1 -fno-inline -fno-omit-frame-pointer   -wd4996 -wd4068 -wd4715 -wd4351 -wd4503 /showIncludes /FoCMakeFiles\GUIDANCE.dir\src\extractor\intersection\node_based_graph_walker.cpp.obj /FdCMakeFiles\GUIDANCE.dir\ -c ..\..\..\src\extractor\intersection\node_based_graph_walker.cpp
      FAILED: CMakeFiles/GUIDANCE.dir/src/extractor/intersection/node_based_graph_walker.cpp.obj

    Where are the additional flags comming from? How can I get rid of them?

    Many thanks in advance!

    The configuration:

        {
          "name": "clang-cl-x64-Debug",
          "generator": "Ninja",
          "configurationType": "Debug",
          "buildRoot": "${projectDir}\\out\\build\\${name}",
          "installRoot": "${projectDir}\\out\\install\\${name}",
          "cmakeCommandArgs": "",
          "buildCommandArgs": "-v",
          "ctestCommandArgs": "",
          "inheritEnvironments": [ "clang_cl_x64" ],
          "variables": [
            {
              "name": "CMAKE_ARCHIVE_OUTPUT_DIRECTORY",
              "value": "${projectDir}/../../out/clang_cl_x64/debug",
              "type": "FILEPATH"
            },
            {
              "name": "CMAKE_LIBRARY_OUTPUT_DIRECTORY",
              "value": "${projectDir}/../../out/clang_cl_x64/debug",
              "type": "FILEPATH"
            },
            {
              "name": "CMAKE_RUNTIME_OUTPUT_DIRECTORY",
              "value": "${projectDir}/../../out/clang_cl_x64/debug",
              "type": "FILEPATH"
            },
            {
              "name": "BOOST_ROOT",
              "value": "${projectDir}/../boost/boost_1_70_0",
              "type": "FILEPATH"
            },
            {
              "name": "TBB_ARCH_PLATFORM",
              "value": "intel64_Vc14.2",
              "type": "STRING"
            },
            {
              "name": "TBB_ROOT",
              "value": "${projectDir}../tbb",
              "type": "STRING"
            },
            {
              "name": "EXPAT_LIBRARY",
              "value": "${projectDir}/osrm-deps/libs/lib/libexpat.lib",
              "type": "FILEPATH"
            },
            {
              "name": "EXPAT_INCLUDE_DIR",
              "value": "${projectDir}/osrm-deps/libs/include",
              "type": "FILEPATH"
            },
            {
              "name": "BZIP2_LIBRARIES",
              "value": "${projectDir}/osrm-deps/libs/lib/bzip2.lib",
              "type": "FILEPATH"
            },
            {
              "name": "BZIP2_INCLUDE_DIR",
              "value": "${projectDir}/osrm-deps/libs/include",
              "type": "FILEPATH"
            },
            {
              "name": "LUA_DIR",
              "value": "${projectDir}/osrm-deps/libs/lib",
              "type": "FILEPATH"
            },
            {
              "name": "LUA_INCLUDE_DIR",
              "value": "${projectDir}/osrm-deps/libs/include",
              "type": "FILEPATH"
            },
            {
              "name": "ZLIB_LIBRARY",
              "value": "${projectDir}/../boost/boost_1_70_0/stage/lib/libboost_zlib-vc142-mt-x64-1_70.lib",
              "type": "FILEPATH"
            },
            {
              "name": "ZLIB_INCLUDE_DIR",
              "value": "${projectDir}/osrm-deps/libs/include",
              "type": "FILEPATH"
            },
            {
              "name": "ENABLE_MASON",
              "value": "false",
              "type": "BOOL"
            },
            {
              "name": "ENABLE_LTO",
              "value": "true",
              "type": "BOOL"
            },
            {
              "name": "CMAKE_C_FLAGS",
              "value": "-v -m64 -fdiagnostics-absolute-paths  -fdelayed-template-parsing -fms-compatibility -stdlib=libstdc++ -D_GLIBCXX_DEBUG /DWIN32 /D_WINDOWS /W3 /GR /EHsc -Werror=no-unused-variable -Werror=no-unused-result -D_USE_MATH_DEFINES=ON -D_WIN32_WINNT=0x0601 -DBOOST_USE_WINDOWS_H=ON -DBOOST_ALL_DYN_LINK=ON",
              "type": "STRING"
            },
            {
              "name": "CMAKE_CXX_FLAGS",
              "value": "-v -m64 -fdiagnostics-absolute-paths -fms-extensions -fdelayed-template-parsing -fms-compatibility -stdlib=libstdc++ -D_GLIBCXX_DEBUG /DWIN32 /D_WINDOWS /W3 /GR /EHsc -D_USE_MATH_DEFINES=ON -D_WIN32_WINNT=0x0601 -DBOOST_USE_WINDOWS_H=ON -DBOOST_ALL_DYN_LINK=ON -Wno-error=all ",
              "type": "STRING"
            },
            {
              "name": "LDFLAGS",
              "value": "-stdlib=libc++",
              "type": "STRING"
            },
            {
              "name": "BUILD_PACKAGE",
              "value": "OFF",
              "type": "BOOL"
            }
          ]
        }

    Wednesday, April 22, 2020 9:19 AM

All replies

  • Hi,

    Thank you for posting here.

    Our forum is discussing about Visual C++ IDE, libraries, samples, tools, setup, and Windows programming using MFC and ATL. Since your issue contains CMake and Clang , it is likely that it is beyond our support.I suggest you could ask it in CMake forum for better support.

    Best Regards,

    Jeanine Zhang

    Thursday, April 23, 2020 2:04 AM
  • Hi,

    thanks for quick reply :-)

    The Question is about the CLang / CMake support form within the Visual Studio IDE. Therefore I believe the CMake support will send me right back.

    Cloud you please take a closer look at my question.

    Many thanks in advance

    Kai

    Friday, April 24, 2020 7:58 AM