Commit 82d788d3 authored by Chris Cantwell's avatar Chris Cantwell

Combine Ptscotch cmake stuff into scotch.

parent 773e47a1
......@@ -205,7 +205,6 @@ INCLUDE (ThirdPartyTinyxml)
INCLUDE (ThirdPartyMetis)
INCLUDE (ThirdPartyHDF5)
INCLUDE (ThirdPartyScotch)
INCLUDE (ThirdPartyPtScotch)
INCLUDE (ThirdPartyZlib)
INCLUDE (ThirdPartyBoost)
INCLUDE (ThirdPartyPython)
......
########################################################################
#
# ThirdParty configuration for Nektar++
#
# Scotch partitioner
#
########################################################################
IF (NOT WIN32)
OPTION(NEKTAR_USE_PTSCOTCH
"Use PtScotch library for parallel mesh partitioning." OFF)
ENDIF(NOT WIN32)
IF (NEKTAR_USE_PTSCOTCH)
# First search for system TinyXML installs. Hint /opt/local for MacPorts.
FIND_LIBRARY(PTSCOTCH_LIBRARY NAMES ptscotch PATHS ${MACPORTS_PREFIX}/lib)
FIND_LIBRARY(PTSCOTCHERR_LIBRARY NAMES ptscotcherr PATHS ${MACPORTS_PREFIX}/lib)
FIND_PATH (PTSCOTCH_INCLUDE_DIR ptscotch.h PATHS ${MACPORTS_PREFIX}/include PATH_SUFFIXES scotch)
MESSAGE(STATUS ${PTSCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY} ${PTSCOTCH_INCLUDE_DIR})
IF (PTSCOTCH_LIBRARY AND PTSCOTCHERR_LIBRARY AND PTSCOTCH_INCLUDE_DIR)
SET(BUILD_PTSCOTCH OFF)
ELSE()
SET(BUILD_PTSCOTCH ON)
ENDIF ()
CMAKE_DEPENDENT_OPTION(THIRDPARTY_BUILD_PTSCOTCH
"Build Scotch library from ThirdParty" ${BUILD_PTSCOTCH}
"NEKTAR_USE_PTSCOTCH" OFF)
IF (THIRDPARTY_BUILD_PTSCOTCH)
UNSET(FLEX CACHE)
FIND_PROGRAM(FLEX flex)
IF(NOT FLEX)
MESSAGE(FATAL_ERROR
"'flex' lexical parser not found. Cannot build scotch.")
ENDIF(NOT FLEX)
MARK_AS_ADVANCED(FLEX)
# Note that scotch is compiled in the source-tree, so we unpack the
# source code in the ThirdParty builds directory.
SET(PTSCOTCH_SRC ${TPBUILD}/ptscotch-6.0.4/src)
IF (APPLE)
SET(PTSCOTCH_MAKE Makefile.inc.i686_mac_darwin8)
SET(PTSCOTCH_LDFLAGS "")
SET(PTSCOTCH_CFLAGS "-O3 -Drestrict=__restrict -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DCOMMON_TIMING_OLD -DSCOTCH_RENAME -DCOMMON_PTHREAD_BARRIER")
ELSE ()
IF (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
SET(PTSCOTCH_MAKE Makefile.inc.x86-64_pc_linux2)
SET(PTSCOTCH_CFLAGS "-O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -Drestrict=__restrict -DIDXSIZE64")
ELSE ()
SET(PTSCOTCH_MAKE Makefile.inc.i686_pc_linux2)
SET(PTSCOTCH_CFLAGS "-O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -Drestrict=__restrict")
ENDIF ()
SET(PTSCOTCH_LDFLAGS "-lz -lm -lrt -lpthread")
ENDIF ()
INCLUDE(ExternalProject)
EXTERNALPROJECT_ADD(
ptscotch-6.0.4
PREFIX ${TPSRC}
URL ${TPURL}/scotch_6.0.4.tar.gz
URL_MD5 "d58b825eb95e1db77efe8c6ff42d329f"
STAMP_DIR ${TPBUILD}/stamp
DOWNLOAD_DIR ${TPSRC}
SOURCE_DIR ${TPBUILD}/ptscotch-6.0.4
BINARY_DIR ${TPBUILD}/ptscotch-6.0.4
TMP_DIR ${TPBUILD}/ptscotch-6.0.4-tmp
INSTALL_DIR ${TPDIST}
CONFIGURE_COMMAND rm -f ${PTSCOTCH_SRC}/Makefile.inc
COMMAND ln -s
${PTSCOTCH_SRC}/Make.inc/${PTSCOTCH_MAKE}
${PTSCOTCH_SRC}/Makefile.inc
BUILD_COMMAND $(MAKE) -C ${PTSCOTCH_SRC}
"CFLAGS=${PTSCOTCH_CFLAGS}"
"LDFLAGS=${PTSCOTCH_LDFLAGS}"
"CLIBFLAGS=-fPIC"
"CCP=${MPI_C_COMPILER}"
"CCD=${MPI_C_COMPILER}"
ptscotch
INSTALL_COMMAND $(MAKE) -C ${PTSCOTCH_SRC}
prefix=${TPDIST} install
)
THIRDPARTY_LIBRARY(PTSCOTCH_LIBRARY STATIC ptscotch
DESCRIPTION "PT-Scotch library")
THIRDPARTY_LIBRARY(PTSCOTCHERR_LIBRARY STATIC ptscotcherr
DESCRIPTION "PT-Scotch error library")
SET(PTSCOTCH_INCLUDE_DIR ${TPDIST}/include CACHE FILEPATH
"PT-Scotch include directory" FORCE)
MESSAGE(STATUS "Build PT-Scotch: ${PTSCOTCH_LIBRARY}")
SET(PTSCOTCH_CONFIG_INCLUDE_DIR ${TPINC})
ELSE (THIRDPARTY_BUILD_PTSCOTCH)
ADD_CUSTOM_TARGET(ptscotch-6.0.4 ALL)
MESSAGE(STATUS "Found PT-Scotch: ${PTSCOTCH_LIBRARY}")
SET(PTSCOTCH_CONFIG_INCLUDE_DIR ${PTSCOTCH_INCLUDE_DIR})
ENDIF (THIRDPARTY_BUILD_PTSCOTCH)
INCLUDE_DIRECTORIES(${PTSCOTCH_INCLUDE_DIR})
MARK_AS_ADVANCED(PTSCOTCH_LIBRARY)
MARK_AS_ADVANCED(PTSCOTCHERR_LIBRARY)
MARK_AS_ADVANCED(PTSCOTCH_INCLUDE_DIR)
ENDIF()
......@@ -12,17 +12,31 @@ IF (NOT WIN32)
ENDIF(NOT WIN32)
IF (NEKTAR_USE_SCOTCH)
# First search for system TinyXML installs. Hint /opt/local for MacPorts.
# Assume we build scotch by default
SET(BUILD_SCOTCH OFF)
# First search for system serial scotch installs. Hint /opt/local for MacPorts.
FIND_LIBRARY(SCOTCH_LIBRARY NAMES scotch PATHS ${MACPORTS_PREFIX}/lib)
FIND_LIBRARY(SCOTCHERR_LIBRARY NAMES scotcherr PATHS ${MACPORTS_PREFIX}/lib)
FIND_PATH (SCOTCH_INCLUDE_DIR scotch.h PATHS ${MACPORTS_PREFIX}/include PATH_SUFFIXES scotch)
IF (SCOTCH_LIBRARY AND SCOTCHERR_LIBRARY AND SCOTCH_INCLUDE_DIR)
SET(BUILD_SCOTCH OFF)
ELSE()
# If not found, we need to build scotch
IF (NOT SCOTCH_LIBRARY OR NOT SCOTCHERR_LIBRARY OR NOT SCOTCH_INCLUDE_DIR)
SET(BUILD_SCOTCH ON)
ENDIF ()
# If we are also using MPI, search for PT-Scotch library
IF (NEKTAR_USE_MPI)
FIND_LIBRARY(PTSCOTCH_LIBRARY NAMES ptscotch PATHS ${MACPORTS_PREFIX}/lib)
FIND_LIBRARY(PTSCOTCHERR_LIBRARY NAMES ptscotcherr PATHS ${MACPORTS_PREFIX}/lib)
FIND_PATH (PTSCOTCH_INCLUDE_DIR ptscotch.h PATHS ${MACPORTS_PREFIX}/include PATH_SUFFIXES scotch)
# If we cannot find PT-Scotch, we need to build them
IF (NOT PTSCOTCH_LIBRARY OR NOT PTSCOTCHERR_LIBRARY OR NOT PTSCOTCH_INCLUDE_DIR)
SET(BUILD_SCOTCH ON)
ENDIF ()
ENDIF ()
CMAKE_DEPENDENT_OPTION(THIRDPARTY_BUILD_SCOTCH
"Build Scotch library from ThirdParty" ${BUILD_SCOTCH}
"NEKTAR_USE_SCOTCH" OFF)
......@@ -56,6 +70,13 @@ IF (NEKTAR_USE_SCOTCH)
ENDIF ()
SET(SCOTCH_LDFLAGS "-lz -lm -lrt -lpthread")
ENDIF ()
SET(SCOTCH_BUILD_TARGET "scotch")
SET(SCOTCH_C_COMPILER ${CMAKE_C_COMPILER})
IF (NEKTAR_USE_MPI)
SET(SCOTCH_BUILD_TARGET "ptscotch")
SET(SCOTCH_C_COMPILER ${MPI_C_COMPILER})
ENDIF ()
INCLUDE(ExternalProject)
EXTERNALPROJECT_ADD(
......@@ -76,7 +97,10 @@ IF (NEKTAR_USE_SCOTCH)
BUILD_COMMAND $(MAKE) -C ${SCOTCH_SRC}
"CFLAGS=-I${TPDIST}/include ${SCOTCH_CFLAGS}"
"LDFLAGS=-L${TPDIST}/lib ${SCOTCH_LDFLAGS}"
"CLIBFLAGS=-fPIC" scotch
"CLIBFLAGS=-fPIC"
"CCP=${SCOTCH_C_COMPILER}"
"CCD=${SCOTCH_C_COMPILER}"
${SCOTCH_BUILD_TARGET}
INSTALL_COMMAND $(MAKE) -C ${SCOTCH_SRC}
prefix=${TPDIST} install
)
......@@ -85,8 +109,14 @@ IF (NEKTAR_USE_SCOTCH)
DESCRIPTION "Scotch library")
THIRDPARTY_LIBRARY(SCOTCHERR_LIBRARY STATIC scotcherr
DESCRIPTION "Scotch error library")
THIRDPARTY_LIBRARY(PTSCOTCH_LIBRARY STATIC ptscotch
DESCRIPTION "PT-Scotch library")
THIRDPARTY_LIBRARY(PTSCOTCHERR_LIBRARY STATIC ptscotcherr
DESCRIPTION "PT-Scotch error library")
SET(SCOTCH_INCLUDE_DIR ${TPDIST}/include CACHE FILEPATH
"Scotch include directory" FORCE)
SET(PTSCOTCH_INCLUDE_DIR ${TPDIST}/include CACHE FILEPATH
"PT-Scotch include directory" FORCE)
MESSAGE(STATUS "Build Scotch: ${SCOTCH_LIBRARY}")
SET(SCOTCH_CONFIG_INCLUDE_DIR ${TPINC})
ELSE (THIRDPARTY_BUILD_SCOTCH)
......@@ -99,5 +129,8 @@ IF (NEKTAR_USE_SCOTCH)
MARK_AS_ADVANCED(SCOTCH_LIBRARY)
MARK_AS_ADVANCED(SCOTCHERR_LIBRARY)
MARK_AS_ADVANCED(PTSCOTCH_LIBRARY)
MARK_AS_ADVANCED(PTSCOTCHERR_LIBRARY)
MARK_AS_ADVANCED(SCOTCH_INCLUDE_DIR)
MARK_AS_ADVANCED(PTSCOTCH_INCLUDE_DIR)
ENDIF()
......@@ -54,11 +54,11 @@ ENDIF()
IF(NEKTAR_USE_SCOTCH)
SET(SPATIAL_DOMAINS_HEADERS ${SPATIAL_DOMAINS_HEADERS} MeshPartitionScotch.h)
SET(SPATIAL_DOMAINS_SOURCES ${SPATIAL_DOMAINS_SOURCES} MeshPartitionScotch.cpp)
ENDIF()
IF(NEKTAR_USE_PTSCOTCH)
SET(SPATIAL_DOMAINS_HEADERS ${SPATIAL_DOMAINS_HEADERS} MeshPartitionPtScotch.h)
SET(SPATIAL_DOMAINS_SOURCES ${SPATIAL_DOMAINS_SOURCES} MeshPartitionPtScotch.cpp)
IF (NEKTAR_USE_MPI)
SET(SPATIAL_DOMAINS_HEADERS ${SPATIAL_DOMAINS_HEADERS} MeshPartitionPtScotch.h)
SET(SPATIAL_DOMAINS_SOURCES ${SPATIAL_DOMAINS_SOURCES} MeshPartitionPtScotch.cpp)
ENDIF()
ENDIF()
IF(NEKTAR_USE_METIS)
......@@ -82,18 +82,17 @@ IF (NEKTAR_USE_METIS)
TARGET_LINK_LIBRARIES(SpatialDomains LINK_PRIVATE ${METIS_LIBRARY})
ENDIF()
#IF (NEKTAR_USE_SCOTCH)
# # Scotch
# TARGET_LINK_LIBRARIES(SpatialDomains LINK_PUBLIC
# ${SCOTCH_LIBRARY} ${SCOTCHERR_LIBRARY})
# ADD_DEPENDENCIES(SpatialDomains scotch-6.0.4)
#ENDIF()
IF (NEKTAR_USE_SCOTCH)
IF (NEKTAR_USE_MPI)
TARGET_LINK_LIBRARIES(SpatialDomains LINK_PRIVATE
${PTSCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY})
ENDIF ()
IF( NEKTAR_USE_PTSCOTCH )
# Scotch
TARGET_LINK_LIBRARIES(SpatialDomains LINK_PRIVATE
${PTSCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY})
ADD_DEPENDENCIES(SpatialDomains ptscotch-6.0.4)
ENDIF ()
${SCOTCH_LIBRARY} ${SCOTCHERR_LIBRARY})
ADD_DEPENDENCIES(SpatialDomains scotch-6.0.4)
ENDIF()
IF (NEKTAR_BUILD_PYTHON)
SUBDIRS(Python)
......
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