[cmake-developers] patch for FindProtobuf.cmake

Brad King brad.king at kitware.com
Thu Jun 23 10:31:15 EDT 2016


On 06/22/2016 08:08 PM, Miroslav Drahos wrote:
> I believe I found a bug in FindProtobuf.cmake. Using set with two
> parameters will insert an unwanted semicolon, the list separator.
> The changes I made are like this (several occurrences):
> 
> -    set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
> +    set(_protobuf_include_path "-I${CMAKE_CURRENT_SOURCE_DIR}")

The ";" in the value of the _protobuf_include_path are just normal
list separators which will be used to divide the list when the variable
is later referenced as ${_protobuf_include_path} in add_custom_command
calls.  The difference that this patch makes is `-I foo` v. `-Ifoo` on
the resulting command lines.

> I also added a test for FindProtobuf.cmake, which is a new addition.
> The complete patch is attached. What I cannot figure out is how to
> run the test? When I configure cmake build, I don’t see an option
> to set the path to protobuf.

Thanks for writing a test!  The `CMake_TEST_Find...` options are all
undocumented options that have to be added explicitly to the cache
when configuring (e.g. -DCMake_TEST_FindProtobuf=1).  The problem is
that we don't know what packages are installed on a system such that
running a find module test for them will work.  Therefore we just
keep them off by default and enable the tests on nightly testing
machines where they are expected to work.  I'd like to find a better
solution but this is at least better than when we had no tests for
individual find modules at all.

Currently the patch makes the test get added as part of the build
of CMake itself.  Please see the other Tests/Find* directories for
how the tests should be laid out.

Thanks,
-Brad



More information about the cmake-developers mailing list