diff --git a/cmake/functions.cmake b/cmake/functions.cmake index b41aa6f97..fdd0ba8d2 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -105,102 +105,6 @@ function(prepend variable prep) set(${variable} ${res} PARENT_SCOPE) endfunction() -# Wrapper around find_library to autodetect debug and -# release versions of a library. -# -# This is necessary when building on Windows in VS (ABI conflicts between MT and MTd). -# -# Note: only effects msvc so far -# Usage: find_cpp_library( [NOCACHE]) -# Arguments: -# VAR – Output variable -# LIB - the Library name -# Example: find_cpp_library(PROTOBUF_LIBRARIES protobuf) -# -function(find_cpp_library VAR LIB) - if(DEFINED HAS_FIND_LIBRARY_WRAPPER) - definition_find_cpp_library(tmp ${LIB}) - if(NOT tmp) - find_library(tmp ${LIB}) - endif() - else() - find_library(tmp ${LIB}) - endif() - - if (ARGN STREQUAL "NOCACHE") - set(${VAR} "${tmp}" PARENT_SCOPE) - else() - set(${VAR} "${tmp}" CACHE INTERNAL "") - endif() - - unset(tmp CACHE) -endfunction() - -# Search for multiple libraries with multiple possible names -# -# This is be useful, when a module requires multiple libs or -# when a lib can have multiple names. -# -# Wrapper around find_cpp_library, so libs with debug and -# release versions are supported, which in turn is a wrapper -# around find library, so you can omit /^lib/ and the usual -# suffixes (.dll/.so/.o/.obj/.a) -# -# USAGE: find_libs( lib1_names... -# [LIB libN_names... ]... NOCACHE) -# -# EXAMPLE: -# You are working on module `cuteness` module cuteness; -# cuteness depends on two libraries: libkittens.so and -# libdog.a; libdog.a might however also be called libpuppy.so. -# You could use the following command: -# -# find_libs(CUTENESS_LIBS kittens LIB dog puppy) -function(find_libs) - set(out "") - set(found "") - set(outvar "") - set(nocache "") - set(attempts "") - - ## READING ARGS - - foreach(arg ${ARGN}) - - if(${arg} STREQUAL "NOCACHE") - set(nocache true) - - elseif(${arg} STREQUAL "LIB") - if (NOT found AND NOT attempts STREQUAL "") - message(SEND_ERROR "Could not find a lib for ${attempts} !") - endif() - set(found "") - set(attempts "") - - elseif(NOT outvar) # First real arg: OUTVAR - set(outvar "${arg}") - - elseif(NOT found) # Real arg: lib name - find_cpp_library(lib "${arg}" NOCACHE) - if (lib) - set(found true) - list(APPEND out "${lib}") - else() - list(APPEND attempts "${arg}") - endif() - - endif() - endforeach() - - ## RETURN - - if (out AND nocache) - set(${outvar} ${out} PARENT_SCOPE) - elseif(out) - set(${outvar} ${out} CACHE INTERNAL "") - endif() -endfunction() - function(add_windows_manifest target) add_custom_command( TARGET ${target}