CMAKE_BUILD_TYPE is automatically set to a default initial value by CMake in
most cases before it gets to your IF(NOT DEFINED... (So, it's "always"
defined -- in your case.)

It is conditionally set from different cmake scripts that are run based on
generator and compiler chosen. It is not set at all when using a Visual
Studio or Xcode generator, for example, so you can build any configuration
from the build environment's UI.

So... if you want others to be able to use Visual Studio or Xcode generators
on your project, it's best to avoid assumptions about CMAKE_BUILD_TYPE in
your CMakeLists files. If it's set, you can use it's value. If it's not set,
then the target environment probably supports multiple configurations
selectable at build time by the developer. You can also poke around for
examples dealing with variables CMAKE_CONFIGURATION_TYPES and
CMAKE_CFG_INTDIR for supporting multiple configuration build systems at
CMake configure time...


HTH,
David Cole


On 12/6/06, David Blado <[EMAIL PROTECTED]> wrote:

 Hi,



I'm trying to setup a cmake system where as cmake <directory> will by
default be a release build.  If someone issues cmake
–DCMAKE_BUILD_TYPE:STRING=debug it should overwrite the default to produce a
debug build.



The only way I've found to do this is with:



  IF(CMAKE_BUILD_TYPE MATCHES "debug")

    SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE})

  ELSE(CMAKE_BUILD_TYPE MATCHES "debug")

    SET(CMAKE_BUILD_TYPE "release")

  ENDIF(CMAKE_BUILD_TYPE MATCHES "debug")



I would have thought that the following should work:



IF(NOT DEFINED CMAKE_BUILD_TYPE)

   SET(CMAKE_BUILD_TYPE "release")

ENDIF(NOT DEFINED CMAKE_BUILD_TYPE)



Obviously this is preferred since it is fewer lines and executes just a
tiny bit faster J



Anyone have any ideas as to why only the former works?



Cheers,

David



_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to