summaryrefslogtreecommitdiffstats
path: root/Modules/FindProtobuf.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/FindProtobuf.cmake')
-rw-r--r--Modules/FindProtobuf.cmake45
1 files changed, 23 insertions, 22 deletions
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 2f13b09..0875349 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -210,32 +210,33 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_PROTOBUF_ARCH_DIR x64/)
endif()
+include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+
# 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
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)
- else()
- # There IS a debug library
- set(${name}_LIBRARIES
- optimized ${${name}_LIBRARY}
- debug ${${name}_LIBRARY_DEBUG}
- PARENT_SCOPE
- )
- endif()
+ if(${name}_LIBRARIES)
+ # Use result recorded by a previous call.
+ return()
+ elseif(${name}_LIBRARY)
+ # Honor cache entry used by CMake 3.5 and lower.
+ set(${name}_LIBRARIES "${${name}_LIBRARY}" PARENT_SCOPE)
+ else()
+ 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 "${${name}_LIBRARY}" PARENT_SCOPE)
+ set(${name}_LIBRARIES "${${name}_LIBRARIES}" PARENT_SCOPE)
+ endif()
endfunction()
# Internal function: find threads library