Commit f0165e88 authored by PRUVOST Florent's avatar PRUVOST Florent

find_pkgconfig_libraries_absolute_path macro is now factorized in a morse module file

parent d9521641
......@@ -335,44 +335,6 @@ if ( BLAS_DIR OR ( BLAS_INCDIR AND BLAS_LIBDIR) OR ENV_BLAS_DIR OR (ENV_BLAS_INC
set(BLAS_GIVEN_BY_USER "TRUE")
endif()
macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix)
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
elseif(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
set(${_prefix}_LIBRARIES_COPY "${${_prefix}_LIBRARIES}")
set(${_prefix}_LIBRARIES "")
foreach(_library ${${_prefix}_LIBRARIES_COPY})
get_filename_component(_library "${_library}" NAME_WE)
find_library(_library_path NAMES ${_library}
HINTS ${${_prefix}_LIBDIR} ${${_prefix}_LIBRARY_DIRS} ${_lib_env})
if (_library_path)
list(APPEND ${_prefix}_LIBRARIES ${_library_path})
else()
message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND")
endif()
unset(_library_path CACHE)
endforeach()
set(${_prefix}_STATIC_LIBRARIES_COPY "${${_prefix}_STATIC_LIBRARIES}")
set(${_prefix}_STATIC_LIBRARIES "")
foreach(_library ${${_prefix}_STATIC_LIBRARIES_COPY})
get_filename_component(_library "${_library}" NAME_WE)
find_library(_library_path NAMES ${_library}
HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env})
if (_library_path)
list(APPEND ${_prefix}_STATIC_LIBRARIES ${_library_path})
else()
message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND")
endif()
unset(_library_path CACHE)
endforeach()
endmacro()
# Optionally use pkg-config to detect include/library dirs (if pkg-config is available)
# -------------------------------------------------------------------------------------
include(FindPkgConfig)
......@@ -533,7 +495,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER )
HINTS ${_libdir})
mark_as_advanced(M_LIBRARY)
if(M_LIBRARY)
set(LM "-lm")
set(LM "${M_LIBRARY}")
else()
set(LM "")
endif()
......
......@@ -3,7 +3,7 @@
# @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation.
# All rights reserved.
# @copyright (c) 2012-2016 Inria. All rights reserved.
# @copyright (c) 2012-2018 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
......@@ -320,7 +320,7 @@ if(BLAS_FOUND)
find_library(M_LIBRARY NAMES m)
mark_as_advanced(M_LIBRARY)
if(M_LIBRARY)
set(LM "-lm")
set(LM "${M_LIBRARY}")
else()
set(LM "")
endif()
......@@ -365,44 +365,6 @@ if(BLAS_FOUND)
set(LAPACK_GIVEN_BY_USER "TRUE")
endif()
macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix)
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
elseif(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
set(${_prefix}_LIBRARIES_COPY "${${_prefix}_LIBRARIES}")
set(${_prefix}_LIBRARIES "")
foreach(_library ${${_prefix}_LIBRARIES_COPY})
get_filename_component(_library "${_library}" NAME_WE)
find_library(_library_path NAMES ${_library}
HINTS ${${_prefix}_LIBDIR} ${${_prefix}_LIBRARY_DIRS} ${_lib_env})
if (_library_path)
list(APPEND ${_prefix}_LIBRARIES ${_library_path})
else()
message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND")
endif()
unset(_library_path CACHE)
endforeach()
set(${_prefix}_STATIC_LIBRARIES_COPY "${${_prefix}_STATIC_LIBRARIES}")
set(${_prefix}_STATIC_LIBRARIES "")
foreach(_library ${${_prefix}_STATIC_LIBRARIES_COPY})
get_filename_component(_library "${_library}" NAME_WE)
find_library(_library_path NAMES ${_library}
HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env})
if (_library_path)
list(APPEND ${_prefix}_STATIC_LIBRARIES ${_library_path})
else()
message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND")
endif()
unset(_library_path CACHE)
endforeach()
endmacro()
# Optionally use pkg-config to detect include/library dirs (if pkg-config is available)
# -------------------------------------------------------------------------------------
include(FindPkgConfig)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment