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.

Add ability to customize the CMake generator

See original GitHub issue

When using the CMake class with MinGW it automatically use the “MinGW Makefiles” generator. However, when using MSys and “MinGW Makefiles”, CMake complains when it finds sh.exe in the PATH. A solution is to remove sh.exe but for some of my builds I need to have sh.exe so, in the test_package, I’m forced to override the default behavior of the CMake class as following:

if os_info.is_windows and self.settings.compiler == "gcc":
    self.run('cmake "%s" %s -G "Unix Makefiles"' % (self.conanfile_directory, cmake.command_line))
else:
    self.run('cmake "%s" %s' % (self.conanfile_directory, cmake.command_line))

It ends as the following call:

cmake "path/to/source" -G "MinGW Makefiles" ... -G "Unix Makefiles"

It’s not really clean and I think it would be better if there was an option in the CMake class to choose the CMake generator.

What do you think?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
memshardedcommented, Nov 7, 2016

Ok, I see the point. What would be the suggested interface?

def build(self):
    cmake = CMake(self.settings)
    if platform.system() == "Windows":
        cmake.generator = "Unix Makefiles"
    ...
0reactions
lasotecommented, Nov 7, 2016

It’s ok for me. just remember to update the docs to see how to do it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Step 4: Adding Generator Expressions - CMake
Generator expressions are evaluated during build system generation to produce information specific to each build configuration. Generator expressions are ...
Read more >
CMake customization points, how to configure your project?
We will see how to use variables, build configurations and then generator expressions so that you can provide flexible options to your users....
Read more >
Changing current cmake generator - Stack Overflow
A scenario where changing the generator is needed is that you are keeping the CMake GUI open and reusing the same directory (source...
Read more >
Customize CMake build settings in Visual Studio
The editor lets you add CMake configurations and customize their settings easily. It's intended to be a simpler alternative to manually ...
Read more >
CMake-Episode 003 : CMake Generators | CMake Starts Here
CMake Generators explained in plain English. We use several generators to build a C++ project both on Windows and LinuxPlaylist: ...
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