[cmake-developers] [PATCH] FindProtobuf: fix wrong library list for Unix

Antonio Perez Barrero apbarrero at gmail.com
Mon Feb 8 11:47:21 EST 2016


Avoid looking for debug library unless configuring for MSVC.

Before this change the variable PROTOBUF_LIBRARIES under unix was
'optimized;/usr/lib/libprotobuf.so;debug;/usr/lib/libprotobuf.so'
---
 Modules/FindProtobuf.cmake | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 2f13b09..a07aa83 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -219,10 +219,12 @@ function(_protobuf_find_libraries name filename)
        PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release)
    mark_as_advanced(${name}_LIBRARY)
 
-   find_library(${name}_LIBRARY_DEBUG
-       NAMES ${filename}
-       PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug)
-   mark_as_advanced(${name}_LIBRARY_DEBUG)
+   if(MSVC)
+       find_library(${name}_LIBRARY_DEBUG
+           NAMES ${filename}
+           PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug)
+       mark_as_advanced(${name}_LIBRARY_DEBUG)
+   endif()
 
    if(NOT ${name}_LIBRARY_DEBUG)
       # There is no debug library
-- 
1.9.1



More information about the cmake-developers mailing list