[prev in list] [next in list] [prev in thread] [next in thread]
List: cmake
Subject: Re: [CMake] Where do all the extra clang flags come from in Xcode?
From: Ruslan Baratov via CMake <cmake () cmake ! org>
Date: 2015-05-18 10:32:52
Message-ID: 5559BFD4.5030404 () yahoo ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
On 18-May-15 06:50, Paul Smith wrote:
> On Sun, 2015-05-17 at 14:43 +0200, Ruslan Baratov via CMake wrote:
>> As far as I know extra flags set by Xcode itself. You can use
>> XCODE_ATTRIBUTE_* target properties to enable/disable warnings. This
>> table can be helpful:
>> https://github.com/ruslo/leathers/wiki/List#xcodeclang-table
> Thanks for your reply... but I don't quite understand what this table is
> telling me.
This table tells you what attribute you need to set to disable/enable
specific warning.
E.g.:
| Clang | Xcode |
+-----------------+----------------------------+
| enum-conversion | CLANG_WARN_ENUM_CONVERSION |
Makefile generator:
> cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(Foo)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wenum-conversion")
add_library(foo foo.cpp)
> cmake -H. -B_builds "-GUnix Makefiles" -DCMAKE_VERBOSE_MAKEFILE=ON
> cmake --build _builds
/.../usr/bin/c++ -Wenum-conversion ...
Xcode generator (default):
> cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(Foo)
add_library(foo foo.cpp)
> cmake -H. -B_builds -GXcode
> cmake --build _builds
/.../usr/bin/clang ... -Wno-enum-conversion ...
Xcode generator (enable):
> cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(Foo)
add_library(foo foo.cpp)
set_target_properties(
foo
PROPERTIES
XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION YES
)
> cmake -H. -B_builds -GXcode
> cmake --build _builds
/.../usr/bin/clang ... -Wenum-conversion ...
Xcode generator (disable):
> cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(Foo)
add_library(foo foo.cpp)
set_target_properties(
foo
PROPERTIES
XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION NO
)
> cmake -H. -B_builds -GXcode
> cmake --build _builds
/.../usr/bin/clang ... -Wno-enum-conversion ...
>
> As mentioned, these builds are performed on build servers running OSX,
> where basically the code is retrieved via Git, then cmake is run, then
> cmake -build is run (which invokes xcodebuild via the command line), all
> using SSH commands from a build control server. At no time is Xcode
> itself invoked.
I don't understand what you mean by "no time is Xcode itself invoked".
When you set generator to "Unix Makefiles" then Makefile project generated:
> cmake -H. -B_builds "-GUnix Makefiles"
> ls _builds/Makefile
_builds/Makefile
when you set generator to "Xcode" then Xcode project used:
> cmake -H. -B_builds -GXcode
> ls _builds/Foo.xcodeproj/project.pbxproj
_builds/Foo.xcodeproj/project.pbxproj
so there is no difference between:
* open Xcode project and hit "Build"
* cmake --build _builds
* (cd _builds && xcodebuild -alltargets)
>
> So, if the properties you describe are Xcode settings that need to be
> tweaked then do you know if there is some command-line way to do it,
> that I could encode into my build scripts for example?
See example above.
Also you can use some helper functions to do it in cross-platform way:
sugar_generate_warning_flags(
target_compile_options
target_properties
ENABLE enum-conversion
)
set_target_properties(
foo
PROPERTIES
${target_properties}
COMPILE_OPTIONS
"${target_compile_options}"
)
This will set MSVC flags too. See this wiki:
https://github.com/ruslo/sugar/wiki/Cross-platform-warning-suppression
Cheers, Ruslo
[Attachment #5 (text/html)]
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 18-May-15 06:50, Paul Smith wrote:<br>
</div>
<blockquote cite="mid:1431924624.22116.99.camel@mad-scientist.net"
type="cite">
<pre wrap="">On Sun, 2015-05-17 at 14:43 +0200, Ruslan Baratov via CMake wrote:
</pre>
<blockquote type="cite">
<pre wrap="">As far as I know extra flags set by Xcode itself. You can use
XCODE_ATTRIBUTE_* target properties to enable/disable warnings. This
table can be helpful:
<a class="moz-txt-link-freetext" \
href="https://github.com/ruslo/leathers/wiki/List#xcodeclang-table">https://github.com/ruslo/leathers/wiki/List#xcodeclang-table</a>
</pre>
</blockquote>
<pre wrap="">
Thanks for your reply... but I don't quite understand what this table is
telling me.</pre>
</blockquote>
This table tells you what attribute you need to set to
disable/enable specific warning.<br>
E.g.:<br>
<blockquote>
<pre>| Clang | Xcode |</pre>
<pre>+-----------------+----------------------------+</pre>
<pre>| enum-conversion | CLANG_WARN_ENUM_CONVERSION |</pre>
</blockquote>
<br>
Makefile generator:<br>
<blockquote>> cat CMakeLists.txt<br>
cmake_minimum_required(VERSION 3.0)<br>
project(Foo)<br>
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wenum-conversion")<br>
add_library(foo foo.cpp)<br>
<br>
> cmake -H. -B_builds "-GUnix Makefiles"
-DCMAKE_VERBOSE_MAKEFILE=ON<br>
> cmake --build _builds<br>
/.../usr/bin/c++ -Wenum-conversion ...<br>
</blockquote>
<br>
Xcode generator (default):<br>
<blockquote>> cat CMakeLists.txt<br>
cmake_minimum_required(VERSION 3.0)<br>
project(Foo)<br>
add_library(foo foo.cpp)<br>
<br>
> cmake -H. -B_builds -GXcode<br>
> cmake --build _builds<br>
/.../usr/bin/clang ... -Wno-enum-conversion ...<br>
</blockquote>
Xcode generator (enable):<br>
<blockquote>> cat CMakeLists.txt<br>
cmake_minimum_required(VERSION 3.0)<br>
project(Foo)<br>
add_library(foo foo.cpp)<br>
<br>
set_target_properties(<br>
foo<br>
PROPERTIES<br>
XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION YES<br>
)<br>
<br>
> cmake -H. -B_builds -GXcode<br>
> cmake --build _builds<br>
/.../usr/bin/clang ... -Wenum-conversion ...<br>
</blockquote>
Xcode generator (disable):<br>
<blockquote>> cat CMakeLists.txt<br>
cmake_minimum_required(VERSION 3.0)<br>
project(Foo)<br>
add_library(foo foo.cpp)<br>
<br>
set_target_properties(<br>
foo<br>
PROPERTIES<br>
XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION NO<br>
)<br>
<br>
> cmake -H. -B_builds -GXcode<br>
> cmake --build _builds<br>
/.../usr/bin/clang ... -Wno-enum-conversion ...<br>
</blockquote>
<blockquote cite="mid:1431924624.22116.99.camel@mad-scientist.net"
type="cite">
<pre wrap="">
As mentioned, these builds are performed on build servers running OSX,
where basically the code is retrieved via Git, then cmake is run, then
cmake -build is run (which invokes xcodebuild via the command line), all
using SSH commands from a build control server. At no time is Xcode
itself invoked.</pre>
</blockquote>
I don't understand what you mean by "no time is Xcode itself
invoked". When you set generator to "Unix Makefiles" then Makefile
project generated:<br>
> cmake -H. -B_builds "-GUnix Makefiles"<br>
> ls _builds/Makefile<br>
_builds/Makefile<br>
<br>
when you set generator to "Xcode" then Xcode project used:<br>
> cmake -H. -B_builds -GXcode<br>
> ls _builds/Foo.xcodeproj/project.pbxproj<br>
_builds/Foo.xcodeproj/project.pbxproj<br>
<br>
so there is no difference between:<br>
* open Xcode project and hit "Build"<br>
* cmake --build _builds<br>
* (cd _builds && xcodebuild -alltargets)<br>
<blockquote cite="mid:1431924624.22116.99.camel@mad-scientist.net"
type="cite">
<pre wrap="">
So, if the properties you describe are Xcode settings that need to be
tweaked then do you know if there is some command-line way to do it,
that I could encode into my build scripts for example?
</pre>
</blockquote>
See example above.<br>
<br>
Also you can use some helper functions to do it in cross-platform
way:<br>
<blockquote>
<pre>sugar_generate_warning_flags(
target_compile_options
target_properties
ENABLE enum-conversion
)
<span class="pl-c1">set_target_properties</span>(
foo
<span class="pl-k">PROPERTIES</span>
<span class="pl-v">${target_properties}
</span> COMPILE_OPTIONS
<span class="pl-s">"<span class="pl-v">${target_compile_options}</span>"</span>
)
</pre>
</blockquote>
This will set MSVC flags too. See this wiki:
<a class="moz-txt-link-freetext" \
href="https://github.com/ruslo/sugar/wiki/Cross-platform-warning-suppression">https://github.com/ruslo/sugar/wiki/Cross-platform-warning-suppression</a><br>
<br>
Cheers, Ruslo<br>
</body>
</html>
--
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic