[CMake] problem setting CMAKE_BUILD_TYPE and CMAKE_INSTALL_PREFIX

Yogesh Marwaha yogeshm.007 at gmail.com
Fri Feb 1 02:14:32 EST 2008


On 29/01/2008, Brandon Van Every <bvanevery at gmail.com> wrote:
> On Jan 29, 2008 10:42 AM, Yogesh Marwaha <yogeshm.007 at gmail.com> wrote:
> > Here is new CMakeLists.txt
> > ========================
> > project (eSpy)
> > cmake_minimum_required (VERSION 2.4.0)
> > if(NOT CMAKE_BUILD_TYPE)
> >     set (CMAKE_BUILD_TYPE Release)
> > endif(NOT CMAKE_BUILD_TYPE)
> > if(NOT CMAKE_INSTALL_PREFIX)
> >     set (CMAKE_INSTALL_PREFIX "/usr/local")
> > endif(NOT CMAKE_INSTALL_PREFIX)
> > find_package (Qt4 REQUIRED)
> > add_subdirectory (eSpy)
> > add_subdirectory (eSpyDLin)
> > ======================
> >
> > Now CMAKE_BUILD_TYPE and CMAKE_INSTALL_PREFIX are only set if not
> > previously set/defined.
> > Now no one should have any complaint. Right?
>
> CMAKE_INSTALL_PREFIX always has a default.  Your command above does nothing.

Yes, you are right. Sorry that i didn't checked it properly.

>
> Similarly, if(NOT CMAKE_BUILD_TYPE) is nonsensical.  From the CMake
> Useful Variables wiki entry: "Note that CMAKE_BUILD_TYPE is not
> initialized with a readable value at configuration time. This is
> because the user is free to select a build type at build time. Use
> CMAKE_CFG_INTDIR if you need a variable that evaluates to the correct
> build time directory. "
>
But, as per CMake docs...
" IF(NOT variable)
True if the variable's value is empty, 0, N, NO, OFF, FALSE, NOTFOUND,
or <variable>-NOTFOUND."

and I'm still getting the desired behaviour. For example...

cmake .. -DCMAKE_BUILD_TYPE=Debug -> Configures correctly to build in
"debug" mode.
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo-> Configures correctly to
build in "release with debug info" mode
cmake .. -> Configures correctly to build in "release" (as per above
CMakeLists.txt) mode.


Please bear with me if I'm annoying you, I just want to be clear about
what I'm doing. btw I've still not mentioned it so here it is: I'm
using CMake 2.4.7 that came with openSUSE 10.3

Regards,

-- 
Yogesh M


More information about the CMake mailing list