My ugly macro looks like... Build project macro creates targets 'build${PROJECT}' which can be depended on each other...<div><br></div><div>It writes to a output batch file, and then calls that batch. The batch file contains a cmake execution for that target, and then ${CMAKE_MAKE_PROGRAM} command.</div>
<div><br></div><div>-----------------------------------</div><div><div><br></div><div>macro( BuildProject PROJECT SOLUTION PROJECT_SOURCE INSTALL_RESULT )</div><div><br></div><div> set( LAST_TARGET Build${PROJECT} )</div>
<div> if( CMAKE_BINARY_DIR MATCHES ${CMAKE_BUILD_TYPE}_solution\$ )</div><div> set( INSTALL ${CMAKE_BINARY_DIR}/../${CMAKE_BUILD_TYPE}_out/${PROJECT} )</div><div> set( BUILD ${CMAKE_BINARY_DIR}/../${CMAKE_BUILD_TYPE}_solution/${PROJECT} ) </div>
<div> else()</div><div> set( INSTALL ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}_out/${PROJECT} )</div><div> set( BUILD ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}_solution/${PROJECT} ) </div><div> endif( CMAKE_BINARY_DIR MATCHES ${CMAKE_BUILD_TYPE}_solution\$ )</div>
<div> set( ${INSTALL_RESULT} ${INSTALL} )</div><div><br></div><div> FILE( MAKE_DIRECTORY ${BUILD} )</div><div><br></div><div> if( MSVC )</div><div> if( NOT EXISTS ${BUILD}/${SOLUTION}.sln )</div><div> FILE( WRITE ${BUILD}/${SOLUTION}.sln )</div>
<div> endif()</div><div> if( ${CMAKE_MAKE_PROGRAM} MATCHES .*[Mm][Ss][Bb]uild.* )</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span> build_command( BUILD_COMMAND CONFIGURATION ${CMAKE_BUILD_TYPE} PROJECT_NAME ${SOLUTION} TARGET INSTALL )</div>
<div> SET( MORE_ARGS /m:4 /v:m )</div><div> else()</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span> build_command( BUILD_COMMAND CONFIGURATION ${CMAKE_BUILD_TYPE} PROJECT_NAME ${SOLUTION} TARGET INSTALL.vcxproj )</div>
<div> endif()</div><div> SEPARATE_ARGUMENTS( BUILD_COMMAND WINDOWS_COMMAND ${BUILD_COMMAND} )</div><div> SET( BUILD_COMMAND ${BUILD_COMMAND} ${MORE_ARGS} )</div><div> SET( ADD_SOURCES SOURCES ${BUILD}/${SOLUTION}.sln )</div>
<div> else( MSVC )</div><div> build_command( BUILD_COMMAND CONFIGURATION ${CMAKE_BUILD_TYPE} PROJECT_NAME ${SOLUTION} TARGET install )</div><div> SEPARATE_ARGUMENTS( BUILD_COMMAND UNIX_COMMAND ${BUILD_COMMAND} )</div>
<div> endif( MSVC )</div><div><br></div><div> if( CMAKE_TOOLCHAIN_FILE )</div><div> set( TOOLCHAIN -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} )</div><div> endif( CMAKE_TOOLCHAIN_FILE )</div><div><br></div><div> set( FAKE_ARGN1 ${ARGN})</div>
<div> string (REPLACE ";" " " FAKE_ARGN2 "${FAKE_ARGN1}")</div><div> FILE( WRITE ${BUILD}/makeit.bat "\"${CMAKE_COMMAND}\" -G \"${CMAKE_GENERATOR}\" ${TOOLCHAIN} \"${PROJECT_SOURCE}\" -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${INSTALL} ${FAKE_ARGN2}\n" )</div>
<div> string (REPLACE ";" " " FAKE_BUILD_COMMAND "${BUILD_COMMAND}")</div><div> FILE( APPEND ${BUILD}/makeit.bat ${FAKE_BUILD_COMMAND} )</div><div><br></div><div> add_custom_target( Build${PROJECT} ALL</div>
<div> COMMAND makeit.bat</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> WORKING_DIRECTORY ${BUILD}</div><div> ${ADD_SOURCES}</div><div> )</div><div>endmacro( BuildProject )</div>
<div>-----------------</div><div>usage is something like</div><div><br></div><div><br></div><div><div>set( PROJECT intershell )</div><div>set( EXTRA_FLAGS -DSACK_SDK_ROOT_PATH=${SACK_SDK_ROOT_PATH} )</div><div>BuildProject( ${PROJECT} ${PROJECT} ${CMAKE_CURRENT_LIST_DIR}/../src/InterShell INTERSHELL_SDK_ROOT_PATH ${EXTRA_FLAGS} )</div>
<div>Add_custom_command( TARGET Build${PROJECT} </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>COMMAND ${INTERSHELL_SDK_ROOT_PATH}/intershell_deploy${CMAKE_EXECUTABLE_SUFFIX} -nr</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>WORKING_DIRECTORY ${INTERSHELL_SDK_ROOT_PATH}</div>
<div>) </div><div>add_dependencies( ${LAST_TARGET} Buildcore )</div></div><div><br></div><div>-----------------</div><div><br></div><div>Above sourced from</div><div><br></div><div><a href="https://code.google.com/p/c-system-abstraction-component-gui/source/browse/cmake_all/CMakeLists.txt">https://code.google.com/p/c-system-abstraction-component-gui/source/browse/cmake_all/CMakeLists.txt</a></div>
<div>and</div><div><a href="https://code.google.com/p/c-system-abstraction-component-gui/source/browse/cmake_all/CMakeBuild.txt">https://code.google.com/p/c-system-abstraction-component-gui/source/browse/cmake_all/CMakeBuild.txt</a></div>
<div><br></div><div>--------------------</div><div><br></div><br><div class="gmail_quote">On Fri, Mar 15, 2013 at 4:37 AM, J Decker <span dir="ltr"><<a href="mailto:d3ck0r@gmail.com" target="_blank">d3ck0r@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If the dependencies are already satisfied, and the cmake_make_program can run mutliple in parallel, then it works great.<div>
<br></div><div>I have a cmake script that builds other cmake top level projects; and this ends up building in parallel on visual studio.</div>
<div><br></div><div>can't do it with any other compiler I use for windows (make can be aliased on linux to include a /j4).<div><div class="h5"><br><br><div class="gmail_quote">On Fri, Mar 15, 2013 at 1:37 AM, Gregoire Aujay <span dir="ltr"><<a href="mailto:gaujay@movea.com" target="_blank">gaujay@movea.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
Thanks for your replies. I understand that I can only 'cmake --build' one target at a time.<br>
I think that the solutions you propose do not benefit from tools, like ninja, that have parallel build capabilities.<br>
<br>
I'll file a feature request.<br>
<br>
Regards,<br>
Greg<br>
<div><div><br>
-----Original Message-----<br>
From: Nick Overdijk [mailto:<a href="mailto:nick@astrant.net" target="_blank">nick@astrant.net</a>]<br>
Sent: jeudi 14 mars 2013 19:10<br>
To: John Drescher<br>
Cc: Gregoire Aujay; <a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a><br>
Subject: Re: [CMake] Build several targets using cmake --build <dir><br>
<br>
You can only 'cmake' a single-target. If you want to have more targets, create more directories: for each target one.<br>
<br>
On 2013-14-03, at 19:07:36 , John Drescher wrote:<br>
<br>
>> I use cmake 2.8.10 on windows.<br>
>><br>
>><br>
>><br>
>> I would like to build several targets with cmake --build <dir> so<br>
>> the underlying build tool to do parallel jobs.<br>
>><br>
>><br>
>><br>
>> Currently it only seems to be possible to build one target at a time,<br>
>> using --target .<br>
>> (<a href="http://www.cmake.org/cmake/help/v2.8.10/cmake.html#opt:--builddir" target="_blank">http://www.cmake.org/cmake/help/v2.8.10/cmake.html#opt:--builddir</a>)<br>
>><br>
>><br>
>><br>
>> Can someone tell me how I could achieve that with current cmake version?<br>
>><br>
>><br>
> I execute more than 1 cmake --build at the same time on windows. I<br>
> actually do this in a program called runjobs<br>
><br>
> <a href="http://www.codeproject.com/Articles/25810/Run-All-Jobs-at-Once-Utility" target="_blank">http://www.codeproject.com/Articles/25810/Run-All-Jobs-at-Once-Utility</a><br>
><br>
> John<br>
> --<br>
><br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the CMake FAQ at:<br>
> <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
<br>
<br>
<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>