On Mar 8, 2008, at 8:57 AM, Philip Lowman wrote:

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


I use the following code for MSVC2003.Net. Not sure if it works on VS2005 or VS2008:

IF (BUILD_SHARED_LIBS)
    IF (WIN32)
        SET(LIB_RELEASE_NAME "expatdll")
        SET(LIB_DEBUG_NAME "expatdll_D")
    ELSE (WIN32)
        SET(LIB_RELEASE_NAME "expat")
        SET(LIB_DEBUG_NAME "expat_D")
    ENDIF(WIN32)
ELSE (BUILD_SHARED_LIBS)
    IF (WIN32)
        SET(LIB_RELEASE_NAME "libexpat")
        SET(LIB_DEBUG_NAME "libexpat_D")
    ELSE (WIN32)
        SET(LIB_RELEASE_NAME "expat")
        SET(LIB_DEBUG_NAME "expat_D")
    ENDIF(WIN32)
ENDIF (BUILD_SHARED_LIBS)

ADD_LIBRARY(expat ${LIB_TYPE} ${SOURCES} ${HEADERS})

SET_TARGET_PROPERTIES( expat
    PROPERTIES
    DEBUG_OUTPUT_NAME ${LIB_DEBUG_NAME}
    RELEASE_OUTPUT_NAME ${LIB_RELEASE_NAME}
)

I use this so I can install both the debug and release versions of a library in the same location. I have similarly matched FindExpat.cmake file that looks for these variations and will select the proper library based on Debug or Release and again works correctly with VS2003 no matter what is selected in the IDE.

--
Mike Jackson
imikejackson & gmail * com

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

Reply via email to