[CMake] IF(DEFINED) syntax
David Blado
dblado at decarta.com
Wed Dec 6 22:00:13 EST 2006
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20061206/6f5b51f6/attachment.html
More information about the CMake
mailing list