<div dir="ltr">Kevin, I have a shell script for such tasks, see <a href="https://gist.github.com/tamaskenez/d4509f240f4224eb9853">https://gist.github.com/tamaskenez/d4509f240f4224eb9853</a>. Feel free to use it if that's what you need.<div>It extends the `cmake` command by executing multiple, related `cmake` calls with one command. See docs in gist.</div><div><br><div>Your 'make release' example looks like this:</div><div><br></div><div>    cmakex cr -Hsourcedir -Bbuilddir # Configure Release</div><div><br></div><div>with additional options you can do many tasks with one command</div><div><br></div><div>    cmakex cbitdr -Hsourcedir -Bbuilddir -GXcode # Configure, Build, Install, Test Debug & Release using Xcode</div><div><br></div><div>Tamas</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 8, 2015 at 7:44 PM, Kevin Wojniak <span dir="ltr"><<a href="mailto:kainjow@kainjow.com" target="_blank">kainjow@kainjow.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Functionality like add_custom_target combined with script mode is close, but not quite there. add_custom_target already requires a build directory and a generator, so it’s too late. Script mode requires setting variables on the command line, so it’s too verbose. For example:<br>
<br>
if(“${ACTION}” STREQUAL “release”)<br>
    execute_process(…)<br>
endif()<br>
<br>
cmake -P myscript.cmake -DACTION=release<br>
<br>
I suppose you could have multiple *.cmake files for each task, and those could then call the master file with necessary variables set, but then you’d need one file per task and that could become excessive.<span class="HOEnZb"><font color="#888888"><br>
<br>
Kevin</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On 8 Dec 2015, at 10:22, Nils Gladitz wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 08.12.2015 19:04, Kevin Wojniak wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
add_task(release<br>
COMMAND ${CMAKE_COMMAND} -E make_directory “build_dir”<br>
COMMAND ${CMAKE_COMMAND} -E chdir “build_dir” ${CMAKE_COMMAND} “-DCMAKE_BUILD_TYPE=Release”, “..”<br>
)<br>
<br>
</blockquote>
<br>
There is add_custom_target().<br>
<br>
You can e.g. add_custom_target(release ${CMAKE_COMMAND} -E echo foobar)<br>
and with the Makefiles generator run "make release" and with visual studio trigger the build of the "release" project.<br>
<br>
For scripting you can use cmake in script mode with -P.<br>
<br>
e.g. given a script file release.cmake:<br>
 message("Hello World")<br>
<br>
add_custom_target(release ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/release.cmake)<br>
<br>
Nils<br>
</blockquote>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a></div></div></blockquote></div><br></div>