-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use cmake generator "NMake Makefiles" with conan #2388
Comments
I am going to submit a fix for this for 1.0.4, but if you want to try now to patch your if "Makefiles" in self.generator and "NMake" not in self.generator: your feedback will be welcomed. |
Yes, this way it works for me, thanks. BTW, there is another NMake-related problem: to use "NMake Makefiles" generator one have to set vcvars environment before calling cmake (otherwise cmake won't find |
Does it work when you do the |
Well, I'm experimenting with Use conanfile.py for consumers and trying to configure & build my own cmake project that uses NMake Makefiles generator. So I run |
Just for curiosity and willing to learn, what is the reason to generate NMake files instead of VS solution if you want to actually use VS compiler? What are the advantages of using NMake, I haven't used it yet. Maybe you can try to use the |
I can't use
Thanks. But it also seems not working correctly - it replaces |
Yes, Visual Studio generator is multi-config, and CMAKE_BUILD_TYPE is not defined like in single-config environments. But later switch in IDE or with |
Regarding def environment_append(env_vars):
"""
:param env_vars: List of simple environment vars. {name: value, name2: value2} => e.j: MYVAR=1
The values can also be lists of appendable environment vars. {name: [value, value2]}
=> e.j. PATH=/path/1:/path/2
:return: None
"""
old_env = dict(os.environ)
for name, value in env_vars.items():
if isinstance(value, list):
env_vars[name] = os.pathsep.join(value)
if name in old_env:
env_vars[name] += os.pathsep + old_env[name]
os.environ.update(env_vars)
def vcvars(*args, **kwargs):
new_env = vcvars_dict(*args, **kwargs)
with environment_append(new_env):
yield |
if you don't pass a list it doesn't have to do anything special, just update the environ with the string. |
You can try with: def build(self):
with tools.vcvars(self.settings, filter_known_paths=False):
cmake = CMake(self, generator="NMake Makefiles")
cmake.configure(source_folder="src")
cmake.build() This is possibly a bug (the default value of I am a bit surprised that CMake is not able to find VS cl.exe while using NMake Makefiles generator, but with the above you are able to inject the VS path to cl.exe before executing CMake. In any case, I still feel it like a small workaround, as we are talking mainly about user consumption, I feel that going with |
Yes, so the problem is probably in |
That's quite obvious. For |
Yes, that makes sense, thanks for the clarification :) Did you try the above? Did it work? Please tell me. |
Yes, it works for me. Thanks a lot! |
Released in 1.0.4 |
|
Hi @aissat ! We'd need more information, for example what is the profile you are using to build that. Because by default in Windows, latest Visual Studio is used. Also, any environment variable that you might be using, like CONAN_CMAKE_GENERATOR, as env-var or defined in conan.conf. Thanks! |
hi @memsharded
my profile
|
Could you please check what is the line in your conan.conf?:
Seems like a wrong Note also that the flags:
won't be used in Windows. In Windows, it is building with CMake (the CMake build helper will automatically handle fPIC and std flags). Other arbitrary flags that you could provide here won't necessarily be passed to CMake, as it doesn't honor such environment variables. There are some ongoing ideas trying to provide such functionality that CMake doesn't implement out of the box. |
Hi again @aissat I am failing to see how your issue is related to NMake, which is the title of this issue. I have been able to build zlib with my profile with: conan install zlib/1.2.11@conan/stable --build=zlib -pr=myprofile
zlib/1.2.11@conan/stable: Not found in local cache, looking in remotes...
zlib/1.2.11@conan/stable: Trying with 'conan-center'...
Downloading conanmanifest.txt
[==================================================] 121B/121B
Downloading conanfile.py
[==================================================] 5.9KB/5.9KB
zlib/1.2.11@conan/stable: Installing package
Requirements
zlib/1.2.11@conan/stable from 'conan-center'
Packages
zlib/1.2.11@conan/stable:7bc8c2c85db7a618e5320dc997f27fc33e1df074
zlib/1.2.11@conan/stable: WARN: Forced build from source
Downloading conan_sources.tgz
[==================================================] 281B/281B
zlib/1.2.11@conan/stable: Building your package in C:\...i\.conan\data\zlib\1.2.11\conan\stable\build\7bc8c2c85db7a618e5320dc997f27fc33e1df074
zlib/1.2.11@conan/stable: Configuring sources in C:\...\.conan\data\zlib\1.2.11\conan\stable\source
[==================================================] 607.7KB/607.7KB
zlib/1.2.11@conan/stable: Copying sources to build folder
zlib/1.2.11@conan/stable: Generator cmake created conanbuildinfo.cmake
zlib/1.2.11@conan/stable: Calling build()
-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
... it doesn't use NMake at all. Please open a new issue, make sure that you provide:
Thanks! |
hi @memsharded |
when i removed
|
What configuration are you trying to install? Note the difference between
and |
I think the problem was solved by adding the following
But another problem appeared that every time he downloaded |
If I set environment variable CONAN_CMAKE_GENERATOR to"NMake Makefiles", conan correctly passes
-G "NMake Makefiles"
to cmake during configure but build fails withthe problem is here:
https://github.com/conan-io/conan/blob/develop/conans/client/build/cmake.py
You always add -j flag for Makefiles generators but NMake does not understand that.
The text was updated successfully, but these errors were encountered: