Skip to content

Instantly share code, notes, and snippets.

@handicraftsman
Created December 12, 2019 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save handicraftsman/87255754eb059b1bd9c53fca0d0cff3a to your computer and use it in GitHub Desktop.
Save handicraftsman/87255754eb059b1bd9c53fca0d0cff3a to your computer and use it in GitHub Desktop.
LibFinder.cmake
macro(_LIBFINDER_LIB variable lib)
find_library(${lib}-LIB ${lib})
if(${lib}-LIB-NOTFOUND)
message(FATAL "Unable to find library ${lib}")
endif()
message(STATUS "${lib} library at ${${lib}-LIB}")
list(APPEND ${variable} ${${lib}-LIB})
endmacro()
macro(LIBFINDER_LIBRARIES variable)
foreach(lib ${ARGN})
_LIBFINDER_LIB("${variable}" "${lib}")
endforeach()
endmacro()
macro(_LIBFINDER_DIR variable file)
find_path(${file}-FILE ${file})
if(${file}-FILE-NOTFOUND)
message(FATAL "Unable to find directory for file ${file}")
endif()
message(STATUS "${file} file at ${${file}-FILE} directory")
list(APPEND ${variable} ${${file}-FILE})
endmacro()
macro(LIBFINDER_DIRECTORIES variable)
foreach(file ${ARGN})
_LIBFINDER_DIR("${variable}" "${file}")
endforeach()
endmacro()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment