8000 Fix support for building static library with Visual Studio by chrisdembia · Pull Request #61 · docopt/docopt.cpp · GitHub
[go: up one dir, main page]

Skip to content

Fix support for building static library with Visual Studio #61

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

Merged
merged 4 commits into from
Oct 24, 2016

Conversation

chrisdembia
Copy link
Contributor

In PR #60, I tried to improve support for using docopt with Visual Studio when building/using the shared library docopt.dll. In doing so, I introduced a bug when trying to build/use docopt as a static library (docopt_s.lib) in Visual Studio.

Basically, I had been defining DOCOPTAPI to be __declspec(dllimport) when building the static library. But when building a static library, neither __declspec(dllimport) nor __declspec(dllexport) should be used.

This PR fixes the bug. The new behavior is as follows. When building the shared library, one must define both DOCOPT_DLL and DOCOPT_API. When using the shared library, one must define DOCOPT_DLL. The user need not worry about these macros at all; they are handled by CMake. For example, a client project with the following CMakeLists.txt will cause DOCOPT_DLL to automatically be defined when compiling foo.cpp.

project(ClientToDocopt)
cmake_minimum_required(VERSION 3.1)
find_package(docopt)
add_executable(foo foo.cpp)
target_link_libraries(foo docopt)

Locally, I tested both the shared library docopt.dll and the static library docopt_s.lib with a small CMake client project.

@jaredgrubb
Copy link
Member

Looks ok to me but I know nothing about Windows :) This has been up a week and no one has objected so let's merge it.

@chrisdembia
Copy link
Contributor Author

Thank you! I will be happy to address any issues that arise from this PR.

@chrisdembia chrisdembia deleted the windows-support-static-lib branch October 24, 2016 17:07
@jaredgrubb
Copy link
Member

Thanks for your contributions!

@chrisdembia
Copy link
Contributor Author

And thank you for making a great library :)

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
0