[CMake] Determine Installer Build Configuration in Visual Studio
J Decker
d3ck0r at gmail.com
Thu Jun 9 21:22:12 EDT 2011
if(SUPPORTS_PARALLEL_BUILD_TYPE)
CMAKE_INSTALL_CONFIG_NAME is set to the current configuration name
(DEbug, release, minsizerel) as chosen in the visual studio
environment.... so to choose which you build - you choose which you
build.
It doesn't package multiple configurations at once into a single NSIS,
but it will package any single configuration.
?
On Thu, Jun 9, 2011 at 2:12 PM, Jason Gochanour <jrgochan at lanl.gov> wrote:
>
> I've managed to get an NSIS project up and running in VIsual Studio with
> CPack, but I can't figure out how to determine which configuration type is
> being built. Is it possible to write up a CMakeLists that will run through
> different conditionals based off of the Build Configuration Type selected in
> Visual Studio? If a user selects a Debug build I'd like to be able to tell
> the installer to be built with the Debug libraries instead of the Release.
>
> That is what it does. When debug is selected in Visual Studio and you
> build the PACKAGE project it will build this using debug libs.
>
> John
>
> Thank you for the response John. When I first setup CPack it built both
> Release and Debug, but it didn't package the required DLLs in the
> installer. I did some searching and came across the "GetPrerequisites"
> module. I had this scan the executables I wanted to package up to create a
> list of the DLLs I needed. I had to manually specify the directory however,
> because I'm not sure how to tell CPack what configuration the user wants to
> build. I have a feeling there's a better way around this, but I haven't
> figure it out yet.
>
> Here's the code for one of the executables in the package.
>
> ########## INSTALLER ##########
> IF(INSTALLER_WITH_PROGRAM)
> # Add Microsoft DLLs to Installer
> INCLUDE(InstallRequiredSystemLibraries)
> include(GetPrerequisites)
> # Clear Path Variable
> set(PATH_TO_FILE "${PATH_TO_FILE}-NOTFOUND")
> set(DLL "DLL-NOTFOUND")
> # Scan the executable for required DLLs
> IF(EXISTS "${EXECUTABLE_OUTPUT_PATH}/Release/Program.exe")
> GET_PREREQUISITES("${EXECUTABLE_OUTPUT_PATH}/Release/Program.exe"
> DEPENDENCIES 1 1 "" "")
> # Scan for each DLL
> FOREACH(DEPENDENCY ${DEPENDENCIES})
> FOREACH(PATH_TO_FILE ${CMAKE_MODULE_PATH})
> find_file(DLL ${DEPENDENCY} "${PATH_TO_FILE}/bin"})
> ENDFOREACH(PATH_TO_FILE)
>
> # Add discovered DLL to Installer
> install(FILES ${DLL} DESTINATION "bin" )
> # Reset DLL Variable
> set(DLL "DLL-NOTFOUND")
> ENDFOREACH(DEPENDENCY)
> # Add Release TS Executable
> install(TARGETS Program RUNTIME DESTINATION "bin")
> ELSE()
> message("Please build ${EXECUTABLE_OUTPUT_PATH}/Release/Program.exe
> and run CMake again.")
> ENDIF(EXISTS "${EXECUTABLE_OUTPUT_PATH}/Release/Program.exe")
> ENDIF(INSTALLER_WITH_PROGRAM)
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
More information about the CMake
mailing list