<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<blockquote
cite="mid:BANLkTinEeb2twX+xvadRx6kYOA+2V7_-GQ@mail.gmail.com"
type="cite">
<blockquote type="cite">
<pre wrap="">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.
</pre>
</blockquote>
<pre wrap="">
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
</pre>
</blockquote>
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.<br>
<br>
Here's the code for one of the executables in the package.<br>
<br>
<div class="moz-text-html" lang="x-western">
<div><small><font face="Courier New">########## INSTALLER
##########</font></small></div>
<div><small><font face="Courier New">IF(INSTALLER_WITH_PROGRAM)</font></small></div>
<div><small><font face="Courier New"><br>
</font></small></div>
<div><small><font face="Courier New"> # Add Microsoft DLLs to
Installer</font></small></div>
<div><small><font face="Courier New">
INCLUDE(InstallRequiredSystemLibraries)</font></small></div>
<div><small><font face="Courier New"><br>
</font></small></div>
<div><small><font face="Courier New"> include(GetPrerequisites)</font></small></div>
<small>
</small>
<div><small><font face="Courier New"><br>
</font></small></div>
<div><small><font face="Courier New"> # Clear Path Variable</font></small></div>
<div><small><font face="Courier New"> set(PATH_TO_FILE
"${PATH_TO_FILE}-NOTFOUND")</font></small></div>
<div><small><font face="Courier New"> set(DLL "DLL-NOTFOUND")</font></small></div>
<div><small><font face="Courier New"><br>
</font></small></div>
<div><small><font face="Courier New"> # Scan the executable for
required DLLs</font></small></div>
<small>
</small>
<div><small><font face="Courier New"> IF(EXISTS
"${EXECUTABLE_OUTPUT_PATH}/Release/Program.exe")</font></small></div>
<div><small><font face="Courier New">
GET_PREREQUISITES("${EXECUTABLE_OUTPUT_PATH}/Release/Program.exe"
DEPENDENCIES 1 1 "" "")</font></small></div>
<div><small><font face="Courier New"><br>
</font></small></div>
<div><small><font face="Courier New"> # Scan for each DLL</font></small></div>
<div><small><font face="Courier New"> FOREACH(DEPENDENCY
${DEPENDENCIES})</font></small></div>
<div><small><font face="Courier New">
FOREACH(PATH_TO_FILE ${CMAKE_MODULE_PATH})</font></small></div>
<div><small><font face="Courier New"> find_file(DLL
${DEPENDENCY} "${PATH_TO_FILE}/bin"})</font></small></div>
<div><small><font face="Courier New">
ENDFOREACH(PATH_TO_FILE)<span class="Apple-tab-span"
style="white-space: pre;"> </span> <br>
</font></small></div>
<div><small><font face="Courier New"> </font></small></div>
<div><small><font face="Courier New"> # Add discovered
DLL to Installer</font></small></div>
<div><small><font face="Courier New"> install(FILES
${DLL} DESTINATION "bin" )</font></small></div>
<small>
</small>
<div><small><font face="Courier New"><br>
</font></small></div>
<div><small><font face="Courier New"> # Reset DLL
Variable</font></small></div>
<div><small><font face="Courier New"> set(DLL
"DLL-NOTFOUND")</font></small></div>
<div><small><font face="Courier New">
ENDFOREACH(DEPENDENCY)</font></small></div>
<div><small><font face="Courier New"><br>
</font></small></div>
<div><small><font face="Courier New"> # Add Release TS
Executable</font></small></div>
<div><small><font face="Courier New">
install(TARGETS Program RUNTIME DESTINATION "bin")</font></small></div>
<div><small><font face="Courier New"> ELSE()</font></small></div>
<div><small><font face="Courier New"> message("Please build
${EXECUTABLE_OUTPUT_PATH}/Release/Program.exe and run CMake
again.")</font></small></div>
<small>
</small>
<div><small><font face="Courier New"> ENDIF(EXISTS
"${EXECUTABLE_OUTPUT_PATH}/Release/Program.exe")</font></small></div>
<div><small><font face="Courier New">ENDIF(INSTALLER_WITH_PROGRAM)</font></small></div>
<small>
</small></div>
<br>
</body>
</html>