[cmake-developers] [PATCH] FindProtobuf: prevent redundant PROTOBUF_LIBRARIES
Antonio Perez Barrero
apbarrero at gmail.com
Thu Feb 11 03:24:27 EST 2016
Before this change, the variable PROTOBUF_LIBRARIES might get redundant
value for debug and optimized configurations, e.g.
'optimized;/usr/lib/libprotobuf.so;debug;/usr/lib/libprotobuf.so'
---
Modules/FindProtobuf.cmake | 39 +++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 2f13b09..02aca1c 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -213,28 +213,27 @@ endif()
# Internal function: search for normal library as well as a debug one
# if the debug one is specified also include debug/optimized keywords
# in *_LIBRARIES variable
+include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations)
+
function(_protobuf_find_libraries name filename)
- find_library(${name}_LIBRARY
- NAMES ${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(NOT ${name}_LIBRARY_DEBUG)
- # There is no debug library
- set(${name}_LIBRARY_DEBUG ${${name}_LIBRARY} PARENT_SCOPE)
- set(${name}_LIBRARIES ${${name}_LIBRARY} PARENT_SCOPE)
+ if(${name}_LIBRARY)
+ set(${name}_LIBRARIES "${${name}_LIBRARY}" PARENT_SCOPE)
else()
- # There IS a debug library
- set(${name}_LIBRARIES
- optimized ${${name}_LIBRARY}
- debug ${${name}_LIBRARY_DEBUG}
- PARENT_SCOPE
- )
+ find_library(${name}_LIBRARY_RELEASE
+ NAMES ${filename}
+ PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release)
+ mark_as_advanced(${name}_LIBRARY_RELEASE)
+
+ find_library(${name}_LIBRARY_DEBUG
+ NAMES ${filename}
+ PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug)
+ mark_as_advanced(${name}_LIBRARY_DEBUG)
+
+ select_library_configurations(${name})
+ set(${name}_LIBRARY_RELEASE ${${name}_LIBRARY_RELEASE} PARENT_SCOPE)
+ set(${name}_LIBRARY_DEBUG ${${name}_LIBRARY_DEBUG} PARENT_SCOPE)
+ set(${name}_LIBRARY ${${name}_LIBRARY} PARENT_SCOPE)
+ set(${name}_LIBRARIES ${${name}_LIBRARIES} PARENT_SCOPE)
endif()
endfunction()
--
1.9.1
More information about the cmake-developers
mailing list