Skip to content

CMake: Add BUILD_STATIC_LIBS option#461

Merged
squeek502 merged 1 commit intoluvit:masterfrom
squeek502:cmake-static-lib
Feb 29, 2020
Merged

CMake: Add BUILD_STATIC_LIBS option#461
squeek502 merged 1 commit intoluvit:masterfrom
squeek502:cmake-static-lib

Conversation

@squeek502
Copy link
Copy Markdown
Member

@squeek502 squeek502 commented Feb 29, 2020

@zhaozg this is a followup to #459 (comment)


This adds on to the changes in #459 to make it possible to build module, static, and shared libraries all at the same time if requested

  • To build the module, -DBUILD_MODULE=On; the target name for the module is luv
  • To build a static library, -DBUILD_STATIC_LIBS=On; the target name for the static lib is libluv_a (this matches how libuv names its targets [uv for shared and uv_a for static])
  • To build a shared library, -DBUILD_SHARED_LIBS=On; the target name for the shared lib is libluv

These are able to be mixed/matched as needed.

This is a breaking change (as was #459) for users of CMake (e.g. luvi) who will now need to specify linking against libluv/libluv_a and turn on BUILD_SHARED_LIBS/BUILD_STATIC_LIBS before calling add_subdirectory

This adds on to the changes in luvit#459 to make it possible to build module, static, and shared libraries all at the same time if requested

- To build the module, `-DBUILD_MODULE=On`; the target name for the module is `luv`
- To build a static library, `-DBUILD_STATIC_LIBS=On`; the target name for the static lib is `libluv_a` (this matches how `libuv` names its targets; `uv` for shared and `uv_a` for static)
- To build a shared library, `-DBUILD_SHARED_LIBS=On`; the target name for the shared lib is `libluv`

These are able to be mixed/matched as needed.

This is a breaking change (as was luvit#459) for users of CMake (e.g. luvi) who will now need to specify linking against `libluv`/`libluv_a` and turn on `BUILD_STATIC_LIBS`/`BUILD_SHARED_LIBS` before calling `add_subdirectory`
@squeek502
Copy link
Copy Markdown
Member Author

Some notes:

  • It might be possible to fix this being a breaking change when exactly one build target is specified, using luv as the target name for whatever library type is specified.
    • For example, luvi sets BUILD_MODULE=Off and then expects luv to be a static library. This could be maintained by setting the static library's target name luv when both BUILD_MODULE=Off and BUILD_SHARED_LIBS=Off (and also infer BUILD_STATIC_LIBS=On from the other two being off)
  • If anyone has other ideas for how to allow multiple library types to be built at the same time in a less breaking way, let me know

Copy link
Copy Markdown
Member

@zhaozg zhaozg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beauty of symmetry

@squeek502 squeek502 merged commit 02237cd into luvit:master Feb 29, 2020
squeek502 added a commit to squeek502/luvi that referenced this pull request Feb 29, 2020
Updates CMake to be compatible with the changes in luvit/luv#459 and luvit/luv#461
squeek502 added a commit to squeek502/luvi that referenced this pull request Feb 29, 2020
Updates CMake to be compatible with the changes in luvit/luv#459 and luvit/luv#461
justinmk pushed a commit to neovim/neovim that referenced this pull request Feb 29, 2020
- Fix an issue where CMAKE_BUILD_TYPE was not reflected during
  construction.
- Remove the switch that uses the static library(-MTd, -MT) because it was
  specified in the CMakeLists.txt of luv when building on MSVC.

related: luvit/luv#461
squeek502 added a commit to squeek502/luv that referenced this pull request Oct 20, 2020
Should have been added in luvit#461 when BUILD_STATIC_LIBS option was added
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