Я пытался собрать zlib с помощью cmake и clang (8.0) в Windows 64. Я сделал следующие шаги:
mkdir build.clang
cd build.clang
call "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
cmake -E env LDFLAGS="-fuse-ld=lld" cmake -H. -G Ninja ^
-DCMAKE_C_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
-DCMAKE_C_COMPILER_ID="Clang" ^
-DCMAKE_AR="c:\Program Files\LLVM\bin\llvm-ar.exe" ^
-DCMAKE_SYSTEM_NAME="Generic" ..
Конфигурация работает нормально (исключая утверждение, что невозможно создать общие библиотеки, но этона данный момент это не проблема):
-- The C compiler identification is Clang
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done CMake Warning (dev) at CMakeLists.txt:186 (add_library): ADD_LIBRARY called with SHARED option but the target platform does not support dynamic linking. Building a STATIC library instead. This may lead to problems. This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: F:/Project-tests/clang_lept/zlib-1.2.11/build.clang
Однако сборка не удалась:
cmake --build . --config Release
[1/36] Building C object CMakeFiles/zlib.dir/crc32.obj
FAILED: CMakeFiles/zlib.dir/crc32.obj
C:\PROGRA~1\LLVM\bin\clang-cl.exe -DNO_FSEEKO -I. -I../ -MD -MT CMakeFiles/zlib.dir/crc32.obj -MF CMakeFiles\zlib.dir\crc32.obj.d -o CMakeFiles/zlib.dir/crc32.obj -c ../crc32.c
clang-cl: warning: unknown argument ignored in clang-cl: '-MF' [-Wunknown-argument]
clang-cl: error: no such file or directory: 'CMakeFiles/zlib.dir/crc32.obj'
clang-cl: error: no such file or directory: 'CMakeFiles\zlib.dir\crc32.obj.d'
[2/36] Building C object CMakeFiles/zlib.dir/gzread.obj
FAILED: CMakeFiles/zlib.dir/gzread.obj
C:\PROGRA~1\LLVM\bin\clang-cl.exe -DNO_FSEEKO -I. -I../ -MD -MT CMakeFiles/zlib.dir/gzread.obj -MF CMakeFiles\zlib.dir\gzread.obj.d -o CMakeFiles/zlib.dir/gzread.obj -c ../gzread.c
clang-cl: warning: unknown argument ignored in clang-cl: '-MF' [-Wunknown-argument]
clang-cl: error: no such file or directory: 'CMakeFiles/zlib.dir/gzread.obj'
clang-cl: error: no such file or directory: 'CMakeFiles\zlib.dir\gzread.obj.d'
[3/36] Building C object CMakeFiles/zlib.dir/compress.obj
FAILED: CMakeFiles/zlib.dir/compress.obj
C:\PROGRA~1\LLVM\bin\clang-cl.exe -DNO_FSEEKO -I. -I../ -MD -MT CMakeFiles/zlib.dir/compress.obj -MF CMakeFiles\zlib.dir\compress.obj.d -o CMakeFiles/zlib.dir/compress.obj -c ../compress.c
clang-cl: warning: unknown argument ignored in clang-cl: '-MF' [-Wunknown-argument]
clang-cl: error: no such file or directory: 'CMakeFiles/zlib.dir/compress.obj'
clang-cl: error: no such file or directory: 'CMakeFiles\zlib.dir\compress.obj.d'
[4/36] Building C object CMakeFiles/zlib.dir/adler32.obj
FAILED: CMakeFiles/zlib.dir/adler32.obj
C:\PROGRA~1\LLVM\bin\clang-cl.exe -DNO_FSEEKO -I. -I../ -MD -MT CMakeFiles/zlib.dir/adler32.obj -MF CMakeFiles\zlib.dir\adler32.obj.d -o CMakeFiles/zlib.dir/adler32.obj -c ../adler32.c
clang-cl: warning: unknown argument ignored in clang-cl: '-MF' [-Wunknown-argument]
clang-cl: error: no such file or directory: 'CMakeFiles/zlib.dir/adler32.obj'
clang-cl: error: no such file or directory: 'CMakeFiles\zlib.dir\adler32.obj.d'
[5/36] Building C object CMakeFiles/zlib.dir/gzclose.obj
FAILED: CMakeFiles/zlib.dir/gzclose.obj
C:\PROGRA~1\LLVM\bin\clang-cl.exe -DNO_FSEEKO -I. -I../ -MD -MT CMakeFiles/zlib.dir/gzclose.obj -MF CMakeFiles\zlib.dir\gzclose.obj.d -o CMakeFiles/zlib.dir/gzclose.obj -c ../gzclose.c
clang-cl: warning: unknown argument ignored in clang-cl: '-MF' [-Wunknown-argument]
clang-cl: error: no such file or directory: 'CMakeFiles/zlib.dir/gzclose.obj'
clang-cl: error: no such file or directory: 'CMakeFiles\zlib.dir\gzclose.obj.d'
[6/36] Building C object CMakeFiles/zlib.dir/gzlib.obj
FAILED: CMakeFiles/zlib.dir/gzlib.obj
C:\PROGRA~1\LLVM\bin\clang-cl.exe -DNO_FSEEKO -I. -I../ -MD -MT CMakeFiles/zlib.dir/gzlib.obj -MF CMakeFiles\zlib.dir\gzlib.obj.d -o CMakeFiles/zlib.dir/gzlib.obj -c ../gzlib.c
clang-cl: warning: unknown argument ignored in clang-cl: '-MF' [-Wunknown-argument]
clang-cl: error: no such file or directory: 'CMakeFiles/zlib.dir/gzlib.obj'
clang-cl: error: no such file or directory: 'CMakeFiles\zlib.dir\gzlib.obj.d'
ninja: build stopped: subcommand failed.
Когда я пытался использовать GCC-совместимость clang - сборка тоже не удалась, но во время процесса компоновки...
PS: сборка с VS 2017 (cmake .. -G "Visual Studio 15 2017 Win64"
) работает без проблем ...