Commit e08337bf authored by PRUVOST Florent's avatar PRUVOST Florent

use FindPTSCOTCH from morse cmake (more complete)

parent 2444c9e5
Pipeline #23190 failed with stages
in 59 seconds
......@@ -7,12 +7,12 @@
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## any later version.
##
##
## PaMPA is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
##
## In this respect, the user's attention is drawn to the risks associated
## with loading, using, modifying and/or developing or reproducing the
## software by the user in light of its specific status of free software,
......@@ -23,7 +23,7 @@
## their requirements in conditions enabling the security of their
## systems and/or data to be ensured and, more generally, to use and
## operate it in the same conditions as regards security.
##
##
## The fact that you are presently reading this means that you have had
## knowledge of the GPLv3 license and that you accept its terms.
##
......@@ -75,6 +75,8 @@ include(CheckSymbolExists)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeScripts)
# To transform relative path into absolute for a list of libraries
include(LibrariesAbsolutePath)
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/MOD)
# Define some variables which will be fill in with ccmake or cmake-gui
......@@ -205,11 +207,8 @@ endif (COMMON_COMPRESSION)
option (PTSCOTCH "Build PaMPA with PT-Scotch dependencies" ON)
if (PTSCOTCH)
add_definitions (-DPTSCOTCH)
set(PTSCOTCH_HOME "" CACHE PATH "PT-Scotch home directory")
find_package(PTSCOTCH REQUIRED)
file(STRINGS "${PTSCOTCH_INCLUDE_DIR}/scotch.h" CHECK_SCOTCH_VERSION REGEX "^[ \t]*#define[ \t]+SCOTCH_[A-Z]+[ \t]+[0-9]+.*$")
file(STRINGS "${PTSCOTCH_INCLUDE_DIRS}/scotch.h" CHECK_SCOTCH_VERSION REGEX "^[ \t]*#define[ \t]+SCOTCH_[A-Z]+[ \t]+[0-9]+.*$")
foreach(item IN ITEMS VERSION RELEASE PATCHLEVEL)
string(REGEX REPLACE ".*#define[ \t]+SCOTCH_${item}[ \t]+([0-9]+).*" "\\1" XYZ ${CHECK_SCOTCH_VERSION})
set (SCOTCH_${item} ${XYZ})
......@@ -218,9 +217,7 @@ if (PTSCOTCH)
#if (${SCOTCH_VERSION}.${SCOTCH_RELEASE}.${SCOTCH_PATCHLEVEL} VERSION_LESS 6.0.4)
# message (FATAL_ERROR "PT-Scotch version must be greater than or equal to 6.0.4")
#endif ()
include_directories(${PTSCOTCH_INCLUDE_DIR})
else ()
unset (PTSCOTCH_HOME CACHE)
include_directories(${PTSCOTCH_INCLUDE_DIRS})
endif ()
......@@ -362,9 +359,7 @@ add_subdirectory(${PAMPA_SOURCE_DIR}/src/libpampa)
# Add dependency on PT-Scotch
if (PTSCOTCH)
list (APPEND PAMPA_DEPENDENCIES ${PTSCOTCH_LIBRARY})
list (APPEND PAMPA_DEPENDENCIES ${SCOTCH_LIBRARY})
list (APPEND PAMPA_DEPENDENCIES ${PTSCOTCH_EXTRA_LIBRARY})
list (APPEND PAMPA_DEPENDENCIES ${PTSCOTCH_LIBRARIES_DEP})
endif ()
......
This diff is collapsed.
This diff is collapsed.
###
#
# @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_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
##
......@@ -10,7 +10,7 @@ Before compiling PaMPA, make sure that an MPI implementation and the PT-Scotch s
\section unix On Unix:
- In the _build_ folder, run:
- "cmake .."
- In order for CMake to know the path of PT-Scotch, you may have to define the PTSCOTCH_HOME environment variable in the command line, e.g. "cmake -D SCOTCH_HOME=<absolute path to PTSCOTCH directory> ..", or use ccmake;
- In order for CMake to know the path of PT-Scotch, you may have to define the PTSCOTCH_DIR environment variable in the command line, e.g. "cmake -D SCOTCH_HOME=<absolute path to PTSCOTCH directory> ..", or use ccmake;
- In order to use a specific MPI library, you have to define the MPI_COMPILER environment variable (or MPI_C_COMPILER and MPI_Fortran_COMPILER, depending on your version of CMake), e.g. "cmake … -D MPI_COMPILER=<absolute path to the specific MPI compiler> ..";
- "ccmake ." or "cmake-gui .", to define some installation variables.
- Targets _pampa_ and _c_samples_ could be built in parallel, but _fortran_samples_ must be done in sequential. For example if you have 4 processors, _SAMPLES_ and _FORTRAN__INTERFACE_ options enabled: \verbatim make -j4 pampa c_samples && make fortran_samples \endverbatim
......@@ -19,7 +19,7 @@ Before compiling PaMPA, make sure that an MPI implementation and the PT-Scotch s
- Run CMakeSetup.exe;
- For the source code, choose the parent folder of BUILD,
- For the binaries, choose the _build_ folder and:
- If necessary, define the PTSCOTCH_HOME environment variable (see above);
- If necessary, define the PTSCOTCH_DIR environment variable (see above);
- In order to use a specific MPI library, define the MPI_COMPILER environment variable (or MPI_C_COMPILER and MPI_Fortran_COMPILER, depending on your version of CMake).
\section options Options
......
......@@ -51,12 +51,7 @@ find_package (PAMPA REQUIRED)
option (PTSCOTCH "Build PaMPA with PT-Scotch dependencies" ON)
if (PTSCOTCH)
#add_definitions (-DPTSCOTCH)
set(PTSCOTCH_HOME "" CACHE PATH "PT-Scotch home directory")
set(PTSCOTCH_SUFFIX "" CACHE STRING "PT-Scotch suffix name")
find_package(PTSCOTCH REQUIRED)
else ()
unset (PTSCOTCH_HOME CACHE)
unset (PTSCOTCH_SUFFIX CACHE)
endif ()
......
......@@ -44,7 +44,7 @@ if (PTSCOTCH AND PAMPA_MMG3D4 AND PAMPA_GMSH)
target_link_libraries(${EXEC_NAME} ${GMSH_LIBRARY})
endif()
if (PAMPA_MMG3D4_SCOTCH)
target_link_libraries(${EXEC_NAME} ${SCOTCH_LIBRARY})
target_link_libraries(${EXEC_NAME} ${PTSCOTCH_LIBRARIES_DEP})
endif()
if (PAMPA_MSHINT)
target_link_libraries(${EXEC_NAME} pampa-mshint ${MSHINT_LIBRARY} ${LIBMESH5_LIBRARY})
......@@ -74,7 +74,7 @@ if (PTSCOTCH AND PAMPA_MMG3D4 AND PAMPA_TETGEN)
target_link_libraries(${EXEC_NAME} ${TETGEN_LIBRARY})
endif()
if (PAMPA_MMG3D4_SCOTCH)
target_link_libraries(${EXEC_NAME} ${SCOTCH_LIBRARY})
target_link_libraries(${EXEC_NAME} ${PTSCOTCH_LIBRARIES_DEP})
endif()
if (PAMPA_MSHINT)
target_link_libraries(${EXEC_NAME} pampa-mshint ${MSHINT_LIBRARY} ${LIBMESH5_LIBRARY})
......@@ -101,7 +101,7 @@ if (PTSCOTCH AND PAMPA_MMG3D4)
endif ()
target_link_libraries(${EXEC_NAME} pampa-mmg3d4 ${MMG3D4_LIBRARY})
if (PAMPA_MMG3D4_SCOTCH)
target_link_libraries(${EXEC_NAME} ${SCOTCH_LIBRARY})
target_link_libraries(${EXEC_NAME} ${PTSCOTCH_LIBRARIES_DEP})
endif()
if (PAMPA_MSHINT)
target_link_libraries(${EXEC_NAME} pampa-mshint ${MSHINT_LIBRARY} ${LIBMESH5_LIBRARY})
......@@ -130,7 +130,7 @@ if (PTSCOTCH AND PAMPA_MMG3D5)
endif ()
target_link_libraries(${EXEC_NAME} pampa-mmg3d5 ${MMG3D5_LIBRARY})
if (PAMPA_MMG3D5_SCOTCH)
target_link_libraries(${EXEC_NAME} ${SCOTCH_LIBRARY})
target_link_libraries(${EXEC_NAME} ${PTSCOTCH_LIBRARIES_DEP})
endif()
if (PTHREAD)
target_link_libraries(${EXEC_NAME} ${CMAKE_THREAD_LIBS_INIT})
......@@ -156,7 +156,7 @@ if (PTSCOTCH AND PAMPA_MMG3D)
endif ()
target_link_libraries(${EXEC_NAME} pampa-mmg3d ${MMG3D_LIBRARY})
if (PAMPA_MMG3D_SCOTCH)
target_link_libraries(${EXEC_NAME} ${SCOTCH_LIBRARY})
target_link_libraries(${EXEC_NAME} ${PTSCOTCH_LIBRARIES_DEP})
endif()
if (PAMPA_MSHINT)
target_link_libraries(${EXEC_NAME} pampa-mshint ${MSHINT_LIBRARY} ${LIBMESH5_LIBRARY})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment