diff --git a/modules/FindPkgconfigLibrariesAbsolutePath.cmake b/modules/FindPkgconfigLibrariesAbsolutePath.cmake
index 382f6872f38f215c847a57c337743195f00eb40f..88999e421e2ad3ca04a0d84b70834cf040a63d28 100644
--- a/modules/FindPkgconfigLibrariesAbsolutePath.cmake
+++ b/modules/FindPkgconfigLibrariesAbsolutePath.cmake
@@ -71,8 +71,17 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix)
       if (${_index} GREATER -1)
         get_filename_component(_library "${_library}" NAME_WE)
       endif()
+      # try static first
+      set (default_find_library_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
+      set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
       find_library(_library_path NAMES ${_library}
           HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env})
+      set (CMAKE_FIND_LIBRARY_SUFFIXES ${default_find_library_suffixes})
+      # if not found try dynamic
+      if (NOT _library_path)
+        find_library(_library_path NAMES ${_library}
+            HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env})
+      endif()
       if (_library_path)
           list(APPEND ${_prefix}_STATIC_LIBRARIES ${_library_path})
       else()
diff --git a/modules/find/FindBLAS.cmake b/modules/find/FindBLAS.cmake
index 653ba58751b42a8c0dd1d485a1fc23ae372044b9..c470e5a59bd404cdbe7534c92a2b99def2cc6a8c 100644
--- a/modules/find/FindBLAS.cmake
+++ b/modules/find/FindBLAS.cmake
@@ -18,12 +18,13 @@
 # This module sets the following variables:
 #  BLAS_FOUND - set to true if a library implementing the BLAS interface
 #    is found
-#  BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
+#  BLAS_LDFLAGS_OTHER - list of required linker flags (excluding -l
 #    and -L).
-#  BLAS_COMPILER_FLAGS - uncached list of required compiler flags (including -I).
-#  BLAS_LIBRARIES - uncached list of libraries (using full path name) to
+#  BLAS_CFLAGS_OTHER - list of required compiler flags (excluding -I).
+#  BLAS_INCLUDE_DIRS - include directories
+#  BLAS_LIBRARIES - list of libraries (using full path name) to
 #    link against to use BLAS
-#  BLAS95_LIBRARIES - uncached list of libraries (using full path name)
+#  BLAS95_LIBRARIES - list of libraries (using full path name)
 #    to link against to use BLAS95 interface
 #  BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface
 #    is found
@@ -294,7 +295,8 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
       list(APPEND ${LIBRARIES} "-Wl,--end-group")
     endif()
     set(CMAKE_REQUIRED_LIBRARIES "${_flags};${${LIBRARIES}};${_thread}")
-    set(CMAKE_REQUIRED_FLAGS "${BLAS_COMPILER_FLAGS}")
+    set(CMAKE_REQUIRED_INCLUDES "${BLAS_INCLUDE_DIRS}")
+    set(CMAKE_REQUIRED_FLAGS "${BLAS_CFLAGS_OTHER}")
     if (BLAS_VERBOSE)
       message("${Cyan}BLAS libs found for BLA_VENDOR ${BLA_VENDOR}."
         "Try to compile symbol ${_name} with following libraries:"
@@ -331,7 +333,7 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
 endmacro(Check_Fortran_Libraries)
 
 
-set(BLAS_LINKER_FLAGS)
+set(BLAS_LDFLAGS_OTHER)
 set(BLAS_LIBRARIES)
 set(BLAS95_LIBRARIES)
 if ($ENV{BLA_VENDOR} MATCHES ".+")
@@ -354,9 +356,27 @@ endif()
 # -------------------------------------------------------------------------------------
 include(FindPkgConfig)
 find_package(PkgConfig QUIET)
-if( PKG_CONFIG_EXECUTABLE AND NOT BLAS_GIVEN_BY_USER AND BLA_VENDOR STREQUAL "All")
+if( PKG_CONFIG_EXECUTABLE AND NOT BLAS_GIVEN_BY_USER )
 
-  pkg_search_module(BLAS blas)
+  if (BLA_STATIC)
+    set(MKL_STR_BLA_STATIC "static")
+  else()
+    set(MKL_STR_BLA_STATIC "dynamic")
+  endif()
+  # try different blas
+  if (BLA_VENDOR STREQUAL "Intel10_64lp")
+    pkg_search_module(BLAS mkl-${MKL_STR_BLA_STATIC}-lp64-iomp)
+  elseif(BLA_VENDOR STREQUAL "Intel10_64lp_seq")
+    pkg_search_module(BLAS mkl-${MKL_STR_BLA_STATIC}-lp64-seq)
+  elseif(BLA_VENDOR STREQUAL "Open")
+    pkg_search_module(BLAS openblas)
+  elseif(BLA_VENDOR STREQUAL "Generic")
+    pkg_search_module(BLAS blas)
+  else()
+    pkg_search_module(BLAS blas)
+    pkg_search_module(BLAS openblas)
+    pkg_search_module(BLAS mkl-${MKL_STR_BLA_STATIC}-lp64-seq)
+  endif()
 
   if (NOT BLAS_FIND_QUIETLY)
     if (BLAS_FOUND AND BLAS_LIBRARIES)
@@ -371,14 +391,6 @@ if( PKG_CONFIG_EXECUTABLE AND NOT BLAS_GIVEN_BY_USER AND BLA_VENDOR STREQUAL "Al
   if (BLAS_FOUND AND BLAS_LIBRARIES)
     set(BLAS_FOUND_WITH_PKGCONFIG "TRUE")
     find_pkgconfig_libraries_absolute_path(BLAS)
-    if (BLA_STATIC)
-      set(BLAS_LINKER_FLAGS "${BLAS_STATIC_LDFLAGS_OTHER}")
-      set(BLAS_COMPILER_FLAGS "${BLAS_STATIC_CFLAGS_OTHER}")
-      set(BLAS_LIBRARIES "${BLAS_STATIC_LIBRARIES}")
-    else()
-      set(BLAS_LINKER_FLAGS "${BLAS_LDFLAGS_OTHER}")
-      set(BLAS_COMPILER_FLAGS "${BLAS_CFLAGS_OTHER}")
-    endif()
   else()
     set(BLAS_FOUND_WITH_PKGCONFIG "FALSE")
   endif()
@@ -536,7 +548,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER )
             set(LGFORTRAN "{FORTRAN_ifcore_LIBRARY}")
           endif()
         endif()
-        set(BLAS_COMPILER_FLAGS "")
+        set(BLAS_CFLAGS_OTHER "")
         if (NOT BLA_VENDOR STREQUAL "Intel10_64lp_seq")
           if(BLAS_FIND_REQUIRED)
             find_package(OpenMP REQUIRED)
@@ -544,21 +556,18 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER )
             find_package(OpenMP)
           endif()
           if(OPENMP_C_FLAGS)
-            list(APPEND BLAS_COMPILER_FLAGS "${OPENMP_C_FLAGS}")
+            list(APPEND BLAS_CFLAGS_OTHER "${OPENMP_C_FLAGS}")
           endif()
         endif()
         if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
           if (BLA_VENDOR STREQUAL "Intel10_32")
-            list(APPEND BLAS_COMPILER_FLAGS "-m32")
+            list(APPEND BLAS_CFLAGS_OTHER "-m32")
           else()
-            list(APPEND BLAS_COMPILER_FLAGS "-m64")
+            list(APPEND BLAS_CFLAGS_OTHER "-m64")
           endif()
           if (NOT BLA_VENDOR STREQUAL "Intel10_64lp_seq")
             list(APPEND OMP_LIB "-ldl")
           endif()
-          if (ENV_MKLROOT)
-            list(APPEND BLAS_COMPILER_FLAGS "-I${ENV_MKLROOT}/include")
-          endif()
         endif()
 
         set(additional_flags "")
@@ -744,7 +753,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER )
               "${OMP_LIB};${CMAKE_THREAD_LIBS_INIT};${LM}"
               )
             if(_LIBRARIES)
-              set(BLAS_LINKER_FLAGS "${additional_flags}")
+              set(BLAS_LDFLAGS_OTHER "${additional_flags}")
             endif()
           endif()
         endforeach ()
@@ -990,7 +999,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER )
         ""
         )
       if(BLAS_LIBRARIES)
-        set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf")
+        set(BLAS_LDFLAGS_OTHER "-xlic_lib=sunperf")
       endif()
       if(NOT BLAS_FIND_QUIETLY)
         if(BLAS_LIBRARIES)
diff --git a/modules/find/FindBLASEXT.cmake b/modules/find/FindBLASEXT.cmake
index 0fff826bebb1974b5ab2d42ce9df7a927db72620..5842225eb3679e6f750886d37d7afd59b82517a6 100644
--- a/modules/find/FindBLASEXT.cmake
+++ b/modules/find/FindBLASEXT.cmake
@@ -18,20 +18,18 @@
 #
 # The following variables have been added to manage links with sequential or multithreaded
 # versions:
-#  BLAS_INCLUDE_DIRS       - BLAS include directories
-#  BLAS_LIBRARY_DIRS       - Link directories for BLAS libraries
-#  BLAS_SEQ_LIBRARIES      - BLAS component libraries to be linked (sequential)
-#  BLAS_SEQ_COMPILER_FLAGS - uncached list of required compiler flags (including -I for mkl headers).
-#  BLAS_SEQ_LINKER_FLAGS   - uncached list of required linker flags (excluding -l
-#    and -L)
-#  BLAS_PAR_LIBRARIES      - BLAS component libraries to be linked (multithreaded)
-#  BLAS_PAR_COMPILER_FLAGS - uncached list of required compiler flags (including -I for mkl headers)
-#  BLAS_PAR_LINKER_FLAGS   - uncached list of required linker flags (excluding -l
-#    and -L)
-#  BLASEXT_FOUND           - if a BLAS has been found
-#  BLASEXT_LIBRARIES       - Idem BLAS_LIBRARIES
-#  BLASEXT_INCLUDE_DIRS    - Idem BLAS_INCLUDE_DIRS
-#  BLASEXT_LIBRARY_DIRS    - Idem BLAS_LIBRARY_DIRS
+#  BLAS_INCLUDE_DIRS      - BLAS include directories
+#  BLAS_LIBRARY_DIRS      - Link directories for BLAS libraries
+#  BLAS_SEQ_LIBRARIES     - BLAS component libraries to be linked (sequential)
+#  BLAS_SEQ_CFLAGS_OTHER  - compiler flags without headers paths
+#  BLAS_SEQ_LDFLAGS_OTHER - linker flags without libraries
+#  BLAS_PAR_LIBRARIES     - BLAS component libraries to be linked (multithreaded)
+#  BLAS_PAR_CFLAGS_OTHER  - compiler flags without headers paths
+#  BLAS_PAR_LDFLAGS_OTHER - linker flags without libraries
+#  BLASEXT_FOUND          - if a BLAS has been found
+#  BLASEXT_LIBRARIES      - Idem BLAS_LIBRARIES
+#  BLASEXT_INCLUDE_DIRS   - Idem BLAS_INCLUDE_DIRS
+#  BLASEXT_LIBRARY_DIRS   - Idem BLAS_LIBRARY_DIRS
 
 #=============================================================================
 # Copyright 2012-2013 Inria
@@ -90,11 +88,9 @@ if(NOT BLASEXT_FIND_QUIETLY)
     "\n   ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic")
 endif()
 
-if (NOT BLAS_FOUND)
-  # First blas detection in order to decide if we should look for a
-  # multitheaded version
-  find_package_blas(0)
-endif ()
+# First blas detection in order to decide if we should look for a
+# multitheaded version
+find_package_blas(0)
 
 # detect the cases where SEQ and PAR libs are handled
 if(BLA_VENDOR STREQUAL "All" AND
@@ -206,11 +202,11 @@ if(BLA_VENDOR MATCHES "Intel*")
     find_package_blas(0)
     if(BLAS_FOUND)
       set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}")
-      if (BLAS_COMPILER_FLAGS)
-        set (BLAS_SEQ_COMPILER_FLAGS "${BLAS_COMPILER_FLAGS}")
+      if (BLAS_CFLAGS_OTHER)
+        set (BLAS_SEQ_CFLAGS_OTHER "${BLAS_CFLAGS_OTHER}")
       endif()
-      if (BLAS_LINKER_FLAGS)
-        set (BLAS_SEQ_LINKER_FLAGS "${BLAS_LINKER_FLAGS}")
+      if (BLAS_LDFLAGS_OTHER)
+        set (BLAS_SEQ_LDFLAGS_OTHER "${BLAS_LDFLAGS_OTHER}")
       endif()
     else()
       set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}")
@@ -224,11 +220,11 @@ if(BLA_VENDOR MATCHES "Intel*")
     find_package_blas(0)
     if(BLAS_FOUND)
       set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}")
-      if (BLAS_COMPILER_FLAGS)
-        set (BLAS_PAR_COMPILER_FLAGS "${BLAS_COMPILER_FLAGS}")
+      if (BLAS_CFLAGS_OTHER)
+        set (BLAS_PAR_CFLAGS_OTHER "${BLAS_CFLAGS_OTHER}")
       endif()
-      if (BLAS_LINKER_FLAGS)
-        set (BLAS_PAR_LINKER_FLAGS "${BLAS_LINKER_FLAGS}")
+      if (BLAS_LDFLAGS_OTHER)
+        set (BLAS_PAR_LDFLAGS_OTHER "${BLAS_LDFLAGS_OTHER}")
       endif()
     else()
       set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}")
@@ -301,8 +297,8 @@ endif()
 # Reset pure BLAS cmake variables to the sequential case (arbitrary default)
 if(BLAS_SEQ_LIBRARIES)
   set(BLAS_LIBRARIES "${BLAS_SEQ_LIBRARIES}")
-  set(BLAS_COMPILER_FLAGS "${BLAS_SEQ_COMPILER_FLAGS}")
-  set(BLAS_LINKER_FLAGS "${BLAS_SEQ_LINKER_FLAGS}")
+  set(BLAS_CFLAGS_OTHER "${BLAS_SEQ_CFLAGS_OTHER}")
+  set(BLAS_LDFLAGS_OTHER "${BLAS_SEQ_LDFLAGS_OTHER}")
 endif()
 
 # extract libs paths if not given by find_package(BLAS)
diff --git a/modules/find/FindCBLAS.cmake b/modules/find/FindCBLAS.cmake
index 603bbb56eb6e19cebbbbe388cd4f95ddc7c2aafb..9dc87378f2f6f15e262bb0e3df7f015a575d0eb8 100644
--- a/modules/find/FindCBLAS.cmake
+++ b/modules/find/FindCBLAS.cmake
@@ -20,14 +20,18 @@
 #
 # This module finds headers and cblas library.
 # Results are reported in variables:
-#  CBLAS_FOUND            - True if headers and requested libraries were found
-#  CBLAS_INCLUDE_DIRS     - cblas include directories
-#  CBLAS_LIBRARY_DIRS     - Link directories for cblas libraries
-#  CBLAS_LIBRARIES        - cblas component libraries to be linked
-#  CBLAS_INCLUDE_DIRS_DEP - cblas + dependencies include directories
-#  CBLAS_LIBRARY_DIRS_DEP - cblas + dependencies link directories
-#  CBLAS_LIBRARIES_DEP    - cblas libraries + dependencies
-#  CBLAS_HAS_ZGEMM3M      - True if cblas contains zgemm3m fast complex mat-mat product
+#  CBLAS_FOUND             - True if headers and requested libraries were found
+#  CBLAS_CFLAGS_OTHER      - cblas compiler flags without headers paths
+#  CBLAS_LDFLAGS_OTHER     - cblas linker flags without libraries
+#  CBLAS_INCLUDE_DIRS      - cblas include directories
+#  CBLAS_LIBRARY_DIRS      - cblas link directories
+#  CBLAS_LIBRARIES         - cblas libraries to be linked (absolute path)
+#  CBLAS_CFLAGS_OTHER_DEP  - cblas + dependencies compiler flags without headers paths
+#  CBLAS_LDFLAGS_OTHER_DEP - cblas + dependencies linker flags without libraries
+#  CBLAS_INCLUDE_DIRS_DEP  - cblas + dependencies include directories
+#  CBLAS_LIBRARY_DIRS_DEP  - cblas + dependencies link directories
+#  CBLAS_LIBRARIES_DEP     - cblas + dependencies libraries
+#  CBLAS_HAS_ZGEMM3M       - True if cblas contains zgemm3m fast complex mat-mat product
 #
 #  CBLAS_FOUND_WITH_PKGCONFIG - True if found with pkg-config
 #  if found with pkg-config the following variables are set
@@ -98,12 +102,10 @@ endif()
 
 
 # CBLAS depends on BLAS anyway, try to find it
-if (NOT BLAS_FOUND)
-  if(CBLAS_FIND_REQUIRED)
-    find_package(BLASEXT REQUIRED)
-  else()
-    find_package(BLASEXT)
-  endif()
+if(CBLAS_FIND_REQUIRED)
+  find_package(BLAS REQUIRED)
+else()
+  find_package(BLAS)
 endif()
 
 
@@ -114,8 +116,9 @@ if (BLAS_FOUND)
     # check if a cblas function exists in the BLAS lib
     # this can be the case with libs such as MKL, ACML
     include(CheckFunctionExists)
-    set(CMAKE_REQUIRED_LIBRARIES "${BLAS_LINKER_FLAGS};${BLAS_LIBRARIES}")
-    set(CMAKE_REQUIRED_FLAGS "${BLAS_COMPILER_FLAGS}")
+    set(CMAKE_REQUIRED_LIBRARIES "${BLAS_LDFLAGS_OTHER};${BLAS_LIBRARIES}")
+    set(CMAKE_REQUIRED_FLAGS "${BLAS_CFLAGS_OTHER}")
+    set(CMAKE_REQUIRED_INCLUDES "${BLAS_INCLUDE_DIRS}")
     unset(CBLAS_WORKS CACHE)
     check_function_exists(cblas_dscal CBLAS_WORKS)
     check_function_exists(cblas_zgemm3m CBLAS_ZGEMM3M_FOUND)
@@ -135,15 +138,9 @@ if (BLAS_FOUND)
       endif()
       # test succeeds: CBLAS is in BLAS
       set(CBLAS_LIBRARIES "${BLAS_LIBRARIES}")
-      set(CBLAS_LIBRARIES_DEP "${BLAS_LIBRARIES}")
-      if (BLAS_LIBRARY_DIRS)
-        set(CBLAS_LIBRARY_DIRS "${BLAS_LIBRARY_DIRS}")
-      endif()
-      if(BLAS_INCLUDE_DIRS)
-        set(CBLAS_INCLUDE_DIRS "${BLAS_INCLUDE_DIRS}")
-        set(CBLAS_INCLUDE_DIRS_DEP "${BLAS_INCLUDE_DIRS_DEP}")
-      endif()
+
     endif()
+
   endif (NOT CBLAS_STANDALONE)
 
   # test fails with blas: try to find CBLAS lib exterior to BLAS
@@ -166,7 +163,25 @@ if (BLAS_FOUND)
     find_package(PkgConfig QUIET)
     if( PKG_CONFIG_EXECUTABLE AND NOT CBLAS_GIVEN_BY_USER)
 
-      pkg_search_module(CBLAS cblas)
+      if (BLA_STATIC)
+        set(MKL_STR_BLA_STATIC "static")
+      else()
+        set(MKL_STR_BLA_STATIC "dynamic")
+      endif()
+      # try different blas
+      if (BLA_VENDOR STREQUAL "Intel10_64lp")
+        pkg_search_module(CBLAS mkl-${MKL_STR_BLA_STATIC}-lp64-iomp)
+      elseif(BLA_VENDOR STREQUAL "Intel10_64lp_seq")
+        pkg_search_module(CBLAS mkl-${MKL_STR_BLA_STATIC}-lp64-seq)
+      elseif(BLA_VENDOR STREQUAL "Open")
+        pkg_search_module(CBLAS openblas)
+      elseif(BLA_VENDOR STREQUAL "Generic")
+        pkg_search_module(CBLAS cblas)
+      else()
+        pkg_search_module(CBLAS cblas)
+        pkg_search_module(CBLAS openblas)
+        pkg_search_module(CBLAS mkl-${MKL_STR_BLA_STATIC}-lp64-seq)
+      endif()
 
       if (NOT CBLAS_FIND_QUIETLY)
         if (CBLAS_FOUND AND CBLAS_LIBRARIES)
@@ -336,6 +351,7 @@ if (BLAS_FOUND)
   if(CBLAS_LIBRARIES)
 
     set(REQUIRED_INCDIRS)
+    set(REQUIRED_FLAGS)
     set(REQUIRED_LDFLAGS)
     set(REQUIRED_LIBDIRS)
     set(REQUIRED_LIBS)
@@ -345,10 +361,10 @@ if (BLAS_FOUND)
       set(REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}")
     endif()
     if (CBLAS_CFLAGS_OTHER)
-      list(APPEND REQUIRED_FLAGS "${CBLAS_CFLAGS_OTHER}")
+      set(REQUIRED_FLAGS "${CBLAS_CFLAGS_OTHER}")
     endif()
     if (CBLAS_LDFLAGS_OTHER)
-      list(APPEND REQUIRED_LDFLAGS "${CBLAS_LDFLAGS_OTHER}")
+      set(REQUIRED_LDFLAGS "${CBLAS_LDFLAGS_OTHER}")
     endif()
     if (CBLAS_LIBRARY_DIRS)
       set(REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}")
@@ -358,11 +374,11 @@ if (BLAS_FOUND)
     if (BLAS_INCLUDE_DIRS)
       list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}")
     endif()
-    if (BLAS_COMPILER_FLAGS)
-      list(APPEND REQUIRED_FLAGS "${BLAS_COMPILER_FLAGS}")
+    if (BLAS_CFLAGS_OTHER)
+      list(APPEND REQUIRED_FLAGS "${BLAS_CFLAGS_OTHER}")
     endif()
-    if (BLAS_LINKER_FLAGS)
-      list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
+    if (BLAS_LDFLAGS_OTHER)
+      list(APPEND REQUIRED_LDFLAGS "${BLAS_LDFLAGS_OTHER}")
     endif()
     if (BLAS_LIBRARY_DIRS)
       list(APPEND REQUIRED_LIBDIRS "${BLAS_LIBRARY_DIRS}")
@@ -371,12 +387,22 @@ if (BLAS_FOUND)
 
     # set required libraries for link
     set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+    if (REQUIRED_FLAGS)
+      set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+      set(REQUIRED_FLAGS)
+      set(REQUIRED_DEFINITIONS)
+      foreach(_flag ${REQUIRED_FLAGS_COPY})
+        if (_flag MATCHES "^-D")
+         list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+        endif()
+        string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+        list(APPEND REQUIRED_FLAGS "${_flag}")
+      endforeach()
+    endif()
+    set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
     set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
     set(CMAKE_REQUIRED_LIBRARIES)
     list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-    foreach(lib_dir ${REQUIRED_LIBDIRS})
-      list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-    endforeach()
     list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
     string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -399,13 +425,17 @@ if (BLAS_FOUND)
       set(CBLAS_LIBRARIES_DEP "${REQUIRED_LIBS}")
       set(CBLAS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
       set(CBLAS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
+      set(CBLAS_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+      set(CBLAS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
       list(REMOVE_DUPLICATES CBLAS_LIBRARY_DIRS_DEP)
-      list(REMOVE_DUPLICATES CBLAS_INCLUDE_DIRS_DEP)
+      list(REMOVE_DUPLICATES CBLAS_CFLAGS_OTHER_DEP)
+      list(REMOVE_DUPLICATES CBLAS_LDFLAGS_OTHER_DEP)
     else()
       if(NOT CBLAS_FIND_QUIETLY)
         message(STATUS "Looking for cblas : test of cblas_dscal with cblas and blas libraries fails")
         message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
         message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+        message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
         message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
       endif()
     endif()
diff --git a/modules/find/FindCHAMELEON.cmake b/modules/find/FindCHAMELEON.cmake
index d30c9c7eb92e034d99ff34575c89428d5aaf0cbd..018f2ccf7358a0d248c06c3b4fc50dba2cbe4075 100644
--- a/modules/find/FindCHAMELEON.cmake
+++ b/modules/find/FindCHAMELEON.cmake
@@ -30,19 +30,22 @@
 #   - STARPU (default): to activate detection of Chameleon linked with StarPU
 #   - QUARK (STARPU will be deactivated): to activate detection of Chameleon linked with QUARK
 #   - CUDA (comes with cuBLAS): to activate detection of Chameleon linked with CUDA
-#   - MAGMA: to activate detection of Chameleon linked with MAGMA
 #   - MPI: to activate detection of Chameleon linked with MPI
 #   - FXT: to activate detection of Chameleon linked with StarPU+FXT
 #
 # This module finds headers and chameleon library.
 # Results are reported in variables:
-#  CHAMELEON_FOUND            - True if headers and requested libraries were found
-#  CHAMELEON_LINKER_FLAGS     - list of required linker flags (excluding -l and -L)
-#  CHAMELEON_INCLUDE_DIRS     - chameleon include directories
-#  CHAMELEON_LIBRARY_DIRS     - Link directories for chameleon libraries
-#  CHAMELEON_INCLUDE_DIRS_DEP - chameleon + dependencies include directories
-#  CHAMELEON_LIBRARY_DIRS_DEP - chameleon + dependencies link directories
-#  CHAMELEON_LIBRARIES_DEP    - chameleon libraries + dependencies
+#  CHAMELEON_FOUND             - True if headers and requested libraries were found
+#  CHAMELEON_CFLAGS_OTHER      - chameleon compiler flags without headers paths
+#  CHAMELEON_LDFLAGS_OTHER     - chameleon linker flags without libraries
+#  CHAMELEON_INCLUDE_DIRS      - chameleon include directories
+#  CHAMELEON_LIBRARY_DIRS      - chameleon link directories
+#  CHAMELEON_LIBRARIES         - chameleon libraries to be linked (absolute path)
+#  CHAMELEON_CFLAGS_OTHER_DEP  - chameleon + dependencies compiler flags without headers paths
+#  CHAMELEON_LDFLAGS_OTHER_DEP - chameleon + dependencies linker flags without libraries
+#  CHAMELEON_INCLUDE_DIRS_DEP  - chameleon + dependencies include directories
+#  CHAMELEON_LIBRARY_DIRS_DEP  - chameleon + dependencies link directories
+#  CHAMELEON_LIBRARIES_DEP     - chameleon + dependencies libraries
 #
 #  CHAMELEON_FOUND_WITH_PKGCONFIG - True if found with pkg-config
 #  if found with pkg-config the following variables are set
@@ -95,7 +98,6 @@ endif()
 set(CHAMELEON_LOOK_FOR_STARPU ON)
 set(CHAMELEON_LOOK_FOR_QUARK OFF)
 set(CHAMELEON_LOOK_FOR_CUDA OFF)
-set(CHAMELEON_LOOK_FOR_MAGMA OFF)
 set(CHAMELEON_LOOK_FOR_MPI OFF)
 set(CHAMELEON_LOOK_FOR_FXT OFF)
 
@@ -115,10 +117,6 @@ if( CHAMELEON_FIND_COMPONENTS )
       # means we look for Chameleon with CUDA
       set(CHAMELEON_LOOK_FOR_CUDA ON)
     endif()
-    if (${component} STREQUAL "MAGMA")
-      # means we look for Chameleon with MAGMA
-      set(CHAMELEON_LOOK_FOR_MAGMA ON)
-    endif()
     if (${component} STREQUAL "MPI")
       # means we look for Chameleon with MPI
       set(CHAMELEON_LOOK_FOR_MPI ON)
@@ -308,19 +306,6 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN
     endif()
   endif()
 
-  # CHAMELEON may depend on MAGMA gpu kernels
-  # call our cmake module to test (in cmake_modules)
-  # change this call position if not appropriated
-  #-------------------------------------------------
-  if( CUDA_FOUND AND CHAMELEON_LOOK_FOR_MAGMA )
-    set(CHAMELEON_MAGMA_VERSION "1.4" CACHE STRING "oldest MAGMA version desired")
-    if (CHAMELEON_FIND_REQUIRED AND CHAMELEON_FIND_REQUIRED_MAGMA)
-      find_package(MAGMA ${CHAMELEON_MAGMA_VERSION} REQUIRED)
-    else()
-      find_package(MAGMA ${CHAMELEON_MAGMA_VERSION})
-    endif()
-  endif()
-
   # CHAMELEON depends on MPI
   #-------------------------
   if( NOT MPI_FOUND AND CHAMELEON_LOOK_FOR_MPI )
@@ -496,6 +481,9 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN
     list(APPEND CHAMELEON_libs_to_find "chameleon_quark")
   endif()
   list(APPEND CHAMELEON_libs_to_find "coreblas")
+  if (CHAMELEON_LOOK_FOR_CUDA)
+    list(APPEND CHAMELEON_libs_to_find "cudablas")
+  endif()
 
   # call cmake macro to find the lib path
   if(CHAMELEON_LIBDIR)
@@ -549,8 +537,9 @@ endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_F
 # check a function to validate the find
 if(CHAMELEON_LIBRARIES)
 
-  set(REQUIRED_LDFLAGS)
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -574,42 +563,36 @@ if(CHAMELEON_LIBRARIES)
   if (STARPU_FOUND AND CHAMELEON_LOOK_FOR_STARPU)
     if (STARPU_INCLUDE_DIRS_DEP)
       list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS_DEP}")
-    elseif (STARPU_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}")
+    endif()
+    if (STARPU_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${STARPU_CFLAGS_OTHER_DEP}")
+    endif()
+    if (STARPU_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${STARPU_LDFLAGS_OTHER_DEP}")
     endif()
     if(STARPU_LIBRARY_DIRS_DEP)
       list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS_DEP}")
-    elseif(STARPU_LIBRARY_DIRS)
-      list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS}")
     endif()
     if (STARPU_LIBRARIES_DEP)
       list(APPEND REQUIRED_LIBS "${STARPU_LIBRARIES_DEP}")
-    elseif (STARPU_LIBRARIES)
-      foreach(lib ${STARPU_LIBRARIES})
-        if (EXISTS ${lib} OR ${lib} MATCHES "^-")
-          list(APPEND REQUIRED_LIBS "${lib}")
-        else()
-          list(APPEND REQUIRED_LIBS "-l${lib}")
-        endif()
-      endforeach()
     endif()
   endif()
   # QUARK
   if (QUARK_FOUND AND CHAMELEON_LOOK_FOR_QUARK)
     if (QUARK_INCLUDE_DIRS_DEP)
       list(APPEND REQUIRED_INCDIRS "${QUARK_INCLUDE_DIRS_DEP}")
-    elseif(QUARK_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${QUARK_INCLUDE_DIRS}")
+    endif()
+    if (QUARK_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${QUARK_CFLAGS_OTHER_DEP}")
+    endif()
+    if (QUARK_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${QUARK_LDFLAGS_OTHER_DEP}")
     endif()
     if(QUARK_LIBRARY_DIRS_DEP)
       list(APPEND REQUIRED_LIBDIRS "${QUARK_LIBRARY_DIRS_DEP}")
-    elseif(QUARK_LIBRARY_DIRS)
-      list(APPEND REQUIRED_LIBDIRS "${QUARK_LIBRARY_DIRS}")
     endif()
     if (QUARK_LIBRARY_DIRS_DEP)
       list(APPEND REQUIRED_LIBS "${QUARK_LIBRARIES_DEP}")
-    elseif (QUARK_LIBRARY_DIRS_DEP)
-      list(APPEND REQUIRED_LIBS "${QUARK_LIBRARIES}")
     endif()
   endif()
   # CUDA
@@ -624,30 +607,6 @@ if(CHAMELEON_LIBRARIES)
     endforeach()
     list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}")
   endif()
-  # MAGMA
-  if (MAGMA_FOUND AND CHAMELEON_LOOK_FOR_MAGMA)
-    if (MAGMA_INCLUDE_DIRS_DEP)
-      list(APPEND REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS_DEP}")
-    elseif(MAGMA_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${MAGMA_INCLUDE_DIRS}")
-    endif()
-    if (MAGMA_LIBRARY_DIRS_DEP)
-      list(APPEND REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS_DEP}")
-    elseif(MAGMA_LIBRARY_DIRS)
-      list(APPEND REQUIRED_LIBDIRS "${MAGMA_LIBRARY_DIRS}")
-    endif()
-    if (MAGMA_LIBRARIES_DEP)
-      list(APPEND REQUIRED_LIBS "${MAGMA_LIBRARIES_DEP}")
-    elseif(MAGMA_LIBRARIES)
-      foreach(lib ${MAGMA_LIBRARIES})
-        if (EXISTS ${lib} OR ${lib} MATCHES "^-")
-          list(APPEND REQUIRED_LIBS "${lib}")
-        else()
-          list(APPEND REQUIRED_LIBS "-l${lib}")
-        endif()
-      endforeach()
-    endif()
-  endif()
   # MPI
   if (MPI_FOUND AND CHAMELEON_LOOK_FOR_MPI)
     if (MPI_C_INCLUDE_PATH)
@@ -666,80 +625,69 @@ if(CHAMELEON_LIBRARIES)
     if (HWLOC_INCLUDE_DIRS)
       list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}")
     endif()
-    foreach(libdir ${HWLOC_LIBRARY_DIRS})
-      if (libdir)
-        list(APPEND REQUIRED_LIBDIRS "${libdir}")
-      endif()
-    endforeach()
-    foreach(lib ${HWLOC_LIBRARIES})
-      if (EXISTS ${lib} OR ${lib} MATCHES "^-")
-        list(APPEND REQUIRED_LIBS "${lib}")
-      else()
-        list(APPEND REQUIRED_LIBS "-l${lib}")
-      endif()
-    endforeach()
+    if (HWLOC_CFLAGS_OTHER)
+      list(APPEND REQUIRED_FLAGS "${HWLOC_CFLAGS_OTHER}")
+    endif()
+    if (HWLOC_LDFLAGS_OTHER)
+      list(APPEND REQUIRED_LDFLAGS "${HWLOC_LDFLAGS_OTHER}")
+    endif()
+    if (HWLOC_LIBRARY_DIRS)
+      list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}")
+    endif()
+    list(APPEND REQUIRED_LIBS "${HWLOC_LIBRARIES}")
   endif()
   # TMG
   if (TMG_FOUND)
     if (TMG_INCLUDE_DIRS_DEP)
       list(APPEND REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS_DEP}")
-    elseif (TMG_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS}")
+    endif()
+    if (TMG_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${TMG_CFLAGS_OTHER_DEP}")
+    endif()
+    if (TMG_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${TMG_LDFLAGS_OTHER_DEP}")
     endif()
     if(TMG_LIBRARY_DIRS_DEP)
       list(APPEND REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS_DEP}")
-    elseif(TMG_LIBRARY_DIRS)
-      list(APPEND REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS}")
     endif()
     if (TMG_LIBRARIES_DEP)
       list(APPEND REQUIRED_LIBS "${TMG_LIBRARIES_DEP}")
-    elseif(TMG_LIBRARIES)
-      list(APPEND REQUIRED_LIBS "${TMG_LIBRARIES}")
-    endif()
-    if (TMG_LINKER_FLAGS)
-      list(APPEND REQUIRED_LDFLAGS "${TMG_LINKER_FLAGS}")
     endif()
   endif()
   # LAPACKE
   if (LAPACKE_FOUND)
     if (LAPACKE_INCLUDE_DIRS_DEP)
       list(APPEND REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS_DEP}")
-    elseif (LAPACKE_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS}")
+    endif()
+    if (LAPACKE_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${LAPACKE_CFLAGS_OTHER_DEP}")
+    endif()
+    if (LAPACKE_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${LAPACKE_LDFLAGS_OTHER_DEP}")
     endif()
     if(LAPACKE_LIBRARY_DIRS_DEP)
       list(APPEND REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS_DEP}")
-    elseif(LAPACKE_LIBRARY_DIRS)
-      list(APPEND REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS}")
     endif()
     if (LAPACKE_LIBRARIES_DEP)
       list(APPEND REQUIRED_LIBS "${LAPACKE_LIBRARIES_DEP}")
-    elseif(LAPACKE_LIBRARIES)
-      list(APPEND REQUIRED_LIBS "${LAPACKE_LIBRARIES}")
-    endif()
-    if (LAPACK_LINKER_FLAGS)
-      list(APPEND REQUIRED_LDFLAGS "${LAPACK_LINKER_FLAGS}")
     endif()
   endif()
   # CBLAS
   if (CBLAS_FOUND)
     if (CBLAS_INCLUDE_DIRS_DEP)
       list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS_DEP}")
-    elseif (CBLAS_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}")
+    endif()
+    if (CBLAS_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${CBLAS_CFLAGS_OTHER_DEP}")
+    endif()
+    if (CBLAS_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${CBLAS_LDFLAGS_OTHER_DEP}")
     endif()
     if(CBLAS_LIBRARY_DIRS_DEP)
       list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS_DEP}")
-    elseif(CBLAS_LIBRARY_DIRS)
-      list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}")
     endif()
     if (CBLAS_LIBRARIES_DEP)
       list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES_DEP}")
-    elseif(CBLAS_LIBRARIES)
-      list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES}")
-    endif()
-    if (BLAS_LINKER_FLAGS)
-      list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
     endif()
   endif()
   # EXTRA LIBS such that pthread, m, rt
@@ -747,12 +695,22 @@ if(CHAMELEON_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
   set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -767,18 +725,20 @@ if(CHAMELEON_LIBRARIES)
     set(CHAMELEON_LIBRARIES_DEP "${REQUIRED_LIBS}")
     set(CHAMELEON_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
     set(CHAMELEON_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
-    set(CHAMELEON_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
+    set(CHAMELEON_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(CHAMELEON_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
     list(REMOVE_DUPLICATES CHAMELEON_LIBRARY_DIRS_DEP)
-    list(REMOVE_DUPLICATES CHAMELEON_INCLUDE_DIRS_DEP)
-    list(REMOVE_DUPLICATES CHAMELEON_LINKER_FLAGS)
+    list(REMOVE_DUPLICATES CHAMELEON_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES CHAMELEON_LDFLAGS_OTHER_DEP)
   else()
     if(NOT CHAMELEON_FIND_QUIETLY)
       message(STATUS "Looking for chameleon : test of MORSE_Init fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
       message(STATUS "Maybe CHAMELEON is linked with specific libraries. "
-        "Have you tried with COMPONENTS (STARPU/QUARK, CUDA, MAGMA, MPI, FXT)? "
+        "Have you tried with COMPONENTS (STARPU/QUARK, CUDA, MPI, FXT)? "
         "See the explanation in FindCHAMELEON.cmake.")
     endif()
   endif()
diff --git a/modules/find/FindEZTRACE.cmake b/modules/find/FindEZTRACE.cmake
index ef8aa2c407775b4c0bec7f1beda8a78caf284928..698c3314846c007b79989f41ebf6663679639206 100644
--- a/modules/find/FindEZTRACE.cmake
+++ b/modules/find/FindEZTRACE.cmake
@@ -321,12 +321,22 @@ if(EZTRACE_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
   set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -341,6 +351,7 @@ if(EZTRACE_LIBRARIES)
       message(STATUS "Looking for eztrace : test of eztrace_topology_init with eztrace library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindFABULOUS.cmake b/modules/find/FindFABULOUS.cmake
index 9d353ca70908818349457faa8b987f6d69df04e4..9ac9bef2f40ade212805a179decbd69e08b1d94b 100644
--- a/modules/find/FindFABULOUS.cmake
+++ b/modules/find/FindFABULOUS.cmake
@@ -1,165 +1,420 @@
-# - Try to find fabulous (C-api)
+###
 #
-# If this script have difficulties to find fabulous, you can try to help
-# it by setting the variable FABULOUS_DIR to the prefix path where fabulous
-# was installed
+# @copyright (c) 2012-2018 Inria. All rights reserved.
 #
-# Once done this will define
-#  FABULOUS_FOUND - System has fabulous
-#  FABULOUS_INCLUDE_DIRS - The fabulous include directories
-#  FABULOUS_MODULE_DIRS - The fabulous module directories for Fortran API
-#  FABULOUS_LIBRARIES - The libraries needed to use fabulous
-#  FABULOUS_DEFINITIONS - Compiler switches required for using fabulous
+###
 #
-include(FindPackageHandleStandardArgs)
+# - Find FABULOUS include dirs and libraries
+# Use this module by invoking find_package with the form:
+#  find_package(FABULOUS
+#               [REQUIRED]) # Fail with error if fabulous is not found
+#
+#  FABULOUS depends on the following libraries:
+#   - CBLAS
+#   - LAPACKE
+#
+# This module finds headers and fabulous library.
+# Results are reported in variables:
+#  FABULOUS_FOUND             - True if headers and requested libraries were found
+#  FABULOUS_CFLAGS_OTHER      - fabulous compiler flags without headers paths
+#  FABULOUS_LDFLAGS_OTHER     - fabulous linker flags without libraries
+#  FABULOUS_INCLUDE_DIRS      - fabulous include directories
+#  FABULOUS_LIBRARY_DIRS      - fabulous link directories
+#  FABULOUS_LIBRARIES         - fabulous libraries to be linked (absolute path)
+#  FABULOUS_CFLAGS_OTHER_DEP  - fabulous + dependencies compiler flags without headers paths
+#  FABULOUS_LDFLAGS_OTHER_DEP - fabulous + dependencies linker flags without libraries
+#  FABULOUS_INCLUDE_DIRS_DEP  - fabulous + dependencies include directories
+#  FABULOUS_LIBRARY_DIRS_DEP  - fabulous + dependencies link directories
+#  FABULOUS_LIBRARIES_DEP     - fabulous + dependencies libraries
+#
+#  FABULOUS_FOUND_WITH_PKGCONFIG - True if found with pkg-config
+#  if found with pkg-config the following variables are set
+#  <PREFIX>  = FABULOUS
+#  <XPREFIX> = <PREFIX>        for common case
+#  <XPREFIX> = <PREFIX>_STATIC for static linking
+#  <XPREFIX>_FOUND          ... set to 1 if module(s) exist
+#  <XPREFIX>_LIBRARIES      ... only the libraries (w/o the '-l')
+#  <XPREFIX>_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
+#  <XPREFIX>_LDFLAGS        ... all required linker flags
+#  <XPREFIX>_LDFLAGS_OTHER  ... all other linker flags
+#  <XPREFIX>_INCLUDE_DIRS   ... the '-I' preprocessor flags (w/o the '-I')
+#  <XPREFIX>_CFLAGS         ... all required cflags
+#  <XPREFIX>_CFLAGS_OTHER   ... the other compiler flags
+#
+# The user can give specific paths where to find the libraries adding cmake
+# options at configure (ex: cmake path/to/project -DFABULOUS_DIR=path/to/fabulous):
+#  FABULOUS_DIR             - Where to find the base directory of fabulous
+#  FABULOUS_INCDIR          - Where to find the header files
+#  FABULOUS_LIBDIR          - Where to find the library files
+# The module can also look for the following environment variables if paths
+# are not given as cmake variable: FABULOUS_DIR, FABULOUS_INCDIR, FABULOUS_LIBDIR
 
-macro(FABULOUS_FIND_LIBRARIES_FROM_PKGCONFIG_RESULTS _prefix _pc_xprefix)
-    foreach(_library ${${_pc_xprefix}_LIBRARIES})
-        get_filename_component(_library ${_library} NAME_WE)
-        unset(_library_path)
-        unset(_library_path CACHE)
-        find_library(_library_path NAMES ${_library}
-            HINTS ${${_pc_xprefix}_LIBDIR} ${${_pc_xprefix}_LIBRARY_DIRS} )
-        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()
-endmacro()
-
-macro(FABULOUS_CHECK_FUNCTION_EXISTS _prefix _function)
-    include(CheckFunctionExists)
-    unset(${_prefix}_WORKS)
-    unset(${_prefix}_WORKS CACHE)
-    set(CMAKE_REQUIRED_LIBRARIES ${${_prefix}_LIBRARIES})
-    set(CMAKE_REQUIRED_INCLUDES ${${_prefix}_INCLUDE_DIRS})
-    set(CMAKE_REQUIRED_DEFINITIONS ${${_prefix}_DEFINITIONS})
-    check_function_exists(${_function} ${_prefix}_WORKS)
-    set(CMAKE_REQUIRED_LIBRARIES "")
-    set(CMAKE_REQUIRED_INCLUDES "")
-    set(CMAKE_REQUIRED_DEFINITIONS "")
-    mark_as_advanced(${_prefix}_WORKS)
-endmacro()
+#=============================================================================
+# Copyright 2012-2018 Inria
+# Copyright 2013-2018 Florent Pruvost
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file MORSE-Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of Morse, substitute the full
+#  License text for the above reference.)
 
-find_package(PkgConfig QUIET)
+if (NOT FABULOUS_FOUND)
+  set(FABULOUS_DIR "" CACHE PATH "Installation directory of FABULOUS library")
+  if (NOT FABULOUS_FIND_QUIETLY)
+    message(STATUS "A cache variable, namely FABULOUS_DIR, has been set to specify the install directory of FABULOUS")
+  endif()
+endif()
+
+# FABULOUS depends on CBLAS
+#---------------------------
+if (NOT FABULOUS_FIND_QUIETLY)
+  message(STATUS "Looking for FABULOUS - Try to detect CBLAS (depends on BLAS)")
+endif()
+if (FABULOUS_FIND_REQUIRED)
+  find_package(CBLAS REQUIRED)
+else()
+  find_package(CBLAS)
+endif()
 
+# FABULOUS depends on LAPACKE
+#-----------------------------
+if (NOT FABULOUS_FIND_QUIETLY)
+  message(STATUS "Looking for FABULOUS - Try to detect LAPACKE (depends on LAPACK)")
+endif()
+if (FABULOUS_FIND_REQUIRED)
+  find_package(LAPACKE REQUIRED)
+else()
+  find_package(LAPACKE)
+endif()
+  
 set(ENV_FABULOUS_DIR "$ENV{FABULOUS_DIR}")
 set(ENV_FABULOUS_INCDIR "$ENV{FABULOUS_INCDIR}")
 set(ENV_FABULOUS_LIBDIR "$ENV{FABULOUS_LIBDIR}")
 set(FABULOUS_GIVEN_BY_USER "FALSE")
-if ( FABULOUS_DIR OR ENV_FABULOUS_DIR
-        OR ( FABULOUS_INCDIR AND FABULOUS_LIBDIR )
-        OR ( ENV_FABULOUS_INCDIR AND ENV_FABULOUS_LIBDIR ) )
-    set(FABULOUS_GIVEN_BY_USER "TRUE")
+if ( FABULOUS_DIR OR ( FABULOUS_INCDIR AND FABULOUS_LIBDIR) OR ENV_FABULOUS_DIR OR (ENV_FABULOUS_INCDIR AND ENV_FABULOUS_LIBDIR) )
+  set(FABULOUS_GIVEN_BY_USER "TRUE")
 endif()
 
-set(FABULOUS_STATIC_FIND_QUIETLY "TRUE")
-set(FABULOUS_SHARED_FIND_QUIETLY "TRUE")
-
-if ((NOT FABULOUS_FOUND) AND (NOT FABULOUS_GIVEN_BY_USER) AND PKG_CONFIG_FOUND)
-    pkg_check_modules(PC_FABULOUS QUIET fabulous)
-
-    find_path(FABULOUS_STATIC_INCLUDE_DIR NAMES fabulous.h
-        HINTS ${PC_FABULOUS_STATIC_INCLUDEDIR} ${PC_FABULOUS_STATIC_INCLUDE_DIRS} )
-    find_library(FABULOUS_STATIC_LIBRARY NAMES libfabulous.a
-        HINTS ${PC_FABULOUS_STATIC_LIBDIR} ${PC_FABULOUS_STATIC_LIBRARY_DIRS} )
-
-    find_path(FABULOUS_SHARED_INCLUDE_DIR NAMES fabulous.h
-        HINTS ${PC_FABULOUS_INCLUDEDIR} ${PC_FABULOUS_INCLUDE_DIRS} )
-    find_library(FABULOUS_SHARED_LIBRARY NAMES libfabulous.so
-        HINTS ${PC_FABULOUS_LIBDIR} ${PC_FABULOUS_LIBRARY_DIRS} )
-
-    # handle the QUIETLY and REQUIRED arguments and set FABULOUS_FOUND to TRUE
-    # if all listed variables are TRUE
-
-    find_package_handle_standard_args(
-        FABULOUS_STATIC DEFAULT_MSG
-        FABULOUS_STATIC_LIBRARY FABULOUS_STATIC_INCLUDE_DIR)
-    mark_as_advanced(FABULOUS_STATIC_INCLUDE_DIR FABULOUS_STATIC_LIBRARY)
-
-    find_package_handle_standard_args(
-        FABULOUS_SHARED DEFAULT_MSG
-        FABULOUS_SHARED_LIBRARY FABULOUS_SHARED_INCLUDE_DIR)
-    mark_as_advanced(FABULOUS_SHARED_INCLUDE_DIR FABULOUS_SHARED_LIBRARY)
-
-    if (FABULOUS_STATIC_FOUND AND NOT FABULOUS_SHARED_FOUND)
-        set(FABULOUS_INCLUDE_DIRS ${FABULOUS_STATIC_INCLUDE_DIR} )
-        set(FABULOUS_DEFINITIONS ${PC_FABULOUS_STATIC_CFLAGS_OTHER} )
-        set(FABULOUS_LIBRARIES "")
-        fabulous_find_libraries_from_pkgconfig_results(FABULOUS PC_FABULOUS_STATIC)
-    elseif(FABULOUS_SHARED_FOUND)
-        set(FABULOUS_INCLUDE_DIRS ${FABULOUS_INCLUDE_DIR} )
-        set(FABULOUS_DEFINITIONS ${PC_FABULOUS_CFLAGS_OTHER} )
-        set(FABULOUS_LIBRARIES "")
-        fabulous_find_libraries_from_pkgconfig_results(FABULOUS PC_FABULOUS)
-    endif()
-    fabulous_check_function_exists(FABULOUS fabulous_create)
-    find_package_handle_standard_args(
-        FABULOUS DEFAULT_MSG
-        FABULOUS_LIBRARIES FABULOUS_INCLUDE_DIRS FABULOUS_WORKS)
-endif()
+# Optionally use pkg-config to detect include/library dirs (if pkg-config is available)
+# -------------------------------------------------------------------------------------
+include(FindPkgConfig)
+find_package(PkgConfig QUIET)
+if( PKG_CONFIG_EXECUTABLE AND NOT FABULOUS_GIVEN_BY_USER )
+
+  pkg_search_module(FABULOUS fabulous_c_api)
+
+  if (NOT FABULOUS_FIND_QUIETLY)
+    if (FABULOUS_FOUND AND FABULOUS_LIBRARIES)
+      message(STATUS "Looking for FABULOUS - found using PkgConfig")
+    else()
+      message(STATUS "${Magenta}Looking for FABULOUS - not found using PkgConfig."
+        "\n   Perhaps you should add the directory containing fabulous.pc to"
+        "\n   the PKG_CONFIG_PATH environment variable.${ColourReset}")
+    endif()
+  endif()
+
+  if (FABULOUS_FOUND AND FABULOUS_LIBRARIES)
+    set(FABULOUS_FOUND_WITH_PKGCONFIG "TRUE")
+    find_pkgconfig_libraries_absolute_path(FABULOUS)
+  else()
+    set(FABULOUS_FOUND_WITH_PKGCONFIG "FALSE")
+  endif()
 
-if ((NOT FABULOUS_FOUND) AND (FABULOUS_GIVEN_BY_USER OR (NOT PKG_CONFIG_FOUND)))
+endif( PKG_CONFIG_EXECUTABLE AND NOT FABULOUS_GIVEN_BY_USER )
 
-    # Currently the C-api (compiled version) does not depent on chameleon
-    # so the library only depends on CBLAS AND LAPACKE
+if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FABULOUS_FOUND) OR (FABULOUS_GIVEN_BY_USER) )
 
-    set(FABULOUS_DEFINITIONS "")
-    if ( ( FABULOUS_INCDIR AND FABULOUS_LIBDIR ) OR ( ENV_FABULOUS_INCDIR AND ENV_FABULOUS_LIBDIR ) )
+  if (NOT FABULOUS_FIND_QUIETLY)
+    message(STATUS "Looking for FABULOUS - PkgConfig not used")
+  endif()
 
-        if ((NOT FABULOUS_LIBDIR) AND (NOT FABULOUS_INCDIR)
-                AND (ENV_FABULOUS_INCDIR AND ENV_FABULOUS_LIBDIR) )
-            set(FABULOUS_LIBDIR ${ENV_FABULOUS_LIBDIR})
-            set(FABULOUS_INCDIR ${ENV_FABULOUS_INCDIR})
-        endif()
+  # Looking for include
+  # -------------------
 
-        find_path(FABULOUS_INCLUDE_DIRS NAMES fabulous.h HINTS ${FABULOUS_INCDIR})
-        find_path(FABULOUS_MODULE_DIRS NAMES fabulous_mod.mod HINTS ${FABULOUS_INCDIR}
-          PATH_SUFFIXES fabulous)
-        find_library(FABULOUS_STATIC_LIBRARY NAMES libfabulous.a HINTS ${FABULOUS_LIBDIR})
-        find_library(FABULOUS_SHARED_LIBRARY NAMES libfabulous.so HINTS ${FABULOUS_LIBDIR})
+  # Add system include paths to search include
+  # ------------------------------------------
+  unset(_inc_env)
+  if(ENV_FABULOUS_INCDIR)
+    list(APPEND _inc_env "${ENV_FABULOUS_INCDIR}")
+  elseif(ENV_FABULOUS_DIR)
+    list(APPEND _inc_env "${ENV_FABULOUS_DIR}")
+    list(APPEND _inc_env "${ENV_FABULOUS_DIR}/include")
+    list(APPEND _inc_env "${ENV_FABULOUS_DIR}/include/fabulous")
+  else()
+    if(WIN32)
+      string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
     else()
-        if (ENV_FABULOUS_DIR AND NOT FABULOUS_DIR)
-            set(FABULOUS_DIR "${ENV_FABULOUS_DIR}" CACHE PATH "Installation prefix where fabulous is installed")
-        else()
-            set(FABULOUS_DIR "${FABULOUS_DIR}" CACHE PATH "Installation prefix where fabulous is installed")
-        endif()
-
-        find_path(FABULOUS_INCLUDE_DIRS NAMES fabulous.h
-            HINTS ${FABULOUS_DIR}
-            PATH_SUFFIXES include include/fabulous)
-        find_path(FABULOUS_MODULE_DIRS NAMES fabulous_mod.mod
-            HINTS ${FABULOUS_DIR}
-            PATH_SUFFIXES include include/fabulous)
-        find_library(FABULOUS_STATIC_LIBRARY NAMES libfabulous.a
-            HINTS ${FABULOUS_DIR}
-            PATH_SUFFIXES lib lib32 lib64 lib/fabulous lib32/fabulous lib64/fabulous)
-        find_library(FABULOUS_SHARED_LIBRARY NAMES libfabulous.so
-            HINTS ${FABULOUS_DIR}
-            PATH_SUFFIXES lib lib32 lib64 lib/fabulous lib32/fabulous lib64/fabulous)
-    endif()
-
-    find_package_handle_standard_args(FABULOUS_STATIC DEFAULT_MSG FABULOUS_STATIC_LIBRARY)
-    find_package_handle_standard_args(FABULOUS_SHARED DEFAULT_MSG FABULOUS_SHARED_LIBRARY)
-    mark_as_advanced(FABULOUS_STATIC_LIBRARY FABULOUS_SHARED_LIBRARY)
-
-    if (FABULOUS_FIND_REQUIRED)
-      find_package(CBLAS REQUIRED)
-      find_package(LAPACKE REQUIRED)
+      string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
+      list(APPEND _inc_env "${_path_env}")
+      string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
+      list(APPEND _inc_env "${_path_env}")
+      string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
+      list(APPEND _inc_env "${_path_env}")
+      string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
+      list(APPEND _inc_env "${_path_env}")
+    endif()
+  endif()
+  list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
+  list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
+  list(REMOVE_DUPLICATES _inc_env)
+
+  # set paths where to look for
+  set(PATH_TO_LOOK_FOR "${_inc_env}")
+
+  # Try to find the fabulous header in the given paths
+  # -------------------------------------------------
+  # call cmake macro to find the header path
+  if(FABULOUS_INCDIR)
+    set(FABULOUS_fabulous.h_DIRS "FABULOUS_fabulous.h_DIRS-NOTFOUND")
+    find_path(FABULOUS_fabulous.h_DIRS
+      NAMES fabulous.h
+      HINTS ${FABULOUS_INCDIR})
+  else()
+    if(FABULOUS_DIR)
+      set(FABULOUS_fabulous.h_DIRS "FABULOUS_fabulous.h_DIRS-NOTFOUND")
+      find_path(FABULOUS_fabulous.h_DIRS
+        NAMES fabulous.h
+        HINTS ${FABULOUS_DIR}
+        PATH_SUFFIXES "include" "include/fabulous")
     else()
-      find_package(CBLAS)
-      find_package(LAPACKE)
+      set(FABULOUS_fabulous.h_DIRS "FABULOUS_fabulous.h_DIRS-NOTFOUND")
+      find_path(FABULOUS_fabulous.h_DIRS
+        NAMES fabulous.h
+        HINTS ${PATH_TO_LOOK_FOR}
+        PATH_SUFFIXES "fabulous")
+    endif()
+  endif()
+  mark_as_advanced(FABULOUS_fabulous.h_DIRS)
+
+  # Add path to cmake variable
+  # ------------------------------------
+  if (FABULOUS_fabulous.h_DIRS)
+    set(FABULOUS_INCLUDE_DIRS "${FABULOUS_fabulous.h_DIRS}")
+  else ()
+    set(FABULOUS_INCLUDE_DIRS "FABULOUS_INCLUDE_DIRS-NOTFOUND")
+    if(NOT FABULOUS_FIND_QUIETLY)
+      message(STATUS "Looking for fabulous -- fabulous.h not found")
     endif()
+  endif ()
+
+  if (FABULOUS_INCLUDE_DIRS)
+    list(REMOVE_DUPLICATES FABULOUS_INCLUDE_DIRS)
+  endif ()
 
-    if (FABULOUS_STATIC_FOUND AND NOT FABULOUS_SHARED_FOUND)
-        set(FABULOUS_LIBRARIES ${FABULOUS_STATIC_LIBRARY} ${CBLAS_LIBRARIES} ${LAPACKE_LIBRARIES} "-lstdc++" "-lm")
-    elseif(FABULOUS_SHARED_FOUND)
-        set(FABULOUS_LIBRARIES ${FABULOUS_SHARED_LIBRARY} ${CBLAS_LIBRARIES} ${LAPACKE_LIBRARIES})
+
+  # Looking for lib
+  # ---------------
+
+  # Add system library paths to search lib
+  # --------------------------------------
+  unset(_lib_env)
+  if(ENV_FABULOUS_LIBDIR)
+    list(APPEND _lib_env "${ENV_FABULOUS_LIBDIR}")
+  elseif(ENV_FABULOUS_DIR)
+    list(APPEND _lib_env "${ENV_FABULOUS_DIR}")
+    list(APPEND _lib_env "${ENV_FABULOUS_DIR}/lib")
+  else()
+    if(WIN32)
+      string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
+    else()
+      if(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}")
     endif()
-    fabulous_check_function_exists(FABULOUS fabulous_create)
-    find_package_handle_standard_args(
-        FABULOUS DEFAULT_MSG
-        FABULOUS_LIBRARIES FABULOUS_INCLUDE_DIRS FABULOUS_WORKS)
+  endif()
+  list(REMOVE_DUPLICATES _lib_env)
+
+  # set paths where to look for
+  set(PATH_TO_LOOK_FOR "${_lib_env}")
+
+  # Try to find the fabulous lib in the given paths
+  # ----------------------------------------------
+
+  # call cmake macro to find the lib path
+  if(FABULOUS_LIBDIR)
+    set(FABULOUS_fabulous_LIBRARY "FABULOUS_fabulous_LIBRARY-NOTFOUND")
+    find_library(FABULOUS_fabulous_LIBRARY
+      NAMES fabulous
+      HINTS ${FABULOUS_LIBDIR})
+  else()
+    if(FABULOUS_DIR)
+      set(FABULOUS_fabulous_LIBRARY "FABULOUS_fabulous_LIBRARY-NOTFOUND")
+      find_library(FABULOUS_fabulous_LIBRARY
+        NAMES fabulous
+        HINTS ${FABULOUS_DIR}
+        PATH_SUFFIXES lib lib32 lib64)
+    else()
+      set(FABULOUS_fabulous_LIBRARY "FABULOUS_fabulous_LIBRARY-NOTFOUND")
+      find_library(FABULOUS_fabulous_LIBRARY
+        NAMES fabulous
+        HINTS ${PATH_TO_LOOK_FOR})
+    endif()
+  endif()
+  mark_as_advanced(FABULOUS_fabulous_LIBRARY)
+
+  # If found, add path to cmake variable
+  # ------------------------------------
+  if (FABULOUS_fabulous_LIBRARY)
+    get_filename_component(fabulous_lib_path ${FABULOUS_fabulous_LIBRARY} PATH)
+    # set cmake variables (respects naming convention)
+    set(FABULOUS_LIBRARIES    "${FABULOUS_fabulous_LIBRARY}")
+    set(FABULOUS_LIBRARY_DIRS "${fabulous_lib_path}")
+  else ()
+    set(FABULOUS_LIBRARIES    "FABULOUS_LIBRARIES-NOTFOUND")
+    set(FABULOUS_LIBRARY_DIRS "FABULOUS_LIBRARY_DIRS-NOTFOUND")
+    if(NOT FABULOUS_FIND_QUIETLY)
+      message(STATUS "Looking for fabulous -- lib fabulous not found")
+    endif()
+  endif ()
+
+  if (FABULOUS_LIBRARY_DIRS)
+    list(REMOVE_DUPLICATES FABULOUS_LIBRARY_DIRS)
+  endif ()
+
+endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FABULOUS_FOUND) OR (FABULOUS_GIVEN_BY_USER) )
+
+# check a function to validate the find
+if(FABULOUS_LIBRARIES)
+
+  set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
+  set(REQUIRED_LIBDIRS)
+  set(REQUIRED_LIBS)
+
+  # FABULOUS
+  if (FABULOUS_INCLUDE_DIRS)
+    set(REQUIRED_INCDIRS "${FABULOUS_INCLUDE_DIRS}")
+  endif()
+  if (FABULOUS_CFLAGS_OTHER)
+    set(REQUIRED_FLAGS "${FABULOUS_CFLAGS_OTHER}")
+  endif()
+  if (FABULOUS_LDFLAGS_OTHER)
+    set(REQUIRED_LDFLAGS "${FABULOUS_LDFLAGS_OTHER}")
+  endif()
+  if (FABULOUS_LIBRARY_DIRS)
+    set(REQUIRED_LIBDIRS "${FABULOUS_LIBRARY_DIRS}")
+  endif()
+  set(REQUIRED_LIBS "${FABULOUS_LIBRARIES}")
+  # LAPACKE
+  if (LAPACKE_FOUND)
+    if (LAPACKE_INCLUDE_DIRS_DEP)
+      list(APPEND REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS_DEP}")
+    endif()
+    if (LAPACKE_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${LAPACKE_CFLAGS_OTHER_DEP}")
+    endif()
+    if (LAPACKE_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${LAPACKE_LDFLAGS_OTHER_DEP}")
+    endif()
+    if(LAPACKE_LIBRARY_DIRS_DEP)
+      list(APPEND REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS_DEP}")
+    endif()
+    if (LAPACKE_LIBRARIES_DEP)
+      list(APPEND REQUIRED_LIBS "${LAPACKE_LIBRARIES_DEP}")
+    endif()
+  endif()
+  # CBLAS
+  if (CBLAS_FOUND)
+    if (CBLAS_INCLUDE_DIRS_DEP)
+      list(APPEND REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS_DEP}")
+    endif()
+    if (CBLAS_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${CBLAS_CFLAGS_OTHER_DEP}")
+    endif()
+    if (CBLAS_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${CBLAS_LDFLAGS_OTHER_DEP}")
+    endif()
+    if(CBLAS_LIBRARY_DIRS_DEP)
+      list(APPEND REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS_DEP}")
+    endif()
+    if (CBLAS_LIBRARIES_DEP)
+      list(APPEND REQUIRED_LIBS "${CBLAS_LIBRARIES_DEP}")
+    endif()
+  endif()
+  
+  # set required libraries for link
+  set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
+  set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
+  set(CMAKE_REQUIRED_LIBRARIES)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
+  list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
+  string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
+
+  # test link
+  unset(FABULOUS_WORKS CACHE)
+  include(CheckFunctionExists)
+  check_function_exists(fabulous_solve FABULOUS_WORKS)
+  mark_as_advanced(FABULOUS_WORKS)
+
+  if(FABULOUS_WORKS)
+    # save link with dependencies
+    set(FABULOUS_LIBRARIES_DEP "${REQUIRED_LIBS}")
+    set(FABULOUS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
+    set(FABULOUS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
+    set(FABULOUS_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(FABULOUS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
+    list(REMOVE_DUPLICATES FABULOUS_LIBRARY_DIRS_DEP)
+    list(REMOVE_DUPLICATES FABULOUS_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES FABULOUS_LDFLAGS_OTHER_DEP)
+  else()
+    if(NOT FABULOUS_FIND_QUIETLY)
+      message(STATUS "Looking for fabulous : test of fabulous_topology_init with fabulous library fails")
+      message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
+      message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
+      message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
+    endif()
+  endif()
+  set(CMAKE_REQUIRED_INCLUDES)
+  set(CMAKE_REQUIRED_FLAGS)
+  set(CMAKE_REQUIRED_LIBRARIES)
+endif(FABULOUS_LIBRARIES)
+
+if (FABULOUS_LIBRARIES)
+  if (FABULOUS_LIBRARY_DIRS)
+    list(GET FABULOUS_LIBRARY_DIRS 0 first_lib_path)
+  else()
+    list(GET FABULOUS_LIBRARIES 0 first_lib)
+    get_filename_component(first_lib_path "${first_lib}" PATH)
+    set(FABULOUS_LIBRARY_DIRS "${first_lib_path}")
+  endif()
+  if (${first_lib_path} MATCHES "/lib(32|64)?$")
+    string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
+    set(FABULOUS_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of FABULOUS library" FORCE)
+  else()
+    set(FABULOUS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of FABULOUS library" FORCE)
+  endif()
 endif()
+mark_as_advanced(FABULOUS_DIR)
+mark_as_advanced(FABULOUS_DIR_FOUND)
+
+# check that FABULOUS has been found
+# -------------------------------
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(FABULOUS DEFAULT_MSG
+  FABULOUS_LIBRARIES
+  FABULOUS_WORKS)
+
diff --git a/modules/find/FindFFTW.cmake b/modules/find/FindFFTW.cmake
index df0eb44427983e6c7907474ef6055650ac7f0669..ac6d1ac8487febb6344c4703c6b74294bf70d838 100644
--- a/modules/find/FindFFTW.cmake
+++ b/modules/find/FindFFTW.cmake
@@ -28,13 +28,16 @@
 # This module finds headers and fftw library.
 # Results are reported in variables:
 #  FFTW_FOUND            - True if headers and requested libraries were found
-#  FFTW_LINKER_FLAGS     - list of required linker flags (excluding -l and -L)
-#  FFTW_INCLUDE_DIRS     - fftw include directories
-#  FFTW_LIBRARY_DIRS     - Link directories for fftw libraries
-#  FFTW_LIBRARIES        - fftw component libraries to be linked
-#  FFTW_INCLUDE_DIRS_DEP - fftw + dependencies include directories
-#  FFTW_LIBRARY_DIRS_DEP - fftw + dependencies link directories
-#  FFTW_LIBRARIES_DEP    - fftw libraries + dependencies
+#  FFTW_CFLAGS_OTHER      - fftw compiler flags without headers paths
+#  FFTW_LDFLAGS_OTHER     - fftw linker flags without libraries
+#  FFTW_INCLUDE_DIRS      - fftw include directories
+#  FFTW_LIBRARY_DIRS      - fftw link directories
+#  FFTW_LIBRARIES         - fftw libraries to be linked (absolute path)
+#  FFTW_CFLAGS_OTHER_DEP  - fftw + dependencies compiler flags without headers paths
+#  FFTW_LDFLAGS_OTHER_DEP - fftw + dependencies linker flags without libraries
+#  FFTW_INCLUDE_DIRS_DEP  - fftw + dependencies include directories
+#  FFTW_LIBRARY_DIRS_DEP  - fftw + dependencies link directories
+#  FFTW_LIBRARIES_DEP     - fftw + dependencies libraries
 #
 #  FFTW_FOUND_WITH_PKGCONFIG - True if found with pkg-config
 #  if found with pkg-config the following variables are set
@@ -196,10 +199,10 @@ if (FFTW_LOOK_FOR_MKL)
   endif()
   if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL)
     find_package(Threads REQUIRED)
-    find_package(BLASEXT REQUIRED)
+    find_package(BLAS REQUIRED)
   else()
     find_package(Threads)
-    find_package(BLASEXT)
+    find_package(BLAS)
   endif()
 endif()
 
@@ -213,9 +216,9 @@ if (FFTW_LOOK_FOR_ESSL)
     set(BLA_VENDOR "IBMESSL")
   endif()
   if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_ESSL)
-    find_package(BLASEXT REQUIRED)
+    find_package(BLAS REQUIRED)
   else()
-    find_package(BLASEXT)
+    find_package(BLAS)
   endif()
 endif()
 
@@ -749,12 +752,22 @@ if(FFTW_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
   set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
@@ -774,11 +787,11 @@ if(FFTW_LIBRARIES)
     set(FFTW_LIBRARIES_DEP "${REQUIRED_LIBS}")
     set(FFTW_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
     set(FFTW_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
-    set(FFTW_C_FLAGS "${REQUIRED_FLAGS}")
-    set(FFTW_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
+    set(FFTW_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(FFTW_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
     list(REMOVE_DUPLICATES FFTW_LIBRARY_DIRS_DEP)
-    list(REMOVE_DUPLICATES FFTW_INCLUDE_DIRS_DEP)
-    list(REMOVE_DUPLICATES FFTW_LINKER_FLAGS)
+    list(REMOVE_DUPLICATES FFTW_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES FFTW_LDFLAGS_OTHER_DEP)
   else()
     if(NOT FFTW_FIND_QUIETLY)
       message(STATUS "Looking for FFTW : test of ${FFTW_PREC_TESTFUNC}fftw_execute_ with fftw library fails")
diff --git a/modules/find/FindFXT.cmake b/modules/find/FindFXT.cmake
index 479b9ebbcf7cbf90d5fb604ee78aca52c4de4ab9..071e95fb2b8a010ce42004865b33b5e237b290ba 100644
--- a/modules/find/FindFXT.cmake
+++ b/modules/find/FindFXT.cmake
@@ -16,10 +16,9 @@
 # This module finds headers and fxt library.
 # Results are reported in variables:
 #  FXT_FOUND           - True if headers and requested libraries were found
-#  FXT_C_FLAGS         - list of required compilation flags (excluding -I)
 #  FXT_INCLUDE_DIRS    - fxt include directories
-#  FXT_LIBRARY_DIRS    - Link directories for fxt libraries
-#  FXT_LIBRARIES       - fxt component libraries to be linked
+#  FXT_LIBRARY_DIRS    - fxt link directories
+#  FXT_LIBRARIES       - fxt libraries to be linked (absolute path)
 #
 #  FXT_FOUND_WITH_PKGCONFIG - True if found with pkg-config
 #  if found with pkg-config the following variables are set
@@ -93,8 +92,6 @@ if(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER)
     endif()
   endif()
 
-  set(FXT_C_FLAGS "${FXT_CFLAGS_OTHER}")
-
   if (FXT_FOUND AND FXT_LIBRARIES)
     set(FXT_FOUND_WITH_PKGCONFIG "TRUE")
     find_pkgconfig_libraries_absolute_path(FXT)
@@ -260,6 +257,8 @@ endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND)
 if(FXT_LIBRARIES)
 
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -280,12 +279,22 @@ if(FXT_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
   set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -300,6 +309,7 @@ if(FXT_LIBRARIES)
       message(STATUS "Looking for fxt : test of fut_keychange with fxt library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindGTG.cmake b/modules/find/FindGTG.cmake
index b2800054df638d6cdd69d1e2663fa6e56b1e3b12..4c3fc6a5c79136ef95968548e3d0cf9cb8b2f79e 100644
--- a/modules/find/FindGTG.cmake
+++ b/modules/find/FindGTG.cmake
@@ -257,6 +257,8 @@ endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT GTG_FOUND)
 if(GTG_LIBRARIES)
 
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -277,12 +279,22 @@ if(GTG_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
   set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -297,6 +309,7 @@ if(GTG_LIBRARIES)
       message(STATUS "Looking for gtg : test of GTG_start with gtg library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindHQR.cmake b/modules/find/FindHQR.cmake
index 5493392ce84ecba0d640049b7044f7776fa9f891..5136432e5338e22dd3951c79c28966d948c8ce15 100644
--- a/modules/find/FindHQR.cmake
+++ b/modules/find/FindHQR.cmake
@@ -252,6 +252,8 @@ endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HQR_FOUND)
 if(HQR_LIBRARIES)
 
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -272,12 +274,22 @@ if(HQR_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
   set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -292,6 +304,7 @@ if(HQR_LIBRARIES)
       message(STATUS "Looking for hqr : test of libhqr_hqr_init with hqr library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindHWLOC.cmake b/modules/find/FindHWLOC.cmake
index 4960bab8f3b8175e8ed2edc6466736bff1744730..ff6afd1e8d90a9f79a67a0f07f748f129b209760 100644
--- a/modules/find/FindHWLOC.cmake
+++ b/modules/find/FindHWLOC.cmake
@@ -263,6 +263,8 @@ endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND
 if(HWLOC_LIBRARIES)
 
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -283,12 +285,22 @@ if(HWLOC_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
   set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -303,6 +315,7 @@ if(HWLOC_LIBRARIES)
       message(STATUS "Looking for hwloc : test of hwloc_topology_init with hwloc library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindLAPACK.cmake b/modules/find/FindLAPACK.cmake
index 998244f784eef70fcd0f6520d6592ebc83ea3ac3..20cfadadbfc55ab1e5b7b5313bbb042d9230ddf9 100644
--- a/modules/find/FindLAPACK.cmake
+++ b/modules/find/FindLAPACK.cmake
@@ -18,14 +18,16 @@
 # This module sets the following variables:
 #  LAPACK_FOUND - set to true if a library implementing the LAPACK interface
 #    is found
-#  LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l
-#    and -L).
-#  LAPACK_LIBRARIES - uncached list of libraries (using full path name) to
-#    link against to use LAPACK
-#  LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to
-#    link against to use LAPACK95
-#  LAPACK95_FOUND - set to true if a library implementing the LAPACK f95
-#    interface is found
+#  LAPACK_CFLAGS_OTHER      - lapack compiler flags without headers paths
+#  LAPACK_LDFLAGS_OTHER     - lapack linker flags without libraries
+#  LAPACK_INCLUDE_DIRS      - lapack include directories
+#  LAPACK_LIBRARY_DIRS      - lapack link directories
+#  LAPACK_LIBRARIES         - lapack libraries to be linked (absolute path)
+#  LAPACK_CFLAGS_OTHER_DEP  - lapack + dependencies compiler flags without headers paths
+#  LAPACK_LDFLAGS_OTHER_DEP - lapack + dependencies linker flags without libraries
+#  LAPACK_INCLUDE_DIRS_DEP  - lapack + dependencies include directories
+#  LAPACK_LIBRARY_DIRS_DEP  - lapack + dependencies link directories
+#  LAPACK_LIBRARIES_DEP     - lapack + dependencies libraries
 #  BLA_STATIC  if set on this determines what kind of linkage we do (static)
 #  BLA_VENDOR  if set checks only the specified vendor, if not set checks
 #     all the possibilities
@@ -282,6 +284,8 @@ macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads
     else(UNIX AND BLA_STATIC)
       set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads})
     endif(UNIX AND BLA_STATIC)
+    set(CMAKE_REQUIRED_INCLUDES "${LAPACK_INCLUDE_DIRS}")
+    set(CMAKE_REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER}")
     if (LAPACK_VERBOSE)
       message("${Cyan}LAPACK libs found. Try to compile symbol ${_name} with"
         "following libraries: ${CMAKE_REQUIRED_LIBRARIES}")
@@ -308,20 +312,18 @@ macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads
 endmacro(Check_Lapack_Libraries)
 
 
-set(LAPACK_LINKER_FLAGS)
+set(LAPACK_LDFLAGS_OTHER)
 set(LAPACK_LIBRARIES)
 set(LAPACK95_LIBRARIES)
 
-if (NOT BLAS_FOUND)
-  if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
-    find_package(BLASEXT)
-  else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
-    find_package(BLASEXT REQUIRED)
-  endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
-endif ()
+if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
+  find_package(BLAS)
+else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
+  find_package(BLAS REQUIRED)
+endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
 
 if(BLAS_FOUND)
-  set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
+  set(LAPACK_INCLUDE_DIRS ${BLAS_INCLUDE_DIRS})
   if ($ENV{BLA_VENDOR} MATCHES ".+")
     set(BLA_VENDOR $ENV{BLA_VENDOR})
   else ($ENV{BLA_VENDOR} MATCHES ".+")
@@ -386,7 +388,25 @@ if(BLAS_FOUND)
   find_package(PkgConfig QUIET)
   if( PKG_CONFIG_EXECUTABLE AND NOT LAPACK_GIVEN_BY_USER AND BLA_VENDOR STREQUAL "All")
 
-    pkg_search_module(LAPACK lapack)
+    if (BLA_STATIC)
+      set(MKL_STR_BLA_STATIC "static")
+    else()
+      set(MKL_STR_BLA_STATIC "dynamic")
+    endif()
+    # try different blas
+    if (BLA_VENDOR STREQUAL "Intel10_64lp")
+      pkg_search_module(LAPACK mkl-${MKL_STR_BLA_STATIC}-lp64-iomp)
+    elseif(BLA_VENDOR STREQUAL "Intel10_64lp_seq")
+      pkg_search_module(LAPACK mkl-${MKL_STR_BLA_STATIC}-lp64-seq)
+    elseif(BLA_VENDOR STREQUAL "Open")
+      pkg_search_module(LAPACK openblas)
+    elseif(BLA_VENDOR STREQUAL "Generic")
+      pkg_search_module(LAPACK lapack)
+    else()
+      pkg_search_module(LAPACK lapack)
+      pkg_search_module(LAPACK openblas)
+      pkg_search_module(LAPACK mkl-${MKL_STR_BLA_STATIC}-lp64-seq)
+    endif()
 
     if (NOT LAPACK_FIND_QUIETLY)
       if (LAPACK_FOUND AND LAPACK_LIBRARIES)
@@ -401,14 +421,6 @@ if(BLAS_FOUND)
     if (LAPACK_FOUND AND LAPACK_LIBRARIES)
       set(LAPACK_FOUND_WITH_PKGCONFIG "TRUE")
       find_pkgconfig_libraries_absolute_path(LAPACK)
-      if (BLA_STATIC)
-        set(LAPACK_LINKER_FLAGS "${LAPACK_STATIC_LDFLAGS_OTHER}")
-        set(LAPACK_COMPILER_FLAGS "${LAPACK_STATIC_CFLAGS_OTHER}")
-        set(LAPACK_LIBRARIES "${LAPACK_STATIC_LIBRARIES}")
-      else()
-        set(LAPACK_LINKER_FLAGS "${LAPACK_LDFLAGS_OTHER}")
-        set(LAPACK_COMPILER_FLAGS "${LAPACK_CFLAGS_OTHER}")
-      endif()
     else()
       set(LAPACK_FOUND_WITH_PKGCONFIG "FALSE")
     endif()
@@ -473,7 +485,7 @@ if(BLAS_FOUND)
                   "${CMAKE_THREAD_LIBS_INIT};${LM}"
                   )
                 if(_LIBRARIES)
-                  set(LAPACK_LINKER_FLAGS "${additional_flags}")
+                  set(LAPACK_LDFLAGS_OTHER "${additional_flags}")
                 endif()
           endif ()
           # Then try the search libs
@@ -489,7 +501,7 @@ if(BLAS_FOUND)
                     "${CMAKE_THREAD_LIBS_INIT};${LM}"
                     )
                   if(_LIBRARIES)
-                    set(LAPACK_LINKER_FLAGS "${additional_flags}")
+                    set(LAPACK_LDFLAGS_OTHER "${additional_flags}")
                   endif()
                 endif ()
           endforeach ()
@@ -789,6 +801,15 @@ if (LAPACK_FOUND)
   else()
     set(LAPACK_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of LAPACK library" FORCE)
   endif()
+  set(LAPACK_CFLAGS_OTHER_DEP "${LAPACK_CFLAGS_OTHER}" "${BLAS_CFLAGS_OTHER}")
+  set(LAPACK_LDFLAGS_OTHER_DEP "${LAPACK_LDFLAGS_OTHER}" "${BLAS_LDFLAGS_OTHER}")
+  set(LAPACK_INCLUDE_DIRS_DEP "${LAPACK_INCLUDE_DIRS}" "${BLAS_INCLUDE_DIRS}")
+  set(LAPACK_LIBRARY_DIRS_DEP "${LAPACK_LIBRARY_DIRS}" "${BLAS_LIBRARY_DIRS}")
+  set(LAPACK_LIBRARIES_DEP "${LAPACK_LIBRARIES}" "${BLAS_LIBRARIES}")
+  list(REMOVE_DUPLICATES LAPACK_CFLAGS_OTHER_DEP)
+  list(REMOVE_DUPLICATES LAPACK_LDFLAGS_OTHER_DEP)
+  list(REMOVE_DUPLICATES LAPACK_INCLUDE_DIRS_DEP)
+  list(REMOVE_DUPLICATES LAPACK_LIBRARY_DIRS_DEP)
 endif()
 mark_as_advanced(LAPACK_DIR)
 mark_as_advanced(LAPACK_DIR_FOUND)
diff --git a/modules/find/FindLAPACKE.cmake b/modules/find/FindLAPACKE.cmake
index afcfb60d778702391bd983b63fce8e5855a1e1ab..02c6a943196906473022919e2933eeb4de912cfe 100644
--- a/modules/find/FindLAPACKE.cmake
+++ b/modules/find/FindLAPACKE.cmake
@@ -26,13 +26,16 @@
 # This module finds headers and lapacke library.
 # Results are reported in variables:
 #  LAPACKE_FOUND            - True if headers and requested libraries were found
-#  LAPACKE_LINKER_FLAGS     - list of required linker flags (excluding -l and -L)
-#  LAPACKE_INCLUDE_DIRS     - lapacke include directories
-#  LAPACKE_LIBRARY_DIRS     - Link directories for lapacke libraries
-#  LAPACKE_LIBRARIES        - lapacke component libraries to be linked
-#  LAPACKE_INCLUDE_DIRS_DEP - lapacke + dependencies include directories
-#  LAPACKE_LIBRARY_DIRS_DEP - lapacke + dependencies link directories
-#  LAPACKE_LIBRARIES_DEP    - lapacke libraries + dependencies
+#  LAPACKE_CFLAGS_OTHER      - lapacke compiler flags without headers paths
+#  LAPACKE_LDFLAGS_OTHER     - lapacke linker flags without libraries
+#  LAPACKE_INCLUDE_DIRS      - lapacke include directories
+#  LAPACKE_LIBRARY_DIRS      - lapacke link directories
+#  LAPACKE_LIBRARIES         - lapacke libraries to be linked (absolute path)
+#  LAPACKE_CFLAGS_OTHER_DEP  - lapacke + dependencies compiler flags without headers paths
+#  LAPACKE_LDFLAGS_OTHER_DEP - lapacke + dependencies linker flags without libraries
+#  LAPACKE_INCLUDE_DIRS_DEP  - lapacke + dependencies include directories
+#  LAPACKE_LIBRARY_DIRS_DEP  - lapacke + dependencies link directories
+#  LAPACKE_LIBRARIES_DEP     - lapacke + dependencies libraries
 #
 #  LAPACKE_FOUND_WITH_PKGCONFIG - True if found with pkg-config
 #  if found with pkg-config the following variables may be set
@@ -98,12 +101,10 @@ if( LAPACKE_FIND_COMPONENTS )
 endif()
 
 # LAPACKE depends on LAPACK anyway, try to find it
-if (NOT LAPACK_FOUND)
-  if(LAPACKE_FIND_REQUIRED)
-    find_package(LAPACKEXT REQUIRED)
-  else()
-    find_package(LAPACKEXT)
-  endif()
+if(LAPACKE_FIND_REQUIRED)
+  find_package(LAPACK REQUIRED)
+else()
+  find_package(LAPACK)
 endif()
 
 # LAPACKE depends on LAPACK
@@ -112,7 +113,9 @@ if (LAPACK_FOUND)
   if (NOT LAPACKE_STANDALONE)
     # check if a lapacke function exists in the LAPACK lib
     include(CheckFunctionExists)
-    set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LINKER_FLAGS};${LAPACK_LIBRARIES}")
+    set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LDFLAGS_OTHER_DEP};${LAPACK_LIBRARIES_DEP}")
+    set(CMAKE_REQUIRED_INCLUDES "${LAPACK_INCLUDE_DIRS_DEP}")
+    set(CMAKE_REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER_DEP}")
     unset(LAPACKE_WORKS CACHE)
     check_function_exists(LAPACKE_dgeqrf LAPACKE_WORKS)
     mark_as_advanced(LAPACKE_WORKS)
@@ -124,17 +127,6 @@ if (LAPACK_FOUND)
       endif()
       # test succeeds: LAPACKE is in LAPACK
       set(LAPACKE_LIBRARIES "${LAPACK_LIBRARIES}")
-      set(LAPACKE_LIBRARIES_DEP "${LAPACK_LIBRARIES}")
-      if (LAPACK_LIBRARY_DIRS)
-        set(LAPACKE_LIBRARY_DIRS "${LAPACK_LIBRARY_DIRS}")
-      endif()
-      if(LAPACK_INCLUDE_DIRS)
-        set(LAPACKE_INCLUDE_DIRS "${LAPACK_INCLUDE_DIRS}")
-        set(LAPACKE_INCLUDE_DIRS_DEP "${LAPACK_INCLUDE_DIRS}")
-      endif()
-      if (LAPACK_LINKER_FLAGS)
-        set(LAPACKE_LINKER_FLAGS "${LAPACK_LINKER_FLAGS}")
-      endif()
     endif()
   endif (NOT LAPACKE_STANDALONE)
 
@@ -158,7 +150,25 @@ if (LAPACK_FOUND)
     find_package(PkgConfig QUIET)
     if( PKG_CONFIG_EXECUTABLE AND NOT LAPACKE_GIVEN_BY_USER)
 
-      pkg_search_module(LAPACKE lapacke)
+      if (BLA_STATIC)
+        set(MKL_STR_BLA_STATIC "static")
+      else()
+        set(MKL_STR_BLA_STATIC "dynamic")
+      endif()
+      # try different blas
+      if (BLA_VENDOR STREQUAL "Intel10_64lp")
+        pkg_search_module(LAPACKE mkl-${MKL_STR_BLA_STATIC}-lp64-iomp)
+      elseif(BLA_VENDOR STREQUAL "Intel10_64lp_seq")
+        pkg_search_module(LAPACKE mkl-${MKL_STR_BLA_STATIC}-lp64-seq)
+      elseif(BLA_VENDOR STREQUAL "Open")
+        pkg_search_module(LAPACKE openblas)
+      elseif(BLA_VENDOR STREQUAL "Generic")
+        pkg_search_module(LAPACKE lapacke)
+      else()
+        pkg_search_module(LAPACKE lapacke)
+        pkg_search_module(LAPACKE openblas)
+        pkg_search_module(LAPACKE mkl-${MKL_STR_BLA_STATIC}-lp64-seq)
+      endif()
 
       if (NOT LAPACKE_FIND_QUIETLY)
         if (LAPACKE_FOUND AND LAPACKE_LIBRARIES)
@@ -327,8 +337,9 @@ if (LAPACK_FOUND)
   # check a function to validate the find
   if(LAPACKE_LIBRARIES)
 
-    set(REQUIRED_LDFLAGS)
     set(REQUIRED_INCDIRS)
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_LDFLAGS)
     set(REQUIRED_LIBDIRS)
     set(REQUIRED_LIBS)
 
@@ -347,19 +358,19 @@ if (LAPACK_FOUND)
     endif()
     set(REQUIRED_LIBS "${LAPACKE_LIBRARIES}")
     # LAPACK
-    if (LAPACK_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}")
+    if (LAPACK_INCLUDE_DIRS_DEP)
+      list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS_DEP}")
     endif()
-    if (LAPACK_COMPILER_FLAGS)
-      list(APPEND REQUIRED_FLAGS "${LAPACK_COMPILER_FLAGS}")
+    if (LAPACK_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER_DEP}")
     endif()
-    if (LAPACK_LINKER_FLAGS)
-      list(APPEND REQUIRED_LDFLAGS "${LAPACK_LINKER_FLAGS}")
+    if (LAPACK_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${LAPACK_LDFLAGS_OTHER_DEP}")
     endif()
-    if (LAPACK_LIBRARY_DIRS)
-      list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS}")
+    if (LAPACK_LIBRARY_DIRS_DEP)
+      list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS_DEP}")
     endif()
-    list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}")
+    list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES_DEP}")
     # Fortran
     if (CMAKE_C_COMPILER_ID MATCHES "GNU")
       find_library(
@@ -390,12 +401,22 @@ if (LAPACK_FOUND)
     endif()
     # set required libraries for link
     set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+    if (REQUIRED_FLAGS)
+      set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+      set(REQUIRED_FLAGS)
+      set(REQUIRED_DEFINITIONS)
+      foreach(_flag ${REQUIRED_FLAGS_COPY})
+        if (_flag MATCHES "^-D")
+         list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+        endif()
+        string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+        list(APPEND REQUIRED_FLAGS "${_flag}")
+      endforeach()
+    endif()
+    set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
     set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
     set(CMAKE_REQUIRED_LIBRARIES)
     list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-    foreach(lib_dir ${REQUIRED_LIBDIRS})
-      list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-    endforeach()
     list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
     string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -414,13 +435,17 @@ if (LAPACK_FOUND)
       set(LAPACKE_LIBRARIES_DEP "${REQUIRED_LIBS}")
       set(LAPACKE_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
       set(LAPACKE_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
+      set(LAPACKE_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+      set(LAPACKE_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
       list(REMOVE_DUPLICATES LAPACKE_LIBRARY_DIRS_DEP)
-      list(REMOVE_DUPLICATES LAPACKE_INCLUDE_DIRS_DEP)
+      list(REMOVE_DUPLICATES LAPACKE_CFLAGS_OTHER_DEP)
+      list(REMOVE_DUPLICATES LAPACKE_LDFLAGS_OTHER_DEP)
     else()
       if(NOT LAPACKE_FIND_QUIETLY)
         message(STATUS "Looking for lapacke: test of LAPACKE_dgeqrf with lapacke and lapack libraries fails")
         message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
         message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+        message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
         message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
       endif()
     endif()
diff --git a/modules/find/FindLAPACKEXT.cmake b/modules/find/FindLAPACKEXT.cmake
index 52ebd11540d19bd68eb2b25e14e1944102dcede4..289155e19b5ae3055d3993de75ced2a8bece3c51 100644
--- a/modules/find/FindLAPACKEXT.cmake
+++ b/modules/find/FindLAPACKEXT.cmake
@@ -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-2017 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.
 #
 ###
@@ -28,11 +28,11 @@
 #  LAPACKEXT_LIBRARY_DIRS - Idem LAPACK_LIBRARY_DIRS
 
 #=============================================================================
-# Copyright 2012-2013 Inria
+# Copyright 2012-2018 Inria
 # Copyright 2012-2013 Emmanuel Agullo
 # Copyright 2012-2013 Mathieu Faverge
 # Copyright 2012      Cedric Castagnede
-# Copyright 2013-2017 Florent Pruvost
+# Copyright 2013-2018 Florent Pruvost
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file MORSE-Copyright.txt for details.
@@ -63,13 +63,11 @@ macro(find_package_lapack required)
 endmacro()
 
 # LAPACKEXT depends on BLAS
-if (NOT BLAS_FOUND)
-  if(LAPACKEXT_FIND_QUIETLY)
-    find_package(BLAS QUIET)
-  else()
-    find_package(BLAS)
-  endif()
-endif ()
+if(LAPACKEXT_FIND_QUIETLY)
+  find_package(BLASEXT QUIET)
+else()
+  find_package(BLASEXT)
+endif()
 
 if(NOT LAPACKEXT_FIND_QUIETLY)
   message(STATUS "In FindLAPACKEXT")
@@ -217,8 +215,6 @@ else()
   # This module sets the following variables:
   #  LAPACK_FOUND - set to true if a library implementing the LAPACK interface
   #    is found
-  #  LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l
-  #    and -L).
   #  LAPACK_LIBRARIES - uncached list of libraries (using full path name) to
   #    link against to use LAPACK
   #  LAPACK95_LIBRARIES - uncached list of libraries (using full path name)
diff --git a/modules/find/FindMAGMA.cmake b/modules/find/FindMAGMA.cmake
index 040aeac461498ce44e518c18e2c516aebdfe023a..869a5cc14c8fd0864904aa34e7be1ca18388e052 100644
--- a/modules/find/FindMAGMA.cmake
+++ b/modules/find/FindMAGMA.cmake
@@ -72,12 +72,10 @@ if(NOT MAGMA_FOUND)
 endif(NOT MAGMA_FOUND)
 
 # MAGMA depends on CUDA anyway, try to find it
-if (NOT CUDA_FOUND)
-  if(MAGMA_FIND_REQUIRED)
-    find_package(CUDA REQUIRED)
-  else()
-    find_package(CUDA)
-  endif()
+if(MAGMA_FIND_REQUIRED)
+  find_package(CUDA REQUIRED)
+else()
+  find_package(CUDA)
 endif()
 # MAGMA depends on cuBLAS which should come with CUDA, if not found -> error
 if (NOT CUDA_CUBLAS_LIBRARIES)
@@ -87,20 +85,16 @@ if (NOT CUDA_CUBLAS_LIBRARIES)
   endif()
 endif()
 # MAGMA depends on LAPACK anyway, try to find it
-if (NOT LAPACK_FOUND)
-  if(MAGMA_FIND_REQUIRED)
-    find_package(LAPACKEXT REQUIRED)
-  else()
-    find_package(LAPACKEXT)
-  endif()
+if(MAGMA_FIND_REQUIRED)
+  find_package(LAPACK REQUIRED)
+else()
+  find_package(LAPACK)
 endif()
 # MAGMA depends on CBLAS anyway, try to find it
-if (NOT CBLAS_FOUND)
-  if(MAGMA_FIND_REQUIRED)
-    find_package(CBLAS REQUIRED)
-  else()
-    find_package(CBLAS)
-  endif()
+if(MAGMA_FIND_REQUIRED)
+  find_package(CBLAS REQUIRED)
+else()
+  find_package(CBLAS)
 endif()
 
 set(ENV_MAGMA_DIR "$ENV{MAGMA_DIR}")
diff --git a/modules/find/FindMETIS.cmake b/modules/find/FindMETIS.cmake
index a50af750a44a4fbb49dea0bfe2c2b8dac99263fa..446b973f2aac9ed085435b1f83a42e2cf9898cc1 100644
--- a/modules/find/FindMETIS.cmake
+++ b/modules/find/FindMETIS.cmake
@@ -210,15 +210,12 @@ if(METIS_LIBRARIES)
   find_library(M_LIBRARY NAMES m)
   mark_as_advanced(M_LIBRARY)
   if(M_LIBRARY)
-    list(APPEND REQUIRED_LIBS "-lm")
+    list(APPEND REQUIRED_LIBS "${M_LIBRARY}")
   endif()
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
   set(CMAKE_REQUIRED_LIBRARIES)
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -233,6 +230,7 @@ if(METIS_LIBRARIES)
       message(STATUS "Looking for METIS : test of METIS_NodeND with METIS library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindMUMPS.cmake b/modules/find/FindMUMPS.cmake
index 4e991e310559f80678671f4a9a6871257d337c56..d4a5067f10a0db2e4c53016b24c59c9eb85e7a25 100644
--- a/modules/find/FindMUMPS.cmake
+++ b/modules/find/FindMUMPS.cmake
@@ -34,14 +34,17 @@
 #
 # This module finds headers and mumps library.
 # Results are reported in variables:
-#  MUMPS_FOUND            - True if headers and requested libraries were found
-#  MUMPS_LINKER_FLAGS     - list of required linker flags (excluding -l and -L)
-#  MUMPS_INCLUDE_DIRS     - mumps include directories
-#  MUMPS_LIBRARY_DIRS     - Link directories for mumps libraries
-#  MUMPS_LIBRARIES        - mumps libraries
-#  MUMPS_INCLUDE_DIRS_DEP - mumps + dependencies include directories
-#  MUMPS_LIBRARY_DIRS_DEP - mumps + dependencies link directories
-#  MUMPS_LIBRARIES_DEP    - mumps libraries + dependencies
+#  MUMPS_FOUND             - True if headers and requested libraries were found
+#  MUMPS_CFLAGS_OTHER      - mumps compiler flags without headers paths
+#  MUMPS_LDFLAGS_OTHER     - mumps linker flags without libraries
+#  MUMPS_INCLUDE_DIRS      - mumps include directories
+#  MUMPS_LIBRARY_DIRS      - mumps link directories
+#  MUMPS_LIBRARIES         - mumps libraries to be linked (absolute path)
+#  MUMPS_CFLAGS_OTHER_DEP  - mumps + dependencies compiler flags without headers paths
+#  MUMPS_LDFLAGS_OTHER_DEP - mumps + dependencies linker flags without libraries
+#  MUMPS_INCLUDE_DIRS_DEP  - mumps + dependencies include directories
+#  MUMPS_LIBRARY_DIRS_DEP  - mumps + dependencies link directories
+#  MUMPS_LIBRARIES_DEP     - mumps + dependencies libraries
 #
 # The user can give specific paths where to find the libraries adding cmake
 # options at configure (ex: cmake path/to/project -DMUMPS_DIR=path/to/mumps):
@@ -133,12 +136,10 @@ endif()
 if (NOT MUMPS_FIND_QUIETLY)
   message(STATUS "Looking for MUMPS - Try to detect pthread")
 endif()
-if (NOT Threads_FOUND)
-  if (MUMPS_FIND_REQUIRED)
-    find_package(Threads REQUIRED)
-  else()
-    find_package(Threads)
-  endif()
+if (MUMPS_FIND_REQUIRED)
+  find_package(Threads REQUIRED)
+else()
+  find_package(Threads)
 endif()
 set(MUMPS_EXTRA_LIBRARIES "")
 if( THREADS_FOUND )
@@ -150,12 +151,10 @@ endif ()
 if (NOT MUMPS_FIND_QUIETLY)
   message(STATUS "Looking for MUMPS - Try to detect BLAS")
 endif()
-if (NOT BLASEXT_FOUND)
-  if (MUMPS_FIND_REQUIRED)
-    find_package(BLASEXT REQUIRED)
-  else()
-    find_package(BLASEXT)
-  endif()
+if (MUMPS_FIND_REQUIRED)
+  find_package(BLAS REQUIRED)
+else()
+  find_package(BLAS)
 endif()
 
 # Optional dependencies
@@ -163,7 +162,7 @@ endif()
 
 # MUMPS may depend on MPI
 #------------------------
-if (NOT MPI_FOUND AND MUMPS_LOOK_FOR_MPI)
+if (MUMPS_LOOK_FOR_MPI)
   if (NOT MUMPS_FIND_QUIETLY)
     message(STATUS "Looking for MUMPS - Try to detect MPI")
   endif()
@@ -182,11 +181,11 @@ if (NOT MPI_FOUND AND MUMPS_LOOK_FOR_MPI)
     mark_as_advanced(MPI_LIBRARY)
     mark_as_advanced(MPI_EXTRA_LIBRARY)
   endif()
-endif (NOT MPI_FOUND AND MUMPS_LOOK_FOR_MPI)
+endif (MUMPS_LOOK_FOR_MPI)
 
 # MUMPS may depend on ScaLAPACK (if MPI version)
 #-----------------------------------------------
-if (NOT SCALAPACK_FOUND AND MUMPS_LOOK_FOR_MPI)
+if (MUMPS_LOOK_FOR_MPI)
   if (NOT MUMPS_FIND_QUIETLY)
     message(STATUS "Looking for MUMPS - Try to detect SCALAPACK")
   endif()
@@ -196,7 +195,7 @@ if (NOT SCALAPACK_FOUND AND MUMPS_LOOK_FOR_MPI)
   else()
     find_package(SCALAPACK)
   endif()
-endif (NOT SCALAPACK_FOUND AND MUMPS_LOOK_FOR_MPI)
+endif (MUMPS_LOOK_FOR_MPI)
 
 # MUMPS may depends on SCOTCH
 #----------------------------
@@ -226,7 +225,7 @@ endif()
 
 # MUMPS may depends on METIS
 #---------------------------
-if (NOT METIS_FOUND AND MUMPS_LOOK_FOR_METIS)
+if (MUMPS_LOOK_FOR_METIS)
   if (NOT MUMPS_FIND_QUIETLY)
     message(STATUS "Looking for MUMPS - Try to detect METIS")
   endif()
@@ -239,7 +238,7 @@ endif()
 
 # MUMPS may depends on PARMETIS
 #------------------------------
-if (NOT PARMETIS_FOUND AND MUMPS_LOOK_FOR_PARMETIS)
+if (MUMPS_LOOK_FOR_PARMETIS)
   if (NOT MUMPS_FIND_QUIETLY)
     message(STATUS "Looking for MUMPS - Try to detect PARMETIS")
   endif()
@@ -252,7 +251,7 @@ endif()
 
 # MUMPS may depends on OPENMP
 #------------------------------
-if (NOT OPENMP_FOUND AND MUMPS_LOOK_FOR_OPENMP)
+if (MUMPS_LOOK_FOR_OPENMP)
   if (NOT MUMPS_FIND_QUIETLY)
     message(STATUS "Looking for MUMPS - Try to detect OPENMP")
   endif()
@@ -564,8 +563,9 @@ list(REMOVE_DUPLICATES MUMPS_INCLUDE_DIRS)
 # check a function to validate the find
 if(MUMPS_LIBRARIES)
 
-  set(REQUIRED_LDFLAGS)
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -573,26 +573,32 @@ if(MUMPS_LIBRARIES)
   if (MUMPS_INCLUDE_DIRS)
     set(REQUIRED_INCDIRS "${MUMPS_INCLUDE_DIRS}")
   endif()
-  foreach(libdir ${MUMPS_LIBRARY_DIRS})
-    if (libdir)
-      list(APPEND REQUIRED_LIBDIRS "${libdir}")
-    endif()
-  endforeach()
+  if (MUMPS_CFLAGS_OTHER)
+    set(REQUIRED_FLAGS "${MUMPS_CFLAGS_OTHER}")
+  endif()
+  if (MUMPS_LDFLAGS_OTHER)
+    set(REQUIRED_LDFLAGS "${MUMPS_LDFLAGS_OTHER}")
+  endif()
+  if (MUMPS_LIBRARY_DIRS)
+    set(REQUIRED_LIBDIRS "${MUMPS_LIBRARY_DIRS}")
+  endif()
   set(REQUIRED_LIBS "${MUMPS_LIBRARIES}")
-
   # SCALAPACK
   if (MUMPS_LOOK_FOR_MPI AND SCALAPACK_FOUND)
-    if (SCALAPACK_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${SCALAPACK_INCLUDE_DIRS}")
+    if (SCALAPACK_INCLUDE_DIRS_DEP)
+      list(APPEND REQUIRED_INCDIRS "${SCALAPACK_INCLUDE_DIRS_DEP}")
     endif()
-    foreach(libdir ${SCALAPACK_LIBRARY_DIRS})
-      if (libdir)
-        list(APPEND REQUIRED_LIBDIRS "${libdir}")
-      endif()
-    endforeach()
-    list(APPEND REQUIRED_LIBS "${SCALAPACK_LIBRARIES}")
-    if (SCALAPACK_LINKER_FLAGS)
-      list(APPEND REQUIRED_LDFLAGS "${SCALAPACK_LINKER_FLAGS}")
+    if (SCALAPACK_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${SCALAPACK_CFLAGS_OTHER_DEP}")
+    endif()
+    if (SCALAPACK_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${SCALAPACK_LDFLAGS_OTHER_DEP}")
+    endif()
+    if(SCALAPACK_LIBRARY_DIRS_DEP)
+      list(APPEND REQUIRED_LIBDIRS "${SCALAPACK_LIBRARY_DIRS_DEP}")
+    endif()
+    if (SCALAPACK_LIBRARIES_DEP)
+      list(APPEND REQUIRED_LIBS "${SCALAPACK_LIBRARIES_DEP}")
     endif()
   endif()
   # MPI
@@ -608,21 +614,6 @@ if(MUMPS_LIBRARIES)
     endif()
     list(APPEND REQUIRED_LIBS "${MPI_Fortran_LIBRARIES}")
   endif()
-  # BLAS
-  if (BLAS_FOUND)
-    if (BLAS_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}")
-    endif()
-    foreach(libdir ${BLAS_LIBRARY_DIRS})
-      if (libdir)
-        list(APPEND REQUIRED_LIBDIRS "${libdir}")
-      endif()
-    endforeach()
-    list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}")
-    if (BLAS_LINKER_FLAGS)
-      list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
-    endif()
-  endif()
   # SCOTCH
   if (MUMPS_LOOK_FOR_SCOTCH AND SCOTCH_FOUND)
     if (SCOTCH_INCLUDE_DIRS)
@@ -661,15 +652,21 @@ if(MUMPS_LIBRARIES)
   endif()
   # PARMETIS
   if (MUMPS_LOOK_FOR_PARMETIS AND PARMETIS_FOUND)
-    if (PARMETIS_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${PARMETIS_INCLUDE_DIRS}")
+    if (PARMETIS_INCLUDE_DIRS_DEP)
+      list(APPEND REQUIRED_INCDIRS "${PARMETIS_INCLUDE_DIRS_DEP}")
+    endif()
+    if (PARMETIS_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${PARMETIS_CFLAGS_OTHER_DEP}")
+    endif()
+    if (PARMETIS_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${PARMETIS_LDFLAGS_OTHER_DEP}")
+    endif()
+    if(PARMETIS_LIBRARY_DIRS_DEP)
+      list(APPEND REQUIRED_LIBDIRS "${PARMETIS_LIBRARY_DIRS_DEP}")
+    endif()
+    if (PARMETIS_LIBRARIES_DEP)
+      list(APPEND REQUIRED_LIBS "${PARMETIS_LIBRARIES_DEP}")
     endif()
-    foreach(libdir ${PARMETIS_LIBRARY_DIRS})
-      if (libdir)
-        list(APPEND REQUIRED_LIBDIRS "${libdir}")
-      endif()
-    endforeach()
-    list(APPEND REQUIRED_LIBS "${PARMETIS_LIBRARIES}")
   endif()
   # OpenMP
   if(MUMPS_LOOK_FOR_OPENMP AND OPENMP_FOUND)
@@ -702,11 +699,22 @@ if(MUMPS_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
+  set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -735,10 +743,11 @@ if(MUMPS_LIBRARIES)
     set(MUMPS_LIBRARIES_DEP "${REQUIRED_LIBS}")
     set(MUMPS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
     set(MUMPS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
-    set(MUMPS_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
+    set(MUMPS_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(MUMPS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
     list(REMOVE_DUPLICATES MUMPS_LIBRARY_DIRS_DEP)
-    list(REMOVE_DUPLICATES MUMPS_INCLUDE_DIRS_DEP)
-    list(REMOVE_DUPLICATES MUMPS_LINKER_FLAGS)
+    list(REMOVE_DUPLICATES MUMPS_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES MUMPS_LDFLAGS_OTHER_DEP)
   else()
     if(NOT MUMPS_FIND_QUIETLY)
       message(STATUS "Looking for MUMPS : test of [sdcz]mumps() fails")
diff --git a/modules/find/FindPAMPA.cmake b/modules/find/FindPAMPA.cmake
index 8ff5e466e3ba795ec4ca6b3da21f75b6262609b6..4a04983fe05f967e3e30df355dfbaf53fd1573dc 100644
--- a/modules/find/FindPAMPA.cmake
+++ b/modules/find/FindPAMPA.cmake
@@ -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.
 #
 ###
@@ -20,10 +20,17 @@
 #
 # This module finds headers and pampa library.
 # Results are reported in variables:
-#  PAMPA_FOUND           - True if headers and requested libraries were found
-#  PAMPA_INCLUDE_DIRS    - pampa include directories
-#  PAMPA_LIBRARY_DIRS    - Link directories for pampa libraries
-#  PAMPA_LIBRARIES       - pampa component libraries to be linked
+#  PAMPA_FOUND             - True if headers and requested libraries were found
+#  PAMPA_CFLAGS_OTHER      - pampa compiler flags without headers paths
+#  PAMPA_LDFLAGS_OTHER     - pampa linker flags without libraries
+#  PAMPA_INCLUDE_DIRS      - pampa include directories
+#  PAMPA_LIBRARY_DIRS      - pampa link directories
+#  PAMPA_LIBRARIES         - pampa libraries to be linked (absolute path)
+#  PAMPA_CFLAGS_OTHER_DEP  - pampa + dependencies compiler flags without headers paths
+#  PAMPA_LDFLAGS_OTHER_DEP - pampa + dependencies linker flags without libraries
+#  PAMPA_INCLUDE_DIRS_DEP  - pampa + dependencies include directories
+#  PAMPA_LIBRARY_DIRS_DEP  - pampa + dependencies link directories
+#  PAMPA_LIBRARIES_DEP     - pampa + dependencies libraries
 #  PAMPA_INTSIZE         - Number of octets occupied by a PAMPA_Num
 #
 # The user can give specific paths where to find the libraries adding cmake
@@ -35,11 +42,11 @@
 # are not given as cmake variable: PAMPA_DIR, PAMPA_INCDIR, PAMPA_LIBDIR
 
 #=============================================================================
-# Copyright 2012-2013 Inria
+# Copyright 2012-2018 Inria
 # Copyright 2012-2013 Emmanuel Agullo
 # Copyright 2012-2013 Mathieu Faverge
 # Copyright 2012      Cedric Castagnede
-# Copyright 2013-2016 Florent Pruvost
+# Copyright 2013-2018 Florent Pruvost
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file MORSE-Copyright.txt for details.
@@ -59,21 +66,17 @@ if (NOT PAMPA_FOUND)
 endif()
 
 # PAMPA depends on MPI, try to find it
-if (NOT MPI_FOUND)
-  if (PAMPA_FIND_REQUIRED)
-    find_package(MPI REQUIRED)
-  else()
-    find_package(MPI)
-  endif()
+if (PAMPA_FIND_REQUIRED)
+  find_package(MPI REQUIRED)
+else()
+  find_package(MPI)
 endif()
 
 # PAMPA depends on PAMPA, try to find it
-if (NOT PTSCOTCH_FOUND)
-  if (PAMPA_FIND_REQUIRED)
-    find_package(PTSCOTCH REQUIRED)
-  else()
-    find_package(PTSCOTCH)
-  endif()
+if (PAMPA_FIND_REQUIRED)
+  find_package(PTSCOTCH REQUIRED)
+else()
+  find_package(PTSCOTCH)
 endif()
 
 # Looking for include
@@ -243,8 +246,9 @@ list(REMOVE_DUPLICATES PAMPA_LIBRARY_DIRS)
 # check a function to validate the find
 if(PAMPA_LIBRARIES)
 
-  set(REQUIRED_LDFLAGS)
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -272,10 +276,16 @@ if(PAMPA_LIBRARIES)
     list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}")
   endif()
   # PTSCOTCH
-  if (PTSCOTCH_INCLUDE_DIRS)
-    list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}")
+  if (PTSCOTCH_INCLUDE_DIRS_DEP)
+    list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS_DEP}")
+  endif()
+  if (PTSCOTCH_CFLAGS_OTHER_DEP)
+    list(APPEND REQUIRED_FLAGS "${PTSCOTCH_CFLAGS_OTHER_DEP}")
   endif()
-  foreach(libdir ${PTSCOTCH_LIBRARY_DIRS})
+  if (PTSCOTCH_LDFLAGS_OTHER_DEP)
+    list(APPEND REQUIRED_LDFLAGS "${PTSCOTCH_LDFLAGS_OTHER_DEP}")
+  endif()
+  foreach(libdir ${PTSCOTCH_LIBRARY_DIRS_DEP})
     if (libdir)
       list(APPEND REQUIRED_LIBDIRS "${libdir}")
     endif()
@@ -283,13 +293,23 @@ if(PAMPA_LIBRARIES)
   list(APPEND REQUIRED_LIBS "${PTSCOTCH_LIBRARIES_DEP}")
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
+  set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
-  list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
   # test link
@@ -303,15 +323,17 @@ if(PAMPA_LIBRARIES)
     set(PAMPA_LIBRARIES_DEP "${REQUIRED_LIBS}")
     set(PAMPA_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
     set(PAMPA_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
-    set(PAMPA_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
+    set(PAMPA_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(PAMPA_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
     list(REMOVE_DUPLICATES PAMPA_LIBRARY_DIRS_DEP)
-    list(REMOVE_DUPLICATES PAMPA_INCLUDE_DIRS_DEP)
-    list(REMOVE_DUPLICATES PAMPA_LINKER_FLAGS)
+    list(REMOVE_DUPLICATES PAMPA_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES PAMPA_LDFLAGS_OTHER_DEP)
   else()
     if(NOT PAMPA_FIND_QUIETLY)
       message(STATUS "Looking for PAMPA : test of PAMPA_dmeshInit with PAMPA library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindPAPI.cmake b/modules/find/FindPAPI.cmake
index adaf9a017914a13cdcec15dbe0c0e5fe15ccadec..35a5fd82661e18ede504038af1be1614fc24d442 100644
--- a/modules/find/FindPAPI.cmake
+++ b/modules/find/FindPAPI.cmake
@@ -16,7 +16,6 @@
 # This module finds headers and papi library.
 # Results are reported in variables:
 #  PAPI_FOUND           - True if headers and requested libraries were found
-#  PAPI_C_FLAGS         - list of required compilation flags (excluding -I)
 #  PAPI_INCLUDE_DIRS    - papi include directories
 #  PAPI_LIBRARY_DIRS    - Link directories for papi libraries
 #  PAPI_LIBRARIES       - papi component libraries to be linked
@@ -258,6 +257,8 @@ endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PAPI_FOUND)
 if(PAPI_LIBRARIES)
 
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -278,12 +279,22 @@ if(PAPI_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
   set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -298,6 +309,7 @@ if(PAPI_LIBRARIES)
       message(STATUS "Looking for papi : test of PAPI_start with papi library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindPARMETIS.cmake b/modules/find/FindPARMETIS.cmake
index 427f046d83e49057fe516f648db8a1c0236104f7..79a67ad187f3d6d6cc5055e0fe7279b41320ecf3 100644
--- a/modules/find/FindPARMETIS.cmake
+++ b/modules/find/FindPARMETIS.cmake
@@ -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-2017 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.
 #
 ###
@@ -20,28 +20,32 @@
 #
 # This module finds headers and parmetis library.
 # Results are reported in variables:
-#  PARMETIS_FOUND           - True if headers and requested libraries were found
-#  PARMETIS_INCLUDE_DIRS    - parmetis include directories
-#  PARMETIS_LIBRARY_DIRS    - Link directories for parmetis libraries
-#  PARMETIS_LIBRARIES       - parmetis component libraries to be linked
+#  PARMETIS_FOUND             - True if headers and requested libraries were found
+#  PARMETIS_CFLAGS_OTHER      - parmetis compiler flags without headers paths
+#  PARMETIS_LDFLAGS_OTHER     - parmetis linker flags without libraries
+#  PARMETIS_INCLUDE_DIRS      - parmetis include directories
+#  PARMETIS_LIBRARY_DIRS      - parmetis link directories
+#  PARMETIS_LIBRARIES         - parmetis libraries to be linked (absolute path)
+#  PARMETIS_CFLAGS_OTHER_DEP  - parmetis + dependencies compiler flags without headers paths
+#  PARMETIS_LDFLAGS_OTHER_DEP - parmetis + dependencies linker flags without libraries
+#  PARMETIS_INCLUDE_DIRS_DEP  - parmetis + dependencies include directories
+#  PARMETIS_LIBRARY_DIRS_DEP  - parmetis + dependencies link directories
+#  PARMETIS_LIBRARIES_DEP     - parmetis + dependencies libraries
 #
 # The user can give specific paths where to find the libraries adding cmake
 # options at configure (ex: cmake path/to/project -DPARMETIS_DIR=path/to/parmetis):
 #  PARMETIS_DIR              - Where to find the base directory of parmetis
 #  PARMETIS_INCDIR           - Where to find the header files
 #  PARMETIS_LIBDIR           - Where to find the library files
-#  PARMETIS_INCLUDE_DIRS_DEP - parmetis + dependencies include directories
-#  PARMETIS_LIBRARY_DIRS_DEP - parmetis + dependencies link directories
-#  PARMETIS_LIBRARIES_DEP    - parmetis libraries + dependencies
 # The module can also look for the following environment variables if paths
 # are not given as cmake variable: PARMETIS_DIR, PARMETIS_INCDIR, PARMETIS_LIBDIR
 
 #=============================================================================
-# Copyright 2012-2013 Inria
+# Copyright 2012-2018 Inria
 # Copyright 2012-2013 Emmanuel Agullo
 # Copyright 2012-2013 Mathieu Faverge
 # Copyright 2012      Cedric Castagnede
-# Copyright 2017      Florent Pruvost
+# Copyright 2013-2018 Florent Pruvost
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file MORSE-Copyright.txt for details.
@@ -61,21 +65,17 @@ if (NOT PARMETIS_FOUND)
 endif()
 
 # PARMETIS depends on METIS, try to find it
-if (NOT METIS_FOUND)
-  if(PARMETIS_FIND_REQUIRED)
-    find_package(METIS REQUIRED)
-  else()
-    find_package(METIS)
-  endif()
+if(PARMETIS_FIND_REQUIRED)
+  find_package(METIS REQUIRED)
+else()
+  find_package(METIS)
 endif()
 
 # PARMETIS depends on MPI, try to find it
-if (NOT MPI_FOUND)
-  if(PARMETIS_FIND_REQUIRED)
-    find_package(MPI REQUIRED)
-  else()
-    find_package(MPI)
-  endif()
+if(PARMETIS_FIND_REQUIRED)
+  find_package(MPI REQUIRED)
+else()
+  find_package(MPI)
 endif()
 
 # Looking for include
@@ -218,6 +218,8 @@ endif ()
 if(PARMETIS_LIBRARIES)
 
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -258,15 +260,27 @@ if(PARMETIS_LIBRARIES)
   find_library(M_LIBRARY NAMES m)
   mark_as_advanced(M_LIBRARY)
   if(M_LIBRARY)
-    list(APPEND REQUIRED_LIBS "-lm")
+    list(APPEND REQUIRED_LIBS "${M_LIBRARY}")
   endif()
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
+  set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
+  list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -281,15 +295,17 @@ if(PARMETIS_LIBRARIES)
     set(PARMETIS_LIBRARIES_DEP "${REQUIRED_LIBS}")
     set(PARMETIS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
     set(PARMETIS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
-    set(PARMETIS_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
+    set(PARMETIS_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(PARMETIS_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
     list(REMOVE_DUPLICATES PARMETIS_LIBRARY_DIRS_DEP)
-    list(REMOVE_DUPLICATES PARMETIS_INCLUDE_DIRS_DEP)
-    list(REMOVE_DUPLICATES PARMETIS_LINKER_FLAGS)
+    list(REMOVE_DUPLICATES PARMETIS_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES PARMETIS_LDFLAGS_OTHER_DEP)
   else()
     if(NOT PARMETIS_FIND_QUIETLY)
       message(STATUS "Looking for PARMETIS : test of ParMETIS_V3_NodeND with PARMETIS library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindPARSEC.cmake b/modules/find/FindPARSEC.cmake
index 2e8d5a62c466df9277d0fbddf81b464cf610bc50..e72cd0c3233b0c4a9a60a790a1003578cbaafe56 100644
--- a/modules/find/FindPARSEC.cmake
+++ b/modules/find/FindPARSEC.cmake
@@ -28,15 +28,17 @@
 #   - AYUDAME: ??
 #
 # Results are reported in variables:
-#  PARSEC_FOUND                  - True if headers and requested libraries were found
-#  PARSEC_INCLUDE_DIRS           - parsec include directories
-#  PARSEC_LIBRARY_DIRS           - Link directories for parsec libraries
-#  PARSEC_LIBRARIES              - parsec libraries
-#  PARSEC_INCLUDE_DIRS_DEP       - parsec + dependencies include directories
-#  PARSEC_LIBRARY_DIRS_DEP       - parsec + dependencies link directories
-#  PARSEC_LIBRARIES_DEP          - parsec libraries + dependencies
-#  PARSEC_parsec_ptgpp_BIN_DIR   - path to parsec driver parsec_ptgpp
-#  PARSEC_PARSEC_PTGPP           - parsec jdf compiler
+#  PARSEC_FOUND             - True if headers and requested libraries were found
+#  PARSEC_CFLAGS_OTHER      - parsec compiler flags without headers paths
+#  PARSEC_LDFLAGS_OTHER     - parsec linker flags without libraries
+#  PARSEC_INCLUDE_DIRS      - parsec include directories
+#  PARSEC_LIBRARY_DIRS      - parsec link directories
+#  PARSEC_LIBRARIES         - parsec libraries to be linked (absolute path)
+#  PARSEC_CFLAGS_OTHER_DEP  - parsec + dependencies compiler flags without headers paths
+#  PARSEC_LDFLAGS_OTHER_DEP - parsec + dependencies linker flags without libraries
+#  PARSEC_INCLUDE_DIRS_DEP  - parsec + dependencies include directories
+#  PARSEC_LIBRARY_DIRS_DEP  - parsec + dependencies link directories
+#  PARSEC_LIBRARIES_DEP     - parsec + dependencies libraries
 #
 #  PARSEC_FOUND_WITH_PKGCONFIG - True if found with pkg-config
 #  if found with pkg-config the following variables are set
@@ -181,7 +183,7 @@ if (PARSEC_DL_LIBRARY)
 endif()
 
 # PARSEC may depend on HWLOC, try to find it
-if (NOT HWLOC_FOUND AND PARSEC_LOOK_FOR_HWLOC)
+if (PARSEC_LOOK_FOR_HWLOC)
   if (PARSEC_FIND_REQUIRED)
     find_package(HWLOC REQUIRED)
   else()
@@ -190,7 +192,7 @@ if (NOT HWLOC_FOUND AND PARSEC_LOOK_FOR_HWLOC)
 endif()
 
 # PARSEC may depend on CUDA, try to find it
-if (NOT CUDA_FOUND AND PARSEC_LOOK_FOR_CUDA)
+if (PARSEC_LOOK_FOR_CUDA)
   if (PARSEC_FIND_REQUIRED AND PARSEC_FIND_REQUIRED_CUDA)
     find_package(CUDA REQUIRED)
   else()
@@ -206,7 +208,7 @@ if (NOT CUDA_FOUND AND PARSEC_LOOK_FOR_CUDA)
 endif()
 
 # PARSEC may depend on MPI, try to find it
-if (NOT MPI_FOUND AND PARSEC_LOOK_FOR_MPI)
+if (PARSEC_LOOK_FOR_MPI)
   if (PARSEC_FIND_REQUIRED AND PARSEC_FIND_REQUIRED_MPI)
     find_package(MPI REQUIRED)
   else()
@@ -527,16 +529,16 @@ if(PARSEC_LIBRARIES)
     if (HWLOC_INCLUDE_DIRS)
       list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}")
     endif()
+    if (HWLOC_CFLAGS_OTHER)
+      list(APPEND REQUIRED_FLAGS "${HWLOC_CFLAGS_OTHER}")
+    endif()
+    if (HWLOC_LDFLAGS_OTHER)
+      list(APPEND REQUIRED_LDFLAGS "${HWLOC_LDFLAGS_OTHER}")
+    endif()
     if (HWLOC_LIBRARY_DIRS)
       list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}")
     endif()
-    foreach(lib ${HWLOC_LIBRARIES})
-      if (EXISTS ${lib} OR ${lib} MATCHES "^-")
-        list(APPEND REQUIRED_LIBS "${lib}")
-      else()
-        list(APPEND REQUIRED_LIBS "-l${lib}")
-      endif()
-    endforeach()
+    list(APPEND REQUIRED_LIBS "${HWLOC_LIBRARIES}")
   endif()
   # MPI
   if (MPI_FOUND AND PARSEC_LOOK_FOR_MPI)
@@ -588,14 +590,23 @@ if(PARSEC_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
   set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
-  list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
   # test link
@@ -609,13 +620,17 @@ if(PARSEC_LIBRARIES)
     set(PARSEC_LIBRARIES_DEP "${REQUIRED_LIBS}")
     set(PARSEC_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
     set(PARSEC_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
+    set(PARSEC_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(PARSEC_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
     list(REMOVE_DUPLICATES PARSEC_LIBRARY_DIRS_DEP)
-    list(REMOVE_DUPLICATES PARSEC_INCLUDE_DIRS_DEP)
+    list(REMOVE_DUPLICATES PARSEC_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES PARSEC_LDFLAGS_OTHER_DEP)
   else()
     if(NOT PARSEC_FIND_QUIETLY)
       message(STATUS "Looking for parsec : test of parsec_init fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
       message(STATUS "Maybe PARSEC is linked with specific libraries. "
         "Have you tried with COMPONENTS (HWLOC, CUDA, MPI)? "
diff --git a/modules/find/FindPASTIX.cmake b/modules/find/FindPASTIX.cmake
index fca9f3156475f6988a72678897b3897111ef409a..f3523ce6755095d7b5cf8d0e3dda1761018c29b7 100644
--- a/modules/find/FindPASTIX.cmake
+++ b/modules/find/FindPASTIX.cmake
@@ -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-2014 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.
 #
 ###
@@ -39,15 +39,33 @@
 #
 # This module finds headers and pastix library.
 # Results are reported in variables:
-#  PASTIX_FOUND            - True if headers and requested libraries were found
-#  PASTIX_LINKER_FLAGS     - list of required linker flags (excluding -l and -L)
-#  PASTIX_INCLUDE_DIRS     - pastix include directories
-#  PASTIX_LIBRARY_DIRS     - Link directories for pastix libraries
-#  PASTIX_LIBRARIES        - pastix libraries
-#  PASTIX_INCLUDE_DIRS_DEP - pastix + dependencies include directories
-#  PASTIX_LIBRARY_DIRS_DEP - pastix + dependencies link directories
-#  PASTIX_LIBRARIES_DEP    - pastix libraries + dependencies
-#  PASTIX_INTSIZE          - Number of octets occupied by a pastix_int_t
+#  PASTIX_FOUND             - True if headers and requested libraries were found
+#  PASTIX_CFLAGS_OTHER      - pastix compiler flags without headers paths
+#  PASTIX_LDFLAGS_OTHER     - pastix linker flags without libraries
+#  PASTIX_INCLUDE_DIRS      - pastix include directories
+#  PASTIX_LIBRARY_DIRS      - pastix link directories
+#  PASTIX_LIBRARIES         - pastix libraries to be linked (absolute path)
+#  PASTIX_CFLAGS_OTHER_DEP  - pastix + dependencies compiler flags without headers paths
+#  PASTIX_LDFLAGS_OTHER_DEP - pastix + dependencies linker flags without libraries
+#  PASTIX_INCLUDE_DIRS_DEP  - pastix + dependencies include directories
+#  PASTIX_LIBRARY_DIRS_DEP  - pastix + dependencies link directories
+#  PASTIX_LIBRARIES_DEP     - pastix + dependencies libraries
+#  PASTIX_INTSIZE           - Number of octets occupied by a pastix_int_t
+#  PASTIX_VERSION_MAJOR     - pastix Version, first (major) number
+#
+#  PASTIX_FOUND_WITH_PKGCONFIG - True if found with pkg-config
+#  if found with pkg-config the following variables are set
+#  <PREFIX>  = PASTIX
+#  <XPREFIX> = <PREFIX>        for common case
+#  <XPREFIX> = <PREFIX>_STATIC for static linking
+#  <XPREFIX>_FOUND          ... set to 1 if module(s) exist
+#  <XPREFIX>_LIBRARIES      ... only the libraries (w/o the '-l')
+#  <XPREFIX>_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
+#  <XPREFIX>_LDFLAGS        ... all required linker flags
+#  <XPREFIX>_LDFLAGS_OTHER  ... all other linker flags
+#  <XPREFIX>_INCLUDE_DIRS   ... the '-I' preprocessor flags (w/o the '-I')
+#  <XPREFIX>_CFLAGS         ... all required cflags
+#  <XPREFIX>_CFLAGS_OTHER   ... the other compiler flags
 #
 # The user can give specific paths where to find the libraries adding cmake
 # options at configure (ex: cmake path/to/project -DPASTIX_DIR=path/to/pastix):
@@ -62,7 +80,7 @@
 # Copyright 2012-2013 Emmanuel Agullo
 # Copyright 2012-2013 Mathieu Faverge
 # Copyright 2012      Cedric Castagnede
-# Copyright 2013      Florent Pruvost
+# Copyright 2013-2018 Florent Pruvost
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file MORSE-Copyright.txt for details.
@@ -136,7 +154,6 @@ endif()
 # Dependencies detection
 # ----------------------
 
-
 # Required dependencies
 # ---------------------
 
@@ -215,9 +232,9 @@ if (NOT PASTIX_FIND_QUIETLY)
   message(STATUS "Looking for PASTIX - Try to detect BLAS")
 endif()
 if (PASTIX_FIND_REQUIRED)
-  find_package(BLASEXT REQUIRED)
+  find_package(BLAS REQUIRED)
 else()
-  find_package(BLASEXT)
+  find_package(BLAS)
 endif()
 
 # Optional dependencies
@@ -225,7 +242,7 @@ endif()
 
 # PASTIX may depend on MPI
 #-------------------------
-if (NOT MPI_FOUND AND PASTIX_LOOK_FOR_MPI)
+if (PASTIX_LOOK_FOR_MPI)
   if (NOT PASTIX_FIND_QUIETLY)
     message(STATUS "Looking for PASTIX - Try to detect MPI")
   endif()
@@ -244,11 +261,11 @@ if (NOT MPI_FOUND AND PASTIX_LOOK_FOR_MPI)
     mark_as_advanced(MPI_LIBRARY)
     mark_as_advanced(MPI_EXTRA_LIBRARY)
   endif()
-endif (NOT MPI_FOUND AND PASTIX_LOOK_FOR_MPI)
+endif (PASTIX_LOOK_FOR_MPI)
 
 # PASTIX may depends on SCOTCH
 #-----------------------------
-if (NOT PARSEC_FOUND AND PASTIX_LOOK_FOR_PARSEC)
+if (PASTIX_LOOK_FOR_PARSEC)
   if (NOT PASTIX_FIND_QUIETLY)
     message(STATUS "Looking for PASTIX - Try to detect PARSEC")
   endif()
@@ -261,7 +278,7 @@ endif()
 
 # PASTIX may depend on STARPU
 #----------------------------
-if( NOT STARPU_FOUND AND PASTIX_LOOK_FOR_STARPU)
+if(PASTIX_LOOK_FOR_STARPU)
 
   if (NOT PASTIX_FIND_QUIETLY)
     message(STATUS "Looking for PASTIX - Try to detect StarPU")
@@ -298,11 +315,11 @@ if( NOT STARPU_FOUND AND PASTIX_LOOK_FOR_STARPU)
       COMPONENTS ${STARPU_COMPONENT_LIST})
   endif()
 
-endif( NOT STARPU_FOUND AND PASTIX_LOOK_FOR_STARPU)
+endif(PASTIX_LOOK_FOR_STARPU)
 
 # PASTIX may depends on SCOTCH
 #-----------------------------
-if (NOT SCOTCH_FOUND AND PASTIX_LOOK_FOR_SCOTCH)
+if (PASTIX_LOOK_FOR_SCOTCH)
   if (NOT PASTIX_FIND_QUIETLY)
     message(STATUS "Looking for PASTIX - Try to detect SCOTCH")
   endif()
@@ -315,7 +332,7 @@ endif()
 
 # PASTIX may depends on PTSCOTCH
 #-------------------------------
-if (NOT PTSCOTCH_FOUND AND PASTIX_LOOK_FOR_PTSCOTCH)
+if (PASTIX_LOOK_FOR_PTSCOTCH)
   if (NOT PASTIX_FIND_QUIETLY)
     message(STATUS "Looking for PASTIX - Try to detect PTSCOTCH")
   endif()
@@ -328,7 +345,7 @@ endif()
 
 # PASTIX may depends on METIS
 #----------------------------
-if (NOT METIS_FOUND AND PASTIX_LOOK_FOR_METIS)
+if (PASTIX_LOOK_FOR_METIS)
   if (NOT PASTIX_FIND_QUIETLY)
     message(STATUS "Looking for PASTIX - Try to detect METIS")
   endif()
@@ -339,184 +356,233 @@ if (NOT METIS_FOUND AND PASTIX_LOOK_FOR_METIS)
   endif()
 endif()
 
-# Error if pastix required and no partitioning lib found
-if (PASTIX_FIND_REQUIRED AND NOT SCOTCH_FOUND AND NOT PTSCOTCH_FOUND AND NOT METIS_FOUND)
-  message(FATAL_ERROR "Could NOT find any partitioning library on your system"
-    " (install scotch, ptscotch or metis)")
+set(ENV_PASTIX_DIR "$ENV{PASTIX_DIR}")
+set(ENV_PASTIX_INCDIR "$ENV{PASTIX_INCDIR}")
+set(ENV_PASTIX_LIBDIR "$ENV{PASTIX_LIBDIR}")
+set(PASTIX_GIVEN_BY_USER "FALSE")
+if ( PASTIX_DIR OR ( PASTIX_INCDIR AND PASTIX_LIBDIR) OR ENV_PASTIX_DIR OR (ENV_PASTIX_INCDIR AND ENV_PASTIX_LIBDIR) )
+  set(PASTIX_GIVEN_BY_USER "TRUE")
 endif()
 
+# Optionally use pkg-config to detect include/library dirs (if pkg-config is available)
+# -------------------------------------------------------------------------------------
+include(FindPkgConfig)
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_EXECUTABLE AND NOT PASTIX_GIVEN_BY_USER)
 
-# Looking for PaStiX
-# ------------------
+  pkg_search_module(PASTIX pastix)
 
-# Looking for include
-# -------------------
+  if (NOT PASTIX_FIND_QUIETLY)
+    if (PASTIX_FOUND AND PASTIX_LIBRARIES)
+      message(STATUS "Looking for PASTIX - found using PkgConfig")
+    else()
+      message(STATUS "${Magenta}Looking for PASTIX - not found using PkgConfig."
+        "\n   Perhaps you should add the directory containing pastix.pc"
+        "\n   to the PKG_CONFIG_PATH environment variable.${ColourReset}")
+    endif()
+  endif()
 
-# Add system include paths to search include
-# ------------------------------------------
-unset(_inc_env)
-set(ENV_PASTIX_DIR "$ENV{PASTIX_DIR}")
-set(ENV_PASTIX_INCDIR "$ENV{PASTIX_INCDIR}")
-if(ENV_PASTIX_INCDIR)
-  list(APPEND _inc_env "${ENV_PASTIX_INCDIR}")
-elseif(ENV_PASTIX_DIR)
-  list(APPEND _inc_env "${ENV_PASTIX_DIR}")
-  list(APPEND _inc_env "${ENV_PASTIX_DIR}/include")
-  list(APPEND _inc_env "${ENV_PASTIX_DIR}/include/pastix")
-else()
-  if(WIN32)
-    string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
+  if (PASTIX_FOUND AND PASTIX_LIBRARIES)
+    set(PASTIX_FOUND_WITH_PKGCONFIG "TRUE")
+    find_pkgconfig_libraries_absolute_path(PASTIX)
   else()
-    string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
-    list(APPEND _inc_env "${_path_env}")
-    string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
-    list(APPEND _inc_env "${_path_env}")
-    string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
-    list(APPEND _inc_env "${_path_env}")
-    string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
-    list(APPEND _inc_env "${_path_env}")
+    set(PASTIX_FOUND_WITH_PKGCONFIG "FALSE")
   endif()
+
+  set(PASTIX_VERSION_MAJOR)
+  foreach(_lib ${PASTIX_LIBRARIES})
+    if (_lib MATCHES "pastix_murge")
+      set(PASTIX_VERSION_MAJOR "5")
+    endif()
+    if (_lib MATCHES "pastix_kernels")
+      set(PASTIX_VERSION_MAJOR "6")
+    endif()
+  endforeach()
+
+endif(PKG_CONFIG_EXECUTABLE AND NOT PASTIX_GIVEN_BY_USER)
+
+# Error if pastix required and no partitioning lib found
+if (PASTIX_FIND_REQUIRED AND NOT SCOTCH_FOUND AND NOT PTSCOTCH_FOUND AND NOT METIS_FOUND)
+  message(FATAL_ERROR "Could NOT find any partitioning library on your system (install scotch, ptscotch or metis)")
 endif()
-list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
-list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
-list(REMOVE_DUPLICATES _inc_env)
-
-
-# Try to find the pastix header in the given paths
-# ---------------------------------------------------
-# call cmake macro to find the header path
-if(PASTIX_INCDIR)
-  set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND")
-  find_path(PASTIX_pastix.h_DIRS
-    NAMES pastix.h
-    HINTS ${PASTIX_INCDIR})
-else()
-  if(PASTIX_DIR)
-    set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND")
-    find_path(PASTIX_pastix.h_DIRS
-      NAMES pastix.h
-      HINTS ${PASTIX_DIR}
-      PATH_SUFFIXES "include" "include/pastix")
+
+if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PASTIX_FOUND) OR (PASTIX_GIVEN_BY_USER) )
+
+  # Looking for PaStiX
+  # ------------------
+
+  # Looking for include
+  # -------------------
+
+  # Add system include paths to search include
+  # ------------------------------------------
+  unset(_inc_env)
+  set(ENV_PASTIX_DIR "$ENV{PASTIX_DIR}")
+  set(ENV_PASTIX_INCDIR "$ENV{PASTIX_INCDIR}")
+  if(ENV_PASTIX_INCDIR)
+    list(APPEND _inc_env "${ENV_PASTIX_INCDIR}")
+  elseif(ENV_PASTIX_DIR)
+    list(APPEND _inc_env "${ENV_PASTIX_DIR}")
+    list(APPEND _inc_env "${ENV_PASTIX_DIR}/include")
+    list(APPEND _inc_env "${ENV_PASTIX_DIR}/include/pastix")
   else()
+    if(WIN32)
+      string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
+    else()
+      string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
+      list(APPEND _inc_env "${_path_env}")
+      string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
+      list(APPEND _inc_env "${_path_env}")
+      string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
+      list(APPEND _inc_env "${_path_env}")
+      string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
+      list(APPEND _inc_env "${_path_env}")
+    endif()
+  endif()
+  list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
+  list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
+  list(REMOVE_DUPLICATES _inc_env)
+
+
+  # Try to find the pastix header in the given paths
+  # ---------------------------------------------------
+  # call cmake macro to find the header path
+  if(PASTIX_INCDIR)
     set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND")
     find_path(PASTIX_pastix.h_DIRS
       NAMES pastix.h
-      HINTS ${_inc_env}
-      PATH_SUFFIXES "pastix")
+      HINTS ${PASTIX_INCDIR})
+  else()
+    if(PASTIX_DIR)
+      set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND")
+      find_path(PASTIX_pastix.h_DIRS
+        NAMES pastix.h
+        HINTS ${PASTIX_DIR}
+        PATH_SUFFIXES "include" "include/pastix")
+    else()
+      set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND")
+      find_path(PASTIX_pastix.h_DIRS
+        NAMES pastix.h
+        HINTS ${_inc_env}
+        PATH_SUFFIXES "pastix")
+    endif()
   endif()
-endif()
-mark_as_advanced(PASTIX_pastix.h_DIRS)
+  mark_as_advanced(PASTIX_pastix.h_DIRS)
 
-# If found, add path to cmake variable
-# ------------------------------------
-if (PASTIX_pastix.h_DIRS)
-  set(PASTIX_INCLUDE_DIRS "${PASTIX_pastix.h_DIRS}")
-else ()
-  set(PASTIX_INCLUDE_DIRS "PASTIX_INCLUDE_DIRS-NOTFOUND")
-  if(NOT PASTIX_FIND_QUIETLY)
-    message(STATUS "Looking for pastix -- pastix.h not found")
+  # If found, add path to cmake variable
+  # ------------------------------------
+  if (PASTIX_pastix.h_DIRS)
+    set(PASTIX_INCLUDE_DIRS "${PASTIX_pastix.h_DIRS}")
+  else ()
+    set(PASTIX_INCLUDE_DIRS "PASTIX_INCLUDE_DIRS-NOTFOUND")
+    if(NOT PASTIX_FIND_QUIETLY)
+      message(STATUS "Looking for pastix -- pastix.h not found")
+    endif()
   endif()
-endif()
 
 
-# Looking for lib
-# ---------------
+  # Looking for lib
+  # ---------------
 
-# Add system library paths to search lib
-# --------------------------------------
-unset(_lib_env)
-set(ENV_PASTIX_LIBDIR "$ENV{PASTIX_LIBDIR}")
-if(ENV_PASTIX_LIBDIR)
-  list(APPEND _lib_env "${ENV_PASTIX_LIBDIR}")
-elseif(ENV_PASTIX_DIR)
-  list(APPEND _lib_env "${ENV_PASTIX_DIR}")
-  list(APPEND _lib_env "${ENV_PASTIX_DIR}/lib")
-else()
-  if(WIN32)
-    string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
+  # Add system library paths to search lib
+  # --------------------------------------
+  unset(_lib_env)
+  set(ENV_PASTIX_LIBDIR "$ENV{PASTIX_LIBDIR}")
+  if(ENV_PASTIX_LIBDIR)
+    list(APPEND _lib_env "${ENV_PASTIX_LIBDIR}")
+  elseif(ENV_PASTIX_DIR)
+    list(APPEND _lib_env "${ENV_PASTIX_DIR}")
+    list(APPEND _lib_env "${ENV_PASTIX_DIR}/lib")
   else()
-    if(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}")
-  endif()
-endif()
-list(REMOVE_DUPLICATES _lib_env)
-
-# Try to find the pastix lib in the given paths
-# ------------------------------------------------
-
-# create list of libs to find
-set(PASTIX_libs_to_find_v5 "pastix_murge;pastix")
-set(PASTIX_libs_to_find_v6 "pastix;pastix_kernels;pastix_spm;pastix_bcsc")
-foreach(v 5 6)
-  set(V_FOUND TRUE)
-  set(PASTIX_libs_to_find ${PASTIX_libs_to_find_v${v}})
-  message(STATUS "Looking for pastix -- Testing is version ${v}")
-  # call cmake macro to find the lib path
-  foreach(pastix_lib ${PASTIX_libs_to_find})
-    set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND")
-    if(PASTIX_LIBDIR)
-      find_library(PASTIX_${pastix_lib}_LIBRARY
-        NAMES ${pastix_lib}
-        HINTS ${PASTIX_LIBDIR})
+    if(WIN32)
+      string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
     else()
-      if(PASTIX_DIR)
-        find_library(PASTIX_${pastix_lib}_LIBRARY
-          NAMES ${pastix_lib}
-          HINTS ${PASTIX_DIR}
-          PATH_SUFFIXES lib lib32 lib64)
+      if(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}")
+    endif()
+  endif()
+  list(REMOVE_DUPLICATES _lib_env)
+
+  # Try to find the pastix lib in the given paths
+  # ------------------------------------------------
+
+  # create list of libs to find
+  set(PASTIX_libs_to_find_v5 "pastix_murge;pastix")
+  set(PASTIX_libs_to_find_v6 "pastix;pastix_kernels;pastix_spm;pastix_bcsc")
+  foreach(v 5 6)
+    set(V_FOUND TRUE)
+    set(PASTIX_libs_to_find ${PASTIX_libs_to_find_v${v}})
+    message(STATUS "Looking for pastix -- Testing is version ${v}")
+    # call cmake macro to find the lib path
+    foreach(pastix_lib ${PASTIX_libs_to_find})
+      set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND")
+      if(PASTIX_LIBDIR)
         find_library(PASTIX_${pastix_lib}_LIBRARY
           NAMES ${pastix_lib}
-          HINTS ${_lib_env})
+          HINTS ${PASTIX_LIBDIR})
+      else()
+        if(PASTIX_DIR)
+          find_library(PASTIX_${pastix_lib}_LIBRARY
+            NAMES ${pastix_lib}
+            HINTS ${PASTIX_DIR}
+            PATH_SUFFIXES lib lib32 lib64)
+        else()
+          find_library(PASTIX_${pastix_lib}_LIBRARY
+            NAMES ${pastix_lib}
+            HINTS ${_lib_env})
+        endif()
+      endif()
+      if (NOT PASTIX_${pastix_lib}_LIBRARY)
+        set (V_FOUND FALSE)
+        break()
+      endif()
+    endforeach()
+    if (V_FOUND)
+      set(PASTIX_VERSION_MAJOR ${v})
+      message(STATUS "Looking for pastix -- major version detected: ${PASTIX_VERSION_MAJOR}")
+      if (PASTIX_FIND_VERSION)
+        if (NOT ${PASTIX_VERSION_MAJOR} EQUAL ${PASTIX_FIND_VERSION_MAJOR})
+          message(FATAL_ERROR "Looking for pastix -- PaStiX version found differ from required")
+        endif()
       endif()
-    endif()
-    if (NOT PASTIX_${pastix_lib}_LIBRARY)
-      set (V_FOUND FALSE)
       break()
     endif()
   endforeach()
-  if (V_FOUND)
-    set(PASTIX_VERSION_MAJOR ${v})
-    message(STATUS "Looking for pastix -- major version detected: ${PASTIX_VERSION_MAJOR}")
-    if (PASTIX_FIND_VERSION)
-      if (NOT ${PASTIX_VERSION_MAJOR} EQUAL ${PASTIX_FIND_VERSION_MAJOR})
-        message(FATAL_ERROR "Looking for pastix -- PaStiX version found differ from required")
-      endif()
+
+  # If found, add path to cmake variable
+  # ------------------------------------
+  foreach(pastix_lib ${PASTIX_libs_to_find})
+
+    get_filename_component(${pastix_lib}_lib_path ${PASTIX_${pastix_lib}_LIBRARY} PATH)
+    # set cmake variables (respects naming convention)
+    if (PASTIX_LIBRARIES)
+      list(APPEND PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}")
+    else()
+      set(PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}")
     endif()
-    break()
-  endif()
-endforeach()
+    if (PASTIX_LIBRARY_DIRS)
+      list(APPEND PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}")
+    else()
+      set(PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}")
+    endif()
+    mark_as_advanced(PASTIX_${pastix_lib}_LIBRARY)
 
-# If found, add path to cmake variable
-# ------------------------------------
-foreach(pastix_lib ${PASTIX_libs_to_find})
+  endforeach(pastix_lib ${PASTIX_libs_to_find})
 
-  get_filename_component(${pastix_lib}_lib_path ${PASTIX_${pastix_lib}_LIBRARY} PATH)
-  # set cmake variables (respects naming convention)
-  if (PASTIX_LIBRARIES)
-    list(APPEND PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}")
-  else()
-    set(PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}")
-  endif()
-  if (PASTIX_LIBRARY_DIRS)
-    list(APPEND PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}")
-  else()
-    set(PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}")
-  endif()
-  mark_as_advanced(PASTIX_${pastix_lib}_LIBRARY)
+endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PASTIX_FOUND) OR (PASTIX_GIVEN_BY_USER) )
 
-endforeach(pastix_lib ${PASTIX_libs_to_find})
 
 # check a function to validate the find
 if(PASTIX_LIBRARIES)
 
-  set(REQUIRED_LDFLAGS)
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -524,6 +590,12 @@ if(PASTIX_LIBRARIES)
   if (PASTIX_INCLUDE_DIRS)
     set(REQUIRED_INCDIRS "${PASTIX_INCLUDE_DIRS}")
   endif()
+  if (PASTIX_CFLAGS_OTHER)
+    list(APPEND REQUIRED_FLAGS "${PASTIX_CFLAGS_OTHER}")
+  endif()
+  if (PASTIX_LDFLAGS_OTHER)
+    list(APPEND REQUIRED_LDFLAGS "${PASTIX_LDFLAGS_OTHER}")
+  endif()
   foreach(libdir ${PASTIX_LIBRARY_DIRS})
     if (libdir)
       list(APPEND REQUIRED_LIBDIRS "${libdir}")
@@ -534,48 +606,36 @@ if(PASTIX_LIBRARIES)
   if (PASTIX_LOOK_FOR_PARSEC AND PARSEC_FOUND)
     if (PARSEC_INCLUDE_DIRS_DEP)
       list(APPEND REQUIRED_INCDIRS "${PARSEC_INCLUDE_DIRS_DEP}")
-    elseif (PARSEC_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${PARSEC_INCLUDE_DIRS}")
+    endif()
+    if (PARSEC_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${PARSEC_CFLAGS_OTHER_DEP}")
+    endif()
+    if (PARSEC_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${PARSEC_LDFLAGS_OTHER_DEP}")
     endif()
     if(PARSEC_LIBRARY_DIRS_DEP)
       list(APPEND REQUIRED_LIBDIRS "${PARSEC_LIBRARY_DIRS_DEP}")
-    elseif(PARSEC_LIBRARY_DIRS)
-      list(APPEND REQUIRED_LIBDIRS "${PARSEC_LIBRARY_DIRS}")
     endif()
     if (PARSEC_LIBRARIES_DEP)
       list(APPEND REQUIRED_LIBS "${PARSEC_LIBRARIES_DEP}")
-    elseif (PARSEC_LIBRARIES)
-      foreach(lib ${PARSEC_LIBRARIES})
-        if (EXISTS ${lib} OR ${lib} MATCHES "^-")
-          list(APPEND REQUIRED_LIBS "${lib}")
-        else()
-          list(APPEND REQUIRED_LIBS "-l${lib}")
-        endif()
-      endforeach()
     endif()
   endif()
   # STARPU
   if (PASTIX_LOOK_FOR_STARPU AND STARPU_FOUND)
     if (STARPU_INCLUDE_DIRS_DEP)
       list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS_DEP}")
-    elseif (STARPU_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}")
+    endif()
+    if (STARPU_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${STARPU_CFLAGS_OTHER_DEP}")
+    endif()
+    if (STARPU_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${STARPU_LDFLAGS_OTHER_DEP}")
     endif()
     if(STARPU_LIBRARY_DIRS_DEP)
       list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS_DEP}")
-    elseif(STARPU_LIBRARY_DIRS)
-      list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS}")
     endif()
     if (STARPU_LIBRARIES_DEP)
       list(APPEND REQUIRED_LIBS "${STARPU_LIBRARIES_DEP}")
-    elseif (STARPU_LIBRARIES)
-      foreach(lib ${STARPU_LIBRARIES})
-        if (EXISTS ${lib} OR ${lib} MATCHES "^-")
-          list(APPEND REQUIRED_LIBS "${lib}")
-        else()
-          list(APPEND REQUIRED_LIBS "-l${lib}")
-        endif()
-      endforeach()
     endif()
   endif()
   # CUDA
@@ -608,33 +668,32 @@ if(PASTIX_LIBRARIES)
     if (HWLOC_INCLUDE_DIRS)
       list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}")
     endif()
-    foreach(libdir ${HWLOC_LIBRARY_DIRS})
-      if (libdir)
-        list(APPEND REQUIRED_LIBDIRS "${libdir}")
-      endif()
-    endforeach()
-    foreach(lib ${HWLOC_LIBRARIES})
-      if (EXISTS ${lib} OR ${lib} MATCHES "^-")
-        list(APPEND REQUIRED_LIBS "${lib}")
-      else()
-        list(APPEND REQUIRED_LIBS "-l${lib}")
-      endif()
-    endforeach()
+    if (HWLOC_CFLAGS_OTHER)
+      list(APPEND REQUIRED_FLAGS "${HWLOC_CFLAGS_OTHER}")
+    endif()
+    if (HWLOC_LDFLAGS_OTHER)
+      list(APPEND REQUIRED_LDFLAGS "${HWLOC_LDFLAGS_OTHER}")
+    endif()
+    if (HWLOC_LIBRARY_DIRS)
+      list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}")
+    endif()
+    list(APPEND REQUIRED_LIBS "${HWLOC_LIBRARIES}")
   endif()
   # BLAS
   if (BLAS_FOUND)
     if (BLAS_INCLUDE_DIRS)
       list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}")
     endif()
-    foreach(libdir ${BLAS_LIBRARY_DIRS})
-      if (libdir)
-        list(APPEND REQUIRED_LIBDIRS "${libdir}")
-      endif()
-    endforeach()
-    list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}")
-    if (BLAS_LINKER_FLAGS)
-      list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
+    if (BLAS_CFLAGS_OTHER)
+      list(APPEND REQUIRED_FLAGS "${BLAS_CFLAGS_OTHER}")
+    endif()
+    if (BLAS_LDFLAGS_OTHER)
+      list(APPEND REQUIRED_LDFLAGS "${BLAS_LDFLAGS_OTHER}")
     endif()
+    if (BLAS_LIBRARY_DIRS)
+      list(APPEND REQUIRED_LIBDIRS "${BLAS_LIBRARY_DIRS}")
+    endif()
+    list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}")
   endif()
   # SCOTCH
   if (PASTIX_LOOK_FOR_SCOTCH AND SCOTCH_FOUND)
@@ -699,13 +758,23 @@ if(PASTIX_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
+  set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
-  list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
   # test link
@@ -719,15 +788,17 @@ if(PASTIX_LIBRARIES)
     set(PASTIX_LIBRARIES_DEP "${REQUIRED_LIBS}")
     set(PASTIX_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
     set(PASTIX_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
-    set(PASTIX_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
+    set(PASTIX_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(PASTIX_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
     list(REMOVE_DUPLICATES PASTIX_LIBRARY_DIRS_DEP)
-    list(REMOVE_DUPLICATES PASTIX_INCLUDE_DIRS_DEP)
-    list(REMOVE_DUPLICATES PASTIX_LINKER_FLAGS)
+    list(REMOVE_DUPLICATES PASTIX_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES PASTIX_LDFLAGS_OTHER_DEP)
   else()
     if(NOT PASTIX_FIND_QUIETLY)
       message(STATUS "Looking for PASTIX : test of pastix() fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
       message(STATUS "Maybe PASTIX is linked with specific libraries. "
         "Have you tried with COMPONENTS (MPI/SEQ, PARSEC, STARPU, STARPU_CUDA, SCOTCH, PTSCOTCH, METIS)? "
@@ -742,7 +813,7 @@ endif(PASTIX_LIBRARIES)
 
 # Check the size of pastix_int_t
 # ---------------------------------
-set(CMAKE_REQUIRED_INCLUDES ${PASTIX_INCLUDE_DIRS} ${PASTIX_INCLUDE_DIRS_DEP})
+set(CMAKE_REQUIRED_INCLUDES ${PASTIX_INCLUDE_DIRS_DEP})
 
 include(CheckCSourceRuns)
 #mpi.h should be included by pastix.h directly
diff --git a/modules/find/FindPTSCOTCH.cmake b/modules/find/FindPTSCOTCH.cmake
index 04f6844409eb789068f23dde2cfa804aa4a16d77..bfa122b6f8640c6346bde0edbdc9a42db5565bd4 100644
--- a/modules/find/FindPTSCOTCH.cmake
+++ b/modules/find/FindPTSCOTCH.cmake
@@ -25,13 +25,16 @@
 # This module finds headers and ptscotch library.
 # Results are reported in variables:
 #  PTSCOTCH_FOUND            - True if headers and requested libraries were found
-#  PTSCOTCH_LINKER_FLAGS     - list of required linker flags (excluding -l and -L)
-#  PTSCOTCH_INCLUDE_DIRS     - ptscotch include directories
-#  PTSCOTCH_LIBRARY_DIRS     - Link directories for ptscotch libraries
-#  PTSCOTCH_LIBRARIES        - ptscotch component libraries to be linked
-#  PTSCOTCH_INCLUDE_DIRS_DEP - ptscotch + dependencies include directories
-#  PTSCOTCH_LIBRARY_DIRS_DEP - ptscotch + dependencies link directories
-#  PTSCOTCH_LIBRARIES_DEP    - ptscotch libraries + dependencies
+#  PTSCOTCH_CFLAGS_OTHER      - ptscotch compiler flags without headers paths
+#  PTSCOTCH_LDFLAGS_OTHER     - ptscotch linker flags without libraries
+#  PTSCOTCH_INCLUDE_DIRS      - ptscotch include directories
+#  PTSCOTCH_LIBRARY_DIRS      - ptscotch link directories
+#  PTSCOTCH_LIBRARIES         - ptscotch libraries to be linked (absolute path)
+#  PTSCOTCH_CFLAGS_OTHER_DEP  - ptscotch + dependencies compiler flags without headers paths
+#  PTSCOTCH_LDFLAGS_OTHER_DEP - ptscotch + dependencies linker flags without libraries
+#  PTSCOTCH_INCLUDE_DIRS_DEP  - ptscotch + dependencies include directories
+#  PTSCOTCH_LIBRARY_DIRS_DEP  - ptscotch + dependencies link directories
+#  PTSCOTCH_LIBRARIES_DEP     - ptscotch + dependencies libraries
 #  PTSCOTCH_INTSIZE          - Number of octets occupied by a SCOTCH_Num
 #
 # The user can give specific paths where to find the libraries adding cmake
@@ -79,21 +82,17 @@ if( PTSCOTCH_FIND_COMPONENTS )
 endif()
 
 # PTSCOTCH depends on Threads, try to find it
-if (NOT THREADS_FOUND)
-  if (PTSCOTCH_FIND_REQUIRED)
-    find_package(Threads REQUIRED)
-  else()
-    find_package(Threads)
-  endif()
+if (PTSCOTCH_FIND_REQUIRED)
+  find_package(Threads REQUIRED)
+else()
+  find_package(Threads)
 endif()
 
 # PTSCOTCH depends on MPI, try to find it
-if (NOT MPI_FOUND)
-  if (PTSCOTCH_FIND_REQUIRED)
-    find_package(MPI REQUIRED)
-  else()
-    find_package(MPI)
-  endif()
+if (PTSCOTCH_FIND_REQUIRED)
+  find_package(MPI REQUIRED)
+else()
+  find_package(MPI)
 endif()
 
 # Looking for include
@@ -269,14 +268,15 @@ list(REMOVE_DUPLICATES PTSCOTCH_LIBRARY_DIRS)
 # check a function to validate the find
 if(PTSCOTCH_LIBRARIES)
 
-  set(REQUIRED_LDFLAGS)
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
   # PTSCOTCH
   if (PTSCOTCH_INCLUDE_DIRS)
-    set(REQUIRED_INCDIRS  "${PTSCOTCH_INCLUDE_DIRS}")
+    set(REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}")
   endif()
   if (PTSCOTCH_LIBRARY_DIRS)
     set(REQUIRED_LIBDIRS "${PTSCOTCH_LIBRARY_DIRS}")
@@ -303,30 +303,40 @@ if(PTSCOTCH_LIBRARIES)
   find_library(Z_LIBRARY NAMES z)
   mark_as_advanced(Z_LIBRARY)
   if(Z_LIBRARY)
-    list(APPEND REQUIRED_LIBS "-lz")
+    list(APPEND REQUIRED_LIBS "${Z_LIBRARY}")
   endif()
   set(M_LIBRARY "M_LIBRARY-NOTFOUND")
   find_library(M_LIBRARY NAMES m)
   mark_as_advanced(M_LIBRARY)
   if(M_LIBRARY)
-    list(APPEND REQUIRED_LIBS "-lm")
+    list(APPEND REQUIRED_LIBS "${M_LIBRARY}")
   endif()
   set(RT_LIBRARY "RT_LIBRARY-NOTFOUND")
   find_library(RT_LIBRARY NAMES rt)
   mark_as_advanced(RT_LIBRARY)
   if(RT_LIBRARY)
-    list(APPEND REQUIRED_LIBS "-lrt")
+    list(APPEND REQUIRED_LIBS "${RT_LIBRARY}")
   endif()
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
+  set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
-  list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
   # test link
@@ -340,15 +350,17 @@ if(PTSCOTCH_LIBRARIES)
     set(PTSCOTCH_LIBRARIES_DEP "${REQUIRED_LIBS}")
     set(PTSCOTCH_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
     set(PTSCOTCH_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
-    set(PTSCOTCH_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
+    set(PTSCOTCH_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(PTSCOTCH_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
     list(REMOVE_DUPLICATES PTSCOTCH_LIBRARY_DIRS_DEP)
-    list(REMOVE_DUPLICATES PTSCOTCH_INCLUDE_DIRS_DEP)
-    list(REMOVE_DUPLICATES PTSCOTCH_LINKER_FLAGS)
+    list(REMOVE_DUPLICATES PTSCOTCH_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES PTSCOTCH_LDFLAGS_OTHER_DEP)
   else()
     if(NOT PTSCOTCH_FIND_QUIETLY)
       message(STATUS "Looking for PTSCOTCH : test of SCOTCH_dgraphInit with PTSCOTCH library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindQUARK.cmake b/modules/find/FindQUARK.cmake
index 31565a0af2b01a6e675ba209c5be26bff145f3a4..645dc79911dc0c27ec325c3d3b70d93906ba13a2 100644
--- a/modules/find/FindQUARK.cmake
+++ b/modules/find/FindQUARK.cmake
@@ -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-2014 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.
 #
 ###
@@ -25,13 +25,17 @@
 #
 # This module finds headers and quark library.
 # Results are reported in variables:
-#  QUARK_FOUND            - True if headers and requested libraries were found
-#  QUARK_INCLUDE_DIRS     - quark include directories
-#  QUARK_LIBRARY_DIRS     - Link directories for quark libraries
-#  QUARK_LIBRARIES        - quark component libraries to be linked
-#  QUARK_INCLUDE_DIRS_DEP - quark + dependencies include directories
-#  QUARK_LIBRARY_DIRS_DEP - quark + dependencies link directories
-#  QUARK_LIBRARIES_DEP    - quark libraries + dependencies
+#  QUARK_FOUND             - True if headers and requested libraries were found
+#  QUARK_CFLAGS_OTHER      - quark compiler flags without headers paths
+#  QUARK_LDFLAGS_OTHER     - quark linker flags without libraries
+#  QUARK_INCLUDE_DIRS      - quark include directories
+#  QUARK_LIBRARY_DIRS      - quark link directories
+#  QUARK_LIBRARIES         - quark libraries to be linked (absolute path)
+#  QUARK_CFLAGS_OTHER_DEP  - quark + dependencies compiler flags without headers paths
+#  QUARK_LDFLAGS_OTHER_DEP - quark + dependencies linker flags without libraries
+#  QUARK_INCLUDE_DIRS_DEP  - quark + dependencies include directories
+#  QUARK_LIBRARY_DIRS_DEP  - quark + dependencies link directories
+#  QUARK_LIBRARIES_DEP     - quark + dependencies libraries
 #
 # The user can give specific paths where to find the libraries adding cmake
 # options at configure (ex: cmake path/to/project -DQUARK=path/to/quark):
@@ -42,11 +46,11 @@
 # are not given as cmake variable: QUARK_DIR, QUARK_INCDIR, QUARK_LIBDIR
 
 #=============================================================================
-# Copyright 2012-2013 Inria
+# Copyright 2012-2018 Inria
 # Copyright 2012-2013 Emmanuel Agullo
 # Copyright 2012-2013 Mathieu Faverge
 # Copyright 2012      Cedric Castagnede
-# Copyright 2013      Florent Pruvost
+# Copyright 2013-2018 Florent Pruvost
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file MORSE-Copyright.txt for details.
@@ -79,16 +83,14 @@ if( QUARK_FIND_COMPONENTS )
 endif()
 
 # QUARK may depend on Threads, try to find it
-if (NOT Threads_FOUND)
-  if (QUARK_FIND_REQUIRED)
-    find_package(Threads REQUIRED)
-  else()
-    find_package(Threads)
-  endif()
+if (QUARK_FIND_REQUIRED)
+  find_package(Threads REQUIRED)
+else()
+  find_package(Threads)
 endif()
 
 # QUARK may depend on HWLOC, try to find it
-if (NOT HWLOC_FOUND AND QUARK_LOOK_FOR_HWLOC)
+if (QUARK_LOOK_FOR_HWLOC)
   if (QUARK_FIND_REQUIRED AND QUARK_FIND_REQUIRED_HWLOC)
     find_package(HWLOC REQUIRED)
   else()
@@ -237,6 +239,8 @@ endif ()
 if(QUARK_LIBRARIES)
 
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -253,26 +257,38 @@ if(QUARK_LIBRARIES)
     if (HWLOC_INCLUDE_DIRS)
       list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}")
     endif()
+    if (HWLOC_CFLAGS_OTHER)
+      list(APPEND REQUIRED_FLAGS "${HWLOC_CFLAGS_OTHER}")
+    endif()
+    if (HWLOC_LDFLAGS_OTHER)
+      list(APPEND REQUIRED_LDFLAGS "${HWLOC_LDFLAGS_OTHER}")
+    endif()
     if (HWLOC_LIBRARY_DIRS)
       list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}")
     endif()
-    foreach(lib ${HWLOC_LIBRARIES})
-      if (EXISTS ${lib} OR ${lib} MATCHES "^-")
-        list(APPEND REQUIRED_LIBS "${lib}")
-      else()
-        list(APPEND REQUIRED_LIBS "-l${lib}")
-      endif()
-    endforeach()
+    list(APPEND REQUIRED_LIBS "${HWLOC_LIBRARIES}")
   endif()
   # THREADS
   list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}")
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
+  set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
+  list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -287,13 +303,17 @@ if(QUARK_LIBRARIES)
     set(QUARK_LIBRARIES_DEP "${REQUIRED_LIBS}")
     set(QUARK_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
     set(QUARK_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
+    set(QUARK_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(QUARK_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
     list(REMOVE_DUPLICATES QUARK_LIBRARY_DIRS_DEP)
-    list(REMOVE_DUPLICATES QUARK_INCLUDE_DIRS_DEP)
+    list(REMOVE_DUPLICATES QUARK_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES QUARK_LDFLAGS_OTHER_DEP)
   else()
     if(NOT QUARK_FIND_QUIETLY)
       message(STATUS "Looking for QUARK : test of QUARK_New with QUARK library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
       message(STATUS "Maybe QUARK is linked with specific libraries like. "
         "Have you tried with COMPONENTS (HWLOC)? See the explanation in FindQUARK.cmake.")
diff --git a/modules/find/FindSCALAPACK.cmake b/modules/find/FindSCALAPACK.cmake
index e2aa42f241f99baea32b3534ad28fc06d3388d75..49e5717a5a7f830537eadd6a4a014e55840ab4b8 100644
--- a/modules/find/FindSCALAPACK.cmake
+++ b/modules/find/FindSCALAPACK.cmake
@@ -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.
 #
 ###
@@ -15,10 +15,17 @@
 # This module sets the following variables:
 #  SCALAPACK_FOUND - set to true if a library implementing the SCALAPACK interface
 #    is found
-#  SCALAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l
-#    and -L).
-#  SCALAPACK_LIBRARIES - uncached list of libraries (using full path name) to
-#    link against to use SCALAPACK
+#  SCALAPACK_CFLAGS_OTHER      - scalapack compiler flags without headers paths
+#  SCALAPACK_LDFLAGS_OTHER     - scalapack linker flags without libraries
+#  SCALAPACK_INCLUDE_DIRS      - scalapack include directories
+#  SCALAPACK_LIBRARY_DIRS      - scalapack link directories
+#  SCALAPACK_LIBRARIES         - scalapack libraries to be linked (absolute path)
+#  SCALAPACK_CFLAGS_OTHER_DEP  - scalapack + dependencies compiler flags without headers paths
+#  SCALAPACK_LDFLAGS_OTHER_DEP - scalapack + dependencies linker flags without libraries
+#  SCALAPACK_INCLUDE_DIRS_DEP  - scalapack + dependencies include directories
+#  SCALAPACK_LIBRARY_DIRS_DEP  - scalapack + dependencies link directories
+#  SCALAPACK_LIBRARIES_DEP     - scalapack + dependencies libraries
+#
 #  SCALAPACK95_LIBRARIES - uncached list of libraries (using full path name) to
 #    link against to use SCALAPACK95
 #  SCALAPACK95_FOUND - set to true if a library implementing the SCALAPACK f95
@@ -257,6 +264,8 @@ macro(Check_Scalapack_Libraries LIBRARIES _prefix _name _flags _list _blaslapack
     else(UNIX AND BLA_STATIC)
       set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blaslapack} ${_mpi} ${_threads})
     endif(UNIX AND BLA_STATIC)
+    set(CMAKE_REQUIRED_INCLUDES "${SCALAPACK_INCLUDE_DIRS}")
+    set(CMAKE_REQUIRED_FLAGS "${SCALAPACK_CFLAGS_OTHER}")
     if (SCALAPACK_VERBOSE)
       message("${Cyan}SCALAPACK libs found. Try to compile symbol ${_name} with"
         "following libraries: ${CMAKE_REQUIRED_LIBRARIES}")
@@ -283,37 +292,30 @@ macro(Check_Scalapack_Libraries LIBRARIES _prefix _name _flags _list _blaslapack
 endmacro(Check_Scalapack_Libraries)
 
 
-set(SCALAPACK_LINKER_FLAGS)
+set(SCALAPACK_LDFLAGS_OTHER)
 set(SCALAPACK_LIBRARIES)
 set(SCALAPACK95_LIBRARIES)
 
-if (NOT BLAS_FOUND)
-  if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED)
-    find_package(BLASEXT)
-  else()
-    find_package(BLASEXT REQUIRED)
-  endif()
-endif ()
+if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED)
+  find_package(BLAS)
+else()
+  find_package(BLAS REQUIRED)
+endif()
 
-if (NOT LAPACK_FOUND)
-  if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED)
-    find_package(LAPACKEXT)
-  else()
-    find_package(LAPACKEXT REQUIRED)
-  endif()
-endif ()
+if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED)
+  find_package(LAPACK)
+else()
+  find_package(LAPACK REQUIRED)
+endif()
 
-if (NOT MPI_FOUND)
-  if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED)
-    find_package(MPI)
-  else()
-    find_package(MPI REQUIRED)
-  endif()
-endif ()
+if(SCALAPACK_FIND_QUIETLY OR NOT SCALAPACK_FIND_REQUIRED)
+  find_package(MPI)
+else()
+  find_package(MPI REQUIRED)
+endif()
 
 if(BLAS_FOUND AND LAPACK_FOUND AND MPI_FOUND)
-  set(SCALAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
-  list(APPEND SCALAPACK_LINKER_FLAGS ${LAPACK_LINKER_FLAGS})
+  set(SCALAPACK_LDFLAGS_OTHER ${LAPACK_LDFLAGS_OTHER_DEP})
   if ($ENV{BLA_VENDOR} MATCHES ".+")
     set(BLA_VENDOR $ENV{BLA_VENDOR})
   else ($ENV{BLA_VENDOR} MATCHES ".+")
@@ -383,10 +385,8 @@ if(BLAS_FOUND AND LAPACK_FOUND AND MPI_FOUND)
         endif ()
       endforeach ()
     endif ()
-  endif()
-  # Generic SCALAPACK library
-  if (BLA_VENDOR STREQUAL "Generic" OR
-      BLA_VENDOR STREQUAL "All")
+  else()
+    # Generic SCALAPACK library
     if ( NOT SCALAPACK_LIBRARIES )
       check_scalapack_libraries(
         SCALAPACK_LIBRARIES
@@ -411,7 +411,7 @@ if(BLAS_FOUND AND LAPACK_FOUND AND MPI_FOUND)
         ""          # threads libs
         )
     endif ( NOT SCALAPACK_LIBRARIES )
-  endif ()
+  endif()
 else(BLAS_FOUND AND LAPACK_FOUND AND MPI_FOUND)
   message(STATUS "SCALAPACK requires BLAS, LAPACK, and MPI")
 endif(BLAS_FOUND AND LAPACK_FOUND AND MPI_FOUND)
@@ -499,6 +499,15 @@ if (SCALAPACK_LIBRARIES)
   else()
     set(SCALAPACK_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of SCALAPACK library" FORCE)
   endif()
+  set(SCALAPACK_CFLAGS_OTHER_DEP "${SCALAPACK_CFLAGS_OTHER}" "${LAPACK_CFLAGS_OTHER_DEP}")
+  set(SCALAPACK_LDFLAGS_OTHER_DEP "${SCALAPACK_LDFLAGS_OTHER}" "${LAPACK_LDFLAGS_OTHER_DEP}")
+  set(SCALAPACK_INCLUDE_DIRS_DEP "${SCALAPACK_INCLUDE_DIRS}" "${LAPACK_INCLUDE_DIRS_DEP}")
+  set(SCALAPACK_LIBRARY_DIRS_DEP "${SCALAPACK_LIBRARY_DIRS}" "${LAPACK_LIBRARY_DIRS_DEP}")
+  set(SCALAPACK_LIBRARIES_DEP "${SCALAPACK_LIBRARIES}" "${LAPACK_LIBRARIES_DEP}" "${MPI_Fortran_LIBRARIES}")
+  list(REMOVE_DUPLICATES LAPACK_CFLAGS_OTHER_DEP)
+  list(REMOVE_DUPLICATES LAPACK_LDFLAGS_OTHER_DEP)
+  list(REMOVE_DUPLICATES LAPACK_INCLUDE_DIRS_DEP)
+  list(REMOVE_DUPLICATES LAPACK_LIBRARY_DIRS_DEP)
 endif()
 mark_as_advanced(SCALAPACK_DIR)
 mark_as_advanced(SCALAPACK_DIR_FOUND)
diff --git a/modules/find/FindSCOTCH.cmake b/modules/find/FindSCOTCH.cmake
index 20f617055c8327edb209f7f6bd5fc61c078c150b..282fe71a83188b589d182db7943d9f8678bf379e 100644
--- a/modules/find/FindSCOTCH.cmake
+++ b/modules/find/FindSCOTCH.cmake
@@ -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-2014 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.
 #
 ###
@@ -35,11 +35,11 @@
 # are not given as cmake variable: SCOTCH_DIR, SCOTCH_INCDIR, SCOTCH_LIBDIR
 
 #=============================================================================
-# Copyright 2012-2013 Inria
+# Copyright 2012-2018 Inria
 # Copyright 2012-2013 Emmanuel Agullo
 # Copyright 2012-2013 Mathieu Faverge
 # Copyright 2012      Cedric Castagnede
-# Copyright 2013      Florent Pruvost
+# Copyright 2013-2018 Florent Pruvost
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file MORSE-Copyright.txt for details.
@@ -71,12 +71,10 @@ if( SCOTCH_FIND_COMPONENTS )
 endif()
 
 # SCOTCH may depend on Threads, try to find it
-if (NOT THREADS_FOUND)
-  if (SCOTCH_FIND_REQUIRED)
-    find_package(Threads REQUIRED)
-  else()
-    find_package(Threads)
-  endif()
+if (SCOTCH_FIND_REQUIRED)
+  find_package(Threads REQUIRED)
+else()
+  find_package(Threads)
 endif()
 
 # Looking for include
@@ -257,27 +255,24 @@ if(SCOTCH_LIBRARIES)
   find_library(Z_LIBRARY NAMES z)
   mark_as_advanced(Z_LIBRARY)
   if(Z_LIBRARY)
-    list(APPEND REQUIRED_LIBS "-lz")
+    list(APPEND REQUIRED_LIBS "${Z_LIBRARY}")
   endif()
   set(M_LIBRARY "M_LIBRARY-NOTFOUND")
   find_library(M_LIBRARY NAMES m)
   mark_as_advanced(M_LIBRARY)
   if(M_LIBRARY)
-    list(APPEND REQUIRED_LIBS "-lm")
+    list(APPEND REQUIRED_LIBS "${M_LIBRARY}")
   endif()
   set(RT_LIBRARY "RT_LIBRARY-NOTFOUND")
   find_library(RT_LIBRARY NAMES rt)
   mark_as_advanced(RT_LIBRARY)
   if(RT_LIBRARY)
-    list(APPEND REQUIRED_LIBS "-lrt")
+    list(APPEND REQUIRED_LIBS "${RT_LIBRARY}")
   endif()
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
   set(CMAKE_REQUIRED_LIBRARIES)
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -295,6 +290,7 @@ if(SCOTCH_LIBRARIES)
       message(STATUS "Looking for SCOTCH : test of SCOTCH_graphInit with SCOTCH library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindSIMGRID.cmake b/modules/find/FindSIMGRID.cmake
index f21acd12408e13db164568e63eda1b229e013143..d4d175d704c307be0127eaa8aa14ac1812d4e66b 100644
--- a/modules/find/FindSIMGRID.cmake
+++ b/modules/find/FindSIMGRID.cmake
@@ -267,6 +267,8 @@ endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_FOU
 if(SIMGRID_LIBRARIES)
 
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -287,12 +289,22 @@ if(SIMGRID_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
   set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -307,6 +319,7 @@ if(SIMGRID_LIBRARIES)
       message(STATUS "Looking for simgrid : test of fut_keychange with simgrid library fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
     endif()
   endif()
diff --git a/modules/find/FindSTARPU.cmake b/modules/find/FindSTARPU.cmake
index e30a1ec4cbf256e3a25b063bf1b301cb39b93f8e..43ab4aac45b2c1b8c689fd0d4764d7e94d8559f6 100644
--- a/modules/find/FindSTARPU.cmake
+++ b/modules/find/FindSTARPU.cmake
@@ -29,12 +29,16 @@
 #
 # Results are reported in variables:
 #  STARPU_FOUND                  - True if headers and requested libraries were found
+#  STARPU_CFLAGS_OTHER           - starpu compiler flags without headers paths
+#  STARPU_LDFLAGS_OTHER          - starpu linker flags without libraries
 #  STARPU_INCLUDE_DIRS           - starpu include directories
-#  STARPU_LIBRARY_DIRS           - Link directories for starpu libraries
-#  STARPU_LIBRARIES              - starpu libraries
+#  STARPU_LIBRARY_DIRS           - starpu link directories
+#  STARPU_LIBRARIES              - starpu libraries to be linked (absolute path)
+#  STARPU_CFLAGS_OTHER_DEP       - starpu + dependencies compiler flags without headers paths
+#  STARPU_LDFLAGS_OTHER_DEP      - starpu + dependencies linker flags without libraries
 #  STARPU_INCLUDE_DIRS_DEP       - starpu + dependencies include directories
 #  STARPU_LIBRARY_DIRS_DEP       - starpu + dependencies link directories
-#  STARPU_LIBRARIES_DEP          - starpu libraries + dependencies
+#  STARPU_LIBRARIES_DEP          - starpu + dependencies libraries
 #  STARPU_VERSION                - A human-readable string containing the version of the package found
 #  STARPU_VERSION_MAJOR          - The major version of the package found
 #  STARPU_VERSION_MINOR          - The minor version of the package found
@@ -134,7 +138,7 @@ if( RT_rt_LIBRARY )
 endif ()
 
 # STARPU may depend on HWLOC, try to find it
-if (NOT HWLOC_FOUND AND STARPU_LOOK_FOR_HWLOC)
+if (STARPU_LOOK_FOR_HWLOC)
   if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_HWLOC)
     find_package(HWLOC REQUIRED)
   else()
@@ -143,7 +147,7 @@ if (NOT HWLOC_FOUND AND STARPU_LOOK_FOR_HWLOC)
 endif()
 
 # STARPU may depend on CUDA, try to find it
-if (NOT CUDA_FOUND AND STARPU_LOOK_FOR_CUDA)
+if (STARPU_LOOK_FOR_CUDA)
   if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_CUDA)
     find_package(CUDA REQUIRED)
   else()
@@ -159,7 +163,7 @@ if (NOT CUDA_FOUND AND STARPU_LOOK_FOR_CUDA)
 endif()
 
 # STARPU may depend on MPI, try to find it
-if (NOT MPI_FOUND AND STARPU_LOOK_FOR_MPI)
+if (STARPU_LOOK_FOR_MPI)
   if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_MPI)
     find_package(MPI REQUIRED)
   else()
@@ -172,16 +176,16 @@ if (NOT MPI_FOUND AND STARPU_LOOK_FOR_MPI)
 endif()
 
 # STARPU may depend on BLAS, try to find it
-if (NOT BLAS_FOUND AND STARPU_LOOK_FOR_BLAS)
+if (STARPU_LOOK_FOR_BLAS)
   if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_BLAS)
-    find_package(BLASEXT REQUIRED)
+    find_package(BLAS REQUIRED)
   else()
-    find_package(BLASEXT)
+    find_package(BLAS)
   endif()
 endif()
 
 # STARPU may depend on MAGMA, try to find it
-if (NOT MAGMA_FOUND AND STARPU_LOOK_FOR_MAGMA)
+if (STARPU_LOOK_FOR_MAGMA)
   if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_MAGMA)
     find_package(MAGMA REQUIRED)
   else()
@@ -190,7 +194,7 @@ if (NOT MAGMA_FOUND AND STARPU_LOOK_FOR_MAGMA)
 endif()
 
 # STARPU may depend on FXT, try to find it
-if (NOT FXT_FOUND AND STARPU_LOOK_FOR_FXT)
+if (STARPU_LOOK_FOR_FXT)
   if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_FXT)
     find_package(FXT REQUIRED)
   else()
@@ -199,7 +203,7 @@ if (NOT FXT_FOUND AND STARPU_LOOK_FOR_FXT)
 endif()
 
 # STARPU may depend on SIMGRID, try to find it
-if (NOT SIMGRID_FOUND AND STARPU_LOOK_FOR_SIMGRID)
+if (STARPU_LOOK_FOR_SIMGRID)
   if (STARPU_FIND_REQUIRED AND STARPU_FIND_REQUIRED_SIMGRID)
     find_package(SIMGRID REQUIRED)
   else()
@@ -659,16 +663,16 @@ if(STARPU_LIBRARIES)
     if (HWLOC_INCLUDE_DIRS)
       list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}")
     endif()
+    if (HWLOC_CFLAGS_OTHER)
+      list(APPEND REQUIRED_FLAGS "${HWLOC_CFLAGS_OTHER}")
+    endif()
+    if (HWLOC_LDFLAGS_OTHER)
+      list(APPEND REQUIRED_LDFLAGS "${HWLOC_LDFLAGS_OTHER}")
+    endif()
     if (HWLOC_LIBRARY_DIRS)
       list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}")
     endif()
-    foreach(lib ${HWLOC_LIBRARIES})
-      if (EXISTS ${lib} OR ${lib} MATCHES "^-")
-        list(APPEND REQUIRED_LIBS "${lib}")
-      else()
-        list(APPEND REQUIRED_LIBS "-l${lib}")
-      endif()
-    endforeach()
+    list(APPEND REQUIRED_LIBS "${HWLOC_LIBRARIES}")
   endif()
   # MPI
   if (MPI_FOUND AND STARPU_LOOK_FOR_MPI)
@@ -725,32 +729,32 @@ if(STARPU_LIBRARIES)
     if (FXT_INCLUDE_DIRS)
       list(APPEND REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}")
     endif()
+    if (FXT_CFLAGS_OTHER)
+      list(APPEND REQUIRED_FLAGS "${FXT_CFLAGS_OTHER}")
+    endif()
+    if (FXT_LDFLAGS_OTHER)
+      list(APPEND REQUIRED_LDFLAGS "${FXT_LDFLAGS_OTHER}")
+    endif()
     if (FXT_LIBRARY_DIRS)
       list(APPEND REQUIRED_LIBDIRS "${FXT_LIBRARY_DIRS}")
     endif()
-    foreach(lib ${FXT_LIBRARIES})
-      if (EXISTS ${lib} OR ${lib} MATCHES "^-")
-        list(APPEND REQUIRED_LIBS "${lib}")
-      else()
-        list(APPEND REQUIRED_LIBS "-l${lib}")
-      endif()
-    endforeach()
+    list(APPEND REQUIRED_LIBS "${FXT_LIBRARIES}")
   endif()
   # SIMGRID
   if (SIMGRID_FOUND AND STARPU_LOOK_FOR_SIMGRID)
     if (SIMGRID_INCLUDE_DIRS)
       list(APPEND REQUIRED_INCDIRS "${SIMGRID_INCLUDE_DIRS}")
     endif()
+    if (SIMGRID_CFLAGS_OTHER)
+      list(APPEND REQUIRED_FLAGS "${SIMGRID_CFLAGS_OTHER}")
+    endif()
+    if (SIMGRID_LDFLAGS_OTHER)
+      list(APPEND REQUIRED_LDFLAGS "${SIMGRID_LDFLAGS_OTHER}")
+    endif()
     if (SIMGRID_LIBRARY_DIRS)
       list(APPEND REQUIRED_LIBDIRS "${SIMGRID_LIBRARY_DIRS}")
     endif()
-    foreach(lib ${SIMGRID_LIBRARIES})
-      if (EXISTS ${lib} OR ${lib} MATCHES "^-")
-        list(APPEND REQUIRED_LIBS "${lib}")
-      else()
-        list(APPEND REQUIRED_LIBS "-l${lib}")
-      endif()
-    endforeach()
+    list(APPEND REQUIRED_LIBS "${SIMGRID_LIBRARIES}")
     list(APPEND REQUIRED_FLAGS "-include starpu_simgrid_wrap.h")
   endif()
   # BLAS
@@ -758,13 +762,16 @@ if(STARPU_LIBRARIES)
     if (BLAS_INCLUDE_DIRS)
       list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}")
     endif()
+    if (BLAS_CFLAGS_OTHER)
+      list(APPEND REQUIRED_FLAGS "${BLAS_CFLAGS_OTHER}")
+    endif()
+    if (BLAS_LDFLAGS_OTHER)
+      list(APPEND REQUIRED_LDFLAGS "${BLAS_LDFLAGS_OTHER}")
+    endif()
     if (BLAS_LIBRARY_DIRS)
       list(APPEND REQUIRED_LIBDIRS "${BLAS_LIBRARY_DIRS}")
     endif()
     list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}")
-    if (BLAS_LINKER_FLAGS)
-      list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
-    endif()
   endif()
   # Fortran
   if (CMAKE_C_COMPILER_ID MATCHES "GNU")
@@ -793,14 +800,23 @@ if(STARPU_LIBRARIES)
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
   set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
-  list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
   # test link
@@ -814,13 +830,17 @@ if(STARPU_LIBRARIES)
     set(STARPU_LIBRARIES_DEP "${REQUIRED_LIBS}")
     set(STARPU_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
     set(STARPU_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
+    set(STARPU_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(STARPU_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
     list(REMOVE_DUPLICATES STARPU_LIBRARY_DIRS_DEP)
-    list(REMOVE_DUPLICATES STARPU_INCLUDE_DIRS_DEP)
+    list(REMOVE_DUPLICATES STARPU_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES STARPU_LDFLAGS_OTHER_DEP)
   else()
     if(NOT STARPU_FIND_QUIETLY)
       message(STATUS "Looking for starpu : test of starpu_init fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
       message(STATUS "Maybe STARPU is linked with specific libraries. "
         "Have you tried with COMPONENTS (HWLOC, CUDA, MPI, BLAS, MAGMA, FXT, SIMGRID)? "
diff --git a/modules/find/FindSUITESPARSE.cmake b/modules/find/FindSUITESPARSE.cmake
index f0f93f63930f015b03fce88c227c5298f73de0e4..7c7881c2b1c8e5e4c3dd2f23d08aaf13d1fec86f 100644
--- a/modules/find/FindSUITESPARSE.cmake
+++ b/modules/find/FindSUITESPARSE.cmake
@@ -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.
 #
 ###
@@ -21,14 +21,17 @@
 ##
 # This module finds headers and suitesparse library.
 # Results are reported in variables:
-#  SUITESPARSE_FOUND            - True if headers and requested libraries were found
-#  SUITESPARSE_LINKER_FLAGS     - list of required linker flags (excluding -l and -L)
-#  SUITESPARSE_INCLUDE_DIRS     - suitesparse include directories
-#  SUITESPARSE_LIBRARY_DIRS     - Link directories for suitesparse libraries
-#  SUITESPARSE_LIBRARIES        - suitesparse libraries
-#  SUITESPARSE_INCLUDE_DIRS_DEP - suitesparse + dependencies include directories
-#  SUITESPARSE_LIBRARY_DIRS_DEP - suitesparse + dependencies link directories
-#  SUITESPARSE_LIBRARIES_DEP    - suitesparse libraries + dependencies
+#  SUITESPARSE_FOUND             - True if headers and requested libraries were found
+#  SUITESPARSE_CFLAGS_OTHER      - suitesparse compiler flags without headers paths
+#  SUITESPARSE_LDFLAGS_OTHER     - suitesparse linker flags without libraries
+#  SUITESPARSE_INCLUDE_DIRS      - suitesparse include directories
+#  SUITESPARSE_LIBRARY_DIRS      - suitesparse link directories
+#  SUITESPARSE_LIBRARIES         - suitesparse libraries to be linked (absolute path)
+#  SUITESPARSE_CFLAGS_OTHER_DEP  - suitesparse + dependencies compiler flags without headers paths
+#  SUITESPARSE_LDFLAGS_OTHER_DEP - suitesparse + dependencies linker flags without libraries
+#  SUITESPARSE_INCLUDE_DIRS_DEP  - suitesparse + dependencies include directories
+#  SUITESPARSE_LIBRARY_DIRS_DEP  - suitesparse + dependencies link directories
+#  SUITESPARSE_LIBRARIES_DEP     - suitesparse + dependencies libraries
 #
 # The user can give specific paths where to find the libraries adding cmake
 # options at configure (ex: cmake path/to/project -DSUITESPARSE_DIR=path/to/suitesparse):
@@ -37,11 +40,11 @@
 # are not given as cmake variable: SUITESPARSE_DIR
 
 #=============================================================================
-# Copyright 2012-2016 Inria
+# Copyright 2012-2018 Inria
 # Copyright 2012-2013 Emmanuel Agullo
 # Copyright 2012-2013 Mathieu Faverge
 # Copyright 2012      Cedric Castagnede
-# Copyright 2016      Florent Pruvost
+# Copyright 2013-2018 Florent Pruvost
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file MORSE-Copyright.txt for details.
@@ -75,25 +78,10 @@ endif()
 if (NOT SUITESPARSE_FIND_QUIETLY)
   message(STATUS "Looking for SUITESPARSE - Try to detect metis")
 endif()
-if (NOT METIS_FOUND)
-  if (SUITESPARSE_FIND_REQUIRED)
-    find_package(METIS REQUIRED)
-  else()
-    find_package(METIS)
-  endif()
-endif()
-
-# SUITESPARSE depends on BLAS
-#----------------------------
-if (NOT SUITESPARSE_FIND_QUIETLY)
-  message(STATUS "Looking for SUITESPARSE - Try to detect BLAS")
-endif()
-if (NOT BLASEXT_FOUND)
-  if (SUITESPARSE_FIND_REQUIRED)
-    find_package(BLASEXT REQUIRED)
-  else()
-    find_package(BLASEXT)
-  endif()
+if (SUITESPARSE_FIND_REQUIRED)
+  find_package(METIS REQUIRED)
+else()
+  find_package(METIS)
 endif()
 
 # SUITESPARSE depends on LAPACK
@@ -101,12 +89,10 @@ endif()
 if (NOT SUITESPARSE_FIND_QUIETLY)
   message(STATUS "Looking for SUITESPARSE - Try to detect LAPACK")
 endif()
-if (NOT LAPACKEXT_FOUND)
-  if (SUITESPARSE_FIND_REQUIRED)
-    find_package(LAPACKEXT REQUIRED)
-  else()
-    find_package(LAPACKEXT)
-  endif()
+if (SUITESPARSE_FIND_REQUIRED)
+  find_package(LAPACK REQUIRED)
+else()
+  find_package(LAPACK)
 endif()
 
 # Looking for SUITESPARSE
@@ -308,8 +294,9 @@ list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIRS)
 # check a function to validate the find
 if(SUITESPARSE_LIBRARIES)
 
-  set(REQUIRED_LDFLAGS)
   set(REQUIRED_INCDIRS)
+  set(REQUIRED_FLAGS)
+  set(REQUIRED_LDFLAGS)
   set(REQUIRED_LIBDIRS)
   set(REQUIRED_LIBS)
 
@@ -337,49 +324,46 @@ if(SUITESPARSE_LIBRARIES)
   endif()
   # LAPACK
   if (LAPACK_FOUND)
-    if (LAPACK_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}")
+    if (LAPACK_INCLUDE_DIRS_DEP)
+      list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS_DEP}")
     endif()
-    foreach(libdir ${LAPACK_LIBRARY_DIRS})
-      if (libdir)
-        list(APPEND REQUIRED_LIBDIRS "${libdir}")
-      endif()
-    endforeach()
-    list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}")
-    if (LAPACK_LINKER_FLAGS)
-      list(APPEND REQUIRED_LDFLAGS "${LAPACK_LINKER_FLAGS}")
+    if (LAPACK_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER_DEP}")
     endif()
-  endif()
-  # BLAS
-  if (BLAS_FOUND)
-    if (BLAS_INCLUDE_DIRS)
-      list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}")
+    if (LAPACK_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${LAPACK_LDFLAGS_OTHER_DEP}")
     endif()
-    foreach(libdir ${BLAS_LIBRARY_DIRS})
-      if (libdir)
-        list(APPEND REQUIRED_LIBDIRS "${libdir}")
-      endif()
-    endforeach()
-    list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}")
-    if (BLAS_LINKER_FLAGS)
-      list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
+    if (LAPACK_LIBRARY_DIRS_DEP)
+      list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS_DEP}")
     endif()
+    list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES_DEP}")
   endif()
   # others
   set(M_LIBRARY "M_LIBRARY-NOTFOUND")
   find_library(M_LIBRARY NAMES m)
   mark_as_advanced(M_LIBRARY)
   if(M_LIBRARY)
-    list(APPEND REQUIRED_LIBS "-lm")
+    list(APPEND REQUIRED_LIBS "${M_LIBRARY}")
   endif()
 
   # set required libraries for link
   set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+  if (REQUIRED_FLAGS)
+    set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_DEFINITIONS)
+    foreach(_flag ${REQUIRED_FLAGS_COPY})
+      if (_flag MATCHES "^-D")
+       list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+      endif()
+      string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+      list(APPEND REQUIRED_FLAGS "${_flag}")
+    endforeach()
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
+  set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
   set(CMAKE_REQUIRED_LIBRARIES)
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-  foreach(lib_dir ${REQUIRED_LIBDIRS})
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
-  endforeach()
   list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
   string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
 
@@ -394,15 +378,17 @@ if(SUITESPARSE_LIBRARIES)
     set(SUITESPARSE_LIBRARIES_DEP "${REQUIRED_LIBS}")
     set(SUITESPARSE_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
     set(SUITESPARSE_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
-    set(SUITESPARSE_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
+    set(SUITESPARSE_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+    set(SUITESPARSE_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
     list(REMOVE_DUPLICATES SUITESPARSE_LIBRARY_DIRS_DEP)
-    list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIRS_DEP)
-    list(REMOVE_DUPLICATES SUITESPARSE_LINKER_FLAGS)
+    list(REMOVE_DUPLICATES SUITESPARSE_CFLAGS_OTHER_DEP)
+    list(REMOVE_DUPLICATES SUITESPARSE_LDFLAGS_OTHER_DEP)
   else()
     if(NOT SUITESPARSE_FIND_QUIETLY)
       message(STATUS "Looking for SUITESPARSE : test of symbol SuiteSparse_start fails")
       message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
       message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+      message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
       message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
       message(STATUS "Maybe SUITESPARSE is linked with specific libraries. ")
     endif()
diff --git a/modules/find/FindTMG.cmake b/modules/find/FindTMG.cmake
index 5a4137ef8a362b24d8d0c47d7d374aad5cc57dcf..84ae5520ca21ae5ba68fda0082c65be9b38f10a8 100644
--- a/modules/find/FindTMG.cmake
+++ b/modules/find/FindTMG.cmake
@@ -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.
 #
 ###
@@ -17,13 +17,16 @@
 # This module finds headers and tmg library.
 # Results are reported in variables:
 #  TMG_FOUND            - True if headers and requested libraries were found
-#  TMG_LINKER_FLAGS     - list of required linker flags (excluding -l and -L)
-#  TMG_INCLUDE_DIRS     - tmg include directories
-#  TMG_LIBRARY_DIRS     - Link directories for tmg libraries
-#  TMG_LIBRARIES        - tmg component libraries to be linked
-#  TMG_INCLUDE_DIRS_DEP - tmg + dependencies include directories
-#  TMG_LIBRARY_DIRS_DEP - tmg + dependencies link directories
-#  TMG_LIBRARIES_DEP    - tmg libraries + dependencies
+#  TMG_CFLAGS_OTHER      - tmglib compiler flags without headers paths
+#  TMG_LDFLAGS_OTHER     - tmglib linker flags without libraries
+#  TMG_INCLUDE_DIRS      - tmglib include directories
+#  TMG_LIBRARY_DIRS      - tmglib link directories
+#  TMG_LIBRARIES         - tmglib libraries to be linked (absolute path)
+#  TMG_CFLAGS_OTHER_DEP  - tmglib + dependencies compiler flags without headers paths
+#  TMG_LDFLAGS_OTHER_DEP - tmglib + dependencies linker flags without libraries
+#  TMG_INCLUDE_DIRS_DEP  - tmglib + dependencies include directories
+#  TMG_LIBRARY_DIRS_DEP  - tmglib + dependencies link directories
+#  TMG_LIBRARIES_DEP     - tmglib + dependencies libraries
 #
 # The user can give specific paths where to find the libraries adding cmake
 # options at configure (ex: cmake path/to/project -DTMG=path/to/tmg):
@@ -34,11 +37,11 @@
 # are not given as cmake variable: TMG_DIR, TMG_INCDIR, TMG_LIBDIR
 
 #=============================================================================
-# Copyright 2012-2013 Inria
+# Copyright 2012-2018 Inria
 # Copyright 2012-2013 Emmanuel Agullo
 # Copyright 2012-2013 Mathieu Faverge
 # Copyright 2012      Cedric Castagnede
-# Copyright 2013-2016 Florent Pruvost
+# Copyright 2013-2018 Florent Pruvost
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file MORSE-Copyright.txt for details.
@@ -68,19 +71,19 @@ else (NOT _LANGUAGES_ MATCHES Fortran)
 endif (NOT _LANGUAGES_ MATCHES Fortran)
 
 # TMG depends on LAPACK anyway, try to find it
-if (NOT LAPACK_FOUND)
-  if(TMG_FIND_REQUIRED)
-    find_package(LAPACKEXT REQUIRED)
-  else()
-    find_package(LAPACKEXT)
-  endif()
+if(TMG_FIND_REQUIRED)
+  find_package(LAPACK REQUIRED)
+else()
+  find_package(LAPACK)
 endif()
 
 # TMG depends on LAPACK
 if (LAPACK_FOUND)
 
   # check if a tmg function exists in the LAPACK lib
-  set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LINKER_FLAGS};${LAPACK_LIBRARIES}")
+  set(CMAKE_REQUIRED_LIBRARIES "${LAPACK_LDFLAGS_OTHER_DEP};${LAPACK_LIBRARIES_DEP}")
+  set(CMAKE_REQUIRED_INCLUDES "${LAPACK_INCLUDE_DIRS_DEP}")
+  set(CMAKE_REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER_DEP}")
   include(CheckFunctionExists)
   include(CheckFortranFunctionExists)
   unset(TMG_WORKS CACHE)
@@ -98,23 +101,15 @@ if (LAPACK_FOUND)
     endif (NOT _LANGUAGES_ MATCHES Fortran)
     mark_as_advanced(TMG_WORKS)
   endif()
-  set(CMAKE_REQUIRED_LIBRARIES)
 
   if(TMG_WORKS)
+
     if(NOT TMG_FIND_QUIETLY)
       message(STATUS "Looking for tmg: test with lapack succeeds")
     endif()
     # test succeeds: TMG is in LAPACK
     set(TMG_LIBRARIES "${LAPACK_LIBRARIES}")
-    if (LAPACK_LIBRARY_DIRS)
-      set(TMG_LIBRARY_DIRS "${LAPACK_LIBRARY_DIRS}")
-    endif()
-    if(LAPACK_INCLUDE_DIRS)
-      set(TMG_INCLUDE_DIRS "${LAPACK_INCLUDE_DIRS}")
-    endif()
-    if (LAPACK_LINKER_FLAGS)
-      set(TMG_LINKER_FLAGS "${LAPACK_LINKER_FLAGS}")
-    endif()
+
   else()
 
     if(NOT TMG_FIND_QUIETLY)
@@ -195,86 +190,113 @@ if (LAPACK_FOUND)
       list(REMOVE_DUPLICATES TMG_LIBRARY_DIRS)
     endif ()
 
-    # check a function to validate the find
-    if(TMG_LIBRARIES)
+  endif(TMG_WORKS)
 
-      set(REQUIRED_LDFLAGS)
-      set(REQUIRED_INCDIRS)
-      set(REQUIRED_LIBDIRS)
-      set(REQUIRED_LIBS)
+  # check a function to validate the find
+  if(TMG_LIBRARIES)
 
-      # TMG
-      if (TMG_INCLUDE_DIRS)
-        set(REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS}")
-      endif()
-      if (TMG_LIBRARY_DIRS)
-        set(REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS}")
-      endif()
-      set(REQUIRED_LIBS "${TMG_LIBRARIES}")
-      # LAPACK
-      if (LAPACK_INCLUDE_DIRS)
-        list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}")
-      endif()
-      if (LAPACK_LIBRARY_DIRS)
-        list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS}")
-      endif()
-      list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}")
-      if (LAPACK_LINKER_FLAGS)
-        list(APPEND REQUIRED_LDFLAGS "${LAPACK_LINKER_FLAGS}")
-      endif()
+    set(REQUIRED_INCDIRS)
+    set(REQUIRED_FLAGS)
+    set(REQUIRED_LDFLAGS)
+    set(REQUIRED_LIBDIRS)
+    set(REQUIRED_LIBS)
+
+    # TMG
+    if (TMG_INCLUDE_DIRS)
+      set(REQUIRED_INCDIRS "${TMG_INCLUDE_DIRS}")
+    endif()
+    if (TMG_CFLAGS_OTHER)
+      list(APPEND REQUIRED_FLAGS "${TMG_CFLAGS_OTHER}")
+    endif()
+    if (TMG_LDFLAGS_OTHER)
+      list(APPEND REQUIRED_LDFLAGS "${TMG_LDFLAGS_OTHER}")
+    endif()
+    if (TMG_LIBRARY_DIRS)
+      set(REQUIRED_LIBDIRS "${TMG_LIBRARY_DIRS}")
+    endif()
+    set(REQUIRED_LIBS "${TMG_LIBRARIES}")
+    # LAPACK
+    if (LAPACK_INCLUDE_DIRS_DEP)
+      list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS_DEP}")
+    endif()
+    if (LAPACK_CFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_FLAGS "${LAPACK_CFLAGS_OTHER_DEP}")
+    endif()
+    if (LAPACK_LDFLAGS_OTHER_DEP)
+      list(APPEND REQUIRED_LDFLAGS "${LAPACK_LDFLAGS_OTHER_DEP}")
+    endif()
+    if (LAPACK_LIBRARY_DIRS_DEP)
+      list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS_DEP}")
+    endif()
+    list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES_DEP}")
 
-      # set required libraries for link
-      set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
-      set(CMAKE_REQUIRED_LIBRARIES)
-      list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
-      foreach(lib_dir ${REQUIRED_LIBDIRS})
-        list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
+    # set required libraries for link
+    set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
+    if (REQUIRED_FLAGS)
+      set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
+      set(REQUIRED_FLAGS)
+      set(REQUIRED_DEFINITIONS)
+      foreach(_flag ${REQUIRED_FLAGS_COPY})
+        if (_flag MATCHES "^-D")
+         list(APPEND REQUIRED_DEFINITIONS "${_flag}")
+        endif()
+        string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
+        list(APPEND REQUIRED_FLAGS "${_flag}")
       endforeach()
-      list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
-      string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
+    endif()
+    set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
+    set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
+    set(CMAKE_REQUIRED_LIBRARIES)
+    list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
+    list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
+    string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
+    message(STATUS "REQUIRED_INCDIRS: ${REQUIRED_INCDIRS}")
+    message(STATUS "REQUIRED_FLAGS: ${REQUIRED_FLAGS}")
+    message(STATUS "REQUIRED_LDFLAGS: ${REQUIRED_LDFLAGS}")
+    message(STATUS "REQUIRED_LIBS: ${REQUIRED_LIBS}")
 
-      # test link
+    # test link
+    unset(TMG_WORKS CACHE)
+    include(CheckFunctionExists)
+    include(CheckFortranFunctionExists)
+    if (NOT _LANGUAGES_ MATCHES Fortran)
+      check_function_exists(dlarnv TMG_WORKS)
+    else (NOT _LANGUAGES_ MATCHES Fortran)
+      check_fortran_function_exists(dlarnv TMG_WORKS)
+    endif (NOT _LANGUAGES_ MATCHES Fortran)
+    if (TMG_WORKS)
       unset(TMG_WORKS CACHE)
-      include(CheckFunctionExists)
-      include(CheckFortranFunctionExists)
       if (NOT _LANGUAGES_ MATCHES Fortran)
-        check_function_exists(dlarnv TMG_WORKS)
+        check_function_exists(dlagsy TMG_WORKS)
       else (NOT _LANGUAGES_ MATCHES Fortran)
-        check_fortran_function_exists(dlarnv TMG_WORKS)
+        check_fortran_function_exists(dlagsy TMG_WORKS)
       endif (NOT _LANGUAGES_ MATCHES Fortran)
-      if (TMG_WORKS)
-        unset(TMG_WORKS CACHE)
-        if (NOT _LANGUAGES_ MATCHES Fortran)
-          check_function_exists(dlagsy TMG_WORKS)
-        else (NOT _LANGUAGES_ MATCHES Fortran)
-          check_fortran_function_exists(dlagsy TMG_WORKS)
-        endif (NOT _LANGUAGES_ MATCHES Fortran)
-        mark_as_advanced(TMG_WORKS)
-      endif()
+      mark_as_advanced(TMG_WORKS)
+    endif()
 
-      if(TMG_WORKS)
-        # save link with dependencies
-        set(TMG_LIBRARIES_DEP "${REQUIRED_LIBS}")
-        set(TMG_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
-        set(TMG_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
-        set(TMG_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
-        list(REMOVE_DUPLICATES TMG_LIBRARY_DIRS_DEP)
-        list(REMOVE_DUPLICATES TMG_INCLUDE_DIRS_DEP)
-        list(REMOVE_DUPLICATES TMG_LINKER_FLAGS)
-      else()
-        if(NOT TMG_FIND_QUIETLY)
-          message(STATUS "Looking for tmg: test of dlarnv and dlagsy with tmg and lapack libraries fails")
-          message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
-          message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
-          message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
-        endif()
+    if(TMG_WORKS)
+      # save link with dependencies
+      set(TMG_LIBRARIES_DEP "${REQUIRED_LIBS}")
+      set(TMG_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
+      set(TMG_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
+      set(TMG_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
+      set(TMG_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
+      list(REMOVE_DUPLICATES TMG_LIBRARY_DIRS_DEP)
+      list(REMOVE_DUPLICATES TMG_CFLAGS_OTHER_DEP)
+      list(REMOVE_DUPLICATES TMG_LDFLAGS_OTHER_DEP)
+    else()
+      if(NOT TMG_FIND_QUIETLY)
+        message(STATUS "Looking for tmg: test of dlarnv and dlagsy with tmg and lapack libraries fails")
+        message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
+        message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
+        message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
+        message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
       endif()
-      set(CMAKE_REQUIRED_INCLUDES)
-      set(CMAKE_REQUIRED_FLAGS)
-      set(CMAKE_REQUIRED_LIBRARIES)
-    endif(TMG_LIBRARIES)
-
-  endif()
+    endif()
+    set(CMAKE_REQUIRED_INCLUDES)
+    set(CMAKE_REQUIRED_FLAGS)
+    set(CMAKE_REQUIRED_LIBRARIES)
+  endif(TMG_LIBRARIES)
 
 else()