From 6ee95304271b0508adc06cad8328b766e9c98fab Mon Sep 17 00:00:00 2001 From: Florent Pruvost <florent.pruvost@inria.fr> Date: Tue, 10 Apr 2018 16:52:56 +0200 Subject: [PATCH] transform relative path from pkg-config into absolute path and check function exist also when found with pkg-config --- .../FindPkgconfigLibrariesAbsolutePath.cmake | 32 +- modules/find/FindBLAS.cmake | 278 ++++----- modules/find/FindCBLAS.cmake | 438 ++++++++------ modules/find/FindCHAMELEON.cmake | 466 ++++++++------- modules/find/FindEZTRACE.cmake | 126 ++-- modules/find/FindFFTW.cmake | 229 ++++---- modules/find/FindFXT.cmake | 123 ++-- modules/find/FindGTG.cmake | 120 ++-- modules/find/FindHQR.cmake | 117 ++-- modules/find/FindHWLOC.cmake | 119 ++-- modules/find/FindLAPACK.cmake | 78 ++- modules/find/FindLAPACKE.cmake | 478 ++++++++------- modules/find/FindPAPI.cmake | 119 ++-- modules/find/FindPARSEC.cmake | 282 +++++---- modules/find/FindPETSc.cmake | 1 + modules/find/FindSIMGRID.cmake | 128 ++-- modules/find/FindSTARPU.cmake | 555 ++++++++---------- modules/find/tests/CMakeLists.txt | 9 + 18 files changed, 1932 insertions(+), 1766 deletions(-) diff --git a/modules/FindPkgconfigLibrariesAbsolutePath.cmake b/modules/FindPkgconfigLibrariesAbsolutePath.cmake index c36a687..382f687 100644 --- a/modules/FindPkgconfigLibrariesAbsolutePath.cmake +++ b/modules/FindPkgconfigLibrariesAbsolutePath.cmake @@ -20,7 +20,7 @@ # ### -# Transform relative path into absolute path for libraries found with the +# Transform relative path into absolute path for libraries found with the # pkg_search_module cmake macro # _prefix: the name of the CMake variable used when pkg_search_module was called # e.g. for pkg_search_module(BLAS blas) _prefix would be BLAS @@ -34,10 +34,19 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix) endif() list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}") list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + # non static case set(${_prefix}_LIBRARIES_COPY "${${_prefix}_LIBRARIES}") set(${_prefix}_LIBRARIES "") foreach(_library ${${_prefix}_LIBRARIES_COPY}) - get_filename_component(_library "${_library}" NAME_WE) + if(EXISTS "${_library}") + list(APPEND ${_prefix}_LIBRARIES ${_library}) + else() + get_filename_component(_ext "${_library}" EXT) + set(_lib_extensions ".so" ".a" ".dyld" ".dll") + list(FIND _lib_extensions "${_ext}" _index) + if (${_index} GREATER -1) + get_filename_component(_library "${_library}" NAME_WE) + endif() find_library(_library_path NAMES ${_library} HINTS ${${_prefix}_LIBDIR} ${${_prefix}_LIBRARY_DIRS} ${_lib_env}) if (_library_path) @@ -46,22 +55,33 @@ macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix) message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND") endif() unset(_library_path CACHE) - set (${_prefix}_LIBRARIES "${${_prefix}_LIBRARIES}" CACHE INTERNAL "" FORCE) + endif() endforeach() + set (${_prefix}_LIBRARIES "${${_prefix}_LIBRARIES}" CACHE INTERNAL "" FORCE) + # static case set(${_prefix}_STATIC_LIBRARIES_COPY "${${_prefix}_STATIC_LIBRARIES}") set(${_prefix}_STATIC_LIBRARIES "") foreach(_library ${${_prefix}_STATIC_LIBRARIES_COPY}) - get_filename_component(_library "${_library}" NAME_WE) + if(EXISTS "${_library}") + list(APPEND ${_prefix}_STATIC_LIBRARIES ${_library}) + else() + get_filename_component(_ext "${_library}" EXT) + set(_lib_extensions ".so" ".a" ".dyld" ".dll") + list(FIND _lib_extensions "${_ext}" _index) + if (${_index} GREATER -1) + get_filename_component(_library "${_library}" NAME_WE) + endif() find_library(_library_path NAMES ${_library} HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env}) if (_library_path) - list(APPEND ${_prefix}_STATIC_LIBRARIES ${_library_path}) + list(APPEND ${_prefix}_STATIC_LIBRARIES ${_library_path}) else() message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND") endif() unset(_library_path CACHE) - set (${_prefix}_STATIC_LIBRARIES "${${_prefix}_STATIC_LIBRARIES}" CACHE INTERNAL "" FORCE) + endif() endforeach() + set (${_prefix}_STATIC_LIBRARIES "${${_prefix}_STATIC_LIBRARIES}" CACHE INTERNAL "" FORCE) endmacro() ## diff --git a/modules/find/FindBLAS.cmake b/modules/find/FindBLAS.cmake index 905ad04..653ba58 100644 --- a/modules/find/FindBLAS.cmake +++ b/modules/find/FindBLAS.cmake @@ -20,7 +20,7 @@ # is found # BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l # and -L). -# BLAS_COMPILER_FLAGS - uncached list of required compiler flags (including -I for mkl headers). +# BLAS_COMPILER_FLAGS - uncached list of required compiler flags (including -I). # BLAS_LIBRARIES - uncached list of libraries (using full path name) to # link against to use BLAS # BLAS95_LIBRARIES - uncached list of libraries (using full path name) @@ -32,6 +32,21 @@ # all the possibilities # BLAS_VENDOR_FOUND stores the BLAS vendor found # BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK +# +# BLAS_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = BLAS +# <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 -DBLAS_DIR=path/to/blas): # BLAS_DIR - Where to find the base directory of blas @@ -342,8 +357,7 @@ find_package(PkgConfig QUIET) if( PKG_CONFIG_EXECUTABLE AND NOT BLAS_GIVEN_BY_USER AND BLA_VENDOR STREQUAL "All") pkg_search_module(BLAS blas) - find_pkgconfig_libraries_absolute_path(BLAS) - + if (NOT BLAS_FIND_QUIETLY) if (BLAS_FOUND AND BLAS_LIBRARIES) message(STATUS "Looking for BLAS - found using PkgConfig") @@ -354,17 +368,17 @@ if( PKG_CONFIG_EXECUTABLE AND NOT BLAS_GIVEN_BY_USER AND BLA_VENDOR STREQUAL "Al endif() endif() - if (BLA_STATIC) - set(BLAS_LINKER_FLAGS "${BLAS_STATIC_LDFLAGS}") - set(BLAS_COMPILER_FLAGS "${BLAS_STATIC_CFLAGS}") - set(BLAS_LIBRARIES "${BLAS_STATIC_LIBRARIES}") - else() - set(BLAS_LINKER_FLAGS "${BLAS_LDFLAGS}") - set(BLAS_COMPILER_FLAGS "${BLAS_CFLAGS}") - endif() - 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() @@ -374,11 +388,11 @@ endif() if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) #BLAS in intel mkl 10 library? (em64t 64bit) if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES OR BLA_VENDOR MATCHES "Intel*") # Looking for include # ------------------- - + # Add system include paths to search include # ------------------------------------------ unset(_inc_env) @@ -412,10 +426,10 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) 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 fftw header in the given paths # ------------------------------------------------- # call cmake macro to find the header path @@ -439,7 +453,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() mark_as_advanced(BLAS_mkl.h_DIRS) - + # If found, add path to cmake variable # ------------------------------------ if (BLAS_mkl.h_DIRS) @@ -450,7 +464,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) message(STATUS "Looking for BLAS -- mkl.h not found") endif() endif() - + if (WIN32) string(REPLACE ":" ";" _libdir "$ENV{LIB}") elseif (APPLE) @@ -487,7 +501,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) set(OMP_LIB "${OMP_iomp5_LIBRARY}") endif() endif() - + if (UNIX AND NOT WIN32) # m find_library(M_LIBRARY @@ -546,24 +560,24 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) list(APPEND BLAS_COMPILER_FLAGS "-I${ENV_MKLROOT}/include") endif() endif() - + set(additional_flags "") if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") set(additional_flags "-Wl,--no-as-needed") endif() endif () - + if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) find_package(Threads) else() find_package(Threads REQUIRED) endif() - + set(BLAS_SEARCH_LIBS "") - + if(BLA_F95) - + set(BLAS_mkl_SEARCH_SYMBOL SGEMM) set(_LIBRARIES BLAS95_LIBRARIES) if (WIN32) @@ -572,7 +586,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) else() set(BLAS_mkl_DLL_SUFFIX "_dll") endif() - + # Find the main file (32-bit or 64-bit) set(BLAS_SEARCH_LIBS_WIN_MAIN "") if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") @@ -583,7 +597,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN "mkl_blas95_lp64${BLAS_mkl_DLL_SUFFIX} mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") endif () - + # Add threading/sequential libs set(BLAS_SEARCH_LIBS_WIN_THREAD "") if (BLA_VENDOR STREQUAL "*_seq" OR BLA_VENDOR STREQUAL "All") @@ -598,7 +612,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") endif() - + # Cartesian product of the above foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) @@ -633,9 +647,9 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif () endif (WIN32) - + else (BLA_F95) - + set(BLAS_mkl_SEARCH_SYMBOL sgemm) set(_LIBRARIES BLAS_LIBRARIES) if (WIN32) @@ -644,7 +658,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) else() set(BLAS_mkl_DLL_SUFFIX "_dll") endif() - + # Find the main file (32-bit or 64-bit) set(BLAS_SEARCH_LIBS_WIN_MAIN "") if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") @@ -655,7 +669,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN "mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") endif () - + # Add threading/sequential libs set(BLAS_SEARCH_LIBS_WIN_THREAD "") if (NOT BLA_VENDOR STREQUAL "*_seq" OR BLA_VENDOR STREQUAL "All") @@ -670,7 +684,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") endif() - + # Cartesian product of the above foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) @@ -714,9 +728,9 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) "mkl_em64t") endif () endif (WIN32) - + endif (BLA_F95) - + foreach (IT ${BLAS_SEARCH_LIBS}) string(REPLACE " " ";" SEARCH_LIBS ${IT}) if (${_LIBRARIES}) @@ -747,10 +761,10 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) endif(NOT BLAS_LIBRARIES OR BLA_VENDOR MATCHES "Intel*") endif (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") - - + + if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) check_fortran_libraries( @@ -772,13 +786,13 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "Goto") endif() - + endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") - - + + # OpenBlas if (BLA_VENDOR STREQUAL "Open" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) # openblas (http://www.openblas.net/) check_fortran_libraries( @@ -800,13 +814,13 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "Openblas") endif() - + endif (BLA_VENDOR STREQUAL "Open" OR BLA_VENDOR STREQUAL "All") - - + + # EigenBlas if (BLA_VENDOR STREQUAL "Eigen" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) # eigenblas (http://eigen.tuxfamily.org/index.php?title=Main_Page) check_fortran_libraries( @@ -825,7 +839,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if(NOT BLAS_LIBRARIES) # eigenblas (http://eigen.tuxfamily.org/index.php?title=Main_Page) check_fortran_libraries( @@ -847,12 +861,12 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "Eigen") endif() - + endif (BLA_VENDOR STREQUAL "Eigen" OR BLA_VENDOR STREQUAL "All") - - + + if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) check_fortran_libraries( @@ -871,17 +885,17 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "Atlas") endif() - + endif (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") - - + + # BLAS in PhiPACK libraries? (requires generic BLAS lib, too) if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -899,17 +913,17 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "PhiPACK") endif() - + endif (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") - - + + # BLAS in Alpha CXML library? if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -927,17 +941,17 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "CXML") endif() - + endif (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") - - + + # BLAS in Alpha DXML library? (now called CXML, see above) if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -955,17 +969,17 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "DXML") endif() - + endif (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") - - + + # BLAS in Sun Performance library? if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -986,17 +1000,17 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "SunPerf") endif() - + endif () - - + + # BLAS in SCSL library? (SGI/Cray Scientific Library) if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -1014,17 +1028,17 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "SunPerf") endif() - + endif () - - + + # BLAS in SGIMATH library? if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -1042,17 +1056,17 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "SGIMATH") endif() - + endif () - - + + # BLAS in IBM ESSL library (requires generic BLAS lib, too) if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -1070,16 +1084,16 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "IBM ESSL") endif() - + endif () - + # BLAS in IBM ESSL_MT library (requires generic BLAS lib, too) if (BLA_VENDOR STREQUAL "IBMESSLMT" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -1097,21 +1111,21 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "IBM ESSL MT") endif() - + endif () - - + + #BLAS in acml library? if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") - + if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))) - + # try to find acml in "standard" paths if( WIN32 ) file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" ) @@ -1125,9 +1139,9 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() list(GET _ACML_ROOT 0 _ACML_ROOT) list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT) - + if( _ACML_ROOT ) - + get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH ) if( SIZEOF_INTEGER EQUAL 8 ) set( _ACML_PATH_SUFFIX "_int64" ) @@ -1159,7 +1173,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) set( _ACML_COMPILER32 "gfortran32" ) set( _ACML_COMPILER64 "gfortran64" ) endif() - + if( BLA_VENDOR STREQUAL "ACML_MP" ) set(_ACML_MP_LIB_DIRS "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" @@ -1169,15 +1183,15 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib" "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) endif() - + endif(_ACML_ROOT) - + elseif(BLAS_${BLA_VENDOR}_LIB_DIRS) - + set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS}) - + endif() - + if( BLA_VENDOR STREQUAL "ACML_MP" ) foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS}) check_fortran_libraries ( @@ -1215,7 +1229,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endforeach() endif() - + # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both if(NOT BLAS_LIBRARIES) check_fortran_libraries( @@ -1234,7 +1248,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -1252,7 +1266,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -1270,17 +1284,17 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "ACML") endif() - + endif (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") # ACML - - + + # Apple BLAS library? if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") - + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -1298,16 +1312,16 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif() - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "Apple Accelerate") endif() - + endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") - - + + if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - + if ( NOT BLAS_LIBRARIES ) check_fortran_libraries( BLAS_LIBRARIES @@ -1325,17 +1339,17 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endif () - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "NAS") endif() - + endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - - + + # Generic BLAS library? if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") - + set(BLAS_SEARCH_LIBS "blas;blas_LINUX;blas_MAC;blas_WINDOWS;refblas") foreach (SEARCH_LIB ${BLAS_SEARCH_LIBS}) if (BLAS_LIBRARIES) @@ -1357,22 +1371,22 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif() endforeach () - + if (BLAS_LIBRARIES AND NOT BLAS_VENDOR_FOUND) set (BLAS_VENDOR_FOUND "Netlib or other Generic libblas") endif() - + endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") - - + + if(BLA_F95) - + if(BLAS95_LIBRARIES) set(BLAS95_FOUND TRUE) else() set(BLAS95_FOUND FALSE) endif() - + if(NOT BLAS_FIND_QUIETLY) if(BLAS95_FOUND) message(STATUS "A library with BLAS95 API found.") @@ -1397,15 +1411,15 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif(BLAS95_FOUND) endif(NOT BLAS_FIND_QUIETLY) - + set(BLAS_FOUND TRUE) set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}") if (NOT BLAS_LIBRARIES_DEP) set(BLAS_LIBRARIES_DEP "${BLAS95_LIBRARIES}") endif() - + else(BLA_F95) - + if(BLAS_LIBRARIES) set(BLAS_FOUND TRUE) if (NOT BLAS_LIBRARIES_DEP) @@ -1414,7 +1428,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) else() set(BLAS_FOUND FALSE) endif() - + if(NOT BLAS_FIND_QUIETLY) if(BLAS_FOUND) message(STATUS "A library with BLAS API found.") @@ -1439,7 +1453,7 @@ if( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) endif() endif(BLAS_FOUND) endif(NOT BLAS_FIND_QUIETLY) - + endif(BLA_F95) endif( (NOT BLAS_FOUND_WITH_PKGCONFIG) OR BLAS_GIVEN_BY_USER ) diff --git a/modules/find/FindCBLAS.cmake b/modules/find/FindCBLAS.cmake index 81f4ddf..603bbb5 100644 --- a/modules/find/FindCBLAS.cmake +++ b/modules/find/FindCBLAS.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,7 +21,6 @@ # This module finds headers and cblas library. # Results are reported in variables: # CBLAS_FOUND - True if headers and requested libraries were found -# CBLAS_LINKER_FLAGS - list of required linker flags (excluding -l and -L) # CBLAS_INCLUDE_DIRS - cblas include directories # CBLAS_LIBRARY_DIRS - Link directories for cblas libraries # CBLAS_LIBRARIES - cblas component libraries to be linked @@ -30,6 +29,20 @@ # CBLAS_LIBRARIES_DEP - cblas libraries + dependencies # 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 +# <PREFIX> = CBLAS +# <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 -DCBLAS_DIR=path/to/cblas): # CBLAS_DIR - Where to find the base directory of cblas @@ -59,11 +72,11 @@ # #============================================================================= -# 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. @@ -130,235 +143,276 @@ if (BLAS_FOUND) set(CBLAS_INCLUDE_DIRS "${BLAS_INCLUDE_DIRS}") set(CBLAS_INCLUDE_DIRS_DEP "${BLAS_INCLUDE_DIRS_DEP}") endif() - if (BLAS_LINKER_FLAGS) - set(CBLAS_LINKER_FLAGS "${BLAS_LINKER_FLAGS}") - endif() endif() endif (NOT CBLAS_STANDALONE) + # test fails with blas: try to find CBLAS lib exterior to BLAS if (CBLAS_STANDALONE OR NOT CBLAS_WORKS) if(NOT CBLAS_WORKS AND NOT CBLAS_FIND_QUIETLY) message(STATUS "Looking for cblas : test with blas fails") endif() - # test fails: try to find CBLAS lib exterior to BLAS - - # Try to find CBLAS lib - ####################### - # Looking for include - # ------------------- - - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) + # try with pkg-config set(ENV_CBLAS_DIR "$ENV{CBLAS_DIR}") set(ENV_CBLAS_INCDIR "$ENV{CBLAS_INCDIR}") - if(ENV_CBLAS_INCDIR) - list(APPEND _inc_env "${ENV_CBLAS_INCDIR}") - elseif(ENV_CBLAS_DIR) - list(APPEND _inc_env "${ENV_CBLAS_DIR}") - list(APPEND _inc_env "${ENV_CBLAS_DIR}/include") - list(APPEND _inc_env "${ENV_CBLAS_DIR}/include/cblas") - else() - if(WIN32) - string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") - list(APPEND _inc_env "${_path_env}") + set(ENV_CBLAS_LIBDIR "$ENV{CBLAS_LIBDIR}") + set(CBLAS_GIVEN_BY_USER "FALSE") + if ( CBLAS_DIR OR ( CBLAS_INCDIR AND CBLAS_LIBDIR) OR ENV_CBLAS_DIR OR (ENV_CBLAS_INCDIR AND ENV_CBLAS_LIBDIR) ) + set(CBLAS_GIVEN_BY_USER "TRUE") + endif() + + include(FindPkgConfig) + find_package(PkgConfig QUIET) + if( PKG_CONFIG_EXECUTABLE AND NOT CBLAS_GIVEN_BY_USER) + + pkg_search_module(CBLAS cblas) + + if (NOT CBLAS_FIND_QUIETLY) + if (CBLAS_FOUND AND CBLAS_LIBRARIES) + message(STATUS "Looking for CBLAS - found using PkgConfig") + else() + message(STATUS "${Magenta}Looking for CBLAS - not found using PkgConfig." + "\n Perhaps you should add the directory containing cblas.pc to" + "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") + endif() + endif() + + if (CBLAS_FOUND AND CBLAS_LIBRARIES) + set(CBLAS_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(CBLAS) 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(CBLAS_FOUND_WITH_PKGCONFIG "FALSE") 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 cblas header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(CBLAS_INCDIR) - set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND") - find_path(CBLAS_cblas.h_DIRS - NAMES cblas.h - HINTS ${CBLAS_INCDIR}) - else() - if(CBLAS_DIR) - set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND") - find_path(CBLAS_cblas.h_DIRS - NAMES cblas.h - HINTS ${CBLAS_DIR} - PATH_SUFFIXES "include" "include/cblas") + + if (NOT CBLAS_FOUND_WITH_PKGCONFIG OR CBLAS_GIVEN_BY_USER) + # Try to find CBLAS lib + ####################### + + # Looking for include + # ------------------- + + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_CBLAS_DIR "$ENV{CBLAS_DIR}") + set(ENV_CBLAS_INCDIR "$ENV{CBLAS_INCDIR}") + if(ENV_CBLAS_INCDIR) + list(APPEND _inc_env "${ENV_CBLAS_INCDIR}") + elseif(ENV_CBLAS_DIR) + list(APPEND _inc_env "${ENV_CBLAS_DIR}") + list(APPEND _inc_env "${ENV_CBLAS_DIR}/include") + list(APPEND _inc_env "${ENV_CBLAS_DIR}/include/cblas") else() + if(WIN32) + string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}") + list(APPEND _inc_env "${_path_env}") + 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 cblas header in the given paths + # ------------------------------------------------- + # call cmake macro to find the header path + if(CBLAS_INCDIR) set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND") find_path(CBLAS_cblas.h_DIRS NAMES cblas.h - HINTS ${_inc_env} - PATH_SUFFIXES "cblas") + HINTS ${CBLAS_INCDIR}) + else() + if(CBLAS_DIR) + set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND") + find_path(CBLAS_cblas.h_DIRS + NAMES cblas.h + HINTS ${CBLAS_DIR} + PATH_SUFFIXES "include" "include/cblas") + else() + set(CBLAS_cblas.h_DIRS "CBLAS_cblas.h_DIRS-NOTFOUND") + find_path(CBLAS_cblas.h_DIRS + NAMES cblas.h + HINTS ${_inc_env} + PATH_SUFFIXES "cblas") + endif() endif() - endif() - mark_as_advanced(CBLAS_cblas.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (CBLAS_cblas.h_DIRS) - set(CBLAS_INCLUDE_DIRS "${CBLAS_cblas.h_DIRS}") - else () - set(CBLAS_INCLUDE_DIRS "CBLAS_INCLUDE_DIRS-NOTFOUND") - if(NOT CBLAS_FIND_QUIETLY) - message(STATUS "Looking for cblas -- cblas.h not found") + mark_as_advanced(CBLAS_cblas.h_DIRS) + + # If found, add path to cmake variable + # ------------------------------------ + if (CBLAS_cblas.h_DIRS) + set(CBLAS_INCLUDE_DIRS "${CBLAS_cblas.h_DIRS}") + else () + set(CBLAS_INCLUDE_DIRS "CBLAS_INCLUDE_DIRS-NOTFOUND") + if(NOT CBLAS_FIND_QUIETLY) + message(STATUS "Looking for cblas -- cblas.h not found") + endif() endif() - endif() - # Looking for lib - # --------------- + # Looking for lib + # --------------- - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_CBLAS_LIBDIR "$ENV{CBLAS_LIBDIR}") - if(ENV_CBLAS_LIBDIR) - list(APPEND _lib_env "${ENV_CBLAS_LIBDIR}") - elseif(ENV_CBLAS_DIR) - list(APPEND _lib_env "${ENV_CBLAS_DIR}") - list(APPEND _lib_env "${ENV_CBLAS_DIR}/lib") - else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_CBLAS_LIBDIR "$ENV{CBLAS_LIBDIR}") + if(ENV_CBLAS_LIBDIR) + list(APPEND _lib_env "${ENV_CBLAS_LIBDIR}") + elseif(ENV_CBLAS_DIR) + list(APPEND _lib_env "${ENV_CBLAS_DIR}") + list(APPEND _lib_env "${ENV_CBLAS_DIR}/lib") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + 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() - 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) + list(REMOVE_DUPLICATES _lib_env) - # Try to find the cblas lib in the given paths - # ---------------------------------------------- + # Try to find the cblas lib in the given paths + # ---------------------------------------------- - # call cmake macro to find the lib path - if(CBLAS_LIBDIR) - set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") - find_library(CBLAS_cblas_LIBRARY - NAMES cblas - HINTS ${CBLAS_LIBDIR}) - else() - if(CBLAS_DIR) + # call cmake macro to find the lib path + if(CBLAS_LIBDIR) set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") find_library(CBLAS_cblas_LIBRARY NAMES cblas - HINTS ${CBLAS_DIR} - PATH_SUFFIXES lib lib32 lib64) + HINTS ${CBLAS_LIBDIR}) else() - set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") - find_library(CBLAS_cblas_LIBRARY - NAMES cblas - HINTS ${_lib_env}) - endif() - endif() - mark_as_advanced(CBLAS_cblas_LIBRARY) - - # If found, add path to cmake variable - # ------------------------------------ - if (CBLAS_cblas_LIBRARY) - get_filename_component(cblas_lib_path "${CBLAS_cblas_LIBRARY}" PATH) - # set cmake variables - set(CBLAS_LIBRARIES "${CBLAS_cblas_LIBRARY}") - set(CBLAS_LIBRARY_DIRS "${cblas_lib_path}") - else () - set(CBLAS_LIBRARIES "CBLAS_LIBRARIES-NOTFOUND") - set(CBLAS_LIBRARY_DIRS "CBLAS_LIBRARY_DIRS-NOTFOUND") - if (NOT CBLAS_FIND_QUIETLY) - message(STATUS "Looking for cblas -- lib cblas not found") + if(CBLAS_DIR) + set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") + find_library(CBLAS_cblas_LIBRARY + NAMES cblas + HINTS ${CBLAS_DIR} + PATH_SUFFIXES lib lib32 lib64) + else() + set(CBLAS_cblas_LIBRARY "CBLAS_cblas_LIBRARY-NOTFOUND") + find_library(CBLAS_cblas_LIBRARY + NAMES cblas + HINTS ${_lib_env}) + endif() endif() - endif () + mark_as_advanced(CBLAS_cblas_LIBRARY) + + # If found, add path to cmake variable + # ------------------------------------ + if (CBLAS_cblas_LIBRARY) + get_filename_component(cblas_lib_path "${CBLAS_cblas_LIBRARY}" PATH) + # set cmake variables + set(CBLAS_LIBRARIES "${CBLAS_cblas_LIBRARY}") + set(CBLAS_LIBRARY_DIRS "${cblas_lib_path}") + else () + set(CBLAS_LIBRARIES "CBLAS_LIBRARIES-NOTFOUND") + set(CBLAS_LIBRARY_DIRS "CBLAS_LIBRARY_DIRS-NOTFOUND") + if (NOT CBLAS_FIND_QUIETLY) + message(STATUS "Looking for cblas -- lib cblas not found") + endif() + endif () + endif (NOT CBLAS_FOUND_WITH_PKGCONFIG OR CBLAS_GIVEN_BY_USER) - # check a function to validate the find - if(CBLAS_LIBRARIES) + endif (CBLAS_STANDALONE OR NOT CBLAS_WORKS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + # check a function to validate the find + if(CBLAS_LIBRARIES) - # CBLAS - if (CBLAS_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}") - endif() - if (CBLAS_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${CBLAS_LIBRARIES}") - # BLAS - if (BLAS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") - 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() + set(REQUIRED_INCDIRS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # 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}") - endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(CBLAS_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(cblas_dscal CBLAS_WORKS) - mark_as_advanced(CBLAS_WORKS) - - if(CBLAS_WORKS) - - # Check for faster complex GEMM routine - # (only C/Z, no S/D version) - check_function_exists(cblas_zgemm3m CBLAS_ZGEMM3M_FOUND) - if ( CBLAS_ZGEMM3M_FOUND ) - add_definitions(-DCBLAS_HAS_ZGEMM3M -DCBLAS_HAS_CGEMM3M) - endif() + # CBLAS + if (CBLAS_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${CBLAS_INCLUDE_DIRS}") + endif() + if (CBLAS_CFLAGS_OTHER) + list(APPEND REQUIRED_FLAGS "${CBLAS_CFLAGS_OTHER}") + endif() + if (CBLAS_LDFLAGS_OTHER) + list(APPEND REQUIRED_LDFLAGS "${CBLAS_LDFLAGS_OTHER}") + endif() + if (CBLAS_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${CBLAS_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${CBLAS_LIBRARIES}") + # BLAS + if (BLAS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") + endif() + if (BLAS_COMPILER_FLAGS) + list(APPEND REQUIRED_FLAGS "${BLAS_COMPILER_FLAGS}") + endif() + if (BLAS_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}") + endif() + if (BLAS_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${BLAS_LIBRARY_DIRS}") + endif() + list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}") - # save link with dependencies - set(CBLAS_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(CBLAS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(CBLAS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(CBLAS_LINKER_FLAGS "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES CBLAS_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES CBLAS_INCLUDE_DIRS_DEP) - list(REMOVE_DUPLICATES CBLAS_LINKER_FLAGS) - 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 "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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}") + + # test link + unset(CBLAS_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(cblas_dscal CBLAS_WORKS) + mark_as_advanced(CBLAS_WORKS) + + if(CBLAS_WORKS) + + # Check for faster complex GEMM routine + # (only C/Z, no S/D version) + check_function_exists(cblas_zgemm3m CBLAS_ZGEMM3M_FOUND) + if ( CBLAS_ZGEMM3M_FOUND ) + add_definitions(-DCBLAS_HAS_ZGEMM3M -DCBLAS_HAS_CGEMM3M) endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(CBLAS_LIBRARIES) - endif (CBLAS_STANDALONE OR NOT CBLAS_WORKS) + # save link with dependencies + set(CBLAS_LIBRARIES_DEP "${REQUIRED_LIBS}") + set(CBLAS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") + set(CBLAS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + list(REMOVE_DUPLICATES CBLAS_LIBRARY_DIRS_DEP) + list(REMOVE_DUPLICATES CBLAS_INCLUDE_DIRS_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 "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(CBLAS_LIBRARIES) else(BLAS_FOUND) diff --git a/modules/find/FindCHAMELEON.cmake b/modules/find/FindCHAMELEON.cmake index 3b330ee..d30c9c7 100644 --- a/modules/find/FindCHAMELEON.cmake +++ b/modules/find/FindCHAMELEON.cmake @@ -37,14 +37,27 @@ # This module finds headers and chameleon library. # Results are reported in variables: # CHAMELEON_FOUND - True if headers and requested libraries were found -# CHAMELEON_C_FLAGS - list of required compilation flags (excluding -I) # 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_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = CHAMELEON +# <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 -DCHAMELEON_DIR=path/to/chameleon): # CHAMELEON_DIR - Where to find the base directory of chameleon @@ -132,6 +145,7 @@ find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_GIVEN_BY_USER) pkg_search_module(CHAMELEON chameleon) + if (NOT CHAMELEON_FIND_QUIETLY) if (CHAMELEON_FOUND AND CHAMELEON_LIBRARIES) message(STATUS "Looking for CHAMELEON - found using PkgConfig") @@ -163,13 +177,9 @@ if(PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_GIVEN_BY_USER) endif() endif() - set(CHAMELEON_C_FLAGS "${CHAMELEON_CFLAGS_OTHER}") - set(CHAMELEON_INCLUDE_DIRS_DEP "${CHAMELEON_STATIC_INCLUDE_DIRS}") - set(CHAMELEON_LIBRARY_DIRS_DEP "${CHAMELEON_STATIC_LIBRARY_DIRS}") - set(CHAMELEON_LIBRARIES_DEP "${CHAMELEON_STATIC_LIBRARIES}") - if (CHAMELEON_FOUND AND CHAMELEON_LIBRARIES) set(CHAMELEON_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(CHAMELEON) else() set(CHAMELEON_FOUND_WITH_PKGCONFIG "FALSE") endif() @@ -534,126 +544,102 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN endforeach(chameleon_lib ${CHAMELEON_libs_to_find}) - # check a function to validate the find - if(CHAMELEON_LIBRARIES) +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR (CHAMELEON_GIVEN_BY_USER) ) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +# check a function to validate the find +if(CHAMELEON_LIBRARIES) - # CHAMELEON - if (CHAMELEON_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${CHAMELEON_INCLUDE_DIRS}") - endif() - foreach(libdir ${CHAMELEON_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - set(REQUIRED_LIBS "${CHAMELEON_LIBRARIES}") - # STARPU - 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_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_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() + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) + + # CHAMELEON + if (CHAMELEON_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${CHAMELEON_INCLUDE_DIRS}") + endif() + if (CHAMELEON_CFLAGS_OTHER) + list(APPEND REQUIRED_FLAGS "${CHAMELEON_CFLAGS_OTHER}") + endif() + if (CHAMELEON_LDFLAGS_OTHER) + list(APPEND REQUIRED_LDFLAGS "${CHAMELEON_LDFLAGS_OTHER}") + endif() + foreach(libdir ${CHAMELEON_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") endif() - # CUDA - if (CUDA_FOUND AND CHAMELEON_LOOK_FOR_CUDA) - if (CUDA_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") - endif() - foreach(libdir ${CUDA_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") + endforeach() + set(REQUIRED_LIBS "${CHAMELEON_LIBRARIES}") + # STARPU + 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_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() - 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) - list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") - endif() - if (MPI_C_LINK_FLAGS) - if (${MPI_C_LINK_FLAGS} MATCHES " -") - string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) - endif() - list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") - endif() - list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") + 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_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() - # HWLOC - if (HWLOC_FOUND) - if (HWLOC_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") + endif() + # CUDA + if (CUDA_FOUND AND CHAMELEON_LOOK_FOR_CUDA) + if (CUDA_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") + endif() + foreach(libdir ${CUDA_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") endif() - foreach(libdir ${HWLOC_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") - endif() - endforeach() - foreach(lib ${HWLOC_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() @@ -661,114 +647,145 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUN endif() endforeach() 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_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() + # MPI + if (MPI_FOUND AND CHAMELEON_LOOK_FOR_MPI) + if (MPI_C_INCLUDE_PATH) + list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") 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_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}") + if (MPI_C_LINK_FLAGS) + if (${MPI_C_LINK_FLAGS} MATCHES " -") + string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) endif() + list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") 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_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() + list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") + endif() + # HWLOC + if (HWLOC_FOUND) + if (HWLOC_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") endif() - # EXTRA LIBS such that pthread, m, rt - list(APPEND REQUIRED_LIBS ${CHAMELEON_EXTRA_LIBRARIES}) - - # 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}") + foreach(libdir ${HWLOC_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(CHAMELEON_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(MORSE_Init CHAMELEON_WORKS) - mark_as_advanced(CHAMELEON_WORKS) - - if(CHAMELEON_WORKS) - # save link with dependencies - 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}") - list(REMOVE_DUPLICATES CHAMELEON_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES CHAMELEON_INCLUDE_DIRS_DEP) - list(REMOVE_DUPLICATES CHAMELEON_LINKER_FLAGS) - 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 "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)? " - "See the explanation in FindCHAMELEON.cmake.") + foreach(lib ${HWLOC_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") endif() + endforeach() + 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_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() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(CHAMELEON_LIBRARIES) - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_FOUND) OR (CHAMELEON_GIVEN_BY_USER) ) + 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_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_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 + list(APPEND REQUIRED_LIBS ${CHAMELEON_EXTRA_LIBRARIES}) + + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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}") + + # test link + unset(CHAMELEON_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(MORSE_Init CHAMELEON_WORKS) + mark_as_advanced(CHAMELEON_WORKS) + + if(CHAMELEON_WORKS) + # save link with dependencies + 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}") + list(REMOVE_DUPLICATES CHAMELEON_LIBRARY_DIRS_DEP) + list(REMOVE_DUPLICATES CHAMELEON_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES CHAMELEON_LINKER_FLAGS) + 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 "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)? " + "See the explanation in FindCHAMELEON.cmake.") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) +endif(CHAMELEON_LIBRARIES) if (CHAMELEON_LIBRARIES) if (CHAMELEON_LIBRARY_DIRS) @@ -795,11 +812,6 @@ mark_as_advanced(CHAMELEON_DIR_FOUND) # check that CHAMELEON has been found # --------------------------------- include(FindPackageHandleStandardArgs) -if (PKG_CONFIG_EXECUTABLE AND CHAMELEON_FOUND) - find_package_handle_standard_args(CHAMELEON DEFAULT_MSG - CHAMELEON_LIBRARIES) -else() - find_package_handle_standard_args(CHAMELEON DEFAULT_MSG - CHAMELEON_LIBRARIES - CHAMELEON_WORKS) -endif() +find_package_handle_standard_args(CHAMELEON DEFAULT_MSG + CHAMELEON_LIBRARIES + CHAMELEON_WORKS) diff --git a/modules/find/FindEZTRACE.cmake b/modules/find/FindEZTRACE.cmake index f11ae61..ef8aa2c 100644 --- a/modules/find/FindEZTRACE.cmake +++ b/modules/find/FindEZTRACE.cmake @@ -20,11 +20,23 @@ # This module finds headers and eztrace library. # Results are reported in variables: # EZTRACE_FOUND - True if headers and requested libraries were found -# EZTRACE_C_FLAGS - list of required compilation flags (excluding -I) # EZTRACE_INCLUDE_DIRS - eztrace include directories # EZTRACE_LIBRARY_DIRS - Link directories for eztrace libraries # EZTRACE_LIBRARIES - eztrace component libraries to be linked +# # EZTRACE_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = EZTRACE +# <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 -DEZTRACE_DIR=path/to/eztrace): @@ -73,14 +85,10 @@ find_package(PkgConfig QUIET) if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER ) pkg_search_module(EZTRACE eztrace) + if (NOT EZTRACE_FIND_QUIETLY) if (EZTRACE_FOUND AND EZTRACE_LIBRARIES) message(STATUS "Looking for EZTRACE - found using PkgConfig") - #if(NOT EZTRACE_INCLUDE_DIRS) - # message("${Magenta}EZTRACE_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to eztrace headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() else() message(STATUS "${Magenta}Looking for EZTRACE - not found using PkgConfig." "\n Perhaps you should add the directory containing eztrace.pc to" @@ -88,13 +96,12 @@ if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER ) endif() if (EZTRACE_FOUND AND EZTRACE_LIBRARIES) set(EZTRACE_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(EZTRACE) else() set(EZTRACE_FOUND_WITH_PKGCONFIG "FALSE") endif() endif() - set(EZTRACE_C_FLAGS "${EZTRACE_CFLAGS_OTHER}") - endif( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER ) if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) ) @@ -288,51 +295,59 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) list(REMOVE_DUPLICATES EZTRACE_LIBRARY_DIRS) endif () - # check a function to validate the find - if(EZTRACE_LIBRARIES) +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) ) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +# check a function to validate the find +if(EZTRACE_LIBRARIES) - # EZTRACE - if (EZTRACE_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${EZTRACE_INCLUDE_DIRS}") - endif() - if (EZTRACE_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${EZTRACE_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${EZTRACE_LIBRARIES}") - - # 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}") - - # test link - unset(EZTRACE_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(eztrace_start EZTRACE_WORKS) - mark_as_advanced(EZTRACE_WORKS) - - if(NOT EZTRACE_WORKS) - if(NOT EZTRACE_FIND_QUIETLY) - 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 "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(EZTRACE_LIBRARIES) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) ) + # EZTRACE + if (EZTRACE_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${EZTRACE_INCLUDE_DIRS}") + endif() + if (EZTRACE_CFLAGS_OTHER) + set(REQUIRED_FLAGS "${EZTRACE_CFLAGS_OTHER}") + endif() + if (EZTRACE_LDFLAGS_OTHER) + set(REQUIRED_LDFLAGS "${EZTRACE_LDFLAGS_OTHER}") + endif() + if (EZTRACE_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${EZTRACE_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${EZTRACE_LIBRARIES}") + + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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}") + + # test link + unset(EZTRACE_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(eztrace_start EZTRACE_WORKS) + mark_as_advanced(EZTRACE_WORKS) + + if(NOT EZTRACE_WORKS) + if(NOT EZTRACE_FIND_QUIETLY) + 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 "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(EZTRACE_LIBRARIES) if (EZTRACE_LIBRARIES) if (EZTRACE_LIBRARY_DIRS) @@ -355,11 +370,6 @@ mark_as_advanced(EZTRACE_DIR_FOUND) # check that EZTRACE has been found # ------------------------------- include(FindPackageHandleStandardArgs) -if (PKG_CONFIG_EXECUTABLE AND EZTRACE_FOUND) - find_package_handle_standard_args(EZTRACE DEFAULT_MSG - EZTRACE_LIBRARIES) -else() - find_package_handle_standard_args(EZTRACE DEFAULT_MSG - EZTRACE_LIBRARIES - EZTRACE_WORKS) -endif() +find_package_handle_standard_args(EZTRACE DEFAULT_MSG + EZTRACE_LIBRARIES + EZTRACE_WORKS) diff --git a/modules/find/FindFFTW.cmake b/modules/find/FindFFTW.cmake index 00eb652..df0eb44 100644 --- a/modules/find/FindFFTW.cmake +++ b/modules/find/FindFFTW.cmake @@ -28,7 +28,6 @@ # This module finds headers and fftw library. # Results are reported in variables: # FFTW_FOUND - True if headers and requested libraries were found -# FFTW_C_FLAGS - list of required compilation flags (excluding -I) # 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 @@ -36,7 +35,20 @@ # FFTW_INCLUDE_DIRS_DEP - fftw + dependencies include directories # FFTW_LIBRARY_DIRS_DEP - fftw + dependencies link directories # FFTW_LIBRARIES_DEP - fftw libraries + dependencies +# # FFTW_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = FFTW3F or FFTW3 or FFTW3L or FFTW3Q +# <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 -DFFTW_DIR=path/to/fftw): @@ -231,11 +243,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) pkg_search_module(FFTW3F fftw3f) pkg_search_module(FFTW3 fftw3) if (FFTW3F_FOUND) - set(FFTW_C_FLAGS "${FFTW3F_CFLAGS_OTHER}") if (NOT FFTW_FIND_QUIETLY) message(STATUS "Looking for FFTW3F - found using PkgConfig") endif() if (FFTW3F_LIBRARIES) + find_pkgconfig_libraries_absolute_path(FFTW3F) list(APPEND FFTW_LIBRARIES "${FFTW3F_LIBRARIES}") endif() if(FFTW3F_INCLUDE_DIRS) @@ -261,11 +273,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) pkg_search_module(FFTW3L fftw3l) pkg_search_module(FFTW3 fftw3) if (FFTW3L_FOUND) - set(FFTW_C_FLAGS "${FFTW3L_CFLAGS_OTHER}") if (NOT FFTW_FIND_QUIETLY) message(STATUS "Looking for FFTW3L - found using PkgConfig") endif() if (FFTW3L_LIBRARIES) + find_pkgconfig_libraries_absolute_path(FFTW3L) list(APPEND FFTW_LIBRARIES "${FFTW3L_LIBRARIES}") endif() if(FFTW3L_INCLUDE_DIRS) @@ -291,11 +303,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) pkg_search_module(FFTW3Q fftw3q) pkg_search_module(FFTW3 fftw3) if (FFTW3Q_FOUND) - set(FFTW_C_FLAGS "${FFTW3Q_CFLAGS_OTHER}") if (NOT FFTW_FIND_QUIETLY) message(STATUS "Looking for FFTW3Q - found using PkgConfig") endif() if (FFTW3Q_LIBRARIES) + find_pkgconfig_libraries_absolute_path(FFTW3Q) list(APPEND FFTW_LIBRARIES "${FFTW3Q_LIBRARIES}") endif() if(FFTW3Q_INCLUDE_DIRS) @@ -319,13 +331,16 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) endif(FFTW3Q_FOUND) else() pkg_search_module(FFTW3 fftw3) + if (FFTW3_FOUND AND FFTW3_LIBRARIES) + find_pkgconfig_libraries_absolute_path(FFTW3) + endif() endif() if (FFTW3_FOUND) - set(FFTW_C_FLAGS "${FFTW3_CFLAGS_OTHER}") if (NOT FFTW_FIND_QUIETLY) message(STATUS "Looking for FFTW3 - found using PkgConfig") endif() if (FFTW3_LIBRARIES) + find_pkgconfig_libraries_absolute_path(FFTW3) list(APPEND FFTW_LIBRARIES "${FFTW3_LIBRARIES}") endif() if(FFTW3_INCLUDE_DIRS) @@ -348,14 +363,6 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) endif() endif(FFTW3_FOUND) - set(FFTW_INCLUDE_DIRS_DEP "${FFTW_STATIC_INCLUDE_DIRS}") - set(FFTW_LIBRARY_DIRS_DEP "${FFTW_STATIC_LIBRARY_DIRS}") - set(FFTW_LIBRARIES_DEP "${FFTW_STATIC_LIBRARIES}" ) - - if (FFTW_LIBRARIES) - set(FFTW_WORKS TRUE) - endif() - if (FFTW_FOUND AND FFTW_LIBRARIES) set(FFTW_FOUND_WITH_PKGCONFIG "TRUE") else() @@ -688,98 +695,6 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR endif() endforeach() - # check a function to validate the find - if(FFTW_LIBRARIES) - - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) - - # FFTW - if (FFTW_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${FFTW_INCLUDE_DIRS}") - endif() - if (FFTW_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${FFTW_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${FFTW_LIBRARIES}") - # THREADS - if (FFTW_LOOK_FOR_THREADS) - list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") - endif() - # OMP - if(FFTW_LOOK_FOR_OMP) - list(APPEND REQUIRED_FLAGS "${OPENMP_C_FLAGS}") - #if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - # # either gomp ... - # list(APPEND REQUIRED_LIBS "-lgomp") - # # or iomp5 - # list(APPEND REQUIRED_LIBS "-liomp5") - #elseif (CMAKE_C_COMPILER_ID STREQUAL "Intel") - # list(APPEND REQUIRED_LIBS "-liomp5") - #endif() - endif() - # MKL - if(FFTW_LOOK_FOR_MKL) - list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") - list(APPEND REQUIRED_LDFLAGS "-Wl,--no-as-needed") - endif() - endif() - # m - find_library(M_LIBRARY NAMES m) - mark_as_advanced(M_LIBRARY) - if(M_LIBRARY) - list(APPEND REQUIRED_LIBS "-lm") - endif() - - # 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}") - 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 - unset(FFTW_WORKS CACHE) - include(CheckFunctionExists) - if (FFTW_LOOK_FOR_ESSL) - check_function_exists(${FFTW_PREC_TESTFUNC}fftw_execute FFTW_WORKS) - else() - check_function_exists(${FFTW_PREC_TESTFUNC}fftw_execute_ FFTW_WORKS) - endif() - mark_as_advanced(FFTW_WORKS) - - if(FFTW_WORKS) - # save link with dependencies - 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}") - list(REMOVE_DUPLICATES FFTW_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES FFTW_INCLUDE_DIRS_DEP) - list(REMOVE_DUPLICATES FFTW_LINKER_FLAGS) - else() - if(NOT FFTW_FIND_QUIETLY) - message(STATUS "Looking for FFTW : test of ${FFTW_PREC_TESTFUNC}fftw_execute_ with fftw 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(FFTW_LIBRARIES) - endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FFTW_FOUND) OR FFTW_GIVEN_BY_USER OR @@ -787,6 +702,97 @@ endif( (NOT PKG_CONFIG_EXECUTABLE) OR FFTW_LOOK_FOR_ESSL ) +# check a function to validate the find +if(FFTW_LIBRARIES) + + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) + + # FFTW + if (FFTW_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${FFTW_INCLUDE_DIRS}") + endif() + if (FFTW_CFLAGS_OTHER) + set(REQUIRED_FLAGS "${FFTW_CFLAGS_OTHER}") + endif() + if (FFTW_LDFLAGS_OTHER) + set(REQUIRED_LDFLAGS "${FFTW_LDFLAGS_OTHER}") + endif() + if (FFTW_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${FFTW_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${FFTW_LIBRARIES}") + # THREADS + if (FFTW_LOOK_FOR_THREADS) + list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") + endif() + # OMP + if(FFTW_LOOK_FOR_OMP) + list(APPEND REQUIRED_FLAGS "${OPENMP_C_FLAGS}") + endif() + # MKL + if(FFTW_LOOK_FOR_MKL) + list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}") + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + list(APPEND REQUIRED_LDFLAGS "-Wl,--no-as-needed") + endif() + endif() + # m + find_library(M_LIBRARY NAMES m) + mark_as_advanced(M_LIBRARY) + if(M_LIBRARY) + list(APPEND REQUIRED_LIBS "-lm") + endif() + + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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 + unset(FFTW_WORKS CACHE) + include(CheckFunctionExists) + if (FFTW_LOOK_FOR_ESSL) + check_function_exists(${FFTW_PREC_TESTFUNC}fftw_execute FFTW_WORKS) + else() + check_function_exists(${FFTW_PREC_TESTFUNC}fftw_execute_ FFTW_WORKS) + endif() + mark_as_advanced(FFTW_WORKS) + + if(FFTW_WORKS) + # save link with dependencies + 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}") + list(REMOVE_DUPLICATES FFTW_LIBRARY_DIRS_DEP) + list(REMOVE_DUPLICATES FFTW_INCLUDE_DIRS_DEP) + list(REMOVE_DUPLICATES FFTW_LINKER_FLAGS) + else() + if(NOT FFTW_FIND_QUIETLY) + message(STATUS "Looking for FFTW : test of ${FFTW_PREC_TESTFUNC}fftw_execute_ with fftw 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(FFTW_LIBRARIES) + if (FFTW_LIBRARIES) list(GET FFTW_LIBRARIES 0 first_lib) get_filename_component(first_lib_path "${first_lib}" PATH) @@ -806,13 +812,6 @@ mark_as_advanced(FFTW_DIR_FOUND) # check that FFTW has been found # ------------------------------- include(FindPackageHandleStandardArgs) -if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FFTW_FOUND) OR (FFTW_GIVEN_BY_USER) ) - find_package_handle_standard_args(FFTW DEFAULT_MSG - FFTW_LIBRARIES - FFTW_INCLUDE_DIRS - FFTW_WORKS) -else() - find_package_handle_standard_args(FFTW DEFAULT_MSG - FFTW_LIBRARIES - FFTW_WORKS) -endif() +find_package_handle_standard_args(FFTW DEFAULT_MSG + FFTW_LIBRARIES + FFTW_WORKS) diff --git a/modules/find/FindFXT.cmake b/modules/find/FindFXT.cmake index c9aa3ef..479b9eb 100644 --- a/modules/find/FindFXT.cmake +++ b/modules/find/FindFXT.cmake @@ -20,7 +20,20 @@ # FXT_INCLUDE_DIRS - fxt include directories # FXT_LIBRARY_DIRS - Link directories for fxt libraries # FXT_LIBRARIES - fxt component libraries to be linked +# # FXT_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = FXT +# <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 -DFXT_DIR=path/to/fxt): @@ -69,14 +82,10 @@ find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER) pkg_search_module(FXT fxt) + if (NOT FXT_FIND_QUIETLY) if (FXT_FOUND AND FXT_LIBRARIES) message(STATUS "Looking for FXT - found using PkgConfig") - #if(NOT FXT_INCLUDE_DIRS) - # message("${Magenta}FXT_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to fxt headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() else() message(STATUS "${Magenta}Looking for FXT - not found using PkgConfig." "\n Perhaps you should add the directory containing fxt.pc to the" @@ -88,6 +97,7 @@ if(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER) if (FXT_FOUND AND FXT_LIBRARIES) set(FXT_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(FXT) else() set(FXT_FOUND_WITH_PKGCONFIG "FALSE") endif() @@ -244,51 +254,59 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR list(REMOVE_DUPLICATES FXT_LIBRARY_DIRS) endif () - # check a function to validate the find - if(FXT_LIBRARIES) +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR (FXT_GIVEN_BY_USER) ) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +# check a function to validate the find +if(FXT_LIBRARIES) - # FXT - if (FXT_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}") - endif() - if (FXT_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${FXT_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${FXT_LIBRARIES}") - - # 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}") - - # test link - unset(FXT_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(fut_keychange FXT_WORKS) - mark_as_advanced(FXT_WORKS) - - if(NOT FXT_WORKS) - if(NOT FXT_FIND_QUIETLY) - 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 "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(FXT_LIBRARIES) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR (FXT_GIVEN_BY_USER) ) + # FXT + if (FXT_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}") + endif() + if (FXT_CFLAGS_OTHER) + set(REQUIRED_FLAGS "${FXT_CFLAGS_OTHER}") + endif() + if (FXT_LDFLAGS_OTHER) + set(REQUIRED_LDFLAGS "${FXT_LDFLAGS_OTHER}") + endif() + if (FXT_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${FXT_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${FXT_LIBRARIES}") + + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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}") + + # test link + unset(FXT_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(fut_keychange FXT_WORKS) + mark_as_advanced(FXT_WORKS) + + if(NOT FXT_WORKS) + if(NOT FXT_FIND_QUIETLY) + 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 "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(FXT_LIBRARIES) if (FXT_LIBRARIES) if (FXT_LIBRARY_DIRS) @@ -311,11 +329,6 @@ mark_as_advanced(FXT_DIR_FOUND) # check that FXT has been found # ------------------------------- include(FindPackageHandleStandardArgs) -if (PKG_CONFIG_EXECUTABLE AND FXT_FOUND) - find_package_handle_standard_args(FXT DEFAULT_MSG - FXT_LIBRARIES) -else() - find_package_handle_standard_args(FXT DEFAULT_MSG - FXT_LIBRARIES - FXT_WORKS) -endif() +find_package_handle_standard_args(FXT DEFAULT_MSG + FXT_LIBRARIES + FXT_WORKS) diff --git a/modules/find/FindGTG.cmake b/modules/find/FindGTG.cmake index d9ac5a0..b280005 100644 --- a/modules/find/FindGTG.cmake +++ b/modules/find/FindGTG.cmake @@ -16,11 +16,23 @@ # This module finds headers and gtg library. # Results are reported in variables: # GTG_FOUND - True if headers and requested libraries were found -# GTG_C_FLAGS - list of required compilation flags (excluding -I) # GTG_INCLUDE_DIRS - gtg include directories # GTG_LIBRARY_DIRS - Link directories for gtg libraries # GTG_LIBRARIES - gtg component libraries to be linked +# # GTG_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = GTG +# <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 -DGTG_DIR=path/to/gtg): @@ -69,14 +81,10 @@ find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT GTG_GIVEN_BY_USER) pkg_search_module(GTG gtg) + if (NOT GTG_FIND_QUIETLY) if (GTG_FOUND AND GTG_LIBRARIES) message(STATUS "Looking for GTG - found using PkgConfig") - #if(NOT GTG_INCLUDE_DIRS) - # message("${Magenta}GTG_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to gtg headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() else() message(STATUS "${Magenta}Looking for GTG - not found using PkgConfig." "\n Perhaps you should add the directory containing gtg.pc to the" @@ -84,10 +92,9 @@ if(PKG_CONFIG_EXECUTABLE AND NOT GTG_GIVEN_BY_USER) endif() endif() - set(GTG_C_FLAGS "${GTG_CFLAGS_OTHER}") - if (GTG_FOUND AND GTG_LIBRARIES) set(GTG_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(GTG) else() set(GTG_FOUND_WITH_PKGCONFIG "FALSE") endif() @@ -244,51 +251,59 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT GTG_FOUND) OR list(REMOVE_DUPLICATES GTG_LIBRARY_DIRS) endif () - # check a function to validate the find - if(GTG_LIBRARIES) +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT GTG_FOUND) OR (GTG_GIVEN_BY_USER) ) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +# check a function to validate the find +if(GTG_LIBRARIES) - # GTG - if (GTG_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${GTG_INCLUDE_DIRS}") - endif() - if (GTG_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${GTG_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${GTG_LIBRARIES}") + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # 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}") + # GTG + if (GTG_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${GTG_INCLUDE_DIRS}") + endif() + if (GTG_CFLAGS_OTHER) + set(REQUIRED_FLAGS "${GTG_CFLAGS_OTHER}") + endif() + if (GTG_LDFLAGS_OTHER) + set(REQUIRED_LDFLAGS "${GTG_LDFLAGS_OTHER}") + endif() + if (GTG_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${GTG_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${GTG_LIBRARIES}") - # test link - unset(GTG_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(initTrace GTG_WORKS) - mark_as_advanced(GTG_WORKS) + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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}") - if(NOT GTG_WORKS) - if(NOT GTG_FIND_QUIETLY) - 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 "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(GTG_LIBRARIES) + # test link + unset(GTG_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(initTrace GTG_WORKS) + mark_as_advanced(GTG_WORKS) -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT GTG_FOUND) OR (GTG_GIVEN_BY_USER) ) + if(NOT GTG_WORKS) + if(NOT GTG_FIND_QUIETLY) + 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 "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(GTG_LIBRARIES) if (GTG_LIBRARIES) if (GTG_LIBRARY_DIRS) @@ -311,11 +326,6 @@ mark_as_advanced(GTG_DIR_FOUND) # check that GTG has been found # ------------------------------- include(FindPackageHandleStandardArgs) -if (PKG_CONFIG_EXECUTABLE AND GTG_FOUND) - find_package_handle_standard_args(GTG DEFAULT_MSG - GTG_LIBRARIES) -else() - find_package_handle_standard_args(GTG DEFAULT_MSG - GTG_LIBRARIES - GTG_WORKS) -endif() +find_package_handle_standard_args(GTG DEFAULT_MSG + GTG_LIBRARIES + GTG_WORKS) diff --git a/modules/find/FindHQR.cmake b/modules/find/FindHQR.cmake index f3a8250..5493392 100644 --- a/modules/find/FindHQR.cmake +++ b/modules/find/FindHQR.cmake @@ -19,7 +19,20 @@ # HQR_INCLUDE_DIRS - hqr include directories # HQR_LIBRARY_DIRS - Link directories for hqr libraries # HQR_LIBRARIES - hqr component libraries to be linked +# # HQR_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = HQR +# <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 -DHQR_DIR=path/to/hqr): @@ -68,14 +81,10 @@ find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT HQR_GIVEN_BY_USER) pkg_search_module(HQR hqr) + if (NOT HQR_FIND_QUIETLY) if (HQR_FOUND AND HQR_LIBRARIES) message(STATUS "Looking for HQR - found using PkgConfig") - #if(NOT HQR_INCLUDE_DIRS) - # message("${Magenta}HQR_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to hqr headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() else() message(STATUS "${Magenta}Looking for HQR - not found using PkgConfig." "\n Perhaps you should add the directory containing hqr.pc to the" @@ -84,6 +93,7 @@ if(PKG_CONFIG_EXECUTABLE AND NOT HQR_GIVEN_BY_USER) endif() if (HQR_FOUND AND HQR_LIBRARIES) set(HQR_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(HQR) else() set(HQR_FOUND_WITH_PKGCONFIG "FALSE") endif() @@ -236,51 +246,59 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HQR_FOUND) OR list(REMOVE_DUPLICATES HQR_LIBRARY_DIRS) endif () - # check a function to validate the find - if(HQR_LIBRARIES) +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HQR_FOUND) OR (HQR_GIVEN_BY_USER) ) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +# check a function to validate the find +if(HQR_LIBRARIES) - # HQR - if (HQR_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${HQR_INCLUDE_DIRS}") - endif() - if (HQR_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${HQR_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${HQR_LIBRARIES}") + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) + + # HQR + if (HQR_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${HQR_INCLUDE_DIRS}") + endif() + if (HQR_CFLAGS_OTHER) + set(REQUIRED_FLAGS "${HQR_CFLAGS_OTHER}") + endif() + if (HQR_LDFLAGS_OTHER) + set(REQUIRED_LDFLAGS "${HQR_LDFLAGS_OTHER}") + endif() + if (HQR_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${HQR_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${HQR_LIBRARIES}") - # 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}") + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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}") - # test link - unset(HQR_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(libhqr_init_hqr HQR_WORKS) - mark_as_advanced(HQR_WORKS) + # test link + unset(HQR_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(libhqr_init_hqr HQR_WORKS) + mark_as_advanced(HQR_WORKS) - if(NOT HQR_WORKS) - if(NOT HQR_FIND_QUIETLY) - 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 "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() + if(NOT HQR_WORKS) + if(NOT HQR_FIND_QUIETLY) + 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 "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(HQR_LIBRARIES) - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HQR_FOUND) OR (HQR_GIVEN_BY_USER) ) + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) +endif(HQR_LIBRARIES) if (HQR_LIBRARIES) if (HQR_LIBRARY_DIRS) @@ -303,11 +321,6 @@ mark_as_advanced(HQR_DIR_FOUND) # check that HQR has been found # ------------------------------- include(FindPackageHandleStandardArgs) -if (PKG_CONFIG_EXECUTABLE AND HQR_FOUND) - find_package_handle_standard_args(HQR DEFAULT_MSG - HQR_LIBRARIES) -else() - find_package_handle_standard_args(HQR DEFAULT_MSG - HQR_LIBRARIES - HQR_WORKS) -endif() +find_package_handle_standard_args(HQR DEFAULT_MSG + HQR_LIBRARIES + HQR_WORKS) diff --git a/modules/find/FindHWLOC.cmake b/modules/find/FindHWLOC.cmake index adb59b7..4960bab 100644 --- a/modules/find/FindHWLOC.cmake +++ b/modules/find/FindHWLOC.cmake @@ -16,11 +16,23 @@ # This module finds headers and hwloc library. # Results are reported in variables: # HWLOC_FOUND - True if headers and requested libraries were found -# HWLOC_C_FLAGS - list of required compilation flags (excluding -I) # HWLOC_INCLUDE_DIRS - hwloc include directories # HWLOC_LIBRARY_DIRS - Link directories for hwloc libraries # HWLOC_LIBRARIES - hwloc component libraries to be linked +# # HWLOC_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = HWLOC +# <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 -DHWLOC_DIR=path/to/hwloc): @@ -72,6 +84,7 @@ find_package(PkgConfig QUIET) if( PKG_CONFIG_EXECUTABLE AND NOT HWLOC_GIVEN_BY_USER ) pkg_search_module(HWLOC hwloc) + if (NOT HWLOC_FIND_QUIETLY) if (HWLOC_FOUND AND HWLOC_LIBRARIES) message(STATUS "Looking for HWLOC - found using PkgConfig") @@ -82,10 +95,9 @@ if( PKG_CONFIG_EXECUTABLE AND NOT HWLOC_GIVEN_BY_USER ) endif() endif() - set(HWLOC_C_FLAGS "${HWLOC_CFLAGS_OTHER}") - if (HWLOC_FOUND AND HWLOC_LIBRARIES) set(HWLOC_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(HWLOC) else() set(HWLOC_FOUND_WITH_PKGCONFIG "FALSE") endif() @@ -245,51 +257,59 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) O list(REMOVE_DUPLICATES HWLOC_LIBRARY_DIRS) endif () - # check a function to validate the find - if(HWLOC_LIBRARIES) +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR (HWLOC_GIVEN_BY_USER) ) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +# check a function to validate the find +if(HWLOC_LIBRARIES) - # HWLOC - if (HWLOC_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") - endif() - if (HWLOC_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${HWLOC_LIBRARIES}") + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # 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}") - - # test link - unset(HWLOC_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(hwloc_topology_init HWLOC_WORKS) - mark_as_advanced(HWLOC_WORKS) - - if(NOT HWLOC_WORKS) - if(NOT HWLOC_FIND_QUIETLY) - 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 "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(HWLOC_LIBRARIES) + # HWLOC + if (HWLOC_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") + endif() + if (HWLOC_CFLAGS_OTHER) + set(REQUIRED_FLAGS "${HWLOC_CFLAGS_OTHER}") + endif() + if (HWLOC_LDFLAGS_OTHER) + set(REQUIRED_LDFLAGS "${HWLOC_LDFLAGS_OTHER}") + endif() + if (HWLOC_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${HWLOC_LIBRARIES}") -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR (HWLOC_GIVEN_BY_USER) ) + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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}") + + # test link + unset(HWLOC_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(hwloc_topology_init HWLOC_WORKS) + mark_as_advanced(HWLOC_WORKS) + + if(NOT HWLOC_WORKS) + if(NOT HWLOC_FIND_QUIETLY) + 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 "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(HWLOC_LIBRARIES) if (HWLOC_LIBRARIES) if (HWLOC_LIBRARY_DIRS) @@ -312,14 +332,9 @@ mark_as_advanced(HWLOC_DIR_FOUND) # check that HWLOC has been found # ------------------------------- include(FindPackageHandleStandardArgs) -if (PKG_CONFIG_EXECUTABLE AND HWLOC_FOUND) - find_package_handle_standard_args(HWLOC DEFAULT_MSG - HWLOC_LIBRARIES) -else() - find_package_handle_standard_args(HWLOC DEFAULT_MSG - HWLOC_LIBRARIES - HWLOC_WORKS) -endif() +find_package_handle_standard_args(HWLOC DEFAULT_MSG + HWLOC_LIBRARIES + HWLOC_WORKS) if (HWLOC_FOUND) set(HWLOC_SAVE_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES}) diff --git a/modules/find/FindLAPACK.cmake b/modules/find/FindLAPACK.cmake index 731ebb6..998244f 100644 --- a/modules/find/FindLAPACK.cmake +++ b/modules/find/FindLAPACK.cmake @@ -31,6 +31,21 @@ # all the possibilities # LAPACK_VENDOR_FOUND stores the LAPACK vendor found # BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK +# +# LAPACK_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = LAPACK +# <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 -DLAPACK_DIR=path/to/lapack): # LAPACK_DIR - Where to find the base directory of lapack @@ -370,10 +385,9 @@ if(BLAS_FOUND) include(FindPkgConfig) find_package(PkgConfig QUIET) if( PKG_CONFIG_EXECUTABLE AND NOT LAPACK_GIVEN_BY_USER AND BLA_VENDOR STREQUAL "All") - + pkg_search_module(LAPACK lapack) - find_pkgconfig_libraries_absolute_path(LAPACK) - + if (NOT LAPACK_FIND_QUIETLY) if (LAPACK_FOUND AND LAPACK_LIBRARIES) message(STATUS "Looking for LAPACK - found using PkgConfig") @@ -383,49 +397,49 @@ if(BLAS_FOUND) "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") endif() endif() - - if (BLA_STATIC) - set(LAPACK_LINKER_FLAGS "${LAPACK_STATIC_LDFLAGS}") - set(LAPACK_COMPILER_FLAGS "${LAPACK_STATIC_CFLAGS}") - set(LAPACK_LIBRARIES "${LAPACK_STATIC_LIBRARIES}") - else() - set(LAPACK_LINKER_FLAGS "${LAPACK_LDFLAGS}") - set(LAPACK_COMPILER_FLAGS "${LAPACK_CFLAGS}") - endif() - + 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() - + endif() if( (NOT LAPACK_FOUND_WITH_PKGCONFIG) OR LAPACK_GIVEN_BY_USER ) #intel lapack if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - + if(NOT LAPACK_LIBRARIES) if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) - + if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) find_PACKAGE(Threads) else() find_package(Threads REQUIRED) endif() - + set(LAPACK_SEARCH_LIBS "") - + set(additional_flags "") if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") set(additional_flags "-Wl,--no-as-needed") endif() - + if (BLA_F95) set(LAPACK_mkl_SEARCH_SYMBOL "CHEEV") set(_LIBRARIES LAPACK95_LIBRARIES) set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) - + # old list(APPEND LAPACK_SEARCH_LIBS "mkl_lapack95") @@ -438,7 +452,7 @@ if(BLAS_FOUND) set(LAPACK_mkl_SEARCH_SYMBOL "cheev") set(_LIBRARIES LAPACK_LIBRARIES) set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) - + # old list(APPEND LAPACK_SEARCH_LIBS "mkl_lapack") @@ -446,7 +460,7 @@ if(BLAS_FOUND) list(APPEND LAPACK_SEARCH_LIBS "mkl_gf_lp64") endif(BLA_F95) - + # First try empty lapack libs if (NOT ${_LIBRARIES}) check_lapack_libraries( @@ -489,11 +503,11 @@ if(BLAS_FOUND) if(${_LIBRARIES} AND NOT LAPACK_VENDOR_FOUND) set (LAPACK_VENDOR_FOUND "Intel MKL") endif() - + endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) endif(NOT LAPACK_LIBRARIES) endif(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - + #goto lapack if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") if(NOT LAPACK_LIBRARIES) @@ -518,7 +532,7 @@ if(BLAS_FOUND) endif() endif(NOT LAPACK_LIBRARIES) endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") - + #open lapack if (BLA_VENDOR STREQUAL "Open" OR BLA_VENDOR STREQUAL "All") if(NOT LAPACK_LIBRARIES) @@ -543,7 +557,7 @@ if(BLAS_FOUND) endif() endif(NOT LAPACK_LIBRARIES) endif (BLA_VENDOR STREQUAL "Open" OR BLA_VENDOR STREQUAL "All") - + # LAPACK in IBM ESSL library (requires generic lapack lib, too) if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") if(NOT LAPACK_LIBRARIES) @@ -568,7 +582,7 @@ if(BLAS_FOUND) endif() endif() endif () - + # LAPACK in IBM ESSL_MT library (requires generic lapack lib, too) if (BLA_VENDOR STREQUAL "IBMESSLMT" OR BLA_VENDOR STREQUAL "All") if(NOT LAPACK_LIBRARIES) @@ -593,7 +607,7 @@ if(BLAS_FOUND) endif() endif() endif () - + #acml lapack if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") if (BLAS_LIBRARIES MATCHES ".+acml.+") @@ -610,7 +624,7 @@ if(BLAS_FOUND) endif() endif () endif () - + # Apple LAPACK library? if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") if(NOT LAPACK_LIBRARIES) @@ -635,7 +649,7 @@ if(BLAS_FOUND) endif() endif(NOT LAPACK_LIBRARIES) endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") - + if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") if ( NOT LAPACK_LIBRARIES ) check_lapack_libraries( @@ -659,7 +673,7 @@ if(BLAS_FOUND) endif() endif ( NOT LAPACK_LIBRARIES ) endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - + # Generic LAPACK library? if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "ATLAS" OR @@ -687,7 +701,7 @@ if(BLAS_FOUND) endif ( NOT LAPACK_LIBRARIES ) endif () endif( (NOT LAPACK_FOUND_WITH_PKGCONFIG) OR LAPACK_GIVEN_BY_USER ) - + else(BLAS_FOUND) message(STATUS "LAPACK requires BLAS") endif(BLAS_FOUND) diff --git a/modules/find/FindLAPACKE.cmake b/modules/find/FindLAPACKE.cmake index 5008529..afcfb60 100644 --- a/modules/find/FindLAPACKE.cmake +++ b/modules/find/FindLAPACKE.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. # ### @@ -34,6 +34,20 @@ # LAPACKE_LIBRARY_DIRS_DEP - lapacke + dependencies link directories # LAPACKE_LIBRARIES_DEP - lapacke libraries + dependencies # +# LAPACKE_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables may be set +# <PREFIX> = LAPACKE +# <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 -DLAPACKE_DIR=path/to/lapacke): # LAPACKE_DIR - Where to find the base directory of lapacke @@ -50,11 +64,11 @@ # set(LAPACKE_STANDALONE TRUE) #============================================================================= -# 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. @@ -124,250 +138,296 @@ if (LAPACK_FOUND) endif() endif (NOT LAPACKE_STANDALONE) + # test fails with lapack: try to find LAPACKE lib exterior to LAPACK if (LAPACKE_STANDALONE OR NOT LAPACKE_WORKS) if(NOT LAPACKE_WORKS AND NOT LAPACKE_FIND_QUIETLY) message(STATUS "Looking for lapacke : test with lapack fails") endif() - # test fails: try to find LAPACKE lib exterior to LAPACK - - # Try to find LAPACKE lib - ####################### - - # Looking for include - # ------------------- - # Add system include paths to search include - # ------------------------------------------ - unset(_inc_env) + # try with pkg-config set(ENV_LAPACKE_DIR "$ENV{LAPACKE_DIR}") set(ENV_LAPACKE_INCDIR "$ENV{LAPACKE_INCDIR}") - if(ENV_LAPACKE_INCDIR) - list(APPEND _inc_env "${ENV_LAPACKE_INCDIR}") - elseif(ENV_LAPACKE_DIR) - list(APPEND _inc_env "${ENV_LAPACKE_DIR}") - list(APPEND _inc_env "${ENV_LAPACKE_DIR}/include") - list(APPEND _inc_env "${ENV_LAPACKE_DIR}/include/lapacke") - else() - if(WIN32) - string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}") + set(ENV_LAPACKE_LIBDIR "$ENV{LAPACKE_LIBDIR}") + set(LAPACKE_GIVEN_BY_USER "FALSE") + if ( LAPACKE_DIR OR ( LAPACKE_INCDIR AND LAPACKE_LIBDIR) OR ENV_LAPACKE_DIR OR (ENV_LAPACKE_INCDIR AND ENV_LAPACKE_LIBDIR) ) + set(LAPACKE_GIVEN_BY_USER "TRUE") + endif() + + include(FindPkgConfig) + find_package(PkgConfig QUIET) + if( PKG_CONFIG_EXECUTABLE AND NOT LAPACKE_GIVEN_BY_USER) + + pkg_search_module(LAPACKE lapacke) + + if (NOT LAPACKE_FIND_QUIETLY) + if (LAPACKE_FOUND AND LAPACKE_LIBRARIES) + message(STATUS "Looking for LAPACKE - found using PkgConfig") + else() + message(STATUS "${Magenta}Looking for LAPACKE - not found using PkgConfig." + "\n Perhaps you should add the directory containing lapacke.pc to" + "\n the PKG_CONFIG_PATH environment variable.${ColourReset}") + endif() + endif() + + if (LAPACKE_FOUND AND LAPACKE_LIBRARIES) + set(LAPACKE_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(LAPACKE) 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(LAPACKE_FOUND_WITH_PKGCONFIG "FALSE") 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 lapacke header in the given paths - # ------------------------------------------------- - # call cmake macro to find the header path - if(LAPACKE_INCDIR) - set(LAPACKE_lapacke.h_DIRS "LAPACKE_lapacke.h_DIRS-NOTFOUND") - find_path(LAPACKE_lapacke.h_DIRS - NAMES lapacke.h - HINTS ${LAPACKE_INCDIR}) - else() - if(LAPACKE_DIR) - set(LAPACKE_lapacke.h_DIRS "LAPACKE_lapacke.h_DIRS-NOTFOUND") - find_path(LAPACKE_lapacke.h_DIRS - NAMES lapacke.h - HINTS ${LAPACKE_DIR} - PATH_SUFFIXES "include" "include/lapacke") + + if (NOT LAPACKE_FOUND_WITH_PKGCONFIG OR LAPACKE_GIVEN_BY_USER) + + # Try to find LAPACKE lib + ####################### + + # Looking for include + # ------------------- + + # Add system include paths to search include + # ------------------------------------------ + unset(_inc_env) + set(ENV_LAPACKE_DIR "$ENV{LAPACKE_DIR}") + set(ENV_LAPACKE_INCDIR "$ENV{LAPACKE_INCDIR}") + if(ENV_LAPACKE_INCDIR) + list(APPEND _inc_env "${ENV_LAPACKE_INCDIR}") + elseif(ENV_LAPACKE_DIR) + list(APPEND _inc_env "${ENV_LAPACKE_DIR}") + list(APPEND _inc_env "${ENV_LAPACKE_DIR}/include") + list(APPEND _inc_env "${ENV_LAPACKE_DIR}/include/lapacke") 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 lapacke header in the given paths + # ------------------------------------------------- + # call cmake macro to find the header path + if(LAPACKE_INCDIR) set(LAPACKE_lapacke.h_DIRS "LAPACKE_lapacke.h_DIRS-NOTFOUND") find_path(LAPACKE_lapacke.h_DIRS NAMES lapacke.h - HINTS ${_inc_env}) + HINTS ${LAPACKE_INCDIR}) + else() + if(LAPACKE_DIR) + set(LAPACKE_lapacke.h_DIRS "LAPACKE_lapacke.h_DIRS-NOTFOUND") + find_path(LAPACKE_lapacke.h_DIRS + NAMES lapacke.h + HINTS ${LAPACKE_DIR} + PATH_SUFFIXES "include" "include/lapacke") + else() + set(LAPACKE_lapacke.h_DIRS "LAPACKE_lapacke.h_DIRS-NOTFOUND") + find_path(LAPACKE_lapacke.h_DIRS + NAMES lapacke.h + HINTS ${_inc_env}) + endif() endif() - endif() - mark_as_advanced(LAPACKE_lapacke.h_DIRS) - - # If found, add path to cmake variable - # ------------------------------------ - if (LAPACKE_lapacke.h_DIRS) - set(LAPACKE_INCLUDE_DIRS "${LAPACKE_lapacke.h_DIRS}") - else () - set(LAPACKE_INCLUDE_DIRS "LAPACKE_INCLUDE_DIRS-NOTFOUND") - if(NOT LAPACKE_FIND_QUIETLY) - message(STATUS "Looking for lapacke -- lapacke.h not found") + mark_as_advanced(LAPACKE_lapacke.h_DIRS) + + # If found, add path to cmake variable + # ------------------------------------ + if (LAPACKE_lapacke.h_DIRS) + set(LAPACKE_INCLUDE_DIRS "${LAPACKE_lapacke.h_DIRS}") + else () + set(LAPACKE_INCLUDE_DIRS "LAPACKE_INCLUDE_DIRS-NOTFOUND") + if(NOT LAPACKE_FIND_QUIETLY) + message(STATUS "Looking for lapacke -- lapacke.h not found") + endif() endif() - endif() - # Looking for lib - # --------------- + # Looking for lib + # --------------- - # Add system library paths to search lib - # -------------------------------------- - unset(_lib_env) - set(ENV_LAPACKE_LIBDIR "$ENV{LAPACKE_LIBDIR}") - if(ENV_LAPACKE_LIBDIR) - list(APPEND _lib_env "${ENV_LAPACKE_LIBDIR}") - elseif(ENV_LAPACKE_DIR) - list(APPEND _lib_env "${ENV_LAPACKE_DIR}") - list(APPEND _lib_env "${ENV_LAPACKE_DIR}/lib") - else() - if(WIN32) - string(REPLACE ":" ";" _lib_env "$ENV{LIB}") + # Add system library paths to search lib + # -------------------------------------- + unset(_lib_env) + set(ENV_LAPACKE_LIBDIR "$ENV{LAPACKE_LIBDIR}") + if(ENV_LAPACKE_LIBDIR) + list(APPEND _lib_env "${ENV_LAPACKE_LIBDIR}") + elseif(ENV_LAPACKE_DIR) + list(APPEND _lib_env "${ENV_LAPACKE_DIR}") + list(APPEND _lib_env "${ENV_LAPACKE_DIR}/lib") else() - if(APPLE) - string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}") + if(WIN32) + string(REPLACE ":" ";" _lib_env "$ENV{LIB}") else() - string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}") + 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() - 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) + list(REMOVE_DUPLICATES _lib_env) - # Try to find the lapacke lib in the given paths - # ---------------------------------------------- + # Try to find the lapacke lib in the given paths + # ---------------------------------------------- - # call cmake macro to find the lib path - if(LAPACKE_LIBDIR) - set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") - find_library(LAPACKE_lapacke_LIBRARY - NAMES lapacke - HINTS ${LAPACKE_LIBDIR}) - else() - if(LAPACKE_DIR) + # call cmake macro to find the lib path + if(LAPACKE_LIBDIR) set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") find_library(LAPACKE_lapacke_LIBRARY NAMES lapacke - HINTS ${LAPACKE_DIR} - PATH_SUFFIXES lib lib32 lib64) + HINTS ${LAPACKE_LIBDIR}) else() - set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") - find_library(LAPACKE_lapacke_LIBRARY - NAMES lapacke - HINTS ${_lib_env}) - endif() - endif() - mark_as_advanced(LAPACKE_lapacke_LIBRARY) - - # If found, add path to cmake variable - # ------------------------------------ - if (LAPACKE_lapacke_LIBRARY) - get_filename_component(lapacke_lib_path "${LAPACKE_lapacke_LIBRARY}" PATH) - # set cmake variables - set(LAPACKE_LIBRARIES "${LAPACKE_lapacke_LIBRARY}") - set(LAPACKE_LIBRARY_DIRS "${lapacke_lib_path}") - else () - set(LAPACKE_LIBRARIES "LAPACKE_LIBRARIES-NOTFOUND") - set(LAPACKE_LIBRARY_DIRS "LAPACKE_LIBRARY_DIRS-NOTFOUND") - if (NOT LAPACKE_FIND_QUIETLY) - message(STATUS "Looking for lapacke -- lib lapacke not found") + if(LAPACKE_DIR) + set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") + find_library(LAPACKE_lapacke_LIBRARY + NAMES lapacke + HINTS ${LAPACKE_DIR} + PATH_SUFFIXES lib lib32 lib64) + else() + set(LAPACKE_lapacke_LIBRARY "LAPACKE_lapacke_LIBRARY-NOTFOUND") + find_library(LAPACKE_lapacke_LIBRARY + NAMES lapacke + HINTS ${_lib_env}) + endif() endif() - endif () + mark_as_advanced(LAPACKE_lapacke_LIBRARY) + + # If found, add path to cmake variable + # ------------------------------------ + if (LAPACKE_lapacke_LIBRARY) + get_filename_component(lapacke_lib_path "${LAPACKE_lapacke_LIBRARY}" PATH) + # set cmake variables + set(LAPACKE_LIBRARIES "${LAPACKE_lapacke_LIBRARY}") + set(LAPACKE_LIBRARY_DIRS "${lapacke_lib_path}") + else () + set(LAPACKE_LIBRARIES "LAPACKE_LIBRARIES-NOTFOUND") + set(LAPACKE_LIBRARY_DIRS "LAPACKE_LIBRARY_DIRS-NOTFOUND") + if (NOT LAPACKE_FIND_QUIETLY) + message(STATUS "Looking for lapacke -- lib lapacke not found") + endif() + endif () - # check a function to validate the find - if(LAPACKE_LIBRARIES) + endif (NOT LAPACKE_FOUND_WITH_PKGCONFIG OR LAPACKE_GIVEN_BY_USER) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + endif (LAPACKE_STANDALONE OR NOT LAPACKE_WORKS) - # LAPACKE - if (LAPACKE_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS}") - endif() - if (LAPACKE_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${LAPACKE_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() - # Fortran - if (CMAKE_C_COMPILER_ID MATCHES "GNU") - find_library( - FORTRAN_gfortran_LIBRARY - NAMES gfortran - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_gfortran_LIBRARY) - if (FORTRAN_gfortran_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}") - endif() - elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") - find_library( - FORTRAN_ifcore_LIBRARY - NAMES ifcore - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_ifcore_LIBRARY) - if (FORTRAN_ifcore_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}") - endif() + # check a function to validate the find + if(LAPACKE_LIBRARIES) + + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) + + # LAPACKE + if (LAPACKE_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${LAPACKE_INCLUDE_DIRS}") + endif() + if (LAPACKE_CFLAGS_OTHER) + list(APPEND REQUIRED_FLAGS "${LAPACKE_CFLAGS_OTHER}") + endif() + if (LAPACKE_LDFLAGS_OTHER) + list(APPEND REQUIRED_LDFLAGS "${LAPACKE_LDFLAGS_OTHER}") + endif() + if (LAPACKE_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${LAPACKE_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${LAPACKE_LIBRARIES}") + # LAPACK + if (LAPACK_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${LAPACK_INCLUDE_DIRS}") + endif() + if (LAPACK_COMPILER_FLAGS) + list(APPEND REQUIRED_FLAGS "${LAPACK_COMPILER_FLAGS}") + endif() + if (LAPACK_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${LAPACK_LINKER_FLAGS}") + endif() + if (LAPACK_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${LAPACK_LIBRARY_DIRS}") + endif() + list(APPEND REQUIRED_LIBS "${LAPACK_LIBRARIES}") + # Fortran + if (CMAKE_C_COMPILER_ID MATCHES "GNU") + find_library( + FORTRAN_gfortran_LIBRARY + NAMES gfortran + HINTS ${_lib_env} + ) + mark_as_advanced(FORTRAN_gfortran_LIBRARY) + if (FORTRAN_gfortran_LIBRARY) + list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}") endif() - # m - find_library(M_LIBRARY NAMES m HINTS ${_lib_env}) - mark_as_advanced(M_LIBRARY) - if(M_LIBRARY) - list(APPEND REQUIRED_LIBS "-lm") + elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") + find_library( + FORTRAN_ifcore_LIBRARY + NAMES ifcore + HINTS ${_lib_env} + ) + mark_as_advanced(FORTRAN_ifcore_LIBRARY) + if (FORTRAN_ifcore_LIBRARY) + list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}") endif() - # 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}") - endforeach() - list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link + endif() + # m + find_library(M_LIBRARY NAMES m HINTS ${_lib_env}) + mark_as_advanced(M_LIBRARY) + if(M_LIBRARY) + list(APPEND REQUIRED_LIBS "${M_LIBRARY}") + endif() + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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}") + + # test link + unset(LAPACKE_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(LAPACKE_dgeqrf LAPACKE_WORKS) + if (LAPACKE_WORKS AND LAPACKE_WITH_TMG) unset(LAPACKE_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(LAPACKE_dgeqrf LAPACKE_WORKS) - if (LAPACKE_WORKS AND LAPACKE_WITH_TMG) - unset(LAPACKE_WORKS CACHE) - check_function_exists(LAPACKE_dlatms_work LAPACKE_WORKS) - endif() - mark_as_advanced(LAPACKE_WORKS) - - if(LAPACKE_WORKS) - # save link with dependencies - set(LAPACKE_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(LAPACKE_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(LAPACKE_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(LAPACKE_LINKER_FLAGS "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES LAPACKE_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES LAPACKE_INCLUDE_DIRS_DEP) - list(REMOVE_DUPLICATES LAPACKE_LINKER_FLAGS) - 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 "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(LAPACKE_LIBRARIES) + check_function_exists(LAPACKE_dlatms_work LAPACKE_WORKS) + endif() + mark_as_advanced(LAPACKE_WORKS) - endif (LAPACKE_STANDALONE OR NOT LAPACKE_WORKS) + if(LAPACKE_WORKS) + # save link with dependencies + set(LAPACKE_LIBRARIES_DEP "${REQUIRED_LIBS}") + set(LAPACKE_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") + set(LAPACKE_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + list(REMOVE_DUPLICATES LAPACKE_LIBRARY_DIRS_DEP) + list(REMOVE_DUPLICATES LAPACKE_INCLUDE_DIRS_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 "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(LAPACKE_LIBRARIES) else(LAPACK_FOUND) diff --git a/modules/find/FindPAPI.cmake b/modules/find/FindPAPI.cmake index a9745de..adaf9a0 100644 --- a/modules/find/FindPAPI.cmake +++ b/modules/find/FindPAPI.cmake @@ -20,7 +20,20 @@ # PAPI_INCLUDE_DIRS - papi include directories # PAPI_LIBRARY_DIRS - Link directories for papi libraries # PAPI_LIBRARIES - papi component libraries to be linked +# # PAPI_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = PAPI +# <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 -DPAPI_DIR=path/to/papi): @@ -69,14 +82,10 @@ find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT PAPI_GIVEN_BY_USER) pkg_search_module(PAPI papi) + if (NOT PAPI_FIND_QUIETLY) if (PAPI_FOUND AND PAPI_LIBRARIES) message(STATUS "Looking for PAPI - found using PkgConfig") - #if(NOT PAPI_INCLUDE_DIRS) - # message("${Magenta}PAPI_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to papi headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() else() message(STATUS "${Magenta}Looking for PAPI - not found using PkgConfig." "\n Perhaps you should add the directory containing papi.pc to the" @@ -84,10 +93,9 @@ if(PKG_CONFIG_EXECUTABLE AND NOT PAPI_GIVEN_BY_USER) endif() endif() - set(PAPI_C_FLAGS "${PAPI_CFLAGS_OTHER}") - if (PAPI_FOUND AND PAPI_LIBRARIES) set(PAPI_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(PAPI) else() set(PAPI_FOUND_WITH_PKGCONFIG "FALSE") endif() @@ -244,51 +252,59 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PAPI_FOUND) OR list(REMOVE_DUPLICATES PAPI_LIBRARY_DIRS) endif () - # check a function to validate the find - if(PAPI_LIBRARIES) +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PAPI_FOUND) OR (PAPI_GIVEN_BY_USER) ) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +# check a function to validate the find +if(PAPI_LIBRARIES) - # PAPI - if (PAPI_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${PAPI_INCLUDE_DIRS}") - endif() - if (PAPI_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${PAPI_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${PAPI_LIBRARIES}") + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # 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}") + # PAPI + if (PAPI_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${PAPI_INCLUDE_DIRS}") + endif() + if (PAPI_CFLAGS_OTHER) + set(REQUIRED_FLAGS "${PAPI_CFLAGS_OTHER}") + endif() + if (PAPI_LDFLAGS_OTHER) + set(REQUIRED_LDFLAGS "${PAPI_LDFLAGS_OTHER}") + endif() + if (PAPI_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${PAPI_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${PAPI_LIBRARIES}") - # test link - unset(PAPI_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(PAPI_start PAPI_WORKS) - mark_as_advanced(PAPI_WORKS) + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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}") - if(NOT PAPI_WORKS) - if(NOT PAPI_FIND_QUIETLY) - 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 "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(PAPI_LIBRARIES) + # test link + unset(PAPI_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(PAPI_start PAPI_WORKS) + mark_as_advanced(PAPI_WORKS) -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PAPI_FOUND) OR (PAPI_GIVEN_BY_USER) ) + if(NOT PAPI_WORKS) + if(NOT PAPI_FIND_QUIETLY) + 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 "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(PAPI_LIBRARIES) if (PAPI_LIBRARIES) if (PAPI_LIBRARY_DIRS) @@ -311,11 +327,6 @@ mark_as_advanced(PAPI_DIR_FOUND) # check that PAPI has been found # ------------------------------- include(FindPackageHandleStandardArgs) -if (PKG_CONFIG_EXECUTABLE AND PAPI_FOUND) - find_package_handle_standard_args(PAPI DEFAULT_MSG - PAPI_LIBRARIES) -else() - find_package_handle_standard_args(PAPI DEFAULT_MSG - PAPI_LIBRARIES - PAPI_WORKS) -endif() +find_package_handle_standard_args(PAPI DEFAULT_MSG + PAPI_LIBRARIES + PAPI_WORKS) diff --git a/modules/find/FindPARSEC.cmake b/modules/find/FindPARSEC.cmake index d544cf4..2e8d5a6 100644 --- a/modules/find/FindPARSEC.cmake +++ b/modules/find/FindPARSEC.cmake @@ -29,8 +29,6 @@ # # Results are reported in variables: # PARSEC_FOUND - True if headers and requested libraries were found -# PARSEC_C_FLAGS - list of required compilation flags (excluding -I) -# PARSEC_LINKER_FLAGS - list of required linker flags (excluding -l and -L) # PARSEC_INCLUDE_DIRS - parsec include directories # PARSEC_LIBRARY_DIRS - Link directories for parsec libraries # PARSEC_LIBRARIES - parsec libraries @@ -39,7 +37,21 @@ # 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_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = PARSEC +# <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 -DPARSEC=path/to/parsec): # PARSEC_DIR - Where to find the base directory of parsec @@ -222,14 +234,10 @@ find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT PARSEC_GIVEN_BY_USER) pkg_search_module(PARSEC parsec) + if (NOT PARSEC_FIND_QUIETLY) if (PARSEC_FOUND AND PARSEC_LIBRARIES) message(STATUS "Looking for PARSEC - found using PkgConfig") - #if(NOT PARSEC_SHM_INCLUDE_DIRS) - # message("${Magenta}PARSEC_SHM_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to parsec headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() else() message(STATUS "${Magenta}Looking for PARSEC - not found using PkgConfig." "\n Perhaps you should add the directory containing libparsec.pc" @@ -237,11 +245,6 @@ if(PKG_CONFIG_EXECUTABLE AND NOT PARSEC_GIVEN_BY_USER) endif() endif() - set(PARSEC_INCLUDE_DIRS_DEP "${PARSEC_INCLUDE_DIRS}") - set(PARSEC_LIBRARY_DIRS_DEP "${PARSEC_LIBRARY_DIRS}") - set(PARSEC_LIBRARIES_DEP "${PARSEC_LIBRARIES}") - set(PARSEC_C_FLAGS "${PARSEC_CFLAGS_OTHER}") - # create list of binaries to find set(PARSEC_bins_to_find "parsec_ptgpp") @@ -262,6 +265,7 @@ if(PKG_CONFIG_EXECUTABLE AND NOT PARSEC_GIVEN_BY_USER) if (PARSEC_FOUND AND PARSEC_LIBRARIES) set(PARSEC_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(PARSEC) else() set(PARSEC_FOUND_WITH_PKGCONFIG "FALSE") endif() @@ -491,137 +495,137 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PARSEC_FOUND) endif() endif() - # check a function to validate the find - if(PARSEC_LIBRARIES) +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PARSEC_FOUND) OR (PARSEC_GIVEN_BY_USER) ) + +# check a function to validate the find +if(PARSEC_LIBRARIES) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # PARSEC - if (PARSEC_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${PARSEC_INCLUDE_DIRS}") + # PARSEC + if (PARSEC_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${PARSEC_INCLUDE_DIRS}") + endif() + if (PARSEC_CFLAGS_OTHER) + set(REQUIRED_FLAGS "${PARSEC_CFLAGS_OTHER}") + endif() + if (PARSEC_LDFLAGS_OTHER) + set(REQUIRED_LDFLAGS "${PARSEC_LDFLAGS_OTHER}") + endif() + foreach(libdir ${PARSEC_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") endif() - set(CMAKE_REQUIRED_FLAGS) - foreach(libdir ${PARSEC_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") + endforeach() + set(REQUIRED_LIBS "${PARSEC_LIBRARIES}") + # HWLOC + if (HWLOC_FOUND AND PARSEC_LOOK_FOR_HWLOC) + if (HWLOC_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") + 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() - set(REQUIRED_LIBS "${PARSEC_LIBRARIES}") - # HWLOC - if (HWLOC_FOUND AND PARSEC_LOOK_FOR_HWLOC) - if (HWLOC_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") - 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() + endif() + # MPI + if (MPI_FOUND AND PARSEC_LOOK_FOR_MPI) + if (MPI_C_INCLUDE_PATH) + list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") endif() - # MPI - if (MPI_FOUND AND PARSEC_LOOK_FOR_MPI) - if (MPI_C_INCLUDE_PATH) - list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") - endif() - if (MPI_C_LINK_FLAGS) - if (${MPI_C_LINK_FLAGS} MATCHES " -") - string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) - endif() - list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") + if (MPI_C_LINK_FLAGS) + if (${MPI_C_LINK_FLAGS} MATCHES " -") + string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) endif() - list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") + list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") endif() - # CUDA - if (CUDA_FOUND AND PARSEC_LOOK_FOR_CUDA) - if (CUDA_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") - endif() - if (CUDA_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_CUDART_LIBRARY};${CUDA_CUDA_LIBRARY}") + list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") + endif() + # CUDA + if (CUDA_FOUND AND PARSEC_LOOK_FOR_CUDA) + if (CUDA_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") endif() - # Fortran - if (CMAKE_C_COMPILER_ID MATCHES "GNU") - find_library( - FORTRAN_gfortran_LIBRARY - NAMES gfortran - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_gfortran_LIBRARY) - if (FORTRAN_gfortran_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}") - endif() - elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") - find_library( - FORTRAN_ifcore_LIBRARY - NAMES ifcore - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_ifcore_LIBRARY) - if (FORTRAN_ifcore_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}") - endif() + if (CUDA_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}") endif() - # EXTRA LIBS such that pthread, m, rt, dl - list(APPEND REQUIRED_LIBS ${PARSEC_EXTRA_LIBRARIES}) - - # 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}") - 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 - unset(PARSEC_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(parsec_init PARSEC_WORKS) - mark_as_advanced(PARSEC_WORKS) - - if(PARSEC_WORKS) - # save link with dependencies - if (REQUIRED_FLAGS) - set(PARSEC_LIBRARIES_DEP "${REQUIRED_FLAGS};${REQUIRED_LIBS}") - else() - set(PARSEC_LIBRARIES_DEP "${REQUIRED_LIBS}") - endif() - set(PARSEC_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(PARSEC_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(PARSEC_LINKER_FLAGS "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES PARSEC_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES PARSEC_INCLUDE_DIRS_DEP) - list(REMOVE_DUPLICATES PARSEC_LINKER_FLAGS) - 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 "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)? " - "See the explanation in FindPARSEC.cmake.") - endif() + list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_CUDART_LIBRARY};${CUDA_CUDA_LIBRARY}") + endif() + # Fortran + if (CMAKE_C_COMPILER_ID MATCHES "GNU") + find_library( + FORTRAN_gfortran_LIBRARY + NAMES gfortran + HINTS ${_lib_env} + ) + mark_as_advanced(FORTRAN_gfortran_LIBRARY) + if (FORTRAN_gfortran_LIBRARY) + list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}") endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(PARSEC_LIBRARIES) - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PARSEC_FOUND) OR (PARSEC_GIVEN_BY_USER) ) + elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") + find_library( + FORTRAN_ifcore_LIBRARY + NAMES ifcore + HINTS ${_lib_env} + ) + mark_as_advanced(FORTRAN_ifcore_LIBRARY) + if (FORTRAN_ifcore_LIBRARY) + list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}") + endif() + endif() + # EXTRA LIBS such that pthread, m, rt, dl + list(APPEND REQUIRED_LIBS ${PARSEC_EXTRA_LIBRARIES}) + + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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 + unset(PARSEC_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(parsec_init PARSEC_WORKS) + mark_as_advanced(PARSEC_WORKS) + + if(PARSEC_WORKS) + # save link with dependencies + set(PARSEC_LIBRARIES_DEP "${REQUIRED_LIBS}") + set(PARSEC_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") + set(PARSEC_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + list(REMOVE_DUPLICATES PARSEC_LIBRARY_DIRS_DEP) + list(REMOVE_DUPLICATES PARSEC_INCLUDE_DIRS_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 "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)? " + "See the explanation in FindPARSEC.cmake.") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) +endif(PARSEC_LIBRARIES) if (PARSEC_LIBRARIES) if (PARSEC_LIBRARY_DIRS) @@ -648,16 +652,10 @@ mark_as_advanced(PARSEC_DIR_FOUND) # check that PARSEC has been found # -------------------------------- include(FindPackageHandleStandardArgs) -if (PKG_CONFIG_EXECUTABLE AND PARSEC_FOUND) - find_package_handle_standard_args(PARSEC DEFAULT_MSG - PARSEC_LIBRARIES - PARSEC_parsec_ptgpp_BIN_DIR) -else() - find_package_handle_standard_args(PARSEC DEFAULT_MSG - PARSEC_LIBRARIES - PARSEC_parsec_ptgpp_BIN_DIR - PARSEC_WORKS) -endif() +find_package_handle_standard_args(PARSEC DEFAULT_MSG + PARSEC_LIBRARIES + PARSEC_parsec_ptgpp_BIN_DIR + PARSEC_WORKS) if ( PARSEC_parsec_ptgpp_BIN_DIR ) find_program(PARSEC_PARSEC_PTGPP diff --git a/modules/find/FindPETSc.cmake b/modules/find/FindPETSc.cmake index d6e2893..f14576f 100644 --- a/modules/find/FindPETSc.cmake +++ b/modules/find/FindPETSc.cmake @@ -81,6 +81,7 @@ if( PKG_CONFIG_EXECUTABLE AND NOT PETSC_DIR ) set(PETSC_DIR "${PETSC_PREFIX}") if (PETSC_FOUND AND PETSC_LIBRARIES) set(PETSC_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(PETSC) else() set(PETSC_FOUND_WITH_PKGCONFIG "FALSE") endif() diff --git a/modules/find/FindSIMGRID.cmake b/modules/find/FindSIMGRID.cmake index f586c55..f21acd1 100644 --- a/modules/find/FindSIMGRID.cmake +++ b/modules/find/FindSIMGRID.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-2015 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. # ### @@ -16,11 +16,23 @@ # This module finds headers and simgrid library. # Results are reported in variables: # SIMGRID_FOUND - True if headers and requested libraries were found -# SIMGRID_C_FLAGS - list of required compilation flags (excluding -I) # SIMGRID_INCLUDE_DIRS - simgrid include directories # SIMGRID_LIBRARY_DIRS - Link directories for simgrid libraries # SIMGRID_LIBRARIES - simgrid component libraries to be linked +# # SIMGRID_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = SIMGRID +# <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 -DSIMGRID_DIR=path/to/simgrid): @@ -35,7 +47,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. @@ -69,14 +81,10 @@ find_package(PkgConfig QUIET) if(PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_GIVEN_BY_USER) pkg_search_module(SIMGRID simgrid) + if (NOT SIMGRID_FIND_QUIETLY) if (SIMGRID_FOUND AND SIMGRID_LIBRARIES) message(STATUS "Looking for SIMGRID - found using PkgConfig") - #if(NOT SIMGRID_INCLUDE_DIRS) - # message("${Magenta}SIMGRID_INCLUDE_DIRS is empty using PkgConfig." - # "Perhaps the path to simgrid headers is already present in your" - # "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}") - #endif() else() message(STATUS "${Magenta}Looking for SIMGRID - not found using PkgConfig." "\n Perhaps you should add the directory containing simgrid.pc to the" @@ -84,10 +92,9 @@ if(PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_GIVEN_BY_USER) endif() endif() - set(SIMGRID_C_FLAGS "${SIMGRID_CFLAGS_OTHER}") - if (SIMGRID_FOUND AND SIMGRID_LIBRARIES) set(SIMGRID_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(SIMGRID) else() set(SIMGRID_FOUND_WITH_PKGCONFIG "FALSE") endif() @@ -254,51 +261,59 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_FOUND) list(REMOVE_DUPLICATES SIMGRID_LIBRARY_DIRS) endif () - # check a function to validate the find - if(SIMGRID_LIBRARIES) +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_FOUND) OR (SIMGRID_GIVEN_BY_USER) ) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) +# check a function to validate the find +if(SIMGRID_LIBRARIES) - # SIMGRID - if (SIMGRID_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${SIMGRID_INCLUDE_DIRS}") - endif() - if (SIMGRID_LIBRARY_DIRS) - set(REQUIRED_LIBDIRS "${SIMGRID_LIBRARY_DIRS}") - endif() - set(REQUIRED_LIBS "${SIMGRID_LIBRARIES}") + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # 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}") - - # test link - unset(SIMGRID_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(MSG_main SIMGRID_WORKS) - mark_as_advanced(SIMGRID_WORKS) - - if(NOT SIMGRID_WORKS) - if(NOT SIMGRID_FIND_QUIETLY) - 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 "Check in CMakeFiles/CMakeError.log to figure out why it fails") - endif() + # SIMGRID + if (SIMGRID_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${SIMGRID_INCLUDE_DIRS}") + endif() + if (SIMGRID_CFLAGS_OTHER) + set(REQUIRED_FLAGS "${SIMGRID_CFLAGS_OTHER}") + endif() + if (SIMGRID_LDFLAGS_OTHER) + set(REQUIRED_LDFLAGS "${SIMGRID_LDFLAGS_OTHER}") + endif() + if (SIMGRID_LIBRARY_DIRS) + set(REQUIRED_LIBDIRS "${SIMGRID_LIBRARY_DIRS}") + endif() + set(REQUIRED_LIBS "${SIMGRID_LIBRARIES}") + + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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}") + + # test link + unset(SIMGRID_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(MSG_main SIMGRID_WORKS) + mark_as_advanced(SIMGRID_WORKS) + + if(NOT SIMGRID_WORKS) + if(NOT SIMGRID_FIND_QUIETLY) + 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 "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(SIMGRID_LIBRARIES) - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_FOUND) OR (SIMGRID_GIVEN_BY_USER) ) + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) +endif(SIMGRID_LIBRARIES) if (SIMGRID_LIBRARIES) if (SIMGRID_LIBRARY_DIRS) @@ -321,11 +336,6 @@ mark_as_advanced(SIMGRID_DIR_FOUND) # check that SIMGRID has been found # ------------------------------- include(FindPackageHandleStandardArgs) -if (PKG_CONFIG_EXECUTABLE AND SIMGRID_FOUND) - find_package_handle_standard_args(SIMGRID DEFAULT_MSG - SIMGRID_LIBRARIES) -else() - find_package_handle_standard_args(SIMGRID DEFAULT_MSG - SIMGRID_LIBRARIES - SIMGRID_WORKS) -endif() +find_package_handle_standard_args(SIMGRID DEFAULT_MSG + SIMGRID_LIBRARIES + SIMGRID_WORKS) diff --git a/modules/find/FindSTARPU.cmake b/modules/find/FindSTARPU.cmake index 4378b4a..e30a1ec 100644 --- a/modules/find/FindSTARPU.cmake +++ b/modules/find/FindSTARPU.cmake @@ -29,19 +29,30 @@ # # Results are reported in variables: # STARPU_FOUND - True if headers and requested libraries were found -# STARPU_C_FLAGS - list of required compilation flags (excluding -I) -# STARPU_LINKER_FLAGS - list of required linker flags (excluding -l and -L) # STARPU_INCLUDE_DIRS - starpu include directories # STARPU_LIBRARY_DIRS - Link directories for starpu libraries # STARPU_LIBRARIES - starpu libraries -# STARPU_SHM_LIBRARIES - starpu libraries without libstarpumpi -# STARPU_MPI_LIBRARIES - starpu libraries with libstarpumpi # STARPU_INCLUDE_DIRS_DEP - starpu + dependencies include directories # STARPU_LIBRARY_DIRS_DEP - starpu + dependencies link directories # STARPU_LIBRARIES_DEP - starpu libraries + dependencies # 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 +# +# STARPU_FOUND_WITH_PKGCONFIG - True if found with pkg-config +# if found with pkg-config the following variables are set +# <PREFIX> = STARPU +# <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 -DSTARPU=path/to/starpu): # STARPU_DIR - Where to find the base directory of starpu @@ -213,21 +224,20 @@ if(PKG_CONFIG_EXECUTABLE AND NOT STARPU_GIVEN_BY_USER) set (STARPU_VERSION_LIST "1.3;1.2;1.1;1.0") foreach(_version ${STARPU_VERSION_LIST}) - pkg_search_module(STARPU_SHM starpu-${_version}) - if (STARPU_SHM_FOUND) + if(STARPU_LOOK_FOR_MPI) + pkg_search_module(STARPU starpumpi-${_version}) + else() + pkg_search_module(STARPU starpu-${_version}) + endif() + if (STARPU_FOUND) set(STARPU_VERSION "${_version}" CACHE INTERNAL "StarPU version found") break() endif() endforeach() - set(STARPU_INCLUDE_DIRS "${STARPU_SHM_STATIC_INCLUDE_DIRS}") - set(STARPU_LIBRARY_DIRS "${STARPU_SHM_STATIC_LIBRARY_DIRS}") - if(STARPU_LOOK_FOR_MPI AND MPI_FOUND) - pkg_search_module(STARPU_MPI starpumpi-${STARPU_VERSION}) - endif() if (NOT STARPU_FIND_QUIETLY) - if (STARPU_SHM_FOUND AND STARPU_SHM_LIBRARIES) + if (STARPU_FOUND AND STARPU_LIBRARIES) message(STATUS "Looking for STARPU - found using PkgConfig") - set(STARPU_VERSION_STRING "${STARPU_SHM_VERSION}") + set(STARPU_VERSION_STRING "${STARPU_VERSION}") string(REPLACE "." ";" STARPU_VERSION_STRING_LIST ${STARPU_VERSION_STRING}) list(GET STARPU_VERSION_STRING_LIST 0 STARPU_VERSION_MAJOR) list(GET STARPU_VERSION_STRING_LIST 1 STARPU_VERSION_MINOR) @@ -236,15 +246,6 @@ if(PKG_CONFIG_EXECUTABLE AND NOT STARPU_GIVEN_BY_USER) "\n Perhaps you should add the directory containing libstarpu.pc" "\n to the PKG_CONFIG_PATH environment variable.${ColourReset}") endif() - if (STARPU_LOOK_FOR_MPI) - if (STARPU_MPI_FOUND AND STARPU_MPI_LIBRARIES) - message(STATUS "Looking for STARPU MPI - found using PkgConfig") - else() - message(STATUS "${Magenta}Looking for STARPU MPI - not found using PkgConfig." - " Perhaps you should add the directory containing libstarpumpi.pc to" - " the PKG_CONFIG_PATH environment variable.${ColourReset}") - endif() - endif() # check if the version found respects the minimum required if (STARPU_FIND_VERSION_EXACT) @@ -268,41 +269,21 @@ if(PKG_CONFIG_EXECUTABLE AND NOT STARPU_GIVEN_BY_USER) endif() endif() - if (STARPU_SHM_FOUND AND STARPU_SHM_LIBRARIES) + if (STARPU_FOUND AND STARPU_LIBRARIES) set(STARPU_FOUND_WITH_PKGCONFIG "TRUE") + find_pkgconfig_libraries_absolute_path(STARPU) else() set(STARPU_FOUND_WITH_PKGCONFIG "FALSE") endif() endif() - if(STARPU_MPI_LIBRARIES) - if (STARPU_LOOK_FOR_SIMGRID) - # Cmake does not fetch explicit libfxt.a static paths from pkg-config... - find_package(FXT) - string(REGEX MATCH "[^;]*/libfxt.a" FXT_STATIC_LIB "${STARPU_MPI_LDFLAGS_OTHER}") - list(APPEND STARPU_MPI_LIBRARIES "${FXT_STATIC_LIB}") - endif() - set(STARPU_LIBRARIES "${STARPU_MPI_STATIC_LIBRARIES}") - set(STARPU_LINKER_FLAGS "${STARPU_MPI_STATIC_LDFLAGS_OTHER}") - set(STARPU_C_FLAGS "${STARPU_MPI_CFLAGS_OTHER}") - elseif(STARPU_SHM_LIBRARIES) - set(STARPU_LIBRARIES "${STARPU_SHM_STATIC_LIBRARIES}") - set(STARPU_LINKER_FLAGS "${STARPU_SHM_STATIC_LDFLAGS_OTHER}") - set(STARPU_C_FLAGS "${STARPU_CFLAGS_OTHER}") - else() - set(STARPU_LIBRARIES "STARPU_LIBRARIES-NOTFOUND") - endif() - set(STARPU_INCLUDE_DIRS_DEP "${STARPU_INCLUDE_DIRS}") - set(STARPU_LIBRARY_DIRS_DEP "${STARPU_LIBRARY_DIRS}") - set(STARPU_LIBRARIES_DEP "${STARPU_LIBRARIES}") - if (STARPU_SHM_FOUND) - set(STARPU_FOUND "TRUE") - else() - set(STARPU_FOUND "FALSE") - endif() - if (STARPU_LOOK_FOR_MPI AND NOT STARPU_MPI_FOUND) - set(STARPU_FOUND "FALSE") + if(STARPU_LOOK_FOR_MPI AND STARPU_LOOK_FOR_SIMGRID AND STARPU_FOUND) + # Cmake does not fetch explicit libfxt.a static paths from pkg-config... + find_package(FXT) + string(REGEX MATCH "[^;]*/libfxt.a" FXT_STATIC_LIB "${STARPU_MPI_LDFLAGS_OTHER}") + list(APPEND STARPU_LIBRARIES "${FXT_STATIC_LIB}") + list(APPEND STARPU_STATIC_LIBRARIES "${FXT_STATIC_LIB}") endif() endif(PKG_CONFIG_EXECUTABLE AND NOT STARPU_GIVEN_BY_USER) @@ -456,10 +437,10 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) # create list of headers to find list(APPEND STARPU_hdrs_to_find "starpu.h;starpu_profiling.h") - if(STARPU_LOOK_FOR_MPI AND MPI_FOUND) + if(STARPU_LOOK_FOR_MPI) list(APPEND STARPU_hdrs_to_find "starpu_mpi.h") endif() - if(STARPU_LOOK_FOR_CUDA AND CUDA_FOUND) + if(STARPU_LOOK_FOR_CUDA) list(APPEND STARPU_hdrs_to_find "starpu_cuda.h;starpu_scheduler.h") endif() @@ -541,8 +522,7 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) # Looking for lib # --------------- - set(STARPU_SHM_LIBRARIES "") - set(STARPU_MPI_LIBRARIES "") + set(STARPU_LIBRARIES "") set(STARPU_LIBRARY_DIRS "") # Add system library paths to search lib @@ -574,10 +554,8 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) # create list of libs to find set(STARPU_libs_to_find "starpu-${STARPU_VERSION}") - set(STARPU_SHM_libs_to_find "starpu-${STARPU_VERSION}") - if (STARPU_LOOK_FOR_MPI OR MPI_FOUND) + if (STARPU_LOOK_FOR_MPI) list(INSERT STARPU_libs_to_find 0 "starpumpi-${STARPU_VERSION}") - set(STARPU_MPI_libs_to_find "${STARPU_libs_to_find}") endif() # call cmake macro to find the lib path @@ -612,293 +590,247 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) foreach(starpu_lib ${STARPU_libs_to_find}) if (STARPU_${starpu_lib}_LIBRARY) - get_filename_component(${starpu_lib}_lib_path ${STARPU_${starpu_lib}_LIBRARY} PATH) # set cmake variables (respects naming convention) - - foreach(starpu_shm_lib ${STARPU_SHM_libs_to_find}) - if(starpu_shm_lib STREQUAL starpu_lib) - list(APPEND STARPU_SHM_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") - endif() - endforeach() - if (STARPU_LOOK_FOR_MPI AND MPI_FOUND) - foreach(starpu_mpi_lib ${STARPU_MPI_libs_to_find}) - if(starpu_mpi_lib STREQUAL starpu_lib) - list(APPEND STARPU_MPI_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") - endif() - endforeach() - endif () + list(APPEND STARPU_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") list(APPEND STARPU_LIBRARY_DIRS "${${starpu_lib}_lib_path}") - else (STARPU_${starpu_lib}_LIBRARY) - + list(APPEND STARPU_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") if(NOT STARPU_FIND_QUIETLY) message(STATUS "Looking for starpu -- lib ${starpu_lib} not found") endif() - if(starpu_lib STREQUAL "starpumpi-${STARPU_VERSION}" AND - NOT STARPU_FIND_REQUIRED_MPI) - # if MPI optional, not a problem: no NOTFOUND in list of MPI LIBRARIES - if(NOT STARPU_FIND_QUIETLY) - message(STATUS "Looking for starpu -- lib ${starpu_lib} not required") - endif() - else() - # for any other lib, add NOTFOUND in the proper list of LIBRARIES - foreach(starpu_shm_lib ${STARPU_SHM_libs_to_find}) - if(starpu_shm_lib STREQUAL starpu_lib) - set(STARPU_SHM_LIBRARIES "${STARPU_${starpu_lib}_LIBRARY}") - endif() - endforeach() - if (STARPU_LOOK_FOR_MPI AND MPI_FOUND) - foreach(starpu_mpi_lib ${STARPU_MPI_libs_to_find}) - if(starpu_mpi_lib STREQUAL starpu_lib) - list(APPEND STARPU_MPI_LIBRARIES "${STARPU_${starpu_mpi_lib}_LIBRARY}") - endif() - endforeach() - endif () - endif() - endif (STARPU_${starpu_lib}_LIBRARY) mark_as_advanced(STARPU_${starpu_lib}_LIBRARY) endforeach(starpu_lib ${STARPU_libs_to_find}) - list(REMOVE_DUPLICATES STARPU_SHM_LIBRARIES) - list(REMOVE_DUPLICATES STARPU_MPI_LIBRARIES) + list(REMOVE_DUPLICATES STARPU_LIBRARIES) if (STARPU_LIBRARY_DIRS) list(REMOVE_DUPLICATES STARPU_LIBRARY_DIRS) endif () - if (STARPU_SHM_LIBRARIES AND STARPU_LIBRARY_DIRS AND STARPU_INCLUDE_DIRS) - set(STARPU_SHM_FOUND TRUE) - if(STARPU_MPI_LIBRARIES) - set(STARPU_MPI_FOUND TRUE) - endif() + if (STARPU_LIBRARIES AND STARPU_LIBRARY_DIRS AND STARPU_INCLUDE_DIRS) + set(STARPU_FOUND TRUE) endif() else(STARPU_starpu_config.h_INCLUDE_DIRS) + if(NOT STARPU_FIND_QUIETLY) message(STATUS "The version of StarPU is not known so that we do not search libraries") endif() endif(STARPU_starpu_config.h_INCLUDE_DIRS) - foreach(lib ${STARPU_SHM_LIBRARIES}) - if (NOT lib) - set(STARPU_SHM_LIBRARIES "STARPU_SHM_LIBRARIES-NOTFOUND") - endif() - endforeach() - foreach(lib ${STARPU_MPI_LIBRARIES}) - if (NOT lib) - set(STARPU_MPI_LIBRARIES "STARPU_MPI_LIBRARIES-NOTFOUND") + foreach(_lib ${STARPU_LIBRARIES}) + if (NOT _lib) + set(STARPU_LIBRARIES "STARPU_LIBRARIES-NOTFOUND") endif() endforeach() - if(STARPU_LOOK_FOR_MPI) - set(STARPU_LIBRARIES "${STARPU_MPI_LIBRARIES}") - else() - set(STARPU_LIBRARIES "${STARPU_SHM_LIBRARIES}") - endif() - # check a function to validate the find - if(STARPU_LIBRARIES) +endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR (STARPU_GIVEN_BY_USER) ) + +# check a function to validate the find +if(STARPU_LIBRARIES) - set(REQUIRED_FLAGS) - set(REQUIRED_LDFLAGS) - set(REQUIRED_INCDIRS) - set(REQUIRED_LIBDIRS) - set(REQUIRED_LIBS) + set(REQUIRED_FLAGS) + set(REQUIRED_LDFLAGS) + set(REQUIRED_INCDIRS) + set(REQUIRED_LIBDIRS) + set(REQUIRED_LIBS) - # STARPU - if (STARPU_INCLUDE_DIRS) - set(REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}") + # STARPU + if (STARPU_INCLUDE_DIRS) + set(REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}") + endif() + if (STARPU_CFLAGS_OTHER) + set(REQUIRED_FLAGS "${STARPU_CFLAGS_OTHER}") + endif() + if (STARPU_LDFLAGS_OTHER) + set(REQUIRED_LDFLAGS "${STARPU_LDFLAGS_OTHER}") + endif() + foreach(libdir ${STARPU_LIBRARY_DIRS}) + if (libdir) + list(APPEND REQUIRED_LIBDIRS "${libdir}") + endif() + endforeach() + set(REQUIRED_LIBS "${STARPU_LIBRARIES}") + # HWLOC + if (HWLOC_FOUND AND STARPU_LOOK_FOR_HWLOC) + if (HWLOC_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") + endif() + if (HWLOC_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}") endif() - set(CMAKE_REQUIRED_FLAGS) - foreach(libdir ${STARPU_LIBRARY_DIRS}) - if (libdir) - list(APPEND REQUIRED_LIBDIRS "${libdir}") + foreach(lib ${HWLOC_LIBRARIES}) + if (EXISTS ${lib} OR ${lib} MATCHES "^-") + list(APPEND REQUIRED_LIBS "${lib}") + else() + list(APPEND REQUIRED_LIBS "-l${lib}") endif() endforeach() - set(REQUIRED_LIBS "${STARPU_LIBRARIES}") - # HWLOC - if (HWLOC_FOUND AND STARPU_LOOK_FOR_HWLOC) - if (HWLOC_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}") - 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() + endif() + # MPI + if (MPI_FOUND AND STARPU_LOOK_FOR_MPI) + if (MPI_C_INCLUDE_PATH) + list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") endif() - # MPI - if (MPI_FOUND AND STARPU_LOOK_FOR_MPI) - if (MPI_C_INCLUDE_PATH) - list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}") - endif() - if (MPI_C_LINK_FLAGS) - if (${MPI_C_LINK_FLAGS} MATCHES " -") - string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) - endif() - list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") - endif() - list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") - endif() - # MAGMA - if (MAGMA_FOUND AND STARPU_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() - if (MAGMA_LINKER_FLAGS) - list(APPEND REQUIRED_LDFLAGS "${MAGMA_LINKER_FLAGS}") + if (MPI_C_LINK_FLAGS) + if (${MPI_C_LINK_FLAGS} MATCHES " -") + string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS}) endif() + list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}") endif() - # CUDA - if (CUDA_FOUND AND STARPU_LOOK_FOR_CUDA) - if (CUDA_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") - endif() - if (CUDA_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}") - endif() - list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}") + list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}") + endif() + # MAGMA + if (MAGMA_FOUND AND STARPU_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() - # FXT - if (FXT_FOUND AND STARPU_LOOK_FOR_FXT) - if (FXT_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}") - 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() + 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() - # SIMGRID - if (SIMGRID_FOUND AND STARPU_LOOK_FOR_SIMGRID) - if (SIMGRID_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${SIMGRID_INCLUDE_DIRS}") - endif() - if (SIMGRID_LIBRARY_DIRS) - list(APPEND REQUIRED_LIBDIRS "${SIMGRID_LIBRARY_DIRS}") - endif() - foreach(lib ${SIMGRID_LIBRARIES}) + 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() - list(APPEND REQUIRED_FLAGS "-include starpu_simgrid_wrap.h") endif() - # BLAS - if (BLAS_FOUND AND STARPU_LOOK_FOR_BLAS) - if (BLAS_INCLUDE_DIRS) - list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") - 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() + if (MAGMA_LINKER_FLAGS) + list(APPEND REQUIRED_LDFLAGS "${MAGMA_LINKER_FLAGS}") endif() - # Fortran - if (CMAKE_C_COMPILER_ID MATCHES "GNU") - find_library( - FORTRAN_gfortran_LIBRARY - NAMES gfortran - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_gfortran_LIBRARY) - if (FORTRAN_gfortran_LIBRARY AND CMAKE_C_COMPILER_ID STREQUAL "GNU") - list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}") - endif() - elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") - find_library( - FORTRAN_ifcore_LIBRARY - NAMES ifcore - HINTS ${_lib_env} - ) - mark_as_advanced(FORTRAN_ifcore_LIBRARY) - if (FORTRAN_ifcore_LIBRARY) - list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}") - endif() + endif() + # CUDA + if (CUDA_FOUND AND STARPU_LOOK_FOR_CUDA) + if (CUDA_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}") endif() - # EXTRA LIBS such that pthread, m, rt - list(APPEND REQUIRED_LIBS ${STARPU_EXTRA_LIBRARIES}) - - # 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}") + if (CUDA_LIBRARY_DIRS) + list(APPEND REQUIRED_LIBDIRS "${CUDA_LIBRARY_DIRS}") + endif() + list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}") + endif() + # FXT + if (FXT_FOUND AND STARPU_LOOK_FOR_FXT) + if (FXT_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}") + 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 CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") - list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}") - string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - # test link - unset(STARPU_WORKS CACHE) - include(CheckFunctionExists) - check_function_exists(starpu_init STARPU_WORKS) - mark_as_advanced(STARPU_WORKS) - - if(STARPU_WORKS) - # save link with dependencies - set(STARPU_LIBRARIES_DEP "${REQUIRED_LIBS}") - set(STARPU_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") - set(STARPU_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") - set(STARPU_C_FLAGS "${REQUIRED_FLAGS}") - set(STARPU_LINKER_FLAGS "${REQUIRED_LDFLAGS}") - list(REMOVE_DUPLICATES STARPU_LIBRARY_DIRS_DEP) - list(REMOVE_DUPLICATES STARPU_INCLUDE_DIRS_DEP) - list(REMOVE_DUPLICATES STARPU_LINKER_FLAGS) - 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 "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)? " - "See the explanation in FindSTARPU.cmake.") + endif() + # SIMGRID + if (SIMGRID_FOUND AND STARPU_LOOK_FOR_SIMGRID) + if (SIMGRID_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${SIMGRID_INCLUDE_DIRS}") + 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_FLAGS "-include starpu_simgrid_wrap.h") + endif() + # BLAS + if (BLAS_FOUND AND STARPU_LOOK_FOR_BLAS) + if (BLAS_INCLUDE_DIRS) + list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}") endif() - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_LIBRARIES) - endif(STARPU_LIBRARIES) - -endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT STARPU_FOUND) OR (STARPU_GIVEN_BY_USER) ) + 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") + find_library( + FORTRAN_gfortran_LIBRARY + NAMES gfortran + HINTS ${_lib_env} + ) + mark_as_advanced(FORTRAN_gfortran_LIBRARY) + if (FORTRAN_gfortran_LIBRARY AND CMAKE_C_COMPILER_ID STREQUAL "GNU") + list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}") + endif() + elseif (CMAKE_C_COMPILER_ID MATCHES "Intel") + find_library( + FORTRAN_ifcore_LIBRARY + NAMES ifcore + HINTS ${_lib_env} + ) + mark_as_advanced(FORTRAN_ifcore_LIBRARY) + if (FORTRAN_ifcore_LIBRARY) + list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}") + endif() + endif() + # EXTRA LIBS such that pthread, m, rt + list(APPEND REQUIRED_LIBS ${STARPU_EXTRA_LIBRARIES}) + + # set required libraries for link + set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") + 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 + unset(STARPU_WORKS CACHE) + include(CheckFunctionExists) + check_function_exists(starpu_init STARPU_WORKS) + mark_as_advanced(STARPU_WORKS) + + if(STARPU_WORKS) + # save link with dependencies + set(STARPU_LIBRARIES_DEP "${REQUIRED_LIBS}") + set(STARPU_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}") + set(STARPU_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}") + list(REMOVE_DUPLICATES STARPU_LIBRARY_DIRS_DEP) + list(REMOVE_DUPLICATES STARPU_INCLUDE_DIRS_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 "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)? " + "See the explanation in FindSTARPU.cmake.") + endif() + endif() + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) +endif(STARPU_LIBRARIES) if (STARPU_LIBRARIES) if (STARPU_LIBRARY_DIRS) @@ -925,35 +857,6 @@ mark_as_advanced(STARPU_DIR_FOUND) # check that STARPU has been found # -------------------------------- include(FindPackageHandleStandardArgs) -if(NOT STARPU_FIND_QUIETLY) - if(STARPU_SHM_FOUND) - message(STATUS "StarPU library has been found.") - if(STARPU_MPI_LIBRARIES) - message(STATUS "The mpi version of StarPU has been found so that we manage" - " two lists of libs, one sequential and one parallel (see" - " STARPU_SHM_LIBRARIES and STARPU_MPI_LIBRARIES).") - endif() - message(STATUS "StarPU shared memory libraries stored in STARPU_SHM_LIBRARIES") - endif() -endif() -if (PKG_CONFIG_EXECUTABLE AND STARPU_SHM_FOUND AND NOT STARPU_GIVEN_BY_USER) - find_package_handle_standard_args(STARPU DEFAULT_MSG - STARPU_SHM_LIBRARIES) -else() - find_package_handle_standard_args(STARPU DEFAULT_MSG - STARPU_SHM_LIBRARIES - STARPU_WORKS) -endif() -if(STARPU_LOOK_FOR_MPI) - if(STARPU_MPI_LIBRARIES AND NOT STARPU_FIND_QUIETLY) - message(STATUS "StarPU mpi libraries stored in STARPU_MPI_LIBRARIES") - endif() - if (PKG_CONFIG_EXECUTABLE AND STARPU_MPI_FOUND AND NOT STARPU_GIVEN_BY_USER) - find_package_handle_standard_args(STARPU DEFAULT_MSG - STARPU_MPI_LIBRARIES) - else() - find_package_handle_standard_args(STARPU DEFAULT_MSG - STARPU_MPI_LIBRARIES - STARPU_WORKS) - endif() -endif() +find_package_handle_standard_args(STARPU DEFAULT_MSG + STARPU_LIBRARIES + STARPU_WORKS) diff --git a/modules/find/tests/CMakeLists.txt b/modules/find/tests/CMakeLists.txt index 09abe5b..c664e71 100644 --- a/modules/find/tests/CMakeLists.txt +++ b/modules/find/tests/CMakeLists.txt @@ -38,6 +38,9 @@ foreach(_library ${PACKAGES}) else() message(WARNING "${_library}_LIBRARIES not found: ${${_library}_LIBRARIES}") endif() + if (${_library}_STATIC_LIBRARIES) + message(STATUS "${_library}_STATIC_LIBRARIES found: ${${_library}_STATIC_LIBRARIES}") + endif() if (${_library}_LIBRARIES_DEP) message(STATUS "${_library}_LIBRARIES_DEP found: ${${_library}_LIBRARIES_DEP}") endif() @@ -57,6 +60,12 @@ foreach(_library ${PACKAGES}) if (${_library}_INCLUDE_DIRS_DEP) message(STATUS "${_library}_INCLUDE_DIRS_DEP found: ${${_library}_INCLUDE_DIRS_DEP}") endif() + if (${_library}_CFLAGS_OTHER) + message(STATUS "${_library}_CFLAGS_OTHER found: ${${_library}_CFLAGS_OTHER}") + endif() + if (${_library}_LDFLAGS_OTHER) + message(STATUS "${_library}_LDFLAGS_OTHER found: ${${_library}_LDFLAGS_OTHER}") + endif() else() message(FATAL_ERROR "${_library} NOT FOUND !!") endif() -- GitLab