-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
Comments
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. |
Any update on this issue? |
It is being worked on, but the build system for protobuf is pretty large, so it takes time |
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 |
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 |
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>
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>
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>
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>
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>
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>
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?
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.
The cmake build should allow you to create both shared and static libraries at the same time.
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 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.
The text was updated successfully, but these errors were encountered: