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 <mike.jack...@bluequartz.net> 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] mike.jack...@bluequartz.net > > [w] www.bluequartz.net > > > > *From: *Marc CHEVRIER <marc.chevr...@gmail.com> > *Date: *Tuesday, September 11, 2018 at 1:04 PM > *To: *Michael Jackson <mike.jack...@bluequartz.net> > *Cc: *CMake <cmake@cmake.org> > *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 < > mike.jack...@bluequartz.net> 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] mike.jack...@bluequartz.net > > [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