Restructure cmake files, build METIS as dependency

This commit is contained in:
Matthias Hochsteger 2017-02-23 14:45:25 +01:00
parent ea00690a2a
commit 0659961f28
15 changed files with 60 additions and 40 deletions

View File

@ -19,11 +19,13 @@ option( USE_CCACHE "use ccache")
option( USE_SUPERBUILD "use ccache" ON)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_modules")
if (USE_SUPERBUILD)
project (SUPERBUILD)
# execute the superbuild (this script will be invoked again without the
# USE_SUPERBUILD option this time)
include (cmake_modules/SuperBuild.cmake)
include (cmake/SuperBuild.cmake)
return() # stop processing this file further
else()
project(Netgen)
@ -55,7 +57,7 @@ endif(USE_NATIVE_ARCH)
#######################################################################
if(INTEL_MIC)
set(MKL_ARCH "mic")
include(cmake_modules/mic.cmake)
include(cmake/mic.cmake)
else(INTEL_MIC)
set(MKL_ARCH "intel64")
endif(INTEL_MIC)
@ -94,7 +96,6 @@ include_directories ("${PROJECT_SOURCE_DIR}/libsrc/include")
include_directories ("${PROJECT_BINARY_DIR}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake_modules")
set(INCDIR include CACHE PATH "install directory for header files")
if(APPLE)
@ -241,7 +242,7 @@ endif(INSTALL_PROFILES)
#######################################################################
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake "\
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/netgen_fixup.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/netgen_fixup.cmake)
set(APP ${INSTALL_DIR})
message(\${APP})
set(BU_CHMOD_BUNDLE_ITEMS ON)
@ -366,13 +367,13 @@ endif()
#######################################################################
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/NetgenConfig.cmake.in
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/NetgenConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake DESTINATION share/cmake)

View File

@ -6,8 +6,6 @@ set (NETGEN_DEPENDENCIES)
set (LAPACK_DEPENDENCIES)
set (NETGEN_CMAKE_ARGS "" CACHE INTERNAL "")
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake_modules")
macro(set_vars VAR_OUT)
foreach(varname ${ARGN})
if(NOT "${${varname}}" STREQUAL "")
@ -105,9 +103,19 @@ endif(USE_OCC AND WIN32 AND NOT OCC_INCLUDE_DIR)
#######################################################################
if(USE_GUI)
include(cmake_modules/ExternalProject_TCLTK.cmake)
include(cmake/external_projects/tcltk.cmake)
endif(USE_GUI)
#######################################################################
if(USE_MPI)
find_package(METIS QUIET)
if(NOT METIS_FOUND)
message(STATUS "Could not find METIS, it will be built from source")
include(cmake/external_projects/metis.cmake)
endif()
endif(USE_MPI)
#######################################################################
# propagate cmake variables to Netgen subproject
set_vars( NETGEN_CMAKE_ARGS
@ -164,14 +172,14 @@ ExternalProject_Add (netgen
# Check if the git submodules (i.e. pybind11) are up to date
# in case, something is wrong, emit a warning but continue
ExternalProject_Add_Step(netgen check_submodules
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/check_submodules.cmake
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
DEPENDERS install # Steps on which this step depends
)
# Due to 'ALWAYS 1', this step is always run which also forces a build of
# the Netgen subproject
ExternalProject_Add_Step(netgen check_submodules1
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/check_submodules.cmake
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
DEPENDEES configure # Steps on which this step depends
DEPENDERS build # Steps that depend on this step
ALWAYS 1 # No stamp file, step always runs

View File

@ -49,14 +49,8 @@ if (METIS_INCLUDE_DIR)
NAMES ${metis_inc_names}
HINTS ${METIS_INCLUDE_DIR}
NO_DEFAULT_PATH)
if(NOT metis_test_include_path)
message(SEND_ERROR "Can not locate ${metis_inc_names} in ${METIS_INCLUDE_DIR}")
endif()
set(METIS_INCLUDE_DIR "${metis_test_include_path}")
else()
message(SEND_ERROR "METIS_INCLUDE_DIR=${METIS_INCLUDE_DIR} does not exist")
set(METIS_INCLUDE_DIR "METIS_INCLUDE_DIR-NOTFOUND")
endif()
endif()
else()
# Metis sometimes puts the include files in a subdir called Lib
set(metis_inc_suffixes "include" "Lib")
@ -67,19 +61,13 @@ if(METIS_DIR)
HINTS ${METIS_DIR}
PATH_SUFFIXES ${metis_inc_suffixes}
NO_DEFAULT_PATH)
else()
message(SEND_ERROR "METIS_DIR=${METIS_DIR} does not exist")
set(METIS_INCLUDE_DIR "METIS_INCLUDE_DIR-NOTFOUND")
endif()
endif()
else()
find_path(METIS_INCLUDE_DIR
NAMES ${metis_inc_names}
PATH_SUFFIXES ${metis_inc_suffixes})
endif()
endif()
if ( NOT METIS_INCLUDE_DIR )
message(SEND_ERROR "Can not locate METIS include directory")
endif()
# Search for libraries
# Search order preference:
# (1) METIS_LIBRARY_DIR - check existence of path AND if the library file exists
@ -93,9 +81,6 @@ if (METIS_LIBRARY_DIR)
NAMES ${metis_lib_names}
HINTS ${METIS_LIBRARY_DIR}
NO_DEFAULT_PATH)
else()
message(SEND_ERROR "METIS_LIBRARY_DIR=${METIS_LIBRARY_DIR} does not exist")
set(METIS_LIBRARY "METIS_LIBRARY-NOTFOUND")
endif()
else()
list(APPEND metis_lib_suffixes "lib" "Lib")
@ -106,9 +91,6 @@ if(METIS_DIR)
HINTS ${METIS_DIR}
PATH_SUFFIXES ${metis_lib_suffixes}
NO_DEFAULT_PATH)
else()
message(SEND_ERROR "METIS_DIR=${METIS_DIR} does not exist")
set(METISLIBRARY "METIS_LIBRARY-NOTFOUND")
endif()
else()
find_library(METIS_LIBRARY
@ -116,9 +98,6 @@ else()
PATH_SUFFIXES ${metis_lib_suffixes})
endif()
endif()
if ( NOT METIS_LIBRARY )
message(SEND_ERROR "Can not locate METIS library")
endif()
# Define prerequisite packages
set(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR})

View File

@ -0,0 +1,18 @@
set(METIS_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_metis)
set(METIS_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/metis)
ExternalProject_Add(project_metis
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/dependencies
URL "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz"
URL_MD5 5465e67079419a69e0116de24fce58fe
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
CMAKE_ARGS
-DGKLIB_PATH=${METIS_SRC_DIR}/GKlib
-DCMAKE_INSTALL_PREFIX=${METIS_DIR}
UPDATE_COMMAND "" # Disable update
BUILD_IN_SOURCE 1
)
set_vars( NETGEN_CMAKE_ARGS METIS_DIR )
list(APPEND NETGEN_DEPENDENCIES project_metis)

View File

@ -0,0 +1,14 @@
set(METIS_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/parmetis/metis)
set(PARMETIS_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/parametis)
ExternalProject_Add(parmetis
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/dependencies
URL "http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/parmetis-4.0.3.tar.gz"
URL_MD5 f69c479586bf6bb7aff6a9bc0c739628
CMAKE_CACHE_ARGS -DMETIS_PATH:string=${METIS_DIR} -DGKLIB_PATH:string=${METIS_DIR}/GKlib
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
UPDATE_COMMAND "" # Disable update
BUILD_IN_SOURCE 1
)
set_vars( NETGEN_CMAKE_ARGS METIS_DIR )
list(APPEND NETGEN_DEPENDENCIES parmetis)

View File

@ -1,7 +1,7 @@
if(APPLE)
set(HOME $ENV{HOME})
set(tcl_prefix ${CMAKE_INSTALL_PREFIX}/../../)
ExternalProject_Add(tcl
ExternalProject_Add(project_tcl
URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tcl8.6.4-src.tar.gz"
URL_MD5 d7cbb91f1ded1919370a30edd1534304
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
@ -15,8 +15,8 @@ if(APPLE)
LOG_INSTALL 1
)
ExternalProject_Add(tk
DEPENDS tcl
ExternalProject_Add(project_tk
DEPENDS project_tcl
URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tk8.6.4-src.tar.gz"
URL_MD5 261754d7dc2a582f00e35547777e1fea
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
@ -47,7 +47,7 @@ if(APPLE)
#LOG_INSTALL 1
#)
list(APPEND NETGEN_DEPENDENCIES tcl tk)
list(APPEND NETGEN_DEPENDENCIES project_tcl project_tk)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}../Frameworks)
set(TCL_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework/Headers)
set(TCL_LIBRARY ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework)
@ -56,7 +56,7 @@ if(APPLE)
elseif(WIN32)
ExternalProject_Add(win_extlibs
ExternalProject_Add(project_win_extlibs
URL ${EXT_LIBS_DOWNLOAD_URL_WIN}
UPDATE_COMMAND "" # Disable update
BUILD_IN_SOURCE 1
@ -66,7 +66,7 @@ elseif(WIN32)
LOG_DOWNLOAD 1
)
list(APPEND NETGEN_DEPENDENCIES win_extlibs)
list(APPEND NETGEN_DEPENDENCIES project_win_extlibs)
else(WIN32)
find_package(TCL 8.5 REQUIRED)
endif(APPLE)