<div class="gmail_quote">On Mon, Dec 12, 2011 at 1:53 PM, Michael Wild <span dir="ltr"><<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">> CMake script would imply that it runs as part of the configuration</div><div class="im">
> process. I can't build an installer until all binaries are compiled and<br>
> linked, so it needs to be a target in visual studio.<br>
<br>
</div>Wrong.<br>
<br>
add_custom_command(<br>
COMMAND ${CMAKE_EXECUTABLE} -DVAR=VAL<br>
-P ${PROJECT_BINARY_DIR}/script.cmake<br>
DEPENDS ${PROJECT_BINARY_DIR}/script.cmake<br>
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}<br>
COMMENT "Running script.cmake"<br>
VERBATIM)<br></blockquote><div><br></div><div>Interesting, I didn't even think about doing this. Good job :) I will do this.</div><div><br></div><div>I can use add_custom_target instead though, right? Why do you use add_custom_command here? I don't know how that translates in Visual Studio.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">><br>
> Problem with pushing this out to a batch file is that I only have 9<br>
> parameters maximum that I can use to pass CMake variables. I need more<br>
> than 9, as you can see from the number of variables I use in the script<br>
> I sent you. I can't think of a good design for this. Not to mention I<br>
> hate batch files.<br>
<br>
</div>Configured CMake file, it is.<br>
<br>
set(VAR1 VAL1)<br>
set(VAR2 VAL2)<br>
set(VAR3 VAL3)<br>
configure_file(<a href="http://script.cmake.in" target="_blank">script.cmake.in</a> ${PROJECT_BINARY_DIR}/script.cmake @ONLY)<br>
<br>
<br>
Where <a href="http://script.cmake.in" target="_blank">script.cmake.in</a> could look like this:<br>
<br>
set(ENV{VAR1} "@VAR1@")<br>
set(ENV{VAR2} "@VAR2@")<br>
set(ENV{VAR3} "@VAR3@")<br>
message(STATUS<br>
"DEBUG: VAR1=$ENV{VAR1}, VAR2=$ENV{VAR2}, VAR3=$ENV{VAR3}")<br>
<div class="im"><br>
<br>
><br>
> But moving it out to a batch file will guarantee that I can setup the<br>
> environment properly (set environment variables) and also when users<br>
> change the way the installer works, CMake won't need to be reconfigured,<br>
> which is a huge plus.<br>
><br>
> Any advice here on how I could setup my batch file to accept more than 9<br>
> parameters from CMake?<br>
<br>
</div>Make it a configured file. Either batch or CMake script, as shown above.</blockquote><div><br></div><div>If I use a CMake script, I won't need it to be configured, right? As I can pass in as many -D arguments as I want it seems.</div>
<div><br></div><div>I definitely like CMake scripts better than batch files, so I will go with CMake scripts. Thanks for the insight. </div></div>