List Archive

Thread

Thread Index

Message

From: Michał Janiszewski <janisozaur%gmail.com@localhost>
To: Thomas Klausner <tk%giga.or.at@localhost>
Subject: Re: vcpkg support/static builds
Date: Sun, 19 Nov 2017 10:29:05 +0100

I have tried updating libzip vcpkg to 1.3.0 and took a closer look at your suggestions and what is going on there.
Your suggestions to use ZIP_STATIC is perfectly fine, however there is still an issue with it.
ZIP_STATIC can only be set from the build system which is not used anywhere in CMakeLists.txt and vcpkg seems to build multiple versions (shared, static), each with its own header.
The patch in vcpkg looks to make just that – ensure each of static and shared version can have fully-contained headers.
Could you change how the ZIP_STATIC is used, so that it can be configured (CMake's CONFIGURE_FILE) and stored in a header?

On Tue, Aug 29, 2017 at 10:28 AM, Thomas Klausner <tk%giga.or.at@localhost> wrote:
I've switched to that now.

What I don't like is that there seems to be no sane way to build
shared libraries by default using BUILD_SHARED_LIBS -- if it's not
defined, it defaults to "OFF" for me.

 Thomas

On Mon, Aug 14, 2017 at 04:46:27PM +0200, Michał Janiszewski wrote:
> You don't need to expose it as an option explicitly, as it appears CMake
> already does it internally – like CMAKE_BUILD_TYPE and such.
> The code previously was:
>     add_library(myLib SHARED ${MYLIB_SOURCES})
> and only "SHARED" had to be dropped:
>     add_library(myLib ${MYLIB_SOURCES})
>
> Now when building, it will pick up whatever current BUILD_SHARED_LIBS is.
> There was no need to add anything else.
>
> Compare jobs:
> [a] https://travis-ci.org/OpenRCT2/OpenRCT2/jobs/264273471
>     cmake ../ -DBUILD_SHARED_LIBS=ON
>     [ 87%] Linking CXX shared library libopenrct2.so
>
> [b] https://travis-ci.org/OpenRCT2/OpenRCT2/jobs/264273472
>     cmake ../ -DBUILD_SHARED_LIBS=off
>     [ 87%] Linking CXX static library libopenrct2.a
>
> How should it best be handled is a bit unclear, have a look at this
> unanswered call to update the docs:
> http://cmake.3232098.n2.nabble.com/Add-BUILD-SHARED-LIBS-as-an-option-td7595236.html
>
> On Mon, Aug 14, 2017 at 3:46 PM, Thomas Klausner <tk%giga.or.at@localhost> wrote:
>
> > On Mon, Aug 14, 2017 at 01:02:06PM +0200, Michał Janiszewski wrote:
> > > thanks for the update.
> > > Since I posted the previous message, I've learned about CMake-3.0+
> > standard
> > > option "BUILD_SHARED_LIBS":
> > > https://cmake.org/cmake/help/v3.0/variable/BUILD_SHARED_LIBS.html
> > > This allows user to set upon configuration whether they want a shared or
> > > static library, but only for `add_library` targets. All other things
> > retain
> > > their linking mode.
> > > See it getting used here:
> > > https://github.com/OpenRCT2/OpenRCT2/pull/6145/files
> > > Seeing how both your static and shared paths are the same, perhaps you
> > may
> > > want to investigate using said option.
> >
> > I've looked at the documentation and the example you pasted, but it's
> > not clear to me how to use it.
> >
> > Just removing the type is not enough.
> >
> > Removing it and adding
> >
> > OPTION(BUILD_SHARED_LIBS "build shared libraries" ON)
> >
> > in the main CMakeLists.txt file just builds static libraries.
> >
> > Using
> >
> > SET(BUILD_SHARED_LIBS ON)
> >
> > in the main CMakeLists.txt builds shared libraries, but I can't turn
> > it off by running
> >
> > cmake -DBUILD_SHARED_LIBS:BOOL=OFF ..
> >
> > so I don't really know how this is supposed to work. Any ideas?
> >  Thomas
> >
>
>
>
> --
> Michal Janiszewski



--
Michal Janiszewski

Made by MHonArc.