Lemma is an Electromagnetics API
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

FindPaSTiX.cmake 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. ###
  2. #
  3. # @copyright (c) 2009-2014 The University of Tennessee and The University
  4. # of Tennessee Research Foundation.
  5. # All rights reserved.
  6. # @copyright (c) 2012-2014 Inria. All rights reserved.
  7. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
  8. #
  9. ###
  10. #
  11. # - Find PASTIX include dirs and libraries
  12. # Use this module by invoking find_package with the form:
  13. # find_package(PASTIX
  14. # [REQUIRED] # Fail with error if pastix is not found
  15. # [COMPONENTS <comp1> <comp2> ...] # dependencies
  16. # )
  17. #
  18. # PASTIX depends on the following libraries:
  19. # - Threads, m, rt
  20. # - MPI
  21. # - HWLOC
  22. # - BLAS
  23. #
  24. # COMPONENTS are optional libraries PASTIX could be linked with,
  25. # Use it to drive detection of a specific compilation chain
  26. # COMPONENTS can be some of the following:
  27. # - MPI: to activate detection of the parallel MPI version (default)
  28. # it looks for Threads, HWLOC, BLAS, MPI and ScaLAPACK libraries
  29. # - SEQ: to activate detection of the sequential version (exclude MPI version)
  30. # - STARPU: to activate detection of StarPU version
  31. # it looks for MPI version of StarPU (default behaviour)
  32. # if SEQ and STARPU are given, it looks for a StarPU without MPI
  33. # - STARPU_CUDA: to activate detection of StarPU with CUDA
  34. # - STARPU_FXT: to activate detection of StarPU with FxT
  35. # - SCOTCH: to activate detection of PASTIX linked with SCOTCH
  36. # - PTSCOTCH: to activate detection of PASTIX linked with SCOTCH
  37. # - METIS: to activate detection of PASTIX linked with SCOTCH
  38. #
  39. # This module finds headers and pastix library.
  40. # Results are reported in variables:
  41. # PASTIX_FOUND - True if headers and requested libraries were found
  42. # PASTIX_LINKER_FLAGS - list of required linker flags (excluding -l and -L)
  43. # PASTIX_INCLUDE_DIRS - pastix include directories
  44. # PASTIX_LIBRARY_DIRS - Link directories for pastix libraries
  45. # PASTIX_LIBRARIES - pastix libraries
  46. # PASTIX_INCLUDE_DIRS_DEP - pastix + dependencies include directories
  47. # PASTIX_LIBRARY_DIRS_DEP - pastix + dependencies link directories
  48. # PASTIX_LIBRARIES_DEP - pastix libraries + dependencies
  49. #
  50. # The user can give specific paths where to find the libraries adding cmake
  51. # options at configure (ex: cmake path/to/project -DPASTIX_DIR=path/to/pastix):
  52. # PASTIX_DIR - Where to find the base directory of pastix
  53. # PASTIX_INCDIR - Where to find the header files
  54. # PASTIX_LIBDIR - Where to find the library files
  55. # The module can also look for the following environment variables if paths
  56. # are not given as cmake variable: PASTIX_DIR, PASTIX_INCDIR, PASTIX_LIBDIR
  57. #=============================================================================
  58. # Copyright 2012-2013 Inria
  59. # Copyright 2012-2013 Emmanuel Agullo
  60. # Copyright 2012-2013 Mathieu Faverge
  61. # Copyright 2012 Cedric Castagnede
  62. # Copyright 2013 Florent Pruvost
  63. #
  64. # Distributed under the OSI-approved BSD License (the "License");
  65. # see accompanying file MORSE-Copyright.txt for details.
  66. #
  67. # This software is distributed WITHOUT ANY WARRANTY; without even the
  68. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  69. # See the License for more information.
  70. #=============================================================================
  71. # (To distribute this file outside of Morse, substitute the full
  72. # License text for the above reference.)
  73. if (NOT PASTIX_FOUND)
  74. set(PASTIX_DIR "" CACHE PATH "Installation directory of PASTIX library")
  75. if (NOT PASTIX_FIND_QUIETLY)
  76. message(STATUS "A cache variable, namely PASTIX_DIR, has been set to specify the install directory of PASTIX")
  77. endif()
  78. endif()
  79. # Set the version to find
  80. set(PASTIX_LOOK_FOR_MPI ON)
  81. set(PASTIX_LOOK_FOR_SEQ OFF)
  82. set(PASTIX_LOOK_FOR_STARPU OFF)
  83. set(PASTIX_LOOK_FOR_STARPU_CUDA OFF)
  84. set(PASTIX_LOOK_FOR_STARPU_FXT OFF)
  85. set(PASTIX_LOOK_FOR_SCOTCH ON)
  86. set(PASTIX_LOOK_FOR_PTSCOTCH OFF)
  87. set(PASTIX_LOOK_FOR_METIS OFF)
  88. if( PASTIX_FIND_COMPONENTS )
  89. foreach( component ${PASTIX_FIND_COMPONENTS} )
  90. if (${component} STREQUAL "SEQ")
  91. # means we look for the sequential version of PaStiX (without MPI)
  92. set(PASTIX_LOOK_FOR_SEQ ON)
  93. set(PASTIX_LOOK_FOR_MPI OFF)
  94. endif()
  95. if (${component} STREQUAL "MPI")
  96. # means we look for the MPI version of PaStiX (default)
  97. set(PASTIX_LOOK_FOR_SEQ OFF)
  98. set(PASTIX_LOOK_FOR_MPI ON)
  99. endif()
  100. if (${component} STREQUAL "STARPU")
  101. # means we look for PaStiX with StarPU
  102. set(PASTIX_LOOK_FOR_STARPU ON)
  103. endif()
  104. if (${component} STREQUAL "STARPU_CUDA")
  105. # means we look for PaStiX with StarPU + CUDA
  106. set(PASTIX_LOOK_FOR_STARPU ON)
  107. set(PASTIX_LOOK_FOR_STARPU_CUDA ON)
  108. endif()
  109. if (${component} STREQUAL "STARPU_FXT")
  110. # means we look for PaStiX with StarPU + FxT
  111. set(PASTIX_LOOK_FOR_STARPU_FXT ON)
  112. endif()
  113. if (${component} STREQUAL "SCOTCH")
  114. set(PASTIX_LOOK_FOR_SCOTCH ON)
  115. endif()
  116. if (${component} STREQUAL "SCOTCH")
  117. set(PASTIX_LOOK_FOR_PTSCOTCH ON)
  118. endif()
  119. if (${component} STREQUAL "METIS")
  120. set(PASTIX_LOOK_FOR_METIS ON)
  121. endif()
  122. endforeach()
  123. endif()
  124. # Dependencies detection
  125. # ----------------------
  126. # Required dependencies
  127. # ---------------------
  128. if (NOT PASTIX_FIND_QUIETLY)
  129. message(STATUS "Looking for PASTIX - Try to detect pthread")
  130. endif()
  131. if (PASTIX_FIND_REQUIRED)
  132. find_package(Threads REQUIRED QUIET)
  133. else()
  134. find_package(Threads QUIET)
  135. endif()
  136. set(PASTIX_EXTRA_LIBRARIES "")
  137. if( THREADS_FOUND )
  138. list(APPEND PASTIX_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  139. endif ()
  140. # Add math library to the list of extra
  141. # it normally exists on all common systems provided with a C compiler
  142. if (NOT PASTIX_FIND_QUIETLY)
  143. message(STATUS "Looking for PASTIX - Try to detect libm")
  144. endif()
  145. set(PASTIX_M_LIBRARIES "")
  146. if(UNIX OR WIN32)
  147. find_library(
  148. PASTIX_M_m_LIBRARY
  149. NAMES m
  150. )
  151. mark_as_advanced(PASTIX_M_m_LIBRARY)
  152. if (PASTIX_M_m_LIBRARY)
  153. list(APPEND PASTIX_M_LIBRARIES "${PASTIX_M_m_LIBRARY}")
  154. list(APPEND PASTIX_EXTRA_LIBRARIES "${PASTIX_M_m_LIBRARY}")
  155. else()
  156. if (PASTIX_FIND_REQUIRED)
  157. message(FATAL_ERROR "Could NOT find libm on your system."
  158. "Are you sure to a have a C compiler installed?")
  159. endif()
  160. endif()
  161. endif()
  162. # Try to find librt (libposix4 - POSIX.1b Realtime Extensions library)
  163. # on Unix systems except Apple ones because it does not exist on it
  164. if (NOT PASTIX_FIND_QUIETLY)
  165. message(STATUS "Looking for PASTIX - Try to detect librt")
  166. endif()
  167. set(PASTIX_RT_LIBRARIES "")
  168. if(UNIX AND NOT APPLE)
  169. find_library(
  170. PASTIX_RT_rt_LIBRARY
  171. NAMES rt
  172. )
  173. mark_as_advanced(PASTIX_RT_rt_LIBRARY)
  174. if (PASTIX_RT_rt_LIBRARY)
  175. list(APPEND PASTIX_RT_LIBRARIES "${PASTIX_RT_rt_LIBRARY}")
  176. list(APPEND PASTIX_EXTRA_LIBRARIES "${PASTIX_RT_rt_LIBRARY}")
  177. else()
  178. if (PASTIX_FIND_REQUIRED)
  179. message(FATAL_ERROR "Could NOT find librt on your system")
  180. endif()
  181. endif()
  182. endif()
  183. # PASTIX depends on HWLOC
  184. #------------------------
  185. if (NOT PASTIX_FIND_QUIETLY)
  186. message(STATUS "Looking for PASTIX - Try to detect HWLOC")
  187. endif()
  188. if (PASTIX_FIND_REQUIRED)
  189. find_package(HWLOC REQUIRED QUIET)
  190. else()
  191. find_package(HWLOC QUIET)
  192. endif()
  193. # PASTIX depends on BLAS
  194. #-----------------------
  195. if (NOT PASTIX_FIND_QUIETLY)
  196. message(STATUS "Looking for PASTIX - Try to detect BLAS")
  197. endif()
  198. if (PASTIX_FIND_REQUIRED)
  199. find_package(BLASEXT REQUIRED QUIET)
  200. else()
  201. find_package(BLASEXT QUIET)
  202. endif()
  203. # Optional dependencies
  204. # ---------------------
  205. # PASTIX may depend on MPI
  206. #-------------------------
  207. if (NOT MPI_FOUND AND PASTIX_LOOK_FOR_MPI)
  208. if (NOT PASTIX_FIND_QUIETLY)
  209. message(STATUS "Looking for PASTIX - Try to detect MPI")
  210. endif()
  211. # allows to use an external mpi compilation by setting compilers with
  212. # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90
  213. # at cmake configure
  214. if(NOT MPI_C_COMPILER)
  215. set(MPI_C_COMPILER mpicc)
  216. endif()
  217. if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_MPI)
  218. find_package(MPI REQUIRED QUIET)
  219. else()
  220. find_package(MPI QUIET)
  221. endif()
  222. if (MPI_FOUND)
  223. mark_as_advanced(MPI_LIBRARY)
  224. mark_as_advanced(MPI_EXTRA_LIBRARY)
  225. endif()
  226. endif (NOT MPI_FOUND AND PASTIX_LOOK_FOR_MPI)
  227. # PASTIX may depend on STARPU
  228. #----------------------------
  229. if( NOT STARPU_FOUND AND PASTIX_LOOK_FOR_STARPU)
  230. if (NOT PASTIX_FIND_QUIETLY)
  231. message(STATUS "Looking for PASTIX - Try to detect StarPU")
  232. endif()
  233. set(PASTIX_STARPU_VERSION "1.1" CACHE STRING "oldest STARPU version desired")
  234. # create list of components in order to make a single call to find_package(starpu...)
  235. # we explicitly need a StarPU version built with hwloc
  236. set(STARPU_COMPONENT_LIST "HWLOC")
  237. # StarPU may depend on MPI
  238. # allows to use an external mpi compilation by setting compilers with
  239. # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90
  240. # at cmake configure
  241. if (PASTIX_LOOK_FOR_MPI)
  242. if(NOT MPI_C_COMPILER)
  243. set(MPI_C_COMPILER mpicc)
  244. endif()
  245. list(APPEND STARPU_COMPONENT_LIST "MPI")
  246. endif()
  247. if (PASTIX_LOOK_FOR_STARPU_CUDA)
  248. list(APPEND STARPU_COMPONENT_LIST "CUDA")
  249. endif()
  250. if (PASTIX_LOOK_FOR_STARPU_FXT)
  251. list(APPEND STARPU_COMPONENT_LIST "FXT")
  252. endif()
  253. # set the list of optional dependencies we may discover
  254. if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_STARPU)
  255. find_package(STARPU ${PASTIX_STARPU_VERSION} REQUIRED
  256. COMPONENTS ${STARPU_COMPONENT_LIST})
  257. else()
  258. find_package(STARPU ${PASTIX_STARPU_VERSION}
  259. COMPONENTS ${STARPU_COMPONENT_LIST})
  260. endif()
  261. endif( NOT STARPU_FOUND AND PASTIX_LOOK_FOR_STARPU)
  262. # PASTIX may depends on SCOTCH
  263. #-----------------------------
  264. if (NOT SCOTCH_FOUND AND PASTIX_LOOK_FOR_SCOTCH)
  265. if (NOT PASTIX_FIND_QUIETLY)
  266. message(STATUS "Looking for PASTIX - Try to detect SCOTCH")
  267. endif()
  268. if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_SCOTCH)
  269. find_package(SCOTCH REQUIRED QUIET)
  270. else()
  271. find_package(SCOTCH QUIET)
  272. endif()
  273. endif()
  274. # PASTIX may depends on PTSCOTCH
  275. #-------------------------------
  276. if (NOT PTSCOTCH_FOUND AND PASTIX_LOOK_FOR_PTSCOTCH)
  277. if (NOT PASTIX_FIND_QUIETLY)
  278. message(STATUS "Looking for PASTIX - Try to detect PTSCOTCH")
  279. endif()
  280. if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_PTSCOTCH)
  281. find_package(PTSCOTCH REQUIRED QUIET)
  282. else()
  283. find_package(PTSCOTCH QUIET)
  284. endif()
  285. endif()
  286. # PASTIX may depends on METIS
  287. #----------------------------
  288. if (NOT METIS_FOUND AND PASTIX_LOOK_FOR_METIS)
  289. if (NOT PASTIX_FIND_QUIETLY)
  290. message(STATUS "Looking for PASTIX - Try to detect METIS")
  291. endif()
  292. if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_METIS)
  293. find_package(METIS REQUIRED QUIET)
  294. else()
  295. find_package(METIS QUIET)
  296. endif()
  297. endif()
  298. # Error if pastix required and no partitioning lib found
  299. if (PASTIX_FIND_REQUIRED AND NOT SCOTCH_FOUND AND NOT PTSCOTCH_FOUND AND NOT METIS_FOUND)
  300. message(FATAL_ERROR "Could NOT find any partitioning library on your system"
  301. " (install scotch, ptscotch or metis)")
  302. endif()
  303. # Looking for PaStiX
  304. # ------------------
  305. # Looking for include
  306. # -------------------
  307. # Add system include paths to search include
  308. # ------------------------------------------
  309. unset(_inc_env)
  310. set(ENV_PASTIX_DIR "$ENV{PASTIX_DIR}")
  311. set(ENV_PASTIX_INCDIR "$ENV{PASTIX_INCDIR}")
  312. if(ENV_PASTIX_INCDIR)
  313. list(APPEND _inc_env "${ENV_PASTIX_INCDIR}")
  314. elseif(ENV_PASTIX_DIR)
  315. list(APPEND _inc_env "${ENV_PASTIX_DIR}")
  316. list(APPEND _inc_env "${ENV_PASTIX_DIR}/include")
  317. list(APPEND _inc_env "${ENV_PASTIX_DIR}/include/pastix")
  318. else()
  319. if(WIN32)
  320. string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
  321. else()
  322. string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
  323. list(APPEND _inc_env "${_path_env}")
  324. string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
  325. list(APPEND _inc_env "${_path_env}")
  326. string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
  327. list(APPEND _inc_env "${_path_env}")
  328. string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
  329. list(APPEND _inc_env "${_path_env}")
  330. endif()
  331. endif()
  332. list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
  333. list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
  334. list(REMOVE_DUPLICATES _inc_env)
  335. # Try to find the pastix header in the given paths
  336. # ---------------------------------------------------
  337. # call cmake macro to find the header path
  338. if(PASTIX_INCDIR)
  339. set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND")
  340. find_path(PASTIX_pastix.h_DIRS
  341. NAMES pastix.h
  342. HINTS ${PASTIX_INCDIR})
  343. else()
  344. if(PASTIX_DIR)
  345. set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND")
  346. find_path(PASTIX_pastix.h_DIRS
  347. NAMES pastix.h
  348. HINTS ${PASTIX_DIR}
  349. PATH_SUFFIXES "include" "include/pastix")
  350. else()
  351. set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND")
  352. find_path(PASTIX_pastix.h_DIRS
  353. NAMES pastix.h
  354. HINTS ${_inc_env}
  355. PATH_SUFFIXES "pastix")
  356. endif()
  357. endif()
  358. mark_as_advanced(PASTIX_pastix.h_DIRS)
  359. # If found, add path to cmake variable
  360. # ------------------------------------
  361. if (PASTIX_pastix.h_DIRS)
  362. set(PASTIX_INCLUDE_DIRS "${PASTIX_pastix.h_DIRS}")
  363. else ()
  364. set(PASTIX_INCLUDE_DIRS "PASTIX_INCLUDE_DIRS-NOTFOUND")
  365. if(NOT PASTIX_FIND_QUIETLY)
  366. message(STATUS "Looking for pastix -- pastix.h not found")
  367. endif()
  368. endif()
  369. # Looking for lib
  370. # ---------------
  371. # Add system library paths to search lib
  372. # --------------------------------------
  373. unset(_lib_env)
  374. set(ENV_PASTIX_LIBDIR "$ENV{PASTIX_LIBDIR}")
  375. if(ENV_PASTIX_LIBDIR)
  376. list(APPEND _lib_env "${ENV_PASTIX_LIBDIR}")
  377. elseif(ENV_PASTIX_DIR)
  378. list(APPEND _lib_env "${ENV_PASTIX_DIR}")
  379. list(APPEND _lib_env "${ENV_PASTIX_DIR}/lib")
  380. else()
  381. if(WIN32)
  382. string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
  383. else()
  384. if(APPLE)
  385. string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
  386. else()
  387. string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
  388. endif()
  389. list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
  390. list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
  391. endif()
  392. endif()
  393. list(REMOVE_DUPLICATES _lib_env)
  394. # Try to find the pastix lib in the given paths
  395. # ------------------------------------------------
  396. # create list of libs to find
  397. set(PASTIX_libs_to_find "pastix_murge;pastix")
  398. # call cmake macro to find the lib path
  399. if(PASTIX_LIBDIR)
  400. foreach(pastix_lib ${PASTIX_libs_to_find})
  401. set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND")
  402. find_library(PASTIX_${pastix_lib}_LIBRARY
  403. NAMES ${pastix_lib}
  404. HINTS ${PASTIX_LIBDIR})
  405. endforeach()
  406. else()
  407. if(PASTIX_DIR)
  408. foreach(pastix_lib ${PASTIX_libs_to_find})
  409. set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND")
  410. find_library(PASTIX_${pastix_lib}_LIBRARY
  411. NAMES ${pastix_lib}
  412. HINTS ${PASTIX_DIR}
  413. PATH_SUFFIXES lib lib32 lib64)
  414. endforeach()
  415. else()
  416. foreach(pastix_lib ${PASTIX_libs_to_find})
  417. set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND")
  418. find_library(PASTIX_${pastix_lib}_LIBRARY
  419. NAMES ${pastix_lib}
  420. HINTS ${_lib_env})
  421. endforeach()
  422. endif()
  423. endif()
  424. # If found, add path to cmake variable
  425. # ------------------------------------
  426. foreach(pastix_lib ${PASTIX_libs_to_find})
  427. get_filename_component(${pastix_lib}_lib_path ${PASTIX_${pastix_lib}_LIBRARY} PATH)
  428. # set cmake variables (respects naming convention)
  429. if (PASTIX_LIBRARIES)
  430. list(APPEND PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}")
  431. else()
  432. set(PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}")
  433. endif()
  434. if (PASTIX_LIBRARY_DIRS)
  435. list(APPEND PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}")
  436. else()
  437. set(PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}")
  438. endif()
  439. mark_as_advanced(PASTIX_${pastix_lib}_LIBRARY)
  440. endforeach(pastix_lib ${PASTIX_libs_to_find})
  441. # check a function to validate the find
  442. if(PASTIX_LIBRARIES)
  443. set(REQUIRED_LDFLAGS)
  444. set(REQUIRED_INCDIRS)
  445. set(REQUIRED_LIBDIRS)
  446. set(REQUIRED_LIBS)
  447. # PASTIX
  448. if (PASTIX_INCLUDE_DIRS)
  449. set(REQUIRED_INCDIRS "${PASTIX_INCLUDE_DIRS}")
  450. endif()
  451. foreach(libdir ${PASTIX_LIBRARY_DIRS})
  452. if (libdir)
  453. list(APPEND REQUIRED_LIBDIRS "${libdir}")
  454. endif()
  455. endforeach()
  456. set(REQUIRED_LIBS "${PASTIX_LIBRARIES}")
  457. # STARPU
  458. if (PASTIX_LOOK_FOR_STARPU AND STARPU_FOUND)
  459. if (STARPU_INCLUDE_DIRS_DEP)
  460. list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS_DEP}")
  461. elseif (STARPU_INCLUDE_DIRS)
  462. list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}")
  463. endif()
  464. if(STARPU_LIBRARY_DIRS_DEP)
  465. list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS_DEP}")
  466. elseif(STARPU_LIBRARY_DIRS)
  467. list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS}")
  468. endif()
  469. if (STARPU_LIBRARIES_DEP)
  470. list(APPEND REQUIRED_LIBS "${STARPU_LIBRARIES_DEP}")
  471. elseif (STARPU_LIBRARIES)
  472. foreach(lib ${STARPU_LIBRARIES})
  473. if (EXISTS ${lib} OR ${lib} MATCHES "^-")
  474. list(APPEND REQUIRED_LIBS "${lib}")
  475. else()
  476. list(APPEND REQUIRED_LIBS "-l${lib}")
  477. endif()
  478. endforeach()
  479. endif()
  480. endif()
  481. # CUDA
  482. if (PASTIX_LOOK_FOR_STARPU_CUDA AND CUDA_FOUND)
  483. if (CUDA_INCLUDE_DIRS)
  484. list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}")
  485. endif()
  486. foreach(libdir ${CUDA_LIBRARY_DIRS})
  487. if (libdir)
  488. list(APPEND REQUIRED_LIBDIRS "${libdir}")
  489. endif()
  490. endforeach()
  491. list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}")
  492. endif()
  493. # MPI
  494. if (PASTIX_LOOK_FOR_MPI AND MPI_FOUND)
  495. if (MPI_C_INCLUDE_PATH)
  496. list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}")
  497. endif()
  498. if (MPI_C_LINK_FLAGS)
  499. if (${MPI_C_LINK_FLAGS} MATCHES " -")
  500. string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS})
  501. endif()
  502. list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}")
  503. endif()
  504. list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}")
  505. endif()
  506. # HWLOC
  507. if (HWLOC_FOUND)
  508. if (HWLOC_INCLUDE_DIRS)
  509. list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}")
  510. endif()
  511. foreach(libdir ${HWLOC_LIBRARY_DIRS})
  512. if (libdir)
  513. list(APPEND REQUIRED_LIBDIRS "${libdir}")
  514. endif()
  515. endforeach()
  516. foreach(lib ${HWLOC_LIBRARIES})
  517. if (EXISTS ${lib} OR ${lib} MATCHES "^-")
  518. list(APPEND REQUIRED_LIBS "${lib}")
  519. else()
  520. list(APPEND REQUIRED_LIBS "-l${lib}")
  521. endif()
  522. endforeach()
  523. endif()
  524. # BLAS
  525. if (BLAS_FOUND)
  526. if (BLAS_INCLUDE_DIRS)
  527. list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}")
  528. endif()
  529. foreach(libdir ${BLAS_LIBRARY_DIRS})
  530. if (libdir)
  531. list(APPEND REQUIRED_LIBDIRS "${libdir}")
  532. endif()
  533. endforeach()
  534. list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}")
  535. if (BLAS_LINKER_FLAGS)
  536. list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
  537. endif()
  538. endif()
  539. # SCOTCH
  540. if (PASTIX_LOOK_FOR_SCOTCH AND SCOTCH_FOUND)
  541. if (SCOTCH_INCLUDE_DIRS)
  542. list(APPEND REQUIRED_INCDIRS "${SCOTCH_INCLUDE_DIRS}")
  543. endif()
  544. foreach(libdir ${SCOTCH_LIBRARY_DIRS})
  545. if (libdir)
  546. list(APPEND REQUIRED_LIBDIRS "${libdir}")
  547. endif()
  548. endforeach()
  549. list(APPEND REQUIRED_LIBS "${SCOTCH_LIBRARIES}")
  550. endif()
  551. # PTSCOTCH
  552. if (PASTIX_LOOK_FOR_PTSCOTCH AND PTSCOTCH_FOUND)
  553. if (PTSCOTCH_INCLUDE_DIRS)
  554. list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}")
  555. endif()
  556. foreach(libdir ${PTSCOTCH_LIBRARY_DIRS})
  557. if (libdir)
  558. list(APPEND REQUIRED_LIBDIRS "${libdir}")
  559. endif()
  560. endforeach()
  561. list(APPEND REQUIRED_LIBS "${PTSCOTCH_LIBRARIES}")
  562. endif()
  563. # METIS
  564. if (PASTIX_LOOK_FOR_METIS AND METIS_FOUND)
  565. if (METIS_INCLUDE_DIRS)
  566. list(APPEND REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}")
  567. endif()
  568. foreach(libdir ${METIS_LIBRARY_DIRS})
  569. if (libdir)
  570. list(APPEND REQUIRED_LIBDIRS "${libdir}")
  571. endif()
  572. endforeach()
  573. list(APPEND REQUIRED_LIBS "${METIS_LIBRARIES}")
  574. endif()
  575. # Fortran
  576. if (CMAKE_C_COMPILER_ID MATCHES "GNU")
  577. find_library(
  578. FORTRAN_gfortran_LIBRARY
  579. NAMES gfortran
  580. HINTS ${_lib_env}
  581. )
  582. mark_as_advanced(FORTRAN_gfortran_LIBRARY)
  583. if (FORTRAN_gfortran_LIBRARY)
  584. list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}")
  585. endif()
  586. elseif (CMAKE_C_COMPILER_ID MATCHES "Intel")
  587. find_library(
  588. FORTRAN_ifcore_LIBRARY
  589. NAMES ifcore
  590. HINTS ${_lib_env}
  591. )
  592. mark_as_advanced(FORTRAN_ifcore_LIBRARY)
  593. if (FORTRAN_ifcore_LIBRARY)
  594. list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}")
  595. endif()
  596. endif()
  597. # EXTRA LIBS such that pthread, m, rt
  598. list(APPEND REQUIRED_LIBS ${PASTIX_EXTRA_LIBRARIES})
  599. # set required libraries for link
  600. set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
  601. set(CMAKE_REQUIRED_LIBRARIES)
  602. list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
  603. foreach(lib_dir ${REQUIRED_LIBDIRS})
  604. list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
  605. endforeach()
  606. list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
  607. list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
  608. string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
  609. # test link
  610. unset(PASTIX_WORKS CACHE)
  611. include(CheckFunctionExists)
  612. check_function_exists(pastix PASTIX_WORKS)
  613. mark_as_advanced(PASTIX_WORKS)
  614. if(PASTIX_WORKS)
  615. # save link with dependencies
  616. set(PASTIX_LIBRARIES_DEP "${REQUIRED_LIBS}")
  617. set(PASTIX_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
  618. set(PASTIX_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
  619. set(PASTIX_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
  620. list(REMOVE_DUPLICATES PASTIX_LIBRARY_DIRS_DEP)
  621. list(REMOVE_DUPLICATES PASTIX_INCLUDE_DIRS_DEP)
  622. list(REMOVE_DUPLICATES PASTIX_LINKER_FLAGS)
  623. else()
  624. if(NOT PASTIX_FIND_QUIETLY)
  625. message(STATUS "Looking for PASTIX : test of pastix() fails")
  626. message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
  627. message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
  628. message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
  629. message(STATUS "Maybe PASTIX is linked with specific libraries. "
  630. "Have you tried with COMPONENTS (MPI/SEQ, STARPU, STARPU_CUDA, SCOTCH, PTSCOTCH, METIS)? "
  631. "See the explanation in FindPASTIX.cmake.")
  632. endif()
  633. endif()
  634. set(CMAKE_REQUIRED_INCLUDES)
  635. set(CMAKE_REQUIRED_FLAGS)
  636. set(CMAKE_REQUIRED_LIBRARIES)
  637. endif(PASTIX_LIBRARIES)
  638. if (PASTIX_LIBRARIES)
  639. list(GET PASTIX_LIBRARIES 0 first_lib)
  640. get_filename_component(first_lib_path "${first_lib}" PATH)
  641. if (${first_lib_path} MATCHES "/lib(32|64)?$")
  642. string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
  643. set(PASTIX_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PASTIX library" FORCE)
  644. else()
  645. set(PASTIX_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PASTIX library" FORCE)
  646. endif()
  647. endif()
  648. mark_as_advanced(PASTIX_DIR)
  649. mark_as_advanced(PASTIX_DIR_FOUND)
  650. # check that PASTIX has been found
  651. # ---------------------------------
  652. include(FindPackageHandleStandardArgs)
  653. find_package_handle_standard_args(PASTIX DEFAULT_MSG
  654. PASTIX_LIBRARIES
  655. PASTIX_WORKS)