Skip to content

Cannot build with clang-cl #829

@sykhro

Description

@sykhro

Note: for general questions and comments, please use the forums at:
https://groups.google.com/g/json-c

Describe the bug
Building with clang-cl currently fails due to CMake not distinguishing it from clang with the GNU-style CLI.

clang-cl.exe  /nologo -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_UNICODE -IC:\Users\Erin\.conan2\p\b\json-e2cfe01b7c40f\b\src -IC:\Users\Erin\.conan2\p\b\json-e2cfe01b7c40f\b\build\Debug /EHsc /permissive- /Zc:preprocessor /volatile:iso -Wno-unused-command-line-argument -fuse-ld=lld /DWIN32 /D_WINDOWS /W3 -ffunction-sections -fdata-sections -Werror -Wall -Wcast-qual -Wno-error=deprecated-declarations -Wextra -Wwrite-strings -Wno-unused-parameter /Zi /Ob0 /Od /RTC1 -MDd /showIncludes /FoCMakeFiles\json-c.dir\json_util.c.obj /FdCMakeFiles\json-c.dir\json-c.pdb -c -- C:\Users\Erin\.conan2\p\b\json-e2cfe01b7c40f\b\src\json_util.c
clang-cl: error: unknown argument ignored in clang-cl: '-ffunction-sections' [-Werror,-Wunknown-argument]
clang-cl: error: unknown argument ignored in clang-cl: '-fdata-sections' [-Werror,-Wunknown-argument]

The proper fix is using CMAKE_C_COMPILER_FRONTEND_VARIANT, but it would require bumping the CMake version to 3.14.

I know about the DISABLE_WERROR option, but clang-cl needs to be detected as MSVC.

Steps To Reproduce

  1. Configure CMake with CMAKE_C_COMPILER set to clang-cl
  2. Build

Version and Platform

  • json-c version: >= 0.16
  • OS: Any
  • Custom cmake/build flags, if any: None that would be relevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions