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.
* Avoid exporting build tree targets to installation directory
`export(TARGETS ...)` is meant to allow for build trees to be found
from other projects, however, writing the file to an installation
directory causes buildtree paths to be hardcoded in the installed
protobuf-targets.cmake
* Install protobuf-targets.cmake from target, not build tree
This allows for installation prefixes to match the intended
installation directories, instead of being copied from
the build tree.
* 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>
The new option will allow us to generate test XML output.
CTest can discover tests from googletest, but it generates one file
per case. We have several thousand cases, so one file each would be
far from optimal. The approach in this change will generate one file
per test (executable).
This change adds separate libraries for common test utilities and test proto definitions, which are shared by different test targets.
Without this change, cmake fails when generating Xcode files with the error:
```
CMake Error in CMakeLists.txt:
The custom command generating
.../protobuf/src/google/protobuf/unittest_lite.pb.cc
is attached to multiple targets:
tests
lite-test
lite-arena-test
but none of these is a common dependency of the other(s). This is not
allowed by the Xcode "new build system".
```
* 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>
* add plugin options
* refactored comment message
* added tabs for better readability
* removed newlines as they are not working properly
* allow PROTOC_OPTIONS and EXPORT_MACRO in parallel for protobuf_generate
If `-Dprotobuf_USE_EXTERNAL_GTEST=ON` is passed to CMake, it will use an external Google Test copy (i.e. by calling `find_package(GTest REQUIRED)`) rather than the one provided as a submodule.
This makes sense for larger projects that might already include Google Test and want to use a more standard CMake approach.
Also updated build instructions with this information, and more idiomatic usage.
Co-authored-by: Adam Cozzette <acozzette@google.com>
Convenience feature: enable users to test via the familiar `ctest` command rather than making the `check` target.
They would be able to use the familiar CMake pattern:
```
cmake -S source/protobuf -B build/protobuf ...
cmake --build build/protobuf
ctest --test-dir build/protobuf
cmake --install build/protobuf
```
This is a follow-up to 9f447fc9d3da93da29b8301f1a8ca57b1ea812d7
This updates the CMake support to additionally symlink the soversion value
to the generated shared library when so generated. This aligns the
generated soversion with that traditionally used by the Makefile build
workflow and provides cross-compatibility irrespective of build approach
used.
The primary version of the non-symlink library retains the actual
(non-SO) project version for clarity and compatibility with
installations built using prior versions of CMake support. An example of
the net resulting symlink structures is shown below, where the most
important aspect is that the symlink matching the embedded SONAME is
present (libprotobuf.so.30 in the example case).
Makefile:
libprotobuf.so -> libprotobuf.so.30.0.0
libprotobuf.so.30 -> libprotobuf.so.30.0.0
libprotobuf.so.30.0.0
CMake:
libprotobuf.so -> libprotobuf.so.30
libprotobuf.so.30 -> libprotobuf.so.3.19.0.0
libprotobuf.so.3.19.0.0
Fixes: #8635
when using CMake >= 3.15, we use CMAKE_MSVC_RUNTIME_LIBRARY
to reproduce the /MT vs /MD when protobuf_MSVC_STATIC_RUNTIME
is TRUE or FALSE
MultiThreaded is for /MT
MultiThreadedDebug is for /MTd
MultiThreadedDLL is for /MD
MultiThreadedDebugDLL is for /MDd
This is based on @haberman's changes in #8257. Now that we're using
std::mutex we no longer need to check whether pthreads are available, so
this commit removes references to HAVE_PTHREAD. I left the autotools
build alone, though, since we are likely to drop support for it soon
anyway.
The `VERSION_GREATER_EQUAL` operator was introduced in CMake 3.7.0
(released in 2016). Use the long form of the check by splitting the
operation into two comparisons to support the older CMake.