[question] Manually configuring (or disabling) the /MPxx flag for MSVC profiles?
See original GitHub issue- I’ve read the CONTRIBUTING guide.
Question
With an MSVC profile CMakeToolchain generator creates a conan_toolchain.cmake
file that sets the number of compilation processes by setting the /MP
flag like so:
string(APPEND CONAN_CXX_FLAGS " /MP12")
string(APPEND CONAN_C_FLAGS " /MP12")
# snip
string(APPEND CMAKE_CXX_FLAGS_INIT " ${CONAN_CXX_FLAGS}")
# snip
string(APPEND CMAKE_C_FLAGS_INIT " ${CONAN_C_FLAGS}")
How can I modify/disable this functionality? (Obviously aside from manually editing the lines or wrapping the toolchain in my own toolchain.)
Background
I have a project that relies heavily on PCL, which isn’t yet available as a Conan recipe, so it needs to be built manually. I’m attempting to use Conan to set up the CMake toolchain for the PCL dependencies so I can avoid fragmentation as much as possible when I directly use those third-party deps in my own project. It’s straightforward enough with a conanfile.txt
like so:
[requires]
zlib/1.2.12
boost/1.78.0
eigen/3.4.0
flann/1.9.2
qhull/8.0.1
[generators]
CMakeDeps
CMakeToolchain
And using a default profile:
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
build_type=Release
[options]
[conf]
[build_requires]
[env]
This configuration on a 6 core CPU with HT gives me the /MP12 flag, which is sensible, but unfortunately this breaks some of the PCL scripts because they assume that if you’ve set any non-default flags you’ve set every required flag and don’t want any additional added.
I can work around this by wrapping the toolchain and modifying CMAKE_<LANG>_FLAGS_INIT
or by manually setting all required flags, but with CUDA/Ninja etc., that might be a maintainability issue, so wanted to figure out if I can simply disable this from the Conan side. Alternatively I’m open to any other obvious solution if there’s something I missed.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
@memsharded Ahh, you’re right… Thanks for that, it seems like I was just thinking too hard about it.
I was looking at
conan.tools.build.cpu.build_jobs()
and focusing on the defaults forNone
but I overlooked how this obvious if statement falls through on 0.Thanks.
I think that
tools.build:jobs=0
will simply not define that flags, please try it and let me know