>
> 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
> in several find modules.
>
> > Having the PROTOBUF_LIBRARIES variable 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.
>
Thanks for your explanantion, that makes sense. I had issues because I was
appending the value of PROTOBUF_LIBRARIES to a list and then removing
duplicates before calling `target_link_libraries(bar ${LIST})`. So when the
PROTOBUF_LIBRARIES values was
`optimized;/usr/lib/libprotobuf.so;debug;/usr/lib/libprotobuf.so` I was
missing the link flag for /usr/lib/libprotobuf.so in Debug builds. Skipping
the duplicates removal step solves my issue.
Anyway, the root cause is the `find_library` is finding the same library
for optimized and debug configuration. So, would a patch like this be
benefial?
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 2f13b09..35929a4 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -224,7 +224,7 @@ function(_protobuf_find_libraries name filename)
PATHS
${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug)
mark_as_advanced(${name}_LIBRARY_DEBUG)
- if(NOT ${name}_LIBRARY_DEBUG)
+ if((NOT ${name}_LIBRARY_DEBUG) OR (${name}_LIBRARY STREQUAL
${name}_LIBRARY_DEBUG))
# There is no debug library
set(${name}_LIBRARY_DEBUG ${${name}_LIBRARY} PARENT_SCOPE)
set(${name}_LIBRARIES ${${name}_LIBRARY} PARENT_SCOPE)
---
Thanks,
Antonio
--
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