> The PROJECT() command has significant side effects, e.g. for 
> C++ projects, it loads Modules/CMakeCXXInformation.cmake containing:
> 
> SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT}" CACHE STRING
>      "Flags used by the compiler during all build types.")
> 
> If CMAKE_CXX_FLAGS has no value in the cache before, this 
> command will write to the cache *and* to the current scope, 
> see [1]. Thus, it will overwrite the value provided in the 
> CMakeLists.txt in the first case.
> In the second case, the CMakeLists.txt file provides the 
> definitive value in the current scope which will be in effect 
> afterwards.
> 
> IMO, it's best to have PROJECT() as one of the very first 
> commands in CMakeLists.txt files, and to only put other 
> commands before it if one really knows about the consequences.
This behvaior seems to be a little inconsistent. When I remember correctly, the 
optimization switch gets set correctly in both cases, but the /EHa is lost. I 
also think that overwriting the variable in the current scope is unobivious and 
should at least be documented in the manual, but I would prefer to not touch 
the variable or even use the current value.

Best regards,
  Jens
_______________________________________________
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

Reply via email to