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 :-)

 

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

 

Cheers,

David

 

_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to