Skip to content
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

Fix BUILD_PYTHON_MODULE option on Windows/MSVC when BUILD_SHARED_LIBS is ON #18

Merged
merged 1 commit into from
Apr 4, 2021

Conversation

traversaro
Copy link
Contributor

When building the Python bindings on Windows, the python_ruckig target generate three files: a .exp, a .lib and a .dll .The .dll has a special name that avoids its collision with the ruckig.dll shared library, but if OUTPUT_NAME is simply set to ruckig, then the ruckig.lib of the python_ruckig target has the same name of the ruckig.lib of the ruckig target, resulting in compilation errors such as:

C:\src\ruckig\src\velocity-step2.cpp(49,156): warning C4458: declaration of 'aMax' hides class member [C:\src\ruckig\build\ruckig.vcxproj]
C:\src\ruckig\include\ruckig/velocity.hpp(43,12): message : see declaration of 'ruckig::VelocityStep2::aMax' [C:\src\ruckig\build\ruckig.vcxproj]
C:\src\ruckig\src\velocity-step2.cpp(49,156): warning C4458: declaration of 'aMin' hides class member [C:\src\ruckig\build\ruckig.vcxproj]
C:\src\ruckig\include\ruckig/velocity.hpp(43,18): message : see declaration of 'ruckig::VelocityStep2::aMin' [C:\src\ruckig\build\ruckig.vcxproj]
C:\src\ruckig\src\velocity-step2.cpp(49,156): warning C4458: declaration of 'jMax' hides class member [C:\src\ruckig\build\ruckig.vcxproj]
C:\src\ruckig\include\ruckig/velocity.hpp(43,24): message : see declaration of 'ruckig::VelocityStep2::jMax' [C:\src\ruckig\build\ruckig.vcxproj]
  Generating Code...
  Auto build dll exports
     Creating library C:/src/ruckig/build/Release/ruckig.lib and object C:/src/ruckig/build/Release/ruckig.exp
  ruckig.vcxproj -> C:\src\ruckig\build\Release\ruckig.dll
  Building Custom Rule C:/src/ruckig/CMakeLists.txt
  python.cpp
LINK : fatal error LNK1149: output filename matches input filename 'C:\src\ruckig\build\Release\ruckig.lib' [C:\src\ruckig\build\python_ruckig.vcxproj]

This PR avoids the problem by just setting RUNTIME_OUTPUT_NAME (that just change the names of the .dll) when MSVC is used.

@pantor pantor merged commit 3e7650b into pantor:master Apr 4, 2021
@pantor
Copy link
Owner

pantor commented Apr 4, 2021

Thanks @traversaro! There was a bug in the CI pipeline, so I didn't catch this error. Thanks for fixing!

@traversaro
Copy link
Contributor Author

traversaro commented Apr 4, 2021

Hi @ruckig, actually I think that the change I proposed is problematic, as it results in the library being called python_ruckig.cp39-win_amd64.pyd . The correct variable to set is LIBRARY_OUTPUT_NAME, but perhaps a more robust change is just to have the following logic, without any MSVC-specific code:

set_target_properties(python_ruckig PROPERTIES OUTPUT_NAME ruckig)
# To avoid conflicts in import libraries names in MSVC
set_target_properties(python_ruckig PROPERTIES ARCHIVE_OUTPUT_NAME python_ruckig)

@pantor
Copy link
Owner

pantor commented Apr 6, 2021

Now it seems to work fine 👍

@traversaro
Copy link
Contributor Author

Great, thanks! cc @ahoarau

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants