[cmake-developers] [PATCH] FindProtobuf: fix wrong library list for Unix
Konstantin Podsvirov
konstantin at podsvirov.pro
Mon Feb 8 22:50:01 EST 2016
Wonderful project "protobuf" ("protobuf" with a small letter "f") starting with version 3.0 (which is around the corner - now beta 2), will be built with CMake on Windows, and will contain CONFIG scripts with a description of the exported package and an imported goal.
That's the name of the project:
https://github.com/google/protobuf/blob/master/cmake/CMakeLists.txt#L5
All targets will be installed in the standard paths, which optionally can be configured to your needs (use the GNUInstallDirs module):
https://github.com/google/protobuf/blob/master/cmake/install.cmake#L10
There is also the option to configure Postfix in a debug configuration (protobuf_DEBUG_POSTFIX - default "d"):
https://github.com/google/protobuf/blob/master/cmake/CMakeLists.txt#L26
So for protobuf >= 3.0 on Windows you can use
design:
find_package(protobuf CONFIG)
These new features were created with my participation. I tried to create a configuration compatible with the all of us known module. Here is a template script compatibility for the module:
https://github.com/google/protobuf/blob/master/cmake/protobuf-module.cmake.in
Unfortunately, for platforms other than Windows, use CMake to build protobuf not officially planned, but carried out private studies confirm the fact that cmake/CMakeLists workable on other platforms.
Thus the project "protobuf" already cmake/CMakeLists.txt and is open to modifications and development for the benefit of the CMake community.
While we will continue to work as follows:
find_package(Protobuf [MODULE])
But over time, I hope to do just so:
find_package(protobuf CONFIG)
All suggestions and comments as always are welcome.
And for publicity :-)
You can try pre-built protobuf me 3.0 for Windows (MSVC2013) from Dad's Project (installers "testing"):
http://dad.podsvirov.pro/house/installers
(sorry for possible mistakes in text)
09.02.2016, 00:39, "Brad King" <brad.king at kitware.com>:
> On 02/08/2016 04:24 PM, Antonio Pérez Barrero wrote:
>> Yes, it is possible, but currently it's not looking for the debug
>> library with a different name, just in a different path that is
>> unlikely to exist in a Unix system.
>
> The fact that a separate find_library is called for it and the result
> is stored in a separate (user-settable) cache entry means that it is
> possible to get two different values. This convention is well established
> find in several modules.
>
>> Having the variable PROTOBUF_LIBRARIES getting the afore mentioned
>> value messes up the client code using `find_package(Protobuf)` on Unix.
>
> The only supported use for PROTOBUF_LIBRARIES is to pass it to
> target_link_libraries, and that interprets the 'optimized' and 'debug'
> keywords. This is shown in the module documentation example:
>
> target_link_libraries(bar ${PROTOBUF_LIBRARIES})
>
> The documentation makes no other guarantees about the variable value.
>
> -Brad
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake-developers
Regards,
Konstantin Podsvirov
More information about the cmake-developers
mailing list