Skip to content

Enable shared library builds and improve CMake script #3

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 3 commits into from
Aug 16, 2020
Merged

Enable shared library builds and improve CMake script #3

merged 3 commits into from
Aug 16, 2020

Conversation

sztomi
Copy link
Contributor

@sztomi sztomi commented Aug 14, 2020

This PR contains various changes to the CMake build that make it a bit more flexible.

  • Adds the standard BUILD_SHARED_LIBS option that allows consumers to select a shared or static library.
  • Removes the assumption that Windows == MSVC. This is not always true: one can build on Windows via mingw or cross-compile for Windows similarly. In that case, the compiler won't understand the MSVC flag.

There was an incomplete link flag passed which caused the shared build to fail. The relevant section in the flags: -Wl,--version-script -shared -Wl,-soname,libOpenCLRuntimeLoader.so

--version-script requires an argument, so the next linker option, -soname was treated as one, leading to this error:

cannot open linker script file -soname: No such file or directory

I'm not sure what the intention was with this flag, maybe it was a copy-paste error? In any case, this allows building the library in both a shared and static configuration.

@sztomi sztomi changed the title Enable shared library builds Enable shared library builds and improve CMake build Aug 14, 2020
@sztomi sztomi changed the title Enable shared library builds and improve CMake build Enable shared library builds and improve CMake script Aug 14, 2020
@bashbaug
Copy link
Owner

This is great - thank you very much for your contribution!

At some point I may add an override so this specific project can be built as a static lib even if other projects are built with shared libs, similar to the solution here:

https://stackoverflow.com/questions/53499678/cmake-build-shared-libs-for-single-libraries

This is definitely an improvement though in the meantime. Thanks again!

@sztomi
Copy link
Contributor Author

sztomi commented Aug 17, 2020

Thanks!

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