Skip to content
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

Use of cmake and installation of cmake files on Linux #7911

Closed
KantarBruceAdams opened this issue Sep 23, 2020 · 5 comments · Fixed by #10314, #10306 or #10351
Closed

Use of cmake and installation of cmake files on Linux #7911

KantarBruceAdams opened this issue Sep 23, 2020 · 5 comments · Fixed by #10314, #10306 or #10351
Assignees

Comments

@KantarBruceAdams
Copy link

I found installing protocol buffers from source for use with cmake on platforms not having a sufficiently recent version to be suprisingly painful. Most of the issues I had I think relate to the FindProtobuf.cmake module in cmake (links below). This ticket covers the remaining issues I have with protocol buffers itself.

What version of protobuf and what language are you using?
Version: v3.5.0
Language: C++

What operating system (Linux, Windows, ...) and version?

CentOS7

What runtime / compiler are you using (e.g., python version or gcc version)

g++ 4.8.5
cmake 3.18

What did you do?

install using configure/make:

./configure --enable-static --enable-shared --with-pic --prefix=/opt/protobuf-3.5.0
sudo make install

install using cmake:

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/protobuf-3.5.0 -Dprotobuf_BUILD_SHARED_LIBS=off ../cmake
make
sudo make install

What did you expect to see

cmake configuration files should be installed to /opt/protobuf-3.5.0/lib64/cmake.

What did you see instead?

cmake files are not installed for the configure build but are for the cmake based build.

However, with the cmake based build it is not possible to create both static and shared versions of protocol buffers at the same time.
You would have to do:

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/protobuf-3.5.0-static -Dprotobuf_BUILD_SHARED_LIBS=off -DCMAKE_POSITION_INDEPENDENT_CODE=ON ../cmake
make
sudo make install
cd ..

mkdir build2
cd build2
cmake -DCMAKE_INSTALL_PREFIX=/opt/protobuf-3.5.0-shared -Dprotobuf_BUILD_SHARED_LIBS=on ../cmake
make
sudo make install

What would you like to see?

  1. The cmake/README.md should clarify whether the maintainers support its use on Linux or just windows.
    As it works on Linux I suggest it should be considered supported.

  2. The cmake build should allow you to create both shared and static libraries at the same time.

  3. The configure and cmake builds should ideally be consistent and equivalent.
    Both should install .cmake files if possible
    (this could be done by adding a switch to configure to tell it to create them piggy backing of cmake install somehow).

Failing that the build instructions should warn that cmake configuration files will only be installed if the cmake build process is used instead of the configure one.

Anything else we should know about your project / environment

The file protobuf-3.5.0/cmake/README.md starts:

This directory contains CMake files that can be used to build protobuf
with MSVC on Windows. You can build the project form Command Prompt
and using an Visual Studio IDE.

This seems to imply that the cmake build is only intended for use on windows.
However it works just fine on Linux apart from the caveat of not being able install both static and shared libraries simultanously.

I found it necessary to use the cmake build on Linux to work around some issues with FindProtobuf.cmake (in cmake 3.18).
See:


-DCMAKE_POSITION_INDEPENDENT_CODE=ON is needed if the static protocol buffer libraries happen to be
used in shared libraries or you will get recompile with -fPIC errors at link time.
Using static libraries is preferable to avoid end users having to install proto buffers themselves on Linux platforms that don't supply the correct version natively.

@UVV-gh
Copy link

UVV-gh commented Jun 15, 2021

Just stumbled upon this issue and was wondering if there's any activity in that regard? I was also surprised that cmake config files are not installed with autotools build and that cmake build is described only for Windows platform.

@csukuangfj
Copy link

Any update on this issue?

@fowles
Copy link
Contributor

fowles commented Jul 26, 2022

It is being worked on, but the build system for protobuf is pretty large, so it takes time

@mkruskal-google
Copy link
Member

Quick update: We're currently in the process of deprecating Autotools usage entirely, and pivoting to supporting only Bazel and CMake. The CMake configuration is already generated by Bazel today, and we're adding test coverage for build/test/install. Once Autotools is removed, CMake's install will be the only way to install protobuf from source.

I'll make sure to update the documentation and look into the shared/static issue too

@mkruskal-google mkruskal-google linked a pull request Jul 26, 2022 that will close this issue
This was linked to pull requests Aug 2, 2022
@mkruskal-google
Copy link
Member

The README has been updated to make it clear that we do support CMake on linux, and we now have tests for build/test/install. Autotools will be removed entirely very soon (see #10132), so that ambiguity should disappear.

For the static/shared issue I'm a little confused what the problem is. Are you trying to build shared and static library with a single cmake command? Or are you trying to install them both to the same directory? The former seems WAI

kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Aug 25, 2022
Autotools support has been removed and replaced completely by CMake.

See related issues for details:
protocolbuffers/protobuf#7911
protocolbuffers/protobuf#10132

Drop autotools patches too.

Signed-off-by: Vyacheslav Yurkov <Vyacheslav.Yurkov@bruker.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
halstead pushed a commit to openembedded/meta-openembedded that referenced this issue Aug 26, 2022
Autotools support has been removed and replaced completely by CMake.

See related issues for details:
protocolbuffers/protobuf#7911
protocolbuffers/protobuf#10132

Drop autotools patches too.

Signed-off-by: Vyacheslav Yurkov <Vyacheslav.Yurkov@bruker.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Aug 26, 2022
Autotools support has been removed and replaced completely by CMake.

See related issues for details:
protocolbuffers/protobuf#7911
protocolbuffers/protobuf#10132

Drop autotools patches too.

Signed-off-by: Vyacheslav Yurkov <Vyacheslav.Yurkov@bruker.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
halstead pushed a commit to openembedded/meta-openembedded that referenced this issue Aug 27, 2022
Autotools support has been removed and replaced completely by CMake.

See related issues for details:
protocolbuffers/protobuf#7911
protocolbuffers/protobuf#10132

Drop autotools patches too.

Signed-off-by: Vyacheslav Yurkov <Vyacheslav.Yurkov@bruker.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Aug 27, 2022
Autotools support has been removed and replaced completely by CMake.

See related issues for details:
protocolbuffers/protobuf#7911
protocolbuffers/protobuf#10132

Drop autotools patches too.

Signed-off-by: Vyacheslav Yurkov <Vyacheslav.Yurkov@bruker.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
Autotools support has been removed and replaced completely by CMake.

See related issues for details:
protocolbuffers/protobuf#7911
protocolbuffers/protobuf#10132

Drop autotools patches too.

Signed-off-by: Vyacheslav Yurkov <Vyacheslav.Yurkov@bruker.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment