Commit Graph

80 Commits

Author SHA1 Message Date
Kitware Robot
1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Brad King
7afa58b15d Modules/Find*: Include FindPackageHandleStandardArgs normally
Since commit d74210a8bd (CMP0017: Remove support for OLD behavior,
2024-11-17) we can rely on CMP0017's NEW behavior unconditionally.
Calling `include(FindPackageHandleStandardArgs)` in a builtin module
will always get the builtin `FindPackageHandleStandardArgs`.
2025-01-30 08:53:12 -05:00
Nikita Nemkin
9890cfc4ec Help: More syntax highlighting for literal blocks
Covers almost all blocks containing actual code, except:

* Parsed-literal blocks can't be highlighted, including many command
  summaries and substitution-heavy docs like find_... commands.
  This is a Sphinx limitation.

* Code with errors, like CMP0049, DEPLOYMENT_ADDITIONAL_FILES,
  DEPLOYMENT_REMOTE_DIRECTORY, @PACKAGE_INIT@ substitution in the
  tutorial, bracket arguments/comments in cmake-language.7 and
  cmake-developer.7.

* FindQt4 module, which needs reformatting.
2025-01-29 16:48:53 -05:00
Peter Kokot
4e6a13f211 Use lower case style for commands
Where possible this syncs the CS for command names:

- check_c_source_compiles()
- check_cxx_compiler_flag()
- check_cxx_source_compiles()
- check_cxx_symbol_exists()
- check_include_file_cxx()
- check_include_file()
- check_include_files()
- check_library_exists()
- check_source_compiles()
- check_struct_has_member()
- check_symbol_exists()
- check_type_size()
- cmake_dependent_option()
- cmake_parse_arguments()
- feature_summary()
- file()
- find_package_handle_standard_args()
- if(), endif...
- install(FILES)
- list()
- message()
- pkg_check_modules()
- select_library_configurations()
- set_package_info()
- test_big_endian()
2025-01-28 13:51:46 -05:00
Brad King
bd176b430c Renumber post-3.31 development from 3.32 to 4.0
Issue: #26613
2025-01-16 09:18:21 -05:00
Jonathan Ringer
53717488ea FindProtobuf: Add PROTOC_EXE option to protobuf_generate
This option was added to protobuf's upstream cmake package.
2024-10-10 11:39:19 -04:00
Brad King
f4dc24b527 FindProtobuf: Clarify protobuf_generate options documentation 2024-10-10 11:17:07 -04:00
JiaRui Liu
4a1177246d FindProtobuf: Fail protobuf_generate early if protoc is missing 2024-10-08 08:33:35 +08:00
Xiong Nandi
1dc1d000a0 FindProtobuf: Fix IMPORT_DIRS handling and relative directory generation
Append ${CMAKE_CURRENT_SOURCE_DIR} to `_protobuf_include_path` last, since
protoc will search the path in order.

Besides, we have to figure out the output directory by iterating through the
include paths and checking for valid relative paths.
2024-09-11 12:56:28 -04:00
Juan Ramos
3cd64287fe Modules: Fix CMP0159 warnings in modules when tracing
Closes: #25829
2024-03-29 13:51:59 -07:00
André Apitzsch
d7f7bf08cd FindProtobuf: Fix protoc include path regression
This was accidentally broken by commit 31adc11030 (FindProtobuf: Add
PLUGIN_OPTIONS and PROTOC_OPTIONS to protobuf_generate, 2023-06-29,
v3.28.0-rc1~409^2~2).

Fixes: #25368
2023-10-27 11:41:28 -04:00
Brad King
08cdc91c09 Merge topic 'FindProtobuf-version-schemes'
6e90d79577 FindProtobuf: Fix new version number scheme

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8629
2023-07-14 11:03:10 -04:00
Jannik Beyerstedt
6e90d79577 FindProtobuf: Fix new version number scheme
Revise the changes from commit fc7dcc6a24 (FindProtobuf: Support new
version number scheme, 2023-06-19, v3.27.0-rc3~2^2).  Changing the
content of `Protobuf_VERSION` to exclude the major version of the library
might break code as it can't be used to detect breaking changes in the
library any more.

However, protoc v22 and up don't print the major version any more, so we
need to compare the against a truncated version number, too.
2023-07-14 09:34:13 -04:00
Brad King
619d850886 Merge topic 'findprotobuf-mingw'
e978b3b814 FindProtobuf: Fix linking to shared libraries on MinGW

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8609
2023-07-07 10:29:31 -04:00
مهدي شينون (Mehdi Chinoune)
e978b3b814 FindProtobuf: Fix linking to shared libraries on MinGW
Fixes: #25011
2023-07-05 08:25:01 -04:00
André Apitzsch
f784ef75a7 FindProtobuf: Add documentation for protobuf_generate()
Note, the argument `DESCRIPTORS` is not documented as upstream doesn't
provide this argument and code might break when switching to upstream
later.

Instead of the argument `DESCRIPTORS`
`PROTOC_OPTIONS "--descriptor_set_out=NAME.desc"` can be used.

Argument description has been copied from [1].

Fixes: #23037

[1] 8ec0295ad7/docs/cmake_protobuf_generate.md
2023-06-30 09:47:58 -04:00
André Apitzsch
cd3ff53c88
FindProtobuf: Add DEPENDENCIES to protobuf_generate
See upstream PR for details https://github.com/protocolbuffers/protobuf/pull/10014.
2023-06-30 09:10:18 +02:00
André Apitzsch
31adc11030
FindProtobuf: Add PLUGIN_OPTIONS and PROTOC_OPTIONS to protobuf_generate 2023-06-30 09:08:35 +02:00
Jannik Beyerstedt
fc7dcc6a24 FindProtobuf: Support new version number scheme
Protobuf changed it's version number scheme with version 21. The first number
(usually the major version) is not synchronized between compiler and library
version, but the second and third number are. See
https://protobuf.dev/news/2022-05-06/ for more details.

Fixes: #24847
2023-06-20 09:59:53 -04:00
Frank Lange
f2a4b879b1 FindProtobuf: Add PLUGIN parameter to protobuf_generate
This allows for example reusing the function for generating gRPC code by
specifying which grpc plugin to use.
2021-05-06 13:42:21 -04:00
Nikita Nemkin
8fea95319b Help: Add .. versionadded directives to module docs
Issue: #19715
2020-12-02 21:00:30 +05:00
Florian Franzen
2bb3c0a44b FindProtobuf: Support files with multiple extensions (#18329) 2020-11-06 15:40:54 +01:00
Brad King
ae41216878 FindProtobuf: Link to threads dependency only when Protobuf is found
Since commit 03454b0d0d (FindProtobuf: Add missing link dependencies on
threads, 2018-10-31, v3.13.0-rc3~10^2) we add the threads library to the
list of libraries needed for Protobuf.  Update the logic to do this only
when a real protobuf library is actually found.

Fixes: #21161
2020-09-22 08:49:22 -04:00
Sibi Siddharthan
667a229e8d FindProtobuf use NAMES_PER_DIR
Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
2020-07-02 00:41:17 +05:30
Ron Klein
c1de3d1b34 FindProtobuf: Fix typo in documentation
typo: "filess" ==> "files"
2020-06-10 15:01:37 -04:00
Diego Pino Garcia
db0b740fd8 FindProtobuf: Do not verify protoc version if it is not found 2019-12-16 11:43:47 -05:00
gnaggnoyil
3bbd85d5ff FindProtobuf: Fix usage of protobuf dynamic libraries on Windows
Define `PROTOBUF_USE_DLLS` on Windows when linking against dynamic
protobuf libraries so that we import symbols from them.

We use the condition `MSVC` to enable this because that is what
the upstream buildsystem uses.
2019-07-18 07:40:40 -04:00
Rolf Eike Beer
59a30f2acf FindProtobuf: libprotoc also needs C++11 2019-07-03 18:49:49 +02:00
Rolf Eike Beer
e28240ea1f FindProtobuf: C++11 support is required since version 3.6.0 2019-06-25 15:22:01 +02:00
Bob Weinand
9a324cbee0 Protobuf: Fix generated source path with PROTOBUF_GENERATE_CPP_APPEND_PATH OFF 2019-05-08 14:57:00 +02:00
Kyle Edwards
88b40744b5 CMakeParseArguments: Remove superfluous includes of CMakeParseArguments
Because cmake_parse_arguments() has been implemented as a native
command, there is no need to include(CMakeParseArguments) anymore.
Its inclusion has been removed from several CMake modules.

Tests/CMakeOnly/CMakeLists.txt has been changed to include the
*building* CMake's copy of CMakeParseArguments rather than the
*built* CMake's copy. This file included the *built* copy because
when this file was introduced, CMake could still be built with versions
that didn't supply cmake_parse_arguments(). Now, CMake requires 3.1 or
greater, where cmake_parse_arguments() existed but was still in the
form of a module, so we include it from the *building* CMake.
2018-12-13 19:51:01 -05:00
Brad King
133465a0e5 Merge topic 'FindProtobuf-threads'
03454b0d0d FindProtobuf: Add missing link dependencies on threads

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2551
2018-11-01 07:37:30 -04:00
Brad King
03454b0d0d FindProtobuf: Add missing link dependencies on threads
Protobuf headers have dependencies on threads.  On UNIX platforms this
requires linking to a threads library.  We've long done this in the
`Protobuf_LIBRARIES` result variable.  However, the imported targets
added by commit v3.9.0-rc1~81^2~2 (FindProtobuf: add targets,
2017-05-17) and commit v3.9.0-rc1~68^2 (FindProtobuf: Rename imported
targets to match upstream names, 2017-05-22) were missing a dependency
on threads.

Add the dependency to the imported targets, and to the variables
`Protobuf_LITE_LIBRARIES` and `Protobuf_PROTOC_LIBRARIES`.  While this
did not seem to matter in practice for a long time, protobuf 3.6 throws
exceptions in some cases when threads are missing.

Fixes: #18533
2018-10-31 10:24:01 -04:00
Kitware Robot
df4ed1e9ff Help: Convert remaining modules to block-style comments 2018-10-22 11:09:34 -04:00
André Apitzsch
71d99e156b Protobuf: restore previous output directory
The protobuf upstream implementation has a different default output
directory.  Restore our original output directory for compatibility.
2018-07-16 08:59:36 -04:00
André Apitzsch
2ae2d0bd3e Protobuf: restore 'DESCRIPTORS' support
This was not present in the upstream code.
2018-07-16 08:59:33 -04:00
André Apitzsch
1385b4b113 Protobuf: restore 'PROTOBUF_IMPORT_DIRS' check
This was not present in the upstream code.
2018-07-16 08:59:21 -04:00
André Apitzsch
1bcc0f3678 Protobuf: use upstream implementation to generate cpp and python files
Generate functions are taken from [1] and [2].  The license [3] is
already covered by our BSD-3 license for CMake and our inclusion of
"Google Inc" in `Copyright.txt`.

[1] https://github.com/google/protobuf/blob/93f6b67e/cmake/protobuf-config.cmake.in
[2] https://github.com/google/protobuf/blob/93f6b67e/cmake/protobuf-module.cmake.in
[3] https://github.com/google/protobuf/blob/93f6b67e/LICENSE
2018-07-16 08:57:08 -04:00
André Apitzsch
107fe8d5e4 FindProtobuf: fix documentation typo
Fix typo in documentation added by commit v3.10.0-rc1~18^2
(FindProtobuf: add flag to allow descriptor files to be generated,
2017-09-21).
2017-10-06 09:18:48 -04:00
Peter Mitrano
1299f4cc5e FindProtobuf: add flag to allow descriptor files to be generated
- The .desc files will be in the same folder as the generated .cc and .h files.
- Paths to generate .desc files are stored in a variable passed in
- This is only implemented for C++
- Remove legacy ARGS
- Add test that generates and uses C++ protobuf message
- Add test that checks that the generated .desc file can be instantiated
  with DynamicMessageFactory
- Add Help rst for new feature
2017-10-02 08:08:24 -04:00
Brad King
4e91be9532 FindProtobuf: Refactor custom command output listing
Reduce duplication by storing the custom command outputs in variables.
Also, since custom command outputs are automatically marked as generated
we do not need to do so explicitly.
2017-10-02 08:04:24 -04:00
André Apitzsch
c281acf807 FindProtobuf: add target for protoc 2017-07-12 13:48:22 -04:00
André Apitzsch
1ee2019239 FindProtobuf: add optional export declaration macro to generated cpp files 2017-05-26 11:35:03 -04:00
Brad King
a5ccddf057 FindProtobuf: Rename imported targets to match upstream names
Rename our recently added imported targets to match those provided by
the upstream's CMake-based build.  That way a project using
`find_package(Protobuf)` can get the same target names no matter how
protobuf is found.

Suggested-by: Konstantin Podsvirov <konstantin@podsvirov.pro>
2017-05-22 10:51:55 -04:00
André Apitzsch
f29635b667
FindProtobuf: add targets 2017-05-18 13:57:01 +02:00
Sébastien GALLOU
a3f71349de FindProtobuf: Add option to find static libraries on UNIX
Add a `Protobuf_USE_STATIC_LIBS` input variable to optionally restrict
searches to static library names.  This follows the approach of
`FindBoost`.
2017-02-06 16:12:39 -05:00
Adam Martin
d9190f3308 FindProtobuf: Search for debug library named with d suffix
Protobuf now provides a CMake-based build system that optionally adds a
suffix to the debug library name [1].  Update our `find_library` call to
consider names with the default value for this suffix, `d`.

[1] https://github.com/google/protobuf/blob/431cee60/cmake/libprotoc.cmake#L107
2016-10-10 15:44:21 -04:00
Martin Joly
2b9dad694a FindProtobuf: Fix protobuf_generate_*() to handle subdirs
The change in commit v3.7.0-rc1~513^2 (FindProtobuf: fix
protobuf_generate_*() to handle proto files in subdirs, 2016-06-09)
incorrectly adds subdirectories to the path of the generated files when
`*.proto` files are passed to `protobuf_generate_*` with subdirectories.
This behavior is not correct when `PROTOBUF_GENERATE_CPP_APPEND_PATH` is
True (default behavior) as `protoc` will generate output file in the
current build directory.
2016-10-07 09:50:52 -04:00
Brad King
86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Brad King
a85e2a89de Merge topic 'FindProtobuf-restore-PROTOBUF_IMPORT_DIRS'
5790d9b6 FindProtobuf: Restore support for PROTOBUF_IMPORT_DIRS
2016-08-03 09:20:50 -04:00