Re: [CMake] Using Clang + Ninja on Windows?

2016-04-22 Thread Edward Diener

On 4/22/2016 4:51 AM, Mueller-Roemer, Johannes Sebastian wrote:

It is true that there is no official bundled installer with both, but
the official installer works just fine with mingw as long as you pass in
the correct target to clang(++)

For example

clang++ --target=x86_64-w64-mingw32 test.cpp

However, it assumes that mingw64 is installed under C:/mingw64 (the
default location, it’ll work with a junction point though).


As of clang 3.7 there is no need to have a hardcoded mingw directory. 
You just need to have an appropriate mingw(-64)/gcc in your PATH. Also 
all distributed versions of clang 3.4 through 3.7 for Windows default to 
targeting mingw(-64)/gcc and not VC++. Only with 3.8 is the Windows 
release defaulting to targeting VC++.



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] Using Clang + Ninja on Windows?

2016-04-22 Thread Mueller-Roemer, Johannes Sebastian
It is true that there is no official bundled installer with both, but the 
official installer works just fine with mingw as long as you pass in the 
correct target to clang(++)

For example
clang++ --target=x86_64-w64-mingw32 test.cpp

However, it assumes that mingw64 is installed under C:/mingw64 (the default 
location, it’ll work with a junction point though).


From: Cristian Adam [mailto:cristian.a...@gmail.com]
Sent: Friday, April 22, 2016 09:15
To: Mueller-Roemer, Johannes Sebastian 
<johannes.sebastian.mueller-roe...@igd.fraunhofer.de>
Cc: cmake@cmake.org
Subject: Re: [CMake] Using Clang + Ninja on Windows?

On Fri, Apr 22, 2016 at 8:59 AM, Mueller-Roemer, Johannes Sebastian 
<johannes.sebastian.mueller-roe...@igd.fraunhofer.de<mailto:johannes.sebastian.mueller-roe...@igd.fraunhofer.de>>
 wrote:
You are mistaken, Clang absolutely also works with MinGW. Or it did at least up 
to 3.7 (didn’t get around to trying 3.8 yet)


Clang works fine with libstdc++ on Linux and Cygwin, there should be no reason 
why it shouldn't work with MinGW.

What I should have wrote was that Clang on Windows officially supports only a 
Visual C++ setup / Visual Studio integration.

I don't think I have seen a package containing clang and libstdc++ from MinGW.

Cheers,
Cristian.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Using Clang + Ninja on Windows?

2016-04-22 Thread Cristian Adam
On Fri, Apr 22, 2016 at 8:59 AM, Mueller-Roemer, Johannes Sebastian <
johannes.sebastian.mueller-roe...@igd.fraunhofer.de> wrote:

> You are mistaken, Clang absolutely also works with MinGW. Or it did at
> least up to 3.7 (didn’t get around to trying 3.8 yet)
>
>
>

Clang works fine with libstdc++ on Linux and Cygwin, there should be no
reason why it shouldn't work with MinGW.

What I should have wrote was that Clang on Windows officially supports only
a Visual C++ setup / Visual Studio integration.

I don't think I have seen a package containing clang and libstdc++ from
MinGW.

Cheers,
Cristian.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Using Clang + Ninja on Windows?

2016-04-22 Thread Mueller-Roemer, Johannes Sebastian
You are mistaken, Clang absolutely also works with MinGW. Or it did at least up 
to 3.7 (didn’t get around to trying 3.8 yet)

From: CMake [mailto:cmake-boun...@cmake.org] On Behalf Of Cristian Adam
Sent: Thursday, April 21, 2016 23:30
To: Johan Holmberg <johan...@gmail.com>
Cc: cmake@cmake.org
Subject: Re: [CMake] Using Clang + Ninja on Windows?


On Wed, Apr 20, 2016 at 4:01 PM, Johan Holmberg 
<johan...@gmail.com<mailto:johan...@gmail.com>> wrote:
Hi!
How should I setup CMake to build a C/C++ application on Windows using 
clang/clang++ as compilers and Ninja as build tool?
I tried specifying "-GNinja" to cmake, and setting CC/CXX to clang/clang++. But 
this didn't work. I get errors like:

  clang.exe: error: no such file or directory: '/nologo'
indicating that CMake thinks it should pass Visual C++ style options to clang.
I'm thinking about fooling CMake that clang/clang++ are cross compilers (I know 
how to get cross compiling working in other cases). But since clang/clang++ are 
the native tools for Windows, I was hoping to be able to use Clang + Ninja on 
Windows almost like I use on Linux.
If I run Clang from the command line, I can build my application, so my 
Clang-installation works.

I'm using CMake 3.5.1 and Clang 3.8.0.
/Johan Holmberg

Hi,

On Windows Clang works only with Visual C++, since they don't provide libc++. 
MinGW is not supported.
Clang provides a Visual C++'s cl.exe replacement.

You need to have the official 
windows<http://llvm.org/releases/download.html#3.8.0> Clang and Visual C++ 
Express or Community installed.

Then it's just a matter of:
1.   Opening a Visual C++ 2013 64 bit command prompt window
2.   Putting clang's cl.exe in the path and setting clang's INCLUDE path 
first

set PATH=c:\Program Files\LLVM\msbuild-bin\;%PATH%
set INCLUDE=c:\Program Files\LLVM\lib\clang\3.8.0\include\;%INCLUDE%
3.   cmake -G "Ninja"
4.   Ninja
CMake / Ninja will think that they compile with Visual C++, but instead will 
use clang.

Note that you have to match Visual C++ and Clang's build, 32 or 64 bit. You 
can't mix them,
or you'll have weird 
errors<https://cmake.org/pipermail/cmake/2016-March/062978.html>.

Cheers,
Cristian.

P.S. This is actually a re-post, this time adding the mailing list.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Using Clang + Ninja on Windows?

2016-04-21 Thread Gonzalo



El 21/04/16 a las 18:30, Cristian Adam escribió:}

> Note that you have to match Visual C++ and Clang's build, 32 or 64 
bit. You can't mix them,
> or you'll have weird errors 
.


I wonder.  Are the C and C++ ABIs of both compilers compatible? That is, 
can I develop a program with clang but use visualc++ dlls or viceversa.



--
Gonzalo Garramuño
ggarr...@gmail.com

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Using Clang + Ninja on Windows?

2016-04-21 Thread Cristian Adam
On Wed, Apr 20, 2016 at 4:01 PM, Johan Holmberg  wrote:

> Hi!
>
> How should I setup CMake to build a C/C++ application on Windows using
> clang/clang++ as compilers and Ninja as build tool?
>
> I tried specifying "-GNinja" to cmake, and setting CC/CXX to
> clang/clang++. But this didn't work. I get errors like:
>
>   clang.exe: error: no such file or directory: '/nologo'
>
> indicating that CMake thinks it should pass Visual C++ style options to
> clang.
>
> I'm thinking about fooling CMake that clang/clang++ are cross compilers (I
> know how to get cross compiling working in other cases). But since
> clang/clang++ are the native tools for Windows, I was hoping to be able to
> use Clang + Ninja on Windows almost like I use on Linux.
>
> If I run Clang from the command line, I can build my application, so my
> Clang-installation works.
>
> I'm using CMake 3.5.1 and Clang 3.8.0.
>
> /Johan Holmberg
>
>
Hi,

On Windows Clang works only with Visual C++, since they don't provide
libc++. MinGW is not supported.
Clang provides a Visual C++'s cl.exe replacement.

You need to have the official windows
 Clang and Visual C++ Express
or Community installed.

Then it's just a matter of:

   1. Opening a Visual C++ 2013 64 bit command prompt window
   2. Putting clang's cl.exe in the path and setting clang's INCLUDE path
   first

   set PATH=c:\Program Files\LLVM\msbuild-bin\;%PATH%
   set INCLUDE=c:\Program Files\LLVM\lib\clang\3.8.0\include\;%INCLUDE%

   3. cmake -G "Ninja"
   4. Ninja

CMake / Ninja will think that they compile with Visual C++, but instead
will use clang.

Note that you have to match Visual C++ and Clang's build, 32 or 64 bit. You
can't mix them,
or you'll have weird errors
.

Cheers,
Cristian.

P.S. This is actually a re-post, this time adding the mailing list.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Using Clang + Ninja on Windows?

2016-04-21 Thread Brad King
On 04/21/2016 10:15 AM, Johan Holmberg wrote:
> I chose the binaries behaving like "gcc"
> 
> I realize that Cristian Adams recommended using the "cl.exe" wrapper in
> his response, but I wanted at least to try using the "gcc-like" binaries
> first, hoping that they should work with CMake.

I think that is the problem.  See below.

> E:\work\proj\hello1\build> cmake -GNinja ..\src
> -- The C compiler identification is Clang 3.8.0
> -- The CXX compiler identification is Clang 3.8.0

>From the compiler id files you sent me I see:

$ strings build/CMakeFiles/3.5.1/CompilerIdC/a.exe | grep INFO
INFO:compiler[Clang]
INFO:simulate[MSVC]
INFO:compiler_version[0003.0008.]
INFO:simulate_version[0018.]
INFO:platform[Windows]
INFO:arch[x64]
INFO:dialect_default[11]

$ strings build/CMakeFiles/3.5.1/CompilerIdCXX/a.exe | grep INFO
INFO:compiler[Clang]
INFO:simulate[MSVC]
INFO:platform[Windows]
INFO:arch[x64]
INFO:dialect_default[11]
INFO:compiler_version[0003.0008.]
INFO:simulate_version[0018.]

The "INFO:simulate[MSVC]" lines mean that CMake has detected that the given
Clang compiler defines _MSC_VER and therefore acts like MSVC and not GNU
(i.e. uses the msvc ABI instead of the gnu ABI).

CMake then assumes that the compiler command line is compatible with "cl".
We have code that switches off this here:

 
https://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/Platform/Windows-Clang.cmake;hb=v3.5.2
 
https://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/Compiler/Clang.cmake;hb=v3.5.2

When all that was written clang-cl was still under development and our
assumption was that there is no such thing as a Clang that acts like
MSVC but is not cl-compatible on the command line.

-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] Using Clang + Ninja on Windows?

2016-04-21 Thread Johan Holmberg
On Wed, Apr 20, 2016 at 5:54 PM, Brad King  wrote:

> On 04/20/2016 10:01 AM, Johan Holmberg wrote:
> > I tried specifying "-GNinja" to cmake, and setting CC/CXX to
> > clang/clang++.
>
> Good.
>
> > But this didn't work. I get errors like:
> >
> >   clang.exe: error: no such file or directory: '/nologo'
> >
> > indicating that CMake thinks it should pass Visual C++ style
> > options to clang.
>
> There are multiple variants of Clang that behave like "gcc" or "cl".
> Which one is this?  What installer did you use for Clang?
>


I used the installer at http://llvm.org/releases/3.8.0/LLVM-3.8.0-win64.exe
.

I chose the binaries behaving like "gcc": After installation I added the
"bin" directory to my PATH (actual command "set
path=e:\work\install\LLVM\bin;%PATH%"). In the new bin-directory there are
binaries called "clang.exe" and "clang++.exe" + a bunch of other binaries
eg. "clang-cl.exe". I did NOT put the directory
"e:\work\install\LLVM\msbuild-bin" in my PATH (containing a binary
"cl.exe").

I realize that Cristian Adams recommended using the "cl.exe" wrapper in his
response, but I wanted at least to try using the "gcc-like" binaries first,
hoping that they should work with CMake. I will probably try his advice
later, but as I understand it, both ways should be possible to get working
with CMake.


> CMake should start out by printing the compiler id for the C and
> CXX compilers.  What did it show?
>
>
CMake starts by saying:

E:\work\proj\hello1\build> cmake -GNinja ..\src
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- broken
[...rest removed...]


Please try a minimum test project like
>
> >type CMakeLists.txt
> cmake_minimum_required(VERSION 3.5)
> project(Test)
>
> in a fresh build tree and post the files
>
> CMakeFiles/CMake*.log
> CMakeFiles/*/CMake*Compiler.cmake
>
> to see what CMake detected about the compiler.
> Thanks,
> -Brad
>
>

OK, I attach the files to this mail. There were three file created:

build/CMakeFiles/3.5.1/CMakeRCCompiler.cmake
build/CMakeFiles/CMakeError.log
build/CMakeFiles/CMakeOutput.log

On my Windows machine I have Visual Studio 2008, 2012, 2013 and 2015. I
used CMake 3.5.1 and Ninja 1.6.0.

/Johan Holmberg
The system is: Windows - 6.1.7601 - AMD64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: E:/work/install/LLVM/bin/clang.exe 
Build flags: 
Id flags: 

The output was:
0


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.exe"

The C compiler identification is Clang, found in "E:/work/proj/hello1/build/CMakeFiles/3.5.1/CompilerIdC/a.exe"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: E:/work/install/LLVM/bin/clang++.exe 
Build flags: 
Id flags: 

The output was:
0


Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.exe"

The CXX compiler identification is Clang, found in "E:/work/proj/hello1/build/CMakeFiles/3.5.1/CompilerIdCXX/a.exe"

Determining if the C compiler works failed with the following output:
Change Dir: E:/work/proj/hello1/build/CMakeFiles/CMakeTmp

Run Build Command:"C:/Users/holmberg/home/bin/ninja.exe" "cmTC_98675"
[1/2] Building C object CMakeFiles\cmTC_98675.dir\testCCompiler.c.obj

FAILED: E:\work\install\LLVM\bin\clang.exe   /nologo   /DWIN32 /D_WINDOWS /W3  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\cmTC_98675.dir\testCCompiler.c.obj /FdCMakeFiles\cmTC_98675.dir\ -c testCCompiler.c

clang.exe: error: no such file or directory: '/nologo'

clang.exe: error: no such file or directory: '/DWIN32'

clang.exe: error: no such file or directory: '/D_WINDOWS'

clang.exe: error: no such file or directory: '/W3'

clang.exe: error: no such file or directory: '/D_DEBUG'

clang.exe: error: no such file or directory: '/MDd'

clang.exe: error: no such file or directory: '/Zi'

clang.exe: error: no such file or directory: '/Ob0'

clang.exe: error: no such file or directory: '/Od'

clang.exe: error: no such file or directory: '/RTC1'

clang.exe: error: no such file or directory: '/showIncludes'

clang.exe: error: no such file or directory: '/FoCMakeFiles\cmTC_98675.dir\testCCompiler.c.obj'

clang.exe: error: no such file or directory: '/FdCMakeFiles\cmTC_98675.dir\'

ninja: build stopped: subcommand failed.



set(CMAKE_RC_COMPILER "rc")
set(CMAKE_RC_COMPILER_ARG1 "")
set(CMAKE_RC_COMPILER_LOADED 1)
set(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc;RC)
set(CMAKE_RC_OUTPUT_EXTENSION .res)
set(CMAKE_RC_COMPILER_ENV_VAR "RC")
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: 

Re: [CMake] Using Clang + Ninja on Windows?

2016-04-20 Thread Brad King
On 04/20/2016 10:01 AM, Johan Holmberg wrote:
> I tried specifying "-GNinja" to cmake, and setting CC/CXX to
> clang/clang++.

Good.

> But this didn't work. I get errors like:
> 
>   clang.exe: error: no such file or directory: '/nologo'
> 
> indicating that CMake thinks it should pass Visual C++ style
> options to clang.

There are multiple variants of Clang that behave like "gcc" or "cl".
Which one is this?  What installer did you use for Clang?

CMake should start out by printing the compiler id for the C and
CXX compilers.  What did it show?

Please try a minimum test project like

>type CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(Test)

in a fresh build tree and post the files

CMakeFiles/CMake*.log
CMakeFiles/*/CMake*Compiler.cmake

to see what CMake detected about the compiler.

Thanks,
-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake