Commits (28)
...@@ -11,5 +11,5 @@ Find: ...@@ -11,5 +11,5 @@ Find:
- cd modules/find/tests - cd modules/find/tests
- mkdir -p build - mkdir -p build
- cd build - cd build
- cmake .. -DENABLE_CTEST=ON -DLAPACKE_COMPONENTS="TMG" -DQUARK_COMPONENTS="HWLOC" -DPASTIX_COMPONENTS="PARSEC;STARPU" - cmake .. -DENABLE_CTEST=ON -DLAPACKE_COMPONENTS="TMG" -DQUARK_COMPONENTS="HWLOC" -DCHAMELEON_COMPONENTS="MPI;FXT;STARPU"
- ctest -V - ctest -V
...@@ -23,18 +23,19 @@ See the file [morse_cmakefind_doc.org](modules/find/morse_cmakefind_doc.org). ...@@ -23,18 +23,19 @@ See the file [morse_cmakefind_doc.org](modules/find/morse_cmakefind_doc.org).
Installation Installation
--------------------- ---------------------
We recommend to use this project as a `git submodule` of your project.
# Example if morse_cmake is defined as a git submodule in ./cmake_modules/
git submodule add https://gitlab.inria.fr/solverstack/morse_cmake.git cmake_modules/morse_cmake
To use MORSE modules you have to add the path to the modules in your To use MORSE modules you have to add the path to the modules in your
CMake project and include the MorseInit module: CMake project and include the MorseInit module:
# Define where are located module files on your system # Example if Morse CMake modules are located in ./cmake_modules/morse_cmake/modules
set(MORSE_CMAKE_MODULE_PATH "/where/is/morse_cmake" CACHE PATH "Path to morse_cmake sources") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/morse_cmake/modules" )
# Append this directory to the list of directories containing CMake modules
list(APPEND CMAKE_MODULE_PATH "${MORSE_CMAKE_MODULE_PATH}/modules/" )
# Include the init module # Include the init module
include(MorseInit) include(MorseInit)
We recommend to use this project as a `git submodule` of your project.
Testing Testing
--------------------- ---------------------
......
###
#
# @copyright (c) 2018 Inria. All rights reserved.
#
###
#
# @file FindPkgconfigLibrariesAbsolutePath.cmake
#
# @project MORSE
# MORSE is a software package provided by:
# Inria Bordeaux - Sud-Ouest,
# Univ. of Tennessee,
# King Abdullah Univesity of Science and Technology
# Univ. of California Berkeley,
# Univ. of Colorado Denver.
#
# @version 1.0.0
# @author Florent Pruvost
# @date 06-04-2018
#
###
# 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
macro(FIND_PKGCONFIG_LIBRARIES_ABSOLUTE_PATH _prefix)
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
elseif(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
# non static case
set(${_prefix}_LIBRARIES_COPY "${${_prefix}_LIBRARIES}")
set(${_prefix}_LIBRARIES "")
foreach(_library ${${_prefix}_LIBRARIES_COPY})
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)
list(APPEND ${_prefix}_LIBRARIES ${_library_path})
else()
message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND")
endif()
unset(_library_path CACHE)
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})
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()
# try static first
set (default_find_library_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
find_library(_library_path NAMES ${_library}
HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env})
set (CMAKE_FIND_LIBRARY_SUFFIXES ${default_find_library_suffixes})
# if not found try dynamic
if (NOT _library_path)
find_library(_library_path NAMES ${_library}
HINTS ${${_prefix}_STATIC_LIBDIR} ${${_prefix}_STATIC_LIBRARY_DIRS} ${_lib_env})
endif()
if (_library_path)
list(APPEND ${_prefix}_STATIC_LIBRARIES ${_library_path})
else()
message(FATAL_ERROR "Dependency of ${_prefix} '${_library}' NOT FOUND")
endif()
unset(_library_path CACHE)
endif()
endforeach()
set (${_prefix}_STATIC_LIBRARIES "${${_prefix}_STATIC_LIBRARIES}" CACHE INTERNAL "" FORCE)
endmacro()
##
## @end file FindPkgconfigLibrariesAbsolutePath.cmake
##
###
#
# @copyright (c) 2018 Inria. All rights reserved.
#
###
#
# @file LibrariesAbsolutePath.cmake
#
# @project MORSE
# MORSE is a software package provided by:
# Inria Bordeaux - Sud-Ouest,
# Univ. of Tennessee,
# King Abdullah Univesity of Science and Technology
# Univ. of California Berkeley,
# Univ. of Colorado Denver.
#
# @version 1.0.0
# @author Florent Pruvost
# @date 13-04-2018
#
###
# Transform relative path into absolute path for libraries
# lib_list (input/output): the name of the CMake variable containing libraries, e.g. BLAS_LIBRARIES
# hints_paths (input): additional paths to add when looking for libraries
macro(LIBRARIES_ABSOLUTE_PATH lib_list hints_paths)
# collect environment paths to dig
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
elseif(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
# copy the lib list
set (${lib_list}_COPY "${${lib_list}}")
# reset the lib list to populate
set(${lib_list} "")
foreach(_library ${${lib_list}_COPY})
if(EXISTS "${_library}")
# if already an absolute path, nothing special to do
list(APPEND ${lib_list} ${_library})
else()
# replace pattern -lfoo -> foo
string(REGEX REPLACE "^-l" "" _library "${_library}")
# remove extensions if exist
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()
# try to find the lib
find_library(_library_path NAMES ${_library} HINTS ${hints_paths} ${_lib_env})
if (_library_path)
list(APPEND ${lib_list} ${_library_path})
else()
message(FATAL_ERROR "Dependency of ${lib_list} '${_library}' NOT FOUND")
endif()
unset(_library_path CACHE)
endif()
endforeach()
endmacro()
##
## @end file LibrariesAbsolutePath.cmake
##
...@@ -50,6 +50,12 @@ endif() ...@@ -50,6 +50,12 @@ endif()
# To find headers and libs # To find headers and libs
include(FindHeadersAndLibs) include(FindHeadersAndLibs)
# To transform relative path from pkg-config into absolute
include(FindPkgconfigLibrariesAbsolutePath)
# To transform relative path into absolute for a list of libraries
include(LibrariesAbsolutePath)
# Some macros to print status when search for headers and libs # Some macros to print status when search for headers and libs
# PrintFindStatus.cmake is in cmake_modules/morse/find directory # PrintFindStatus.cmake is in cmake_modules/morse/find directory
include(PrintFindStatus) include(PrintFindStatus)
......
...@@ -233,16 +233,21 @@ MACRO(precisions_rules_py) ...@@ -233,16 +233,21 @@ MACRO(precisions_rules_py)
# We generate a dependency only if a file will be generated # We generate a dependency only if a file will be generated
if( got_file ) if( got_file )
set( _compile_flags "-DPRECISION_${_dependency_PREC}" )
set( _listtmp ${PREC_RULE_PRECISIONS})
list(REMOVE_ITEM _listtmp ${_dependency_PREC})
foreach( _prec ${_listtmp})
set( _compile_flags "${_compile_flags} -UPRECISION_${_prec}" )
endforeach()
if( generate_out ) if( generate_out )
# the custom command is executed in CMAKE_CURRENT_BINARY_DIR # the custom command is executed in CMAKE_CURRENT_BINARY_DIR
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT ${_dependency_OUTPUT} OUTPUT ${_dependency_OUTPUT}
COMMAND ${CMAKE_COMMAND} -E remove -f ${_dependency_OUTPUT} && ${pythoncmd} && chmod a-w ${_dependency_OUTPUT} COMMAND ${CMAKE_COMMAND} -E remove -f ${_dependency_OUTPUT} && ${pythoncmd} && chmod a-w ${_dependency_OUTPUT}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_dependency_INPUT} ${RP_CODEGEN} ${RP_${CMAKE_PROJECT_NAME}_DICTIONNARY}) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_dependency_INPUT} ${RP_CODEGEN} ${RP_${CMAKE_PROJECT_NAME}_DICTIONNARY})
set_source_files_properties(${_dependency_OUTPUT} PROPERTIES COMPILE_FLAGS ${_compile_flags} GENERATED 1 IS_IN_BINARY_DIR 1 )
set_source_files_properties(${_dependency_OUTPUT} PROPERTIES COMPILE_FLAGS "-DPRECISION_${_dependency_PREC}" GENERATED 1 IS_IN_BINARY_DIR 1 )
else( generate_out ) else( generate_out )
set_source_files_properties(${_dependency_OUTPUT} PROPERTIES COMPILE_FLAGS "-DPRECISION_${_dependency_PREC}" GENERATED 0 ) set_source_files_properties(${_dependency_OUTPUT} PROPERTIES COMPILE_FLAGS ${_compile_flags} GENERATED 0 )
endif( generate_out ) endif( generate_out )
list(APPEND ${OUTPUTLIST} ${_dependency_OUTPUT}) list(APPEND ${OUTPUTLIST} ${_dependency_OUTPUT})
......
This diff is collapsed.
...@@ -18,20 +18,18 @@ ...@@ -18,20 +18,18 @@
# #
# The following variables have been added to manage links with sequential or multithreaded # The following variables have been added to manage links with sequential or multithreaded
# versions: # versions:
# BLAS_INCLUDE_DIRS - BLAS include directories # BLAS_INCLUDE_DIRS - BLAS include directories
# BLAS_LIBRARY_DIRS - Link directories for BLAS libraries # BLAS_LIBRARY_DIRS - Link directories for BLAS libraries
# BLAS_SEQ_LIBRARIES - BLAS component libraries to be linked (sequential) # BLAS_SEQ_LIBRARIES - BLAS component libraries to be linked (sequential)
# BLAS_SEQ_COMPILER_FLAGS - uncached list of required compiler flags (including -I for mkl headers). # BLAS_SEQ_CFLAGS_OTHER - compiler flags without headers paths
# BLAS_SEQ_LINKER_FLAGS - uncached list of required linker flags (excluding -l # BLAS_SEQ_LDFLAGS_OTHER - linker flags without libraries
# and -L) # BLAS_PAR_LIBRARIES - BLAS component libraries to be linked (multithreaded)
# BLAS_PAR_LIBRARIES - BLAS component libraries to be linked (multithreaded) # BLAS_PAR_CFLAGS_OTHER - compiler flags without headers paths
# BLAS_PAR_COMPILER_FLAGS - uncached list of required compiler flags (including -I for mkl headers) # BLAS_PAR_LDFLAGS_OTHER - linker flags without libraries
# BLAS_PAR_LINKER_FLAGS - uncached list of required linker flags (excluding -l # BLASEXT_FOUND - if a BLAS has been found
# and -L) # BLASEXT_LIBRARIES - Idem BLAS_LIBRARIES
# BLASEXT_FOUND - if a BLAS has been found # BLASEXT_INCLUDE_DIRS - Idem BLAS_INCLUDE_DIRS
# BLASEXT_LIBRARIES - Idem BLAS_LIBRARIES # BLASEXT_LIBRARY_DIRS - Idem BLAS_LIBRARY_DIRS
# BLASEXT_INCLUDE_DIRS - Idem BLAS_INCLUDE_DIRS
# BLASEXT_LIBRARY_DIRS - Idem BLAS_LIBRARY_DIRS
#============================================================================= #=============================================================================
# Copyright 2012-2013 Inria # Copyright 2012-2013 Inria
...@@ -90,11 +88,9 @@ if(NOT BLASEXT_FIND_QUIETLY) ...@@ -90,11 +88,9 @@ if(NOT BLASEXT_FIND_QUIETLY)
"\n ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic") "\n ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic")
endif() endif()
if (NOT BLAS_FOUND) # First blas detection in order to decide if we should look for a
# First blas detection in order to decide if we should look for a # multitheaded version
# multitheaded version find_package_blas(0)
find_package_blas(0)
endif ()
# detect the cases where SEQ and PAR libs are handled # detect the cases where SEQ and PAR libs are handled
if(BLA_VENDOR STREQUAL "All" AND if(BLA_VENDOR STREQUAL "All" AND
...@@ -206,11 +202,11 @@ if(BLA_VENDOR MATCHES "Intel*") ...@@ -206,11 +202,11 @@ if(BLA_VENDOR MATCHES "Intel*")
find_package_blas(0) find_package_blas(0)
if(BLAS_FOUND) if(BLAS_FOUND)
set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}") set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}")
if (BLAS_COMPILER_FLAGS) if (BLAS_CFLAGS_OTHER)
set (BLAS_SEQ_COMPILER_FLAGS "${BLAS_COMPILER_FLAGS}") set (BLAS_SEQ_CFLAGS_OTHER "${BLAS_CFLAGS_OTHER}")
endif() endif()
if (BLAS_LINKER_FLAGS) if (BLAS_LDFLAGS_OTHER)
set (BLAS_SEQ_LINKER_FLAGS "${BLAS_LINKER_FLAGS}") set (BLAS_SEQ_LDFLAGS_OTHER "${BLAS_LDFLAGS_OTHER}")
endif() endif()
else() else()
set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}") set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}")
...@@ -224,11 +220,11 @@ if(BLA_VENDOR MATCHES "Intel*") ...@@ -224,11 +220,11 @@ if(BLA_VENDOR MATCHES "Intel*")
find_package_blas(0) find_package_blas(0)
if(BLAS_FOUND) if(BLAS_FOUND)
set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}") set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}")
if (BLAS_COMPILER_FLAGS) if (BLAS_CFLAGS_OTHER)
set (BLAS_PAR_COMPILER_FLAGS "${BLAS_COMPILER_FLAGS}") set (BLAS_PAR_CFLAGS_OTHER "${BLAS_CFLAGS_OTHER}")
endif() endif()
if (BLAS_LINKER_FLAGS) if (BLAS_LDFLAGS_OTHER)
set (BLAS_PAR_LINKER_FLAGS "${BLAS_LINKER_FLAGS}") set (BLAS_PAR_LDFLAGS_OTHER "${BLAS_LDFLAGS_OTHER}")
endif() endif()
else() else()
set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}") set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}")
...@@ -301,33 +297,34 @@ endif() ...@@ -301,33 +297,34 @@ endif()
# Reset pure BLAS cmake variables to the sequential case (arbitrary default) # Reset pure BLAS cmake variables to the sequential case (arbitrary default)
if(BLAS_SEQ_LIBRARIES) if(BLAS_SEQ_LIBRARIES)
set(BLAS_LIBRARIES "${BLAS_SEQ_LIBRARIES}") set(BLAS_LIBRARIES "${BLAS_SEQ_LIBRARIES}")
set(BLAS_COMPILER_FLAGS "${BLAS_SEQ_COMPILER_FLAGS}") set(BLAS_CFLAGS_OTHER "${BLAS_SEQ_CFLAGS_OTHER}")
set(BLAS_LINKER_FLAGS "${BLAS_SEQ_LINKER_FLAGS}") set(BLAS_LDFLAGS_OTHER "${BLAS_SEQ_LDFLAGS_OTHER}")
endif() endif()
# extract libs paths # extract libs paths if not given by find_package(BLAS)
# remark: because it is not given by find_package(BLAS) if (NOT BLAS_LIBRARY_DIRS)
set(BLAS_LIBRARY_DIRS "") set(BLAS_LIBRARY_DIRS "")
string(REPLACE " " ";" BLAS_LIBRARIES "${BLAS_LIBRARIES}") string(REPLACE " " ";" BLAS_LIBRARIES "${BLAS_LIBRARIES}")
foreach(blas_lib ${BLAS_LIBRARIES}) foreach(blas_lib ${BLAS_LIBRARIES})
if (EXISTS "${blas_lib}")
get_filename_component(a_blas_lib_dir "${blas_lib}" PATH)
list(APPEND BLAS_LIBRARY_DIRS "${a_blas_lib_dir}" )
else()
string(REPLACE "-L" "" blas_lib "${blas_lib}")
if (EXISTS "${blas_lib}") if (EXISTS "${blas_lib}")
list(APPEND BLAS_LIBRARY_DIRS "${blas_lib}" )
else()
get_filename_component(a_blas_lib_dir "${blas_lib}" PATH) get_filename_component(a_blas_lib_dir "${blas_lib}" PATH)
if (EXISTS "${a_blas_lib_dir}") list(APPEND BLAS_LIBRARY_DIRS "${a_blas_lib_dir}" )
list(APPEND BLAS_LIBRARY_DIRS "${a_blas_lib_dir}" ) else()
string(REPLACE "-L" "" blas_lib "${blas_lib}")
if (EXISTS "${blas_lib}")
list(APPEND BLAS_LIBRARY_DIRS "${blas_lib}" )
else()
get_filename_component(a_blas_lib_dir "${blas_lib}" PATH)
if (EXISTS "${a_blas_lib_dir}")
list(APPEND BLAS_LIBRARY_DIRS "${a_blas_lib_dir}" )
endif()
endif() endif()
endif() endif()
endif() endforeach()
endforeach() if (BLAS_LIBRARY_DIRS)
if (BLAS_LIBRARY_DIRS) list(REMOVE_DUPLICATES BLAS_LIBRARY_DIRS)
list(REMOVE_DUPLICATES BLAS_LIBRARY_DIRS) endif ()
endif () endif(NOT BLAS_LIBRARY_DIRS)
# check that BLASEXT has been found # check that BLASEXT has been found
# --------------------------------- # ---------------------------------
......
This diff is collapsed.
This diff is collapsed.
...@@ -20,11 +20,23 @@ ...@@ -20,11 +20,23 @@
# This module finds headers and eztrace library. # This module finds headers and eztrace library.
# Results are reported in variables: # Results are reported in variables:
# EZTRACE_FOUND - True if headers and requested libraries were found # 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_INCLUDE_DIRS - eztrace include directories
# EZTRACE_LIBRARY_DIRS - Link directories for eztrace libraries # EZTRACE_LIBRARY_DIRS - Link directories for eztrace libraries
# EZTRACE_LIBRARIES - eztrace component libraries to be linked # EZTRACE_LIBRARIES - eztrace component libraries to be linked
#
# EZTRACE_FOUND_WITH_PKGCONFIG - True if found with pkg-config # 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 # 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): # options at configure (ex: cmake path/to/project -DEZTRACE_DIR=path/to/eztrace):
...@@ -73,14 +85,10 @@ find_package(PkgConfig QUIET) ...@@ -73,14 +85,10 @@ find_package(PkgConfig QUIET)
if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER ) if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER )
pkg_search_module(EZTRACE eztrace) pkg_search_module(EZTRACE eztrace)
if (NOT EZTRACE_FIND_QUIETLY) if (NOT EZTRACE_FIND_QUIETLY)
if (EZTRACE_FOUND AND EZTRACE_LIBRARIES) if (EZTRACE_FOUND AND EZTRACE_LIBRARIES)
message(STATUS "Looking for EZTRACE - found using PkgConfig") 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() else()
message(STATUS "${Magenta}Looking for EZTRACE - not found using PkgConfig." message(STATUS "${Magenta}Looking for EZTRACE - not found using PkgConfig."
"\n Perhaps you should add the directory containing eztrace.pc to" "\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 ) ...@@ -88,13 +96,12 @@ if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER )
endif() endif()
if (EZTRACE_FOUND AND EZTRACE_LIBRARIES) if (EZTRACE_FOUND AND EZTRACE_LIBRARIES)
set(EZTRACE_FOUND_WITH_PKGCONFIG "TRUE") set(EZTRACE_FOUND_WITH_PKGCONFIG "TRUE")
find_pkgconfig_libraries_absolute_path(EZTRACE)
else() else()
set(EZTRACE_FOUND_WITH_PKGCONFIG "FALSE") set(EZTRACE_FOUND_WITH_PKGCONFIG "FALSE")
endif() endif()
endif() endif()
set(EZTRACE_C_FLAGS "${EZTRACE_CFLAGS_OTHER}")
endif( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER ) 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) ) if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) )
...@@ -288,51 +295,70 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) ...@@ -288,51 +295,70 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND)
list(REMOVE_DUPLICATES EZTRACE_LIBRARY_DIRS) list(REMOVE_DUPLICATES EZTRACE_LIBRARY_DIRS)
endif () endif ()
# check a function to validate the find endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) )
if(EZTRACE_LIBRARIES)
set(REQUIRED_INCDIRS) # check a function to validate the find
set(REQUIRED_LIBDIRS) if(EZTRACE_LIBRARIES)
set(REQUIRED_LIBS)
# EZTRACE set(REQUIRED_INCDIRS)
if (EZTRACE_INCLUDE_DIRS) set(REQUIRED_LIBDIRS)
set(REQUIRED_INCDIRS "${EZTRACE_INCLUDE_DIRS}") set(REQUIRED_LIBS)
endif()
if (EZTRACE_LIBRARY_DIRS)
set(REQUIRED_LIBDIRS "${EZTRACE_LIBRARY_DIRS}")
endif()
set(REQUIRED_LIBS "${EZTRACE_LIBRARIES}")
# set required libraries for link # EZTRACE
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") if (EZTRACE_INCLUDE_DIRS)
set(CMAKE_REQUIRED_LIBRARIES) set(REQUIRED_INCDIRS "${EZTRACE_INCLUDE_DIRS}")
foreach(lib_dir ${REQUIRED_LIBDIRS}) endif()
list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") if (EZTRACE_CFLAGS_OTHER)
endforeach() set(REQUIRED_FLAGS "${EZTRACE_CFLAGS_OTHER}")
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") endif()
string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") if (EZTRACE_LDFLAGS_OTHER)
set(REQUIRED_LDFLAGS "${EZTRACE_LDFLAGS_OTHER}")
# test link endif()
unset(EZTRACE_WORKS CACHE) if (EZTRACE_LIBRARY_DIRS)
include(CheckFunctionExists) set(REQUIRED_LIBDIRS "${EZTRACE_LIBRARY_DIRS}")
check_function_exists(eztrace_start EZTRACE_WORKS) endif()
mark_as_advanced(EZTRACE_WORKS) set(REQUIRED_LIBS "${EZTRACE_LIBRARIES}")
if(NOT EZTRACE_WORKS) # set required libraries for link
if(NOT EZTRACE_FIND_QUIETLY) set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
message(STATUS "Looking for eztrace : test of eztrace_topology_init with eztrace library fails") if (REQUIRED_FLAGS)
message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}") set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") set(REQUIRED_FLAGS)
message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") set(REQUIRED_DEFINITIONS)
foreach(_flag ${REQUIRED_FLAGS_COPY})
if (_flag MATCHES "^-D")
list(APPEND REQUIRED_DEFINITIONS "${_flag}")
endif() endif()
string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
list(APPEND REQUIRED_FLAGS "${_flag}")
endforeach()
endif()
set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
# test link
unset(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 "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) endif()
set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_FLAGS)
endif(EZTRACE_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
endif(EZTRACE_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) )
if (EZTRACE_LIBRARIES) if (EZTRACE_LIBRARIES)
if (EZTRACE_LIBRARY_DIRS) if (EZTRACE_LIBRARY_DIRS)
...@@ -355,11 +381,6 @@ mark_as_advanced(EZTRACE_DIR_FOUND) ...@@ -355,11 +381,6 @@ mark_as_advanced(EZTRACE_DIR_FOUND)
# check that EZTRACE has been found # check that EZTRACE has been found
# ------------------------------- # -------------------------------
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
if (PKG_CONFIG_EXECUTABLE AND EZTRACE_FOUND) find_package_handle_standard_args(EZTRACE DEFAULT_MSG
find_package_handle_standard_args(EZTRACE DEFAULT_MSG EZTRACE_LIBRARIES
EZTRACE_LIBRARIES) EZTRACE_WORKS)
else()
find_package_handle_standard_args(EZTRACE DEFAULT_MSG
EZTRACE_LIBRARIES
EZTRACE_WORKS)
endif()
This diff is collapsed.
...@@ -28,15 +28,30 @@ ...@@ -28,15 +28,30 @@
# This module finds headers and fftw library. # This module finds headers and fftw library.
# Results are reported in variables: # Results are reported in variables:
# FFTW_FOUND - True if headers and requested libraries were found # FFTW_FOUND - True if headers and requested libraries were found
# FFTW_C_FLAGS - list of required compilation flags (excluding -I) # FFTW_CFLAGS_OTHER - fftw compiler flags without headers paths
# FFTW_LINKER_FLAGS - list of required linker flags (excluding -l and -L) # FFTW_LDFLAGS_OTHER - fftw linker flags without libraries
# FFTW_INCLUDE_DIRS - fftw include directories # FFTW_INCLUDE_DIRS - fftw include directories
# FFTW_LIBRARY_DIRS - Link directories for fftw libraries # FFTW_LIBRARY_DIRS - fftw link directories
# FFTW_LIBRARIES - fftw component libraries to be linked # FFTW_LIBRARIES - fftw libraries to be linked (absolute path)
# FFTW_INCLUDE_DIRS_DEP - fftw + dependencies include directories # FFTW_CFLAGS_OTHER_DEP - fftw + dependencies compiler flags without headers paths
# FFTW_LIBRARY_DIRS_DEP - fftw + dependencies link directories # FFTW_LDFLAGS_OTHER_DEP - fftw + dependencies linker flags without libraries
# FFTW_LIBRARIES_DEP - fftw libraries + dependencies # FFTW_INCLUDE_DIRS_DEP - fftw + dependencies include directories
# FFTW_LIBRARY_DIRS_DEP - fftw + dependencies link directories
# FFTW_LIBRARIES_DEP - fftw + dependencies libraries
#
# FFTW_FOUND_WITH_PKGCONFIG - True if found with pkg-config # 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 # 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): # options at configure (ex: cmake path/to/project -DFFTW_DIR=path/to/fftw):
...@@ -184,10 +199,10 @@ if (FFTW_LOOK_FOR_MKL) ...@@ -184,10 +199,10 @@ if (FFTW_LOOK_FOR_MKL)
endif() endif()
if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL) if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_MKL)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
find_package(BLASEXT REQUIRED) find_package(BLAS REQUIRED)
else() else()
find_package(Threads) find_package(Threads)
find_package(BLASEXT) find_package(BLAS)
endif() endif()
endif() endif()
...@@ -201,12 +216,17 @@ if (FFTW_LOOK_FOR_ESSL) ...@@ -201,12 +216,17 @@ if (FFTW_LOOK_FOR_ESSL)
set(BLA_VENDOR "IBMESSL") set(BLA_VENDOR "IBMESSL")
endif() endif()
if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_ESSL) if (FFTW_FIND_REQUIRED AND FFTW_FIND_REQUIRED_ESSL)
find_package(BLASEXT REQUIRED) find_package(BLAS REQUIRED)
else() else()
find_package(BLASEXT) find_package(BLAS)
endif() endif()
endif() endif()
if( THREADS_FOUND )
libraries_absolute_path(CMAKE_THREAD_LIBS_INIT "")
endif ()
set(ENV_FFTW_DIR "$ENV{FFTW_DIR}") set(ENV_FFTW_DIR "$ENV{FFTW_DIR}")
set(ENV_FFTW_INCDIR "$ENV{FFTW_INCDIR}") set(ENV_FFTW_INCDIR "$ENV{FFTW_INCDIR}")
set(ENV_FFTW_LIBDIR "$ENV{FFTW_LIBDIR}") set(ENV_FFTW_LIBDIR "$ENV{FFTW_LIBDIR}")
...@@ -231,11 +251,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) ...@@ -231,11 +251,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
pkg_search_module(FFTW3F fftw3f) pkg_search_module(FFTW3F fftw3f)
pkg_search_module(FFTW3 fftw3) pkg_search_module(FFTW3 fftw3)
if (FFTW3F_FOUND) if (FFTW3F_FOUND)
set(FFTW_C_FLAGS "${FFTW3F_CFLAGS_OTHER}")
if (NOT FFTW_FIND_QUIETLY) if (NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW3F - found using PkgConfig") message(STATUS "Looking for FFTW3F - found using PkgConfig")
endif() endif()
if (FFTW3F_LIBRARIES) if (FFTW3F_LIBRARIES)
find_pkgconfig_libraries_absolute_path(FFTW3F)
list(APPEND FFTW_LIBRARIES "${FFTW3F_LIBRARIES}") list(APPEND FFTW_LIBRARIES "${FFTW3F_LIBRARIES}")
endif() endif()
if(FFTW3F_INCLUDE_DIRS) if(FFTW3F_INCLUDE_DIRS)
...@@ -261,11 +281,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) ...@@ -261,11 +281,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
pkg_search_module(FFTW3L fftw3l) pkg_search_module(FFTW3L fftw3l)
pkg_search_module(FFTW3 fftw3) pkg_search_module(FFTW3 fftw3)
if (FFTW3L_FOUND) if (FFTW3L_FOUND)
set(FFTW_C_FLAGS "${FFTW3L_CFLAGS_OTHER}")
if (NOT FFTW_FIND_QUIETLY) if (NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW3L - found using PkgConfig") message(STATUS "Looking for FFTW3L - found using PkgConfig")
endif() endif()
if (FFTW3L_LIBRARIES) if (FFTW3L_LIBRARIES)
find_pkgconfig_libraries_absolute_path(FFTW3L)
list(APPEND FFTW_LIBRARIES "${FFTW3L_LIBRARIES}") list(APPEND FFTW_LIBRARIES "${FFTW3L_LIBRARIES}")
endif() endif()
if(FFTW3L_INCLUDE_DIRS) if(FFTW3L_INCLUDE_DIRS)
...@@ -291,11 +311,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) ...@@ -291,11 +311,11 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
pkg_search_module(FFTW3Q fftw3q) pkg_search_module(FFTW3Q fftw3q)
pkg_search_module(FFTW3 fftw3) pkg_search_module(FFTW3 fftw3)
if (FFTW3Q_FOUND) if (FFTW3Q_FOUND)
set(FFTW_C_FLAGS "${FFTW3Q_CFLAGS_OTHER}")
if (NOT FFTW_FIND_QUIETLY) if (NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW3Q - found using PkgConfig") message(STATUS "Looking for FFTW3Q - found using PkgConfig")
endif() endif()
if (FFTW3Q_LIBRARIES) if (FFTW3Q_LIBRARIES)
find_pkgconfig_libraries_absolute_path(FFTW3Q)
list(APPEND FFTW_LIBRARIES "${FFTW3Q_LIBRARIES}") list(APPEND FFTW_LIBRARIES "${FFTW3Q_LIBRARIES}")
endif() endif()
if(FFTW3Q_INCLUDE_DIRS) if(FFTW3Q_INCLUDE_DIRS)
...@@ -319,13 +339,16 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) ...@@ -319,13 +339,16 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
endif(FFTW3Q_FOUND) endif(FFTW3Q_FOUND)
else() else()
pkg_search_module(FFTW3 fftw3) pkg_search_module(FFTW3 fftw3)
if (FFTW3_FOUND AND FFTW3_LIBRARIES)
find_pkgconfig_libraries_absolute_path(FFTW3)
endif()
endif() endif()
if (FFTW3_FOUND) if (FFTW3_FOUND)
set(FFTW_C_FLAGS "${FFTW3_CFLAGS_OTHER}")
if (NOT FFTW_FIND_QUIETLY) if (NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW3 - found using PkgConfig") message(STATUS "Looking for FFTW3 - found using PkgConfig")
endif() endif()
if (FFTW3_LIBRARIES) if (FFTW3_LIBRARIES)
find_pkgconfig_libraries_absolute_path(FFTW3)
list(APPEND FFTW_LIBRARIES "${FFTW3_LIBRARIES}") list(APPEND FFTW_LIBRARIES "${FFTW3_LIBRARIES}")
endif() endif()
if(FFTW3_INCLUDE_DIRS) if(FFTW3_INCLUDE_DIRS)
...@@ -348,14 +371,6 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL) ...@@ -348,14 +371,6 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
endif() endif()
endif(FFTW3_FOUND) 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) if (FFTW_FOUND AND FFTW_LIBRARIES)
set(FFTW_FOUND_WITH_PKGCONFIG "TRUE") set(FFTW_FOUND_WITH_PKGCONFIG "TRUE")
else() else()
...@@ -688,98 +703,6 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR ...@@ -688,98 +703,6 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR
endif() endif()
endforeach() 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 endif( (NOT PKG_CONFIG_EXECUTABLE) OR
(PKG_CONFIG_EXECUTABLE AND NOT FFTW_FOUND) OR (PKG_CONFIG_EXECUTABLE AND NOT FFTW_FOUND) OR
FFTW_GIVEN_BY_USER OR FFTW_GIVEN_BY_USER OR
...@@ -787,6 +710,107 @@ endif( (NOT PKG_CONFIG_EXECUTABLE) OR ...@@ -787,6 +710,107 @@ endif( (NOT PKG_CONFIG_EXECUTABLE) OR
FFTW_LOOK_FOR_ESSL 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}")
if (REQUIRED_FLAGS)
set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
set(REQUIRED_FLAGS)
set(REQUIRED_DEFINITIONS)
foreach(_flag ${REQUIRED_FLAGS_COPY})
if (_flag MATCHES "^-D")
list(APPEND REQUIRED_DEFINITIONS "${_flag}")
endif()
string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
list(APPEND REQUIRED_FLAGS "${_flag}")
endforeach()
endif()
set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
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_CFLAGS_OTHER_DEP "${REQUIRED_FLAGS}")
set(FFTW_LDFLAGS_OTHER_DEP "${REQUIRED_LDFLAGS}")
list(REMOVE_DUPLICATES FFTW_LIBRARY_DIRS_DEP)
list(REMOVE_DUPLICATES FFTW_CFLAGS_OTHER_DEP)
list(REMOVE_DUPLICATES FFTW_LDFLAGS_OTHER_DEP)
else()
if(NOT FFTW_FIND_QUIETLY)
message(STATUS "Looking for FFTW : test of ${FFTW_PREC_TESTFUNC}fftw_execute_ with fftw library fails")
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) if (FFTW_LIBRARIES)
list(GET FFTW_LIBRARIES 0 first_lib) list(GET FFTW_LIBRARIES 0 first_lib)
get_filename_component(first_lib_path "${first_lib}" PATH) get_filename_component(first_lib_path "${first_lib}" PATH)
...@@ -806,13 +830,6 @@ mark_as_advanced(FFTW_DIR_FOUND) ...@@ -806,13 +830,6 @@ mark_as_advanced(FFTW_DIR_FOUND)
# check that FFTW has been found # check that FFTW has been found
# ------------------------------- # -------------------------------
include(FindPackageHandleStandardArgs) 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
find_package_handle_standard_args(FFTW DEFAULT_MSG FFTW_LIBRARIES
FFTW_LIBRARIES FFTW_WORKS)
FFTW_INCLUDE_DIRS
FFTW_WORKS)
else()
find_package_handle_standard_args(FFTW DEFAULT_MSG
FFTW_LIBRARIES
FFTW_WORKS)
endif()
...@@ -16,11 +16,23 @@ ...@@ -16,11 +16,23 @@
# This module finds headers and fxt library. # This module finds headers and fxt library.
# Results are reported in variables: # Results are reported in variables:
# FXT_FOUND - True if headers and requested libraries were found # FXT_FOUND - True if headers and requested libraries were found
# FXT_C_FLAGS - list of required compilation flags (excluding -I)
# FXT_INCLUDE_DIRS - fxt include directories # FXT_INCLUDE_DIRS - fxt include directories
# FXT_LIBRARY_DIRS - Link directories for fxt libraries # FXT_LIBRARY_DIRS - fxt link directories
# FXT_LIBRARIES - fxt component libraries to be linked # FXT_LIBRARIES - fxt libraries to be linked (absolute path)
#
# FXT_FOUND_WITH_PKGCONFIG - True if found with pkg-config # 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 # 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): # options at configure (ex: cmake path/to/project -DFXT_DIR=path/to/fxt):
...@@ -69,14 +81,10 @@ find_package(PkgConfig QUIET) ...@@ -69,14 +81,10 @@ find_package(PkgConfig QUIET)
if(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER) if(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER)
pkg_search_module(FXT fxt) pkg_search_module(FXT fxt)
if (NOT FXT_FIND_QUIETLY) if (NOT FXT_FIND_QUIETLY)
if (FXT_FOUND AND FXT_LIBRARIES) if (FXT_FOUND AND FXT_LIBRARIES)
message(STATUS "Looking for FXT - found using PkgConfig") 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() else()
message(STATUS "${Magenta}Looking for FXT - not found using PkgConfig." message(STATUS "${Magenta}Looking for FXT - not found using PkgConfig."
"\n Perhaps you should add the directory containing fxt.pc to the" "\n Perhaps you should add the directory containing fxt.pc to the"
...@@ -84,10 +92,9 @@ if(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER) ...@@ -84,10 +92,9 @@ if(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER)
endif() endif()
endif() endif()
set(FXT_C_FLAGS "${FXT_CFLAGS_OTHER}")
if (FXT_FOUND AND FXT_LIBRARIES) if (FXT_FOUND AND FXT_LIBRARIES)
set(FXT_FOUND_WITH_PKGCONFIG "TRUE") set(FXT_FOUND_WITH_PKGCONFIG "TRUE")
find_pkgconfig_libraries_absolute_path(FXT)
else() else()
set(FXT_FOUND_WITH_PKGCONFIG "FALSE") set(FXT_FOUND_WITH_PKGCONFIG "FALSE")
endif() endif()
...@@ -244,51 +251,72 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR ...@@ -244,51 +251,72 @@ if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR
list(REMOVE_DUPLICATES FXT_LIBRARY_DIRS) list(REMOVE_DUPLICATES FXT_LIBRARY_DIRS)
endif () endif ()
# check a function to validate the find endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR (FXT_GIVEN_BY_USER) )
if(FXT_LIBRARIES)
set(REQUIRED_INCDIRS) # check a function to validate the find
set(REQUIRED_LIBDIRS) if(FXT_LIBRARIES)
set(REQUIRED_LIBS)
# FXT set(REQUIRED_INCDIRS)
if (FXT_INCLUDE_DIRS) set(REQUIRED_FLAGS)
set(REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}") set(REQUIRED_LDFLAGS)
endif() set(REQUIRED_LIBDIRS)
if (FXT_LIBRARY_DIRS) set(REQUIRED_LIBS)
set(REQUIRED_LIBDIRS "${FXT_LIBRARY_DIRS}")
endif()
set(REQUIRED_LIBS "${FXT_LIBRARIES}")
# set required libraries for link # FXT
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}") if (FXT_INCLUDE_DIRS)
set(CMAKE_REQUIRED_LIBRARIES) set(REQUIRED_INCDIRS "${FXT_INCLUDE_DIRS}")
foreach(lib_dir ${REQUIRED_LIBDIRS}) endif()
list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}") 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}")
if (REQUIRED_FLAGS)
set(REQUIRED_FLAGS_COPY "${REQUIRED_FLAGS}")
set(REQUIRED_FLAGS)
set(REQUIRED_DEFINITIONS)
foreach(_flag ${REQUIRED_FLAGS_COPY})
if (_flag MATCHES "^-D")
list(APPEND REQUIRED_DEFINITIONS "${_flag}")
endif()
string(REGEX REPLACE "^-D.*" "" _flag "${_flag}")
list(APPEND REQUIRED_FLAGS "${_flag}")
endforeach() endforeach()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}") endif()
string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") set(CMAKE_REQUIRED_DEFINITIONS "${REQUIRED_DEFINITIONS}")
set(CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
# test link # test link
unset(FXT_WORKS CACHE) unset(FXT_WORKS CACHE)
include(CheckFunctionExists) include(CheckFunctionExists)
check_function_exists(fut_keychange FXT_WORKS) check_function_exists(fut_keychange FXT_WORKS)
mark_as_advanced(FXT_WORKS) mark_as_advanced(FXT_WORKS)
if(NOT FXT_WORKS) if(NOT FXT_WORKS)
if(NOT FXT_FIND_QUIETLY) if(NOT FXT_FIND_QUIETLY)
message(STATUS "Looking for fxt : test of fut_keychange with fxt library fails") 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_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}") message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails") message(STATUS "CMAKE_REQUIRED_FLAGS: ${CMAKE_REQUIRED_FLAGS}")
endif() message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
endif() endif()
set(CMAKE_REQUIRED_INCLUDES) endif()
set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_FLAGS)
endif(FXT_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
endif(FXT_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR (FXT_GIVEN_BY_USER) )
if (FXT_LIBRARIES) if (FXT_LIBRARIES)
if (FXT_LIBRARY_DIRS) if (FXT_LIBRARY_DIRS)
...@@ -311,11 +339,6 @@ mark_as_advanced(FXT_DIR_FOUND) ...@@ -311,11 +339,6 @@ mark_as_advanced(FXT_DIR_FOUND)
# check that FXT has been found # check that FXT has been found
# ------------------------------- # -------------------------------
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
if (PKG_CONFIG_EXECUTABLE AND FXT_FOUND) find_package_handle_standard_args(FXT DEFAULT_MSG
find_package_handle_standard_args(FXT DEFAULT_MSG FXT_LIBRARIES
FXT_LIBRARIES) FXT_WORKS)
else()
find_package_handle_standard_args(FXT DEFAULT_MSG
FXT_LIBRARIES
FXT_WORKS)
endif()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -72,13 +72,14 @@ if(NOT MAGMA_FOUND) ...@@ -72,13 +72,14 @@ if(NOT MAGMA_FOUND)
endif(NOT MAGMA_FOUND) endif(NOT MAGMA_FOUND)
# MAGMA depends on CUDA anyway, try to find it # MAGMA depends on CUDA anyway, try to find it
if (NOT CUDA_FOUND) if(MAGMA_FIND_REQUIRED)
if(MAGMA_FIND_REQUIRED) find_package(CUDA REQUIRED)
find_package(CUDA REQUIRED) else()
else() find_package(CUDA)
find_package(CUDA)
endif()
endif() endif()
if( CUDA_FOUND )
libraries_absolute_path(CUDA_LIBRARIES "$ENV{CUDA_ROOT}/lib64")
endif ()
# MAGMA depends on cuBLAS which should come with CUDA, if not found -> error # MAGMA depends on cuBLAS which should come with CUDA, if not found -> error
if (NOT CUDA_CUBLAS_LIBRARIES) if (NOT CUDA_CUBLAS_LIBRARIES)
if(MAGMA_FIND_REQUIRED) if(MAGMA_FIND_REQUIRED)
...@@ -87,20 +88,16 @@ if (NOT CUDA_CUBLAS_LIBRARIES) ...@@ -87,20 +88,16 @@ if (NOT CUDA_CUBLAS_LIBRARIES)
endif() endif()
endif() endif()
# MAGMA depends on LAPACK anyway, try to find it # MAGMA depends on LAPACK anyway, try to find it
if (NOT LAPACK_FOUND) if(MAGMA_FIND_REQUIRED)
if(MAGMA_FIND_REQUIRED) find_package(LAPACK REQUIRED)
find_package(LAPACKEXT REQUIRED) else()
else() find_package(LAPACK)
find_package(LAPACKEXT)
endif()
endif() endif()
# MAGMA depends on CBLAS anyway, try to find it # MAGMA depends on CBLAS anyway, try to find it
if (NOT CBLAS_FOUND) if(MAGMA_FIND_REQUIRED)
if(MAGMA_FIND_REQUIRED) find_package(CBLAS REQUIRED)
find_package(CBLAS REQUIRED) else()
else() find_package(CBLAS)
find_package(CBLAS)
endif()
endif() endif()
set(ENV_MAGMA_DIR "$ENV{MAGMA_DIR}") set(ENV_MAGMA_DIR "$ENV{MAGMA_DIR}")
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.