clickhouse-cpp icon indicating copy to clipboard operation
clickhouse-cpp copied to clipboard

[WIP] Separate building static and shared libs

Open xakod opened this issue 3 years ago • 6 comments

Introduce separating building static and shared libs, depends on cmake out-of-the-box option BUILD_SHARED_LIBS https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html. Also creates alias target for transparently linking to static or shared lib.

xakod avatar Oct 01 '22 09:10 xakod

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 01 '22 09:10 CLAassistant

Ok, @Enmk

  • Reason: i wanna provide a conan recipe to conan-center-index for clickhouse-cpp. Conan does not support static and shared libs at the same time. Library should be build as static or as shared.
  • Ok, i'll try to figure out how to do that and change pr
  • If project uses library with cmake FetchContent or as subdirectory project may depend on static target name. If we change target name for static libs it will be cmake error. There is only one reason why I do not change target name for static.

xakod avatar Oct 03 '22 12:10 xakod

Regarding the CI/CD testing: IMO you might want to add another matrix parameter, like here. Something like:

      matrix:
        compiler: [clang-6, gcc-7, gcc-8, gcc-9]
        ssl: [ssl_ON, ssl_OFF]
+       build_type: [static, shared]
        include:
...
+       - build_type: shared
+         CMAKE_BUILD_TYPE_FLAG: -BUILD_SHARED_LIBS=ON

etc.

Enmk avatar Oct 04 '22 12:10 Enmk

Also, if you wish to add clickhouse-cpp as a Conan module, please free to add any related CI/CD workflows

Enmk avatar Oct 04 '22 12:10 Enmk

Regarding the CI/CD testing: IMO you might want to add another matrix parameter,

I did this but looks like windows shared build is broken

xakod avatar Oct 04 '22 13:10 xakod

If someone can help with windows shared build with export all, it will be nice

xakod avatar Oct 14 '22 21:10 xakod

If someone can help with windows shared build with export all, it will be nice

Addressed in #226
CI/CD workflows, the exe maybe miss the dll, be careful of their path

1261385937 avatar Oct 16 '22 13:10 1261385937

Another attempt to fix windows build here: #227 227

Enmk avatar Oct 17 '22 12:10 Enmk

@Enmk I dropped support for shared builds for windows and macos due to platforms require exporting symbols. Also @1261385937 will close his draft https://github.com/ClickHouse/clickhouse-cpp/pull/226#issuecomment-1361137815

xakod avatar Dec 22 '22 14:12 xakod