Re: [CMake] How to set compiler flags?

2010-10-01 Thread Michael Wild

On 1. Oct, 2010, at 10:50 , fat...@crackmonkey.us wrote:

 
 Date: Wed, 29 Sep 2010 03:14:57 +0200
 From: Michael Hertling mhertl...@online.de
 Subject: Re: [CMake] How to set compiler flags?
 To: cmake@cmake.org
 Message-ID: 4ca29311.1050...@online.de
 Content-Type: text/plain; charset=ISO-8859-1
 
 [...] So I now use add_definitions instead:
 
 add_definitions( -Wall -m64 -O3 )
 
 Is there a better way of doing this?
 
 Don't do this at all, and adhere to the flags.
 
 
 Interesting - I've been doing this:
 
 if(CMAKE_BUILD_TYPE EQUAL Debug)
   set(CMAKE_CXX_FLAGS -Wno-long-long -Wno-comment -Wwrite-strings
 -std=c++0x -pedantic-errors -pedantic -Wall -W -g -gdwarf-2 -Weffc++
 -Wmain -Wextra)
 else(CMAKE_BUILD_TYPE EQUAL Debug)
   set(CMAKE_CXX_FLAGS -s etc)
 endif(CMAKE_BUILD_TYPE EQUAL Debug)
 
 because it never occurred to me to do it another way.
 
 Is this wrong too?
 
 Regards,
 Adam J Richardson

The problem with this is that the cache makes the promise to the user that he 
can change the flags and you break it.

Michael

--
There is always a well-known solution to every human problem -- neat, 
plausible, and wrong.
H. L. Mencken



PGP.sig
Description: This is a digitally signed message part
___
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] How to set compiler flags?

2010-10-01 Thread Michael Wild

On 1. Oct, 2010, at 11:23 , David Aldrich wrote:

 Hi
 
 if(CMAKE_BUILD_TYPE EQUAL Debug)
   set(CMAKE_CXX_FLAGS -Wno-long-long -Wno-comment -Wwrite-strings
 -std=c++0x -pedantic-errors -pedantic -Wall -W -g -gdwarf-2 -Weffc++
 -Wmain -Wextra)
 else(CMAKE_BUILD_TYPE EQUAL Debug)
   set(CMAKE_CXX_FLAGS -s etc)
 endif(CMAKE_BUILD_TYPE EQUAL Debug)
 
 As a total non-expert I don't see how this will work because if build type is 
 Debug then CMake will use CMAKE_CXX_FLAGS_DEBUG not CMAKE_CXX_FLAGS.
 
 Am I right?
 
 Best regards 
 
 David 

Wrong. CMAKE_CXX_FLAGS is always used, the configuration-specific values are 
appended to it.

Michael

PGP.sig
Description: This is a digitally signed message part
___
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] How to set compiler flags?

2010-10-01 Thread David Aldrich
Hi Michael

 Wrong. CMAKE_CXX_FLAGS is always used, the configuration-specific values are
 appended to it.

This is where I groan a little. I haven't read that in the online documentation.

Best regards 

David
___
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to set compiler flags?

2010-10-01 Thread Michael Wild

On 1. Oct, 2010, at 12:45 , David Aldrich wrote:

 Hi Michael
 
 Wrong. CMAKE_CXX_FLAGS is always used, the configuration-specific values are
 appended to it.
 
 This is where I groan a little. I haven't read that in the online 
 documentation.
 
 Best regards 
 
 David


Couldn't find it in the docs either (just had a superficial look), but in the 
CMakeCache.txt it says cleary:

//Flags used by the compiler during all build types.
CMAKE_CXX_FLAGS:STRING=

//Flags used by the compiler during debug builds.
CMAKE_CXX_FLAGS_DEBUG:STRING=-g

...


Michael

--
There is always a well-known solution to every human problem -- neat, 
plausible, and wrong.
H. L. Mencken



PGP.sig
Description: This is a digitally signed message part
___
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] How to set compiler flags?

2010-10-01 Thread David Aldrich
Well I can't argue with that, but I must admit that I have not read 
CMakeCache.txt ;-)

David 


 -Original Message-
 From: Michael Wild [mailto:them...@gmail.com]
 Sent: 01 October 2010 11:53
 To: David Aldrich
 Cc: fat...@crackmonkey.us; cmake@cmake.org
 Subject: Re: [CMake] How to set compiler flags?
 
 
 On 1. Oct, 2010, at 12:45 , David Aldrich wrote:
 
  Hi Michael
 
  Wrong. CMAKE_CXX_FLAGS is always used, the configuration-specific
  values are appended to it.
 
  This is where I groan a little. I haven't read that in the online
 documentation.
 
  Best regards
 
  David
 
 
 Couldn't find it in the docs either (just had a superficial look), but in the
 CMakeCache.txt it says cleary:
 
 //Flags used by the compiler during all build types.
 CMAKE_CXX_FLAGS:STRING=
 
 //Flags used by the compiler during debug builds.
 CMAKE_CXX_FLAGS_DEBUG:STRING=-g
 
 ...
 
 
 Michael
 
 --
 There is always a well-known solution to every human problem -- neat,
 plausible, and wrong.
 H. L. Mencken

___
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to set compiler flags?

2010-09-29 Thread David Aldrich
Hi Michael

  [...] So I now use add_definitions instead:
 
  add_definitions( -Wall -m64 -O3 )
 
  Is there a better way of doing this?
 
 Don't do this at all, and adhere to the flags.

Thanks for your advice.

 Doesn't the DEBUG variant of the flags, e.g. CMAKE_CXX_FLAGS_DEBUG, and
 other related variables - perhaps in connection with CMAKE_BUILD_TYPE -
 work for you?

Regarding CMAKE_CXX_FLAGS and CMAKE_CXX_FLAGS_RELEASE, is CMAKE_CXX_FLAGS used 
if no build type is specified and CMAKE_CXX_FLAGS_RELEASE used if the build 
type is Release?

If that is so, I plan to assign my desired release options to 
CMAKE_CXX_FLAGS_RELEASE and assign that variable to CMAKE_CXX_FLAGS. That way, 
a release build will happen by default (no build type specified) or if 
Release is specified. I can handle debug builds using CMAKE_CXX_FLAGS_DEBUG.

Am I understanding correctly?

Best regards 

David 


 -Original Message-
 From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf Of
 Michael Hertling
 Sent: 29 September 2010 02:15
 To: cmake@cmake.org
 Subject: Re: [CMake] How to set compiler flags?
 
 On 09/28/2010 05:35 PM, David Aldrich wrote:
  Hi
 
  I am writing CMakeLists.txt files for my C++ application. Initially I set
 the C++ compiler flags by setting CMAKE_CXX_FLAGS:
 
  set( CMAKE_CXX_FLAGS -Wall -m64 -O3  )
 
  Then I realised that those flags get passed to the linker as well, which
 seemed a bit untidy. [...]
 
 But possibly necessary:
 
 http://www.cmake.org/pipermail/cmake/2010-July/038083.html
 
 et seq.
 
  [...] So I now use add_definitions instead:
 
  add_definitions( -Wall -m64 -O3 )
 
  Is there a better way of doing this?
 
 Don't do this at all, and adhere to the flags.
 
  My CMakeLists.txt files only handle a release build currently. If you could
 give me a hint for how to go on to add a debug build option, I would be
 grateful.
 
 Doesn't the DEBUG variant of the flags, e.g. CMAKE_CXX_FLAGS_DEBUG, and
 other related variables - perhaps in connection with CMAKE_BUILD_TYPE -
 work for you?
 
 Regards,
 
 Michael
 ___
 Powered by www.kitware.com
 
 Visit other Kitware open-source projects at
 http://www.kitware.com/opensource/opensource.html
 
 Please keep messages on-topic and check the CMake FAQ at:
 http://www.cmake.org/Wiki/CMake_FAQ
 
 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake
 
 
  Click
 https://www.mailcontrol.com/sr/g!Zu+tz8WoHTndxI!oX7Uq0JINmXjwVqUAeEJxkrmVZ0jY
 kyJOOpuMF6ri4kt+pzfxoBRqvSue5ICd5VsZuQpQ==  to report this email as spam.
___
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to set compiler flags?

2010-09-29 Thread David Aldrich
Hi

 If that is so, I plan to assign my desired release options to
 CMAKE_CXX_FLAGS_RELEASE and assign that variable to CMAKE_CXX_FLAGS. That way,
 a release build will happen by default (no build type specified) or if
 Release is specified. I can handle debug builds using CMAKE_CXX_FLAGS_DEBUG.

Sorry, I have misunderstood. No need to answer.

David

  -Original Message-
  From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf Of
  Michael Hertling
  Sent: 29 September 2010 02:15
  To: cmake@cmake.org
  Subject: Re: [CMake] How to set compiler flags?
 
  On 09/28/2010 05:35 PM, David Aldrich wrote:
   Hi
  
   I am writing CMakeLists.txt files for my C++ application. Initially I set
  the C++ compiler flags by setting CMAKE_CXX_FLAGS:
  
   set( CMAKE_CXX_FLAGS -Wall -m64 -O3  )
  
   Then I realised that those flags get passed to the linker as well, which
  seemed a bit untidy. [...]
 
  But possibly necessary:
 
  http://www.cmake.org/pipermail/cmake/2010-July/038083.html
 
  et seq.
 
   [...] So I now use add_definitions instead:
  
   add_definitions( -Wall -m64 -O3 )
  
   Is there a better way of doing this?
 
  Don't do this at all, and adhere to the flags.
 
   My CMakeLists.txt files only handle a release build currently. If you
 could
  give me a hint for how to go on to add a debug build option, I would be
  grateful.
 
  Doesn't the DEBUG variant of the flags, e.g. CMAKE_CXX_FLAGS_DEBUG, and
  other related variables - perhaps in connection with CMAKE_BUILD_TYPE -
  work for you?
 
  Regards,
 
  Michael
  ___
  Powered by www.kitware.com
 
  Visit other Kitware open-source projects at
  http://www.kitware.com/opensource/opensource.html
 
  Please keep messages on-topic and check the CMake FAQ at:
  http://www.cmake.org/Wiki/CMake_FAQ
 
  Follow this link to subscribe/unsubscribe:
  http://www.cmake.org/mailman/listinfo/cmake
 
 
   Click
 
 https://www.mailcontrol.com/sr/g!Zu+tz8WoHTndxI!oX7Uq0JINmXjwVqUAeEJxkrmVZ0jY
  kyJOOpuMF6ri4kt+pzfxoBRqvSue5ICd5VsZuQpQ==  to report this email as spam.
 ___
 Powered by www.kitware.com
 
 Visit other Kitware open-source projects at
 http://www.kitware.com/opensource/opensource.html
 
 Please keep messages on-topic and check the CMake FAQ at:
 http://www.cmake.org/Wiki/CMake_FAQ
 
 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake
___
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] How to set compiler flags?

2010-09-28 Thread David Aldrich
Hi

I am writing CMakeLists.txt files for my C++ application. Initially I set the 
C++ compiler flags by setting CMAKE_CXX_FLAGS:

set( CMAKE_CXX_FLAGS -Wall -m64 -O3  )

Then I realised that those flags get passed to the linker as well, which seemed 
a bit untidy. So I now use add_definitions instead:

add_definitions( -Wall -m64 -O3 )

Is there a better way of doing this?

My CMakeLists.txt files only handle a release build currently. If you could 
give me a hint for how to go on to add a debug build option, I would be 
grateful.

Best regards
David

___
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] How to set compiler flags?

2010-09-28 Thread Michael Hertling
On 09/28/2010 05:35 PM, David Aldrich wrote:
 Hi
 
 I am writing CMakeLists.txt files for my C++ application. Initially I set the 
 C++ compiler flags by setting CMAKE_CXX_FLAGS:
 
 set( CMAKE_CXX_FLAGS -Wall -m64 -O3  )
 
 Then I realised that those flags get passed to the linker as well, which 
 seemed a bit untidy. [...]

But possibly necessary:

http://www.cmake.org/pipermail/cmake/2010-July/038083.html

et seq.

 [...] So I now use add_definitions instead:
 
 add_definitions( -Wall -m64 -O3 )
 
 Is there a better way of doing this?

Don't do this at all, and adhere to the flags.

 My CMakeLists.txt files only handle a release build currently. If you could 
 give me a hint for how to go on to add a debug build option, I would be 
 grateful.

Doesn't the DEBUG variant of the flags, e.g. CMAKE_CXX_FLAGS_DEBUG, and
other related variables - perhaps in connection with CMAKE_BUILD_TYPE -
work for you?

Regards,

Michael
___
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake