[CMake] Parallel builds

J Decker d3ck0r at gmail.com
Wed Sep 16 11:14:54 EDT 2015


Tools->Option->Projects and soltuions->Build and Run at the top is
'maximum number of parallel project builds.  This is external setting
to what CMake generates.... so in the IDE that's what it uses.

>From the command line...

C:\tools\unix\cmake\bin\cmake.exe --build . --config Debug --target
INSTALL -- /m:4 /v:m

the /m:4 flag is number of processes to parallel build. and that works.

---
now if that's not what you mean and you mean 'Multi-threaded DLL'(/MD)
vs 'multi-threaded'(/MT) which selects the runtime to use cmake by
default generates /MD.

This is set in

CMAKE_${lang}_FLAGS_DEBUG_INIT

which you can do

if( ${CMAKE_BUILD_TYPE} MATCHES "[dD][eE][bB][uU][gG]" )
   string( REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_INIT ${CMAKE_C_FLAGS_INIT} )
   string( REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT} )
else()
    string( REPLACE "/MD" "/MT" CMAKE_C_FLAGS_INIT ${CMAKE_C_FLAGS_INIT} )
    string( REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT} )
endif()

something like that....


On Wed, Sep 16, 2015 at 4:30 AM, Petr Bena <benapetr at gmail.com> wrote:
> There is /MP compiler flag that I need to enable for every single
> project to be precise.
>
> On Wed, Sep 16, 2015 at 1:26 PM, Petr Bena <benapetr at gmail.com> wrote:
>> Hi,
>>
>> Is it possible to enable multithreaded builds by default in Visual
>> Studio projects? It seems that cmake generates the solution files in a
>> way that they are forbidden, so even if global preference is to use
>> multithreaded builds, the compiler never does that for sln files
>> create by cmake, because multithreaded builds are not allowed on
>> project level.
>>
>> Is there any way to enable them so that I don't have to do that by
>> hand all time?
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list