Appending to CMAKE_CXX_FLAGS

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Appending to CMAKE_CXX_FLAGS

Michael Jackson

What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the logic that I would like:

 

If (MSVC)

                Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)

Endif()

 

I have always heard that appending to the compile flags in this way is “bad”. What is the best practice for doing this?

 

Thanks

--

Michael Jackson | Owner, President

      BlueQuartz Software

[e] [hidden email]

[w] www.bluequartz.net


--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Appending to CMAKE_CXX_FLAGS

Marc CHEVRIER
The best approach is to use properties (see https://cmake.org/cmake/help/git-master/manual/cmake-properties.7.html).

At directory level and target level you can use property 'COMPILE_OPTIONS'.  These properties can be updated using, respectively 'add_compile_options' and 'target_compile_options'.

Be aware that variable 'CMAKE_CXX_FLAGS' is a string so to extend it you have to use:
string(APPEND CMAKE_CXX_FLAGS "flag1 flag2")


Le mar. 11 sept. 2018 à 17:58, Michael Jackson <[hidden email]> a écrit :

What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the logic that I would like:

 

If (MSVC)

                Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)

Endif()

 

I have always heard that appending to the compile flags in this way is “bad”. What is the best practice for doing this?

 

Thanks

--

Michael Jackson | Owner, President

      BlueQuartz Software

[e] [hidden email]

[w] www.bluequartz.net

--

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:
https://cmake.org/mailman/listinfo/cmake

--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Appending to CMAKE_CXX_FLAGS

Michael Jackson

Hmm. The idea for the “/MP” flags for those that don’t use Visual Studio is that it will inform the compiler to use all the cores on the system to compile. Much like Ninja does automatically and “make -jN” does for makefiles.

Essentially I want to automatically add the “/MP” flag anytime that I configure using Visual Studio (2015/2017) as the generator. I guess I could put the append string fairly high up in the CMake hierarchy. I am not seeing a property (from the first link you sent) that would allow me to do that.

 

--

Michael Jackson | Owner, President

      BlueQuartz Software

[e] [hidden email]

[w] www.bluequartz.net

 

From: Marc CHEVRIER <[hidden email]>
Date: Tuesday, September 11, 2018 at 1:04 PM
To: Michael Jackson <[hidden email]>
Cc: CMake <[hidden email]>
Subject: Re: [CMake] Appending to CMAKE_CXX_FLAGS

 

The best approach is to use properties (see https://cmake.org/cmake/help/git-master/manual/cmake-properties.7.html).

 

At directory level and target level you can use property 'COMPILE_OPTIONS'.  These properties can be updated using, respectively 'add_compile_options' and 'target_compile_options'.

 

Be aware that variable 'CMAKE_CXX_FLAGS' is a string so to extend it you have to use:

string(APPEND CMAKE_CXX_FLAGS "flag1 flag2")

 

 

Le mar. 11 sept. 2018 à 17:58, Michael Jackson <[hidden email]> a écrit :

What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the logic that I would like:

 

If (MSVC)

                Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)

Endif()

 

I have always heard that appending to the compile flags in this way is “bad”. What is the best practice for doing this?

 

Thanks

--

Michael Jackson | Owner, President

      BlueQuartz Software

[e] [hidden email]

[w] www.bluequartz.net

--

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:
https://cmake.org/mailman/listinfo/cmake


--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Appending to CMAKE_CXX_FLAGS

Marc CHEVRIER
If you set directory property at the top level CMakeList.txt, before any target definition, all targets will inherit this value.

And, because property 'COMPILE_OPTIONS' supports generator expressions (see https://cmake.org/cmake/help/v3.12/manual/cmake-generator-expressions.7.html), you can specify:

add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/MP>")


Le mar. 11 sept. 2018 à 19:19, Michael Jackson <[hidden email]> a écrit :

Hmm. The idea for the “/MP” flags for those that don’t use Visual Studio is that it will inform the compiler to use all the cores on the system to compile. Much like Ninja does automatically and “make -jN” does for makefiles.

Essentially I want to automatically add the “/MP” flag anytime that I configure using Visual Studio (2015/2017) as the generator. I guess I could put the append string fairly high up in the CMake hierarchy. I am not seeing a property (from the first link you sent) that would allow me to do that.

 

--

Michael Jackson | Owner, President

      BlueQuartz Software

[e] [hidden email]

[w] www.bluequartz.net

 

From: Marc CHEVRIER <[hidden email]>
Date: Tuesday, September 11, 2018 at 1:04 PM
To: Michael Jackson <[hidden email]>
Cc: CMake <[hidden email]>
Subject: Re: [CMake] Appending to CMAKE_CXX_FLAGS

 

The best approach is to use properties (see https://cmake.org/cmake/help/git-master/manual/cmake-properties.7.html).

 

At directory level and target level you can use property 'COMPILE_OPTIONS'.  These properties can be updated using, respectively 'add_compile_options' and 'target_compile_options'.

 

Be aware that variable 'CMAKE_CXX_FLAGS' is a string so to extend it you have to use:

string(APPEND CMAKE_CXX_FLAGS "flag1 flag2")

 

 

Le mar. 11 sept. 2018 à 17:58, Michael Jackson <[hidden email]> a écrit :

What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the logic that I would like:

 

If (MSVC)

                Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)

Endif()

 

I have always heard that appending to the compile flags in this way is “bad”. What is the best practice for doing this?

 

Thanks

--

Michael Jackson | Owner, President

      BlueQuartz Software

[e] [hidden email]

[w] www.bluequartz.net

--

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:
https://cmake.org/mailman/listinfo/cmake


--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Appending to CMAKE_CXX_FLAGS

Innokentiy Alaytsev
In reply to this post by Michael Jackson
Hello!

Did you consider adding the flag manually during project configuration? I do
not know you use case, but after some thinking about the best way of
achieving multiprocess compilation under MSVS with CMake I decided, that the
simplest, most portable and flexible is to just add this flag manually. One
of the reasons for such a decision is that I do not know how the project may
be built and multiprocess compilation may cause problems under some hardware
configurations.

Best regards,
Innokentiy



--
Sent from: http://cmake.3232098.n2.nabble.com/
--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Appending to CMAKE_CXX_FLAGS

Richard A. Smith
In reply to this post by Marc CHEVRIER
On 09/11/2018 01:03 PM, Marc CHEVRIER wrote:

> The best approach is to use properties (see
> https://cmake.org/cmake/help/git-master/manual/cmake-properties.7.html).
>
> At directory level and target level you can use property
> 'COMPILE_OPTIONS'.  These properties can be updated using, respectively
> 'add_compile_options' and 'target_compile_options'.

If you have assembly files you may run into trouble.

See my question:  https://www.mail-archive.com/cmake@.../msg59526.html

I don't have a solution yet.

>
> Le mar. 11 sept. 2018 à 17:58, Michael Jackson
> <[hidden email] <mailto:[hidden email]>> a écrit :
>
>     What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the
>     logic that I would like:____
>
>     __ __
>
>     If (MSVC)____
>
>                      Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)____
>
>     Endif()____
>
>     __ __
>
>     I have always heard that appending to the compile flags in this way
>     is “bad”. What is the best practice for doing this?____
>
>     __ __
>
>     Thanks____
>
>     --____
>
>     Michael Jackson | Owner, President____
>
>            BlueQuartz Software____
>
>     [e] [hidden email] <mailto:[hidden email]>____
>
>     [w] www.bluequartz.net <http://www.bluequartz.net>____
--
Richard A. Smith
[hidden email]
--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Appending to CMAKE_CXX_FLAGS

Michael Jackson
In reply to this post by Marc CHEVRIER

Just to be clear I _only_ need it when the generator is Visual Studio so I did the following:

 

if(MSVC_IDE)

  add_compile_options(/MP)

endif()

 

From a clean build directory that did not add it to the CMAKE_CXX_FLAGS when viewed in CMake-Gui.

 

--

Mike Jackson

 

From: Marc CHEVRIER <[hidden email]>
Date: Tuesday, September 11, 2018 at 1:28 PM
To: Michael Jackson <[hidden email]>
Cc: CMake <[hidden email]>
Subject: Re: [CMake] Appending to CMAKE_CXX_FLAGS

 

If you set directory property at the top level CMakeList.txt, before any target definition, all targets will inherit this value.

 

And, because property 'COMPILE_OPTIONS' supports generator expressions (see https://cmake.org/cmake/help/v3.12/manual/cmake-generator-expressions.7.html), you can specify:

 

add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/MP>")

 

 

Le mar. 11 sept. 2018 à 19:19, Michael Jackson <[hidden email]> a écrit :

Hmm. The idea for the “/MP” flags for those that don’t use Visual Studio is that it will inform the compiler to use all the cores on the system to compile. Much like Ninja does automatically and “make -jN” does for makefiles.

Essentially I want to automatically add the “/MP” flag anytime that I configure using Visual Studio (2015/2017) as the generator. I guess I could put the append string fairly high up in the CMake hierarchy. I am not seeing a property (from the first link you sent) that would allow me to do that.

 

--

Michael Jackson | Owner, President

      BlueQuartz Software

[e] [hidden email]

[w] www.bluequartz.net

 

From: Marc CHEVRIER <[hidden email]>
Date: Tuesday, September 11, 2018 at 1:04 PM
To: Michael Jackson <[hidden email]>
Cc: CMake <[hidden email]>
Subject: Re: [CMake] Appending to CMAKE_CXX_FLAGS

 

The best approach is to use properties (see https://cmake.org/cmake/help/git-master/manual/cmake-properties.7.html).

 

At directory level and target level you can use property 'COMPILE_OPTIONS'.  These properties can be updated using, respectively 'add_compile_options' and 'target_compile_options'.

 

Be aware that variable 'CMAKE_CXX_FLAGS' is a string so to extend it you have to use:

string(APPEND CMAKE_CXX_FLAGS "flag1 flag2")

 

 

Le mar. 11 sept. 2018 à 17:58, Michael Jackson <[hidden email]> a écrit :

What is the “modern” way to append to CMAKE_CXX_FLAGS? This is the logic that I would like:

 

If (MSVC)

                Set(CMAKE_CXX_FLAGS ${ CMAKE_CXX_FLAGS} “/MP”)

Endif()

 

I have always heard that appending to the compile flags in this way is “bad”. What is the best practice for doing this?

 

Thanks

--

Michael Jackson | Owner, President

      BlueQuartz Software

[e] [hidden email]

[w] www.bluequartz.net

--

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:
https://cmake.org/mailman/listinfo/cmake


--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Appending to CMAKE_CXX_FLAGS

Michael Jackson
In reply to this post by Innokentiy Alaytsev
I add it manually each and every time. I have to tell all new developers to remember to add the flag otherwise they are still sitting after an hour waiting on our code to compile wondering why it takes so long. Then it hits us, "Oh, Yeah. Open CMake-Gui and set the /MP flag". I'm frustrated at the situation but not sure how to fix it. I tried the other suggestions and just nothing works. This is one of those things that I poke at once a year and figure out that nothing has changed. Been this way since VS 2013. Someday it will change.

--
Mike Jackson

On 9/11/18, 1:28 PM, "CMake on behalf of Innokentiy Alaytsev" <[hidden email] on behalf of [hidden email]> wrote:

    Hello!
   
    Did you consider adding the flag manually during project configuration? I do
    not know you use case, but after some thinking about the best way of
    achieving multiprocess compilation under MSVS with CMake I decided, that the
    simplest, most portable and flexible is to just add this flag manually. One
    of the reasons for such a decision is that I do not know how the project may
    be built and multiprocess compilation may cause problems under some hardware
    configurations.
   
    Best regards,
    Innokentiy
   
   
   
    --
    Sent from: http://cmake.3232098.n2.nabble.com/
    --
   
    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:
    https://cmake.org/mailman/listinfo/cmake
   


--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Appending to CMAKE_CXX_FLAGS

Thompson, KT
Michael,

I agree heartily with your frustration concerning how CMake handles compiler flags -- especially when the FLAG strings seen in cmake-gui don't match the baseline flags used by the build.  I use a heavy handed, old-fashioned approach to solve this problem.

I ignore all of CMake's default compiler flags.  Instead of using CMake's defaults, I set these flags manually for every supported build environment. For example, I have a setflags.cmake file included from my top level CMakeLists.txt that contains logic that looks something like this:

if( NOT C_FLAGS_INITIALIZED )
  # only do this on the first pass through to avoid overwriting user added options.
  set( C_FLAGS_INITIALIZED "yes" CACHE INTERNAL "Are compiler flags already set?" )

  # Overwrite CMake's defaults...
  if( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
    set( CMAKE_C_FLAGS                "-Wall -pedantic -Wunused-macros" )
    set( CMAKE_C_FLAGS_DEBUG          "-g -DDEBUG")
    set( CMAKE_C_FLAGS_RELEASE        "-O3 -DNDEBUG" )
    set( CMAKE_C_FLAGS_MINSIZEREL     "${CMAKE_C_FLAGS_RELEASE}" )
    set( CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -gdwarf-3" )
    # in a similar fashion, provide CXX_FLAGS and Fortran_FLAGS

  elseif( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" )
    set( CMAKE_C_FLAGS "/fp:precise /DWIN32 /D_WINDOWS /MP" )
    ...
  endif()
endif()

# Save the current compiler flags to the cache every time cmake configures the project.
set(CMAKE_C_FLAGS                "${CMAKE_C_FLAGS}"                CACHE
     STRING "compiler flags" FORCE)
set(CMAKE_C_FLAGS_DEBUG          "${CMAKE_C_FLAGS_DEBUG}"          CACHE
     STRING "compiler flags" FORCE)
set(CMAKE_C_FLAGS_RELEASE        "${CMAKE_C_FLAGS_RELEASE}"        CACHE
     STRING "compiler flags" FORCE)
set(CMAKE_C_FLAGS_MINSIZEREL     "${CMAKE_C_FLAGS_MINSIZEREL}"     CACHE
     STRING "compiler flags" FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}" CACHE
     STRING "compiler flags" FORCE)
# and similar for CXX_FLAGS and Fortran_FLAGS...

With this logic, I have customized baseline compiler flags that show up for everyone and they match the strings found in CMakeCache.txt (and via cmake-gui).  If I modify the flags via ccmake or cmake-gui, the new options are saved to the cache and are used by the build.  

I manually set many more flags for my default set than I show in the example above and I have extra logic to check compiler version or option availability (e.g.: if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) -> add some gcc-8 flags).  I also have some logic that looks for flags set in the environment and these options are appended to these strings before the strings are saved to the cache.  

There are a few downsides to this approach:
- I build on many different platforms with many different compilers, so I have a significant amount of cmake code to manage.
- Some flags that are set automagically set by cmake don't show up in the _FLAGS strings.  For example, setting CMAKE_CXX_STANDARD will add appropriate compiler flags like '-std=c++14' but you don't see them in cmake-gui.

In a few cases I also use per-sourcefile, per-target, and per-directory properties (sometimes via generator expressions) as other have described in replying to your question.  In most cases, I have found that the default flags that are set by the top level of my build system prevent me from needing to customize compile flags for individual targets.

I hope this helps.

-kt

-----Original Message-----
From: CMake <[hidden email]> On Behalf Of Michael Jackson
Sent: Tuesday, September 11, 2018 2:10 PM
To: [hidden email]
Subject: Re: [CMake] Appending to CMAKE_CXX_FLAGS

I add it manually each and every time. I have to tell all new developers to remember to add the flag otherwise they are still sitting after an hour waiting on our code to compile wondering why it takes so long. Then it hits us, "Oh, Yeah. Open CMake-Gui and set the /MP flag". I'm frustrated at the situation but not sure how to fix it. I tried the other suggestions and just nothing works. This is one of those things that I poke at once a year and figure out that nothing has changed. Been this way since VS 2013. Someday it will change.

--
Mike Jackson

On 9/11/18, 1:28 PM, "CMake on behalf of Innokentiy Alaytsev" <[hidden email] on behalf of [hidden email]> wrote:

    Hello!
   
    Did you consider adding the flag manually during project configuration? I do
    not know you use case, but after some thinking about the best way of
    achieving multiprocess compilation under MSVS with CMake I decided, that the
    simplest, most portable and flexible is to just add this flag manually. One
    of the reasons for such a decision is that I do not know how the project may
    be built and multiprocess compilation may cause problems under some hardware
    configurations.
   
    Best regards,
    Innokentiy
   
   
   
    --
    Sent from: http://cmake.3232098.n2.nabble.com/
    --
   
    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:
    https://cmake.org/mailman/listinfo/cmake
   


--

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:
https://cmake.org/mailman/listinfo/cmake
--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Appending to CMAKE_CXX_FLAGS

Eric Noulard
In reply to this post by Michael Jackson


Le mar. 11 sept. 2018 à 22:09, Michael Jackson <[hidden email]> a écrit :
I add it manually each and every time. I have to tell all new developers to remember to add the flag otherwise they are still sitting after an hour waiting on our code to compile wondering why it takes so long. Then it hits us, "Oh, Yeah. Open CMake-Gui and set the /MP flag". I'm frustrated at the situation but not sure how to fix it. I tried the other suggestions and just nothing works. This is one of those things that I poke at once a year and figure out that nothing has changed. Been this way since VS 2013. Someday it will change.

I don't know your constraint on using msbuild but if the "main" issue is to automatically exploit parallel build did you try to switch to ninja instead of msbuild?

Visual C++ Tools for CMake seems to  [begin to] support that path as well: https://blogs.msdn.microsoft.com/vcblog/2017/05/10/cmake-support-in-visual-studio-whats-new-in-2017-15-3-update/


--
Eric

--

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:
https://cmake.org/mailman/listinfo/cmake