question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] Manually configuring (or disabling) the /MPxx flag for MSVC profiles?

See original GitHub issue

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:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mvhvcommented, May 19, 2022

@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 for None but I overlooked how this obvious if statement falls through on 0.

Thanks.

1reaction
memshardedcommented, May 19, 2022

I think that tools.build:jobs=0 will simply not define that flags, please try it and let me know

Read more comments on GitHub >

github_iconTop Results From Across the Web

[question] Manually configuring (or disabling) the /MPxx flag for ...
With an MSVC profile CMakeToolchain generator creates a conan_toolchain.cmake file that sets the number of compilation processes by setting the /MP flag ......
Read more >
Migrating from Visual Studio 2017 to 2019, trouble with /MP ...
I'm getting the following error when trying to build in Visual Studio 2019: 2>cl : command line warning D9002: ignoring unknown option '/mp'....
Read more >
gcc(1) - Linux manual page - man7.org
-fvisibility-ms-compat This flag attempts to use visibility settings to make GCC's C++ linkage model compatible with that of Microsoft Visual Studio.
Read more >
/MP (Build with multiple processes) | Microsoft Learn
For example, a computer has one effective processor if it has one physical processor that has one core, and hyperthreading is disabled. In ......
Read more >
CUDA Compiler Driver NVCC - NVIDIA Documentation Center
Defined when the --expt-relaxed-constexpr flag is specified on the command line. ... Disable nvcc check for supported host compiler versions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found