In CMake >= 3.0 it is more idiomatic to set per-target compiler options than global compiler settings. I have kept these options and defines as `PRIVATE` so they won't be exported with the target.
Closes#12916
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12916 from coryan:cleanup-cmake-avoid-global-compile-settings 3d586dc0e8
PiperOrigin-RevId: 536517165
This will require C++14 (or higher) for the `libproto*` targets **and** anything that links them. If multiple dependencies have different C++ requirements, CMake will use the maximum version. It does not work with pkg-config, and does not work if the downstream dependency forcibly downgrades the compiler to C++11 (or lower). But prevents many problems. Note that if Abseil was compiled with C++17 it will require C++17 and that will propagate through Protobuf.
Closes#12901
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12901 from coryan:feat-cmake-use-target-compile-features 95084ac691
PiperOrigin-RevId: 535579816
This cl hit an issue during the shared library cmake build from ODR violations, leading to mismatched absl hash seeds. The problem was pre-existing but didn't manifest until now, and can be traced to the fact that in shared library builds we linked Abseil statically. All of the cmake changes here remove the underlying ODR violation.
PiperOrigin-RevId: 485787671
descriptor.h includes abseil's mutex.h directly, thus abseil is not a
private dependency any more but must be included by every user of
libprotobuf.
Co-authored-by: Harald Fernengel <547273+haraldF@users.noreply.github.com>
* Proof of concept for Abseil dependency
* Adding most common Abseil libraries
* Fixing shared library breakages
* Switching to quotes over angled brackets
* Disable install target by default
* Fixing abseil to LTS commit
* Upgrade to latest Abseil LTS
* Turning install back on by default, removing unnecessary export statements
* Add note to future self
* Fixing unsafe globals
This is in preparation for generating file lists automatically.
I am putting the list of files under src/, not under cmake/, so that it will be next to the file list for automake (see #10029). I can certainly put the list back under cmake/, but in general, I think we probably want to move the cmake targets e.g. to src/CMakeLists.txt anyhow.
* Revert "Added cmake abseil include guard"
This reverts commit b6ee841d7c.
* Revert "Update CMake configuration to add a dependency on Abseil (#9793)"
This reverts commit e9246cd789.
These filenames stutter, but are still being used by some users. So, these forward to the correct header. They should eventually be deprecated and removed.
* Proof of concept for CMake Abseil dependency
* Hooked up Abseil linking
* Adding test binaries
* Reverting absl::string view use added for testing. This will still be broken for automake and bazel
* Adding new cmake config to dist list
* Whitespace fixes and an attempt at fix for Windows Python Release (CMake version < 3.13)
* Hook up LTS to windows cmake
* Fix 'git cd' typo
* Adding clarifying comment for fix
* Adding abseil dependency to protobuf-lite too
* Update submodules instead of cloning abseil-cpp
* Adding explicit pointer to abseil root directory
Co-authored-by: Jason Lunn <jason.lunn@gmail.com>
Co-authored-by: Jorg Brown <jorg.brown@gmail.com>
* Support older versions of CMake.
VERSION_GREATER_EQUAL is supported by CMake >=3.7:
https://cmake.org/cmake/help/latest/command/if.html#version-greater-equal
target_link_options() is supported by CMake >=3.13:
https://cmake.org/cmake/help/latest/command/target_link_options.html
* Use PROTOBUF_USE_DLLS and LIBPROTOC_EXPORTS for libprotoc.so shared library
Similar change for libprotobuf.so and libprotobuf-lite.so was made
in commit 5a0887fc65.
* Make value of PROTOC_EXPORT dependent on LIBPROTOC_EXPORTS instead of LIBPROTOBUF_EXPORTS
This was probably intention, and LIBPROTOC_EXPORTS is also used above
in _MSC_VER branch.
Soname was set for libprotobuf.so in commit a9cf69a0ed,
but similar changes for libprotobuf-lite.so and libprotoc.so were missed.
Fixes: #8635
Co-authored-by: Arfrever Frehtes Taifersar Arahesis <Arfrever@GMail.Com>