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
ninja does not support cmake build of both shared and static libs on windows when using cmake's OUTPUT_NAME #1128
Comments
Maybe it's a problem with cmake and not ninja than? How does cmake behave when generating makefile in this case? |
It works as expected with visual studio and the build rules with ninja look On Thu, Apr 7, 2016 at 1:04 AM, Dmytro Ivanov notifications@github.com
|
I don't know much about cmake, but:
From these I conclude:
On Wed, Apr 6, 2016 at 8:30 PM, MarkMLunarG notifications@github.com
|
Both the SHARED library and the STATIC library will produce a file called MyLib.lib. For the former it's the DLL's import library for the later it's the static library itself. Even if visual studio doesn't diagnose this it likely results in one silently replacing the other which probably isn't what you want either. |
That is not what I observe. Ninja is producing only the MyLib.dll I tried hacking the build.ninja file and found I could make the warning go So my guess is that there is a lexical compare that considers MyLib.lib and On Thu, Apr 7, 2016 at 12:28 PM, Nils Gladitz notifications@github.com
|
I am not sure what you mean by "both"?
If you don't have / want an import library for your DLL (e.g. because you are creating a runtime loadable plugin without DLL exports rather than a linkable library) you should use the MODULE rather than SHARED library type. Either way you can not have two files occupy the same space at the same time. |
Ah, forehead slap, I see it now. This is not the first bug that Ninja has On Thu, Apr 7, 2016 at 1:28 PM, Nils Gladitz notifications@github.com
|
In windows this cmake language can be used to build both static and dyn libs:
add_library(MyLib SHARED source1.c source2.c)
add_library(MyLibStatic STATIC source1.c source2.c)
set_target_properties(MyLibStatic PROPERTIES OUTPUT_NAME MyLib)
target_link_libraries(MyLib)
But only MyLib.dll is built by ninja, no MyLib.lib is built. When the ninja build is run, this warning is generated:
ninja: warning: multiple rules generate MyLib.lib. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
All attempts to link against MyLib.lib then fail
The text was updated successfully, but these errors were encountered: