On Thu, Mar 6, 2008 at 10:01 PM, Surya Kiran Gullapalli <
[EMAIL PROTECTED]> wrote:

> Hello,
> Can I change my install prefix on the fly for windows build.
>
> On Unix I can do some thing like this
>
> IF (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
>     set_my_debug_install_prefix
> ELSE (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
>     set_my_release_install_prefix
> ENDIF (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
>
> I cannot do the same thing for windows as I select the build type after
> loading the IDE.


The CMAKE_BUILD_TYPE variable is only valid for the single-configuration
generators (like the Makefile generator).  You can't dynamically change the
behavior of CMake for the multiple-configuration generators like Visual
Studio because CMake has already finished running and outputting the project
files and doesn't know what kind of solution you're planning on building
from within the IDE.

If you must have two separate install prefixes with Visual Studio one way to
do this is with multiple solution files (generate one for Release, one for
Debug)

IF(MSVC)
   SET(MY_BUILD_TYPE Debug STRING CACHE "My build variable")
   SET(CMAKE_CONFIGURATION_TYPES ${MY_BUILD_TYPE})   # limit the solution
types available in the IDE to "MY_BUILD_TYPE"

   IF(MY_BUILD_TYPE STREQUAL Debug)
      # set debug install prefix)
   ELSE(MY_BUILD_TYPE STREQUAL Debug)
      # set release install prefix)
    ENDIF(MY_BUILD_TYPE STREQUAL Debug)

ENDIF(MSVC)

Someone else might have a better idea, this is all I can think of barring
someone adding a feature for this to CMake (feel free to add it as a feature
request).

I want to do similar change for ADD_EXECUTABLE as well.
>
> For Debug builds I want to have a console popping up to show the debug
> messages, and for release builds I do not want the console.
>
> How can i change the ADD_EXECUTABLE  call accordingly to supply extra
> option WIN32 based on the build type.?


Same limiting issue here.  You can build the executable twice for all
configurations (one with WIN32, one without) or you can resort to a single
build configuration per Visual Studio solution file.

For you to get the kind of behavior you want, CMake would have to be
modified to run multiple times for each build type in
CMAKE_CONFIGURATION_TYPES and then modify the project files accordingly for
each configuration type, depending on the CMake commands the user issued.
This would be a neat feature request to add but could prove difficult to
implement.

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

Reply via email to