2016-12-22 23:12:11 +05:00
|
|
|
include (ExternalProject)
|
|
|
|
|
|
|
|
set_property (DIRECTORY PROPERTY EP_PREFIX dependencies)
|
|
|
|
|
|
|
|
set (NETGEN_DEPENDENCIES)
|
|
|
|
set (LAPACK_DEPENDENCIES)
|
2017-02-10 15:33:05 +05:00
|
|
|
set (NETGEN_CMAKE_ARGS "" CACHE INTERNAL "")
|
2016-12-22 23:12:11 +05:00
|
|
|
|
|
|
|
macro(set_vars VAR_OUT)
|
|
|
|
foreach(varname ${ARGN})
|
|
|
|
if(NOT "${${varname}}" STREQUAL "")
|
|
|
|
string(REPLACE ";" "$<SEMICOLON>" varvalue "${${varname}}" )
|
2017-02-10 15:33:05 +05:00
|
|
|
set(${VAR_OUT} ${${VAR_OUT}};-D${varname}=${varvalue} CACHE INTERNAL "")
|
2016-12-22 23:12:11 +05:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
#######################################################################
|
|
|
|
if(WIN32)
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
|
|
|
string(REGEX REPLACE "/W[0-4]" "/W0" CMAKE_CXX_FLAGS_NEW ${CMAKE_CXX_FLAGS})
|
|
|
|
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_NEW} CACHE STRING "compile flags" FORCE)
|
|
|
|
string(REGEX REPLACE "/W[0-4]" "/W0" CMAKE_CXX_FLAGS_NEW ${CMAKE_CXX_FLAGS_RELEASE})
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_NEW} CACHE STRING "compile flags" FORCE)
|
|
|
|
|
|
|
|
string(REGEX REPLACE "/W[0-4]" "/W0" CMAKE_SHARED_LINKER_FLAGS_NEW ${CMAKE_SHARED_LINKER_FLAGS})
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_NEW} /IGNORE:4217,4049" CACHE STRING "compile flags" FORCE)
|
|
|
|
string(REGEX REPLACE "/W[0-4]" "/W0" CMAKE_EXE_LINKER_FLAGS_NEW ${CMAKE_EXE_LINKER_FLAGS})
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS"${CMAKE_EXE_LINKER_FLAGS_NEW}/IGNORE:4217,4049" CACHE STRING "compile flags" FORCE)
|
|
|
|
|
|
|
|
endif(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
|
|
|
|
|
|
|
if(${CMAKE_SIZEOF_VOID_P} MATCHES 4)
|
|
|
|
# 32 bit
|
|
|
|
set(EXT_LIBS_DOWNLOAD_URL_WIN "http://www.asc.tuwien.ac.at/~mhochsteger/ngsuite/ext_libs32.zip" CACHE STRING INTERNAL)
|
|
|
|
set(OCC_DOWNLOAD_URL_WIN "http://www.asc.tuwien.ac.at/~mhochsteger/ngsuite/occ32.zip" CACHE STRING INTERNAL)
|
|
|
|
else(${CMAKE_SIZEOF_VOID_P} MATCHES 4)
|
|
|
|
# 64 bit
|
|
|
|
set(EXT_LIBS_DOWNLOAD_URL_WIN "http://www.asc.tuwien.ac.at/~mhochsteger/ngsuite/ext_libs64.zip" CACHE STRING INTERNAL)
|
|
|
|
set(OCC_DOWNLOAD_URL_WIN "http://www.asc.tuwien.ac.at/~mhochsteger/ngsuite/occ64.zip" CACHE STRING INTERNAL)
|
|
|
|
endif(${CMAKE_SIZEOF_VOID_P} MATCHES 4)
|
|
|
|
endif(WIN32)
|
|
|
|
|
2017-01-10 16:01:48 +05:00
|
|
|
if(UNIX)
|
2017-01-10 22:45:49 +05:00
|
|
|
message("Checking for write permissions in install directory...")
|
2017-05-30 00:19:34 +05:00
|
|
|
execute_process(COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX})
|
|
|
|
execute_process(COMMAND test -w ${CMAKE_INSTALL_PREFIX} RESULT_VARIABLE res)
|
2017-01-10 22:45:49 +05:00
|
|
|
if(res)
|
2017-01-31 16:20:27 +05:00
|
|
|
message(WARNING "No write access at install directory, please set correct permissions")
|
2017-01-10 16:01:48 +05:00
|
|
|
endif()
|
|
|
|
endif(UNIX)
|
2016-12-22 23:12:11 +05:00
|
|
|
|
|
|
|
if(NOT WIN32)
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
set_vars(NETGEN_CMAKE_ARGS ZLIB_INCLUDE_DIRS ZLIB_LIBRARIES)
|
|
|
|
endif(NOT WIN32)
|
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
if (USE_PYTHON)
|
2017-01-09 23:16:53 +05:00
|
|
|
find_path(PYBIND_INCLUDE_DIR pybind11/pybind11.h PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/pybind11/include NO_DEFAULT_PATH)
|
2016-12-22 23:12:11 +05:00
|
|
|
if( NOT PYBIND_INCLUDE_DIR )
|
2017-01-20 14:16:48 +05:00
|
|
|
# if the pybind submodule is missing, try to initialize and update all submodules
|
2016-12-22 23:12:11 +05:00
|
|
|
execute_process(COMMAND git submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
find_path(PYBIND_INCLUDE_DIR pybind11/pybind11.h ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/pybind11/include)
|
|
|
|
endif( NOT PYBIND_INCLUDE_DIR )
|
|
|
|
if( PYBIND_INCLUDE_DIR )
|
|
|
|
message("-- Found Pybind11: ${PYBIND_INCLUDE_DIR}")
|
|
|
|
else( PYBIND_INCLUDE_DIR )
|
|
|
|
message(FATAL_ERROR "Could NOT find pybind11!")
|
|
|
|
endif( PYBIND_INCLUDE_DIR )
|
2017-01-09 18:02:50 +05:00
|
|
|
find_package(PythonInterp 3 REQUIRED)
|
|
|
|
find_package(PythonLibs 3 REQUIRED)
|
2016-12-22 23:12:11 +05:00
|
|
|
|
|
|
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))" OUTPUT_VARIABLE PYTHON_PACKAGES_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2017-01-05 19:05:13 +05:00
|
|
|
file(TO_CMAKE_PATH ${PYTHON_PACKAGES_INSTALL_DIR} PYTHON_PACKAGES_INSTALL_DIR)
|
2017-01-09 23:15:44 +05:00
|
|
|
set_vars(NETGEN_CMAKE_ARGS PYTHON_PACKAGES_INSTALL_DIR PYTHON_INCLUDE_DIRS PYTHON_LIBRARIES PYTHON_EXECUTABLE PYTHON_VERSION PYBIND_INCLUDE_DIR)
|
2016-12-22 23:12:11 +05:00
|
|
|
endif (USE_PYTHON)
|
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
|
2017-02-09 16:07:09 +05:00
|
|
|
if(USE_OCC AND WIN32 AND NOT OCC_INCLUDE_DIR)
|
2016-12-22 23:12:11 +05:00
|
|
|
ExternalProject_Add(win_download_occ
|
|
|
|
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/tcl
|
|
|
|
URL ${OCC_DOWNLOAD_URL_WIN}
|
|
|
|
UPDATE_COMMAND "" # Disable update
|
|
|
|
BUILD_IN_SOURCE 1
|
|
|
|
CONFIGURE_COMMAND ""
|
|
|
|
BUILD_COMMAND ""
|
2017-05-30 00:19:34 +05:00
|
|
|
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}
|
2016-12-22 23:12:11 +05:00
|
|
|
LOG_DOWNLOAD 1
|
|
|
|
)
|
|
|
|
list(APPEND NETGEN_DEPENDENCIES win_download_occ)
|
2017-02-09 16:07:09 +05:00
|
|
|
endif(USE_OCC AND WIN32 AND NOT OCC_INCLUDE_DIR)
|
2016-12-22 23:12:11 +05:00
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
|
|
|
|
if(USE_GUI)
|
2017-02-23 18:45:25 +05:00
|
|
|
include(cmake/external_projects/tcltk.cmake)
|
2016-12-22 23:12:11 +05:00
|
|
|
endif(USE_GUI)
|
|
|
|
|
2017-02-23 18:45:25 +05:00
|
|
|
#######################################################################
|
|
|
|
if(USE_MPI)
|
2017-03-10 20:01:00 +05:00
|
|
|
if(UNIX)
|
|
|
|
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()
|
|
|
|
else(UNIX)
|
|
|
|
find_package(METIS REQUIRED)
|
|
|
|
endif(UNIX)
|
2017-02-23 18:45:25 +05:00
|
|
|
endif(USE_MPI)
|
|
|
|
|
|
|
|
|
2016-12-22 23:12:11 +05:00
|
|
|
#######################################################################
|
|
|
|
# propagate cmake variables to Netgen subproject
|
|
|
|
set_vars( NETGEN_CMAKE_ARGS
|
2017-02-07 20:53:38 +05:00
|
|
|
CMAKE_CXX_COMPILER
|
2017-01-26 18:52:15 +05:00
|
|
|
CMAKE_BUILD_TYPE
|
|
|
|
CMAKE_SHARED_LINKER_FLAGS
|
|
|
|
CMAKE_SHARED_LINKER_FLAGS_RELEASE
|
|
|
|
CMAKE_CXX_FLAGS
|
|
|
|
CMAKE_CXX_FLAGS_RELEASE
|
|
|
|
|
2016-12-22 23:12:11 +05:00
|
|
|
USE_GUI
|
|
|
|
USE_PYTHON
|
|
|
|
USE_MPI
|
|
|
|
USE_VT
|
|
|
|
USE_VTUNE
|
|
|
|
USE_NUMA
|
|
|
|
USE_CCACHE
|
|
|
|
USE_NATIVE_ARCH
|
|
|
|
USE_OCC
|
2017-02-03 19:28:59 +05:00
|
|
|
USE_MPEG
|
2017-09-22 14:06:00 +05:00
|
|
|
USE_JPEG
|
2017-05-30 00:19:34 +05:00
|
|
|
USE_INTERNAL_TCL
|
2017-02-16 19:01:16 +05:00
|
|
|
INSTALL_PROFILES
|
2016-12-22 23:12:11 +05:00
|
|
|
INTEL_MIC
|
2017-01-15 23:32:59 +05:00
|
|
|
CMAKE_PREFIX_PATH
|
2017-05-30 00:19:34 +05:00
|
|
|
CMAKE_INSTALL_PREFIX
|
2016-12-22 23:12:11 +05:00
|
|
|
)
|
|
|
|
|
2017-02-10 15:33:05 +05:00
|
|
|
# propagate all variables set on the command line using cmake -DFOO=BAR
|
|
|
|
# to Netgen subproject
|
|
|
|
get_cmake_property(CACHE_VARS CACHE_VARIABLES)
|
|
|
|
foreach(CACHE_VAR ${CACHE_VARS})
|
|
|
|
get_property(CACHE_VAR_HELPSTRING CACHE ${CACHE_VAR} PROPERTY HELPSTRING)
|
|
|
|
if(CACHE_VAR_HELPSTRING STREQUAL "No help, variable specified on the command line.")
|
|
|
|
get_property(CACHE_VAR_TYPE CACHE ${CACHE_VAR} PROPERTY TYPE)
|
|
|
|
set(NETGEN_CMAKE_ARGS ${NETGEN_CMAKE_ARGS};-D${CACHE_VAR}:${CACHE_VAR_TYPE}=${${CACHE_VAR}} CACHE INTERNAL "")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2017-01-10 16:39:12 +05:00
|
|
|
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
|
|
|
|
set(NETGEN_BUILD_COMMAND $(MAKE) --silent )
|
|
|
|
else()
|
|
|
|
set(NETGEN_BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/netgen --config ${CMAKE_BUILD_TYPE})
|
|
|
|
endif()
|
|
|
|
|
2016-12-22 23:12:11 +05:00
|
|
|
ExternalProject_Add (netgen
|
|
|
|
DEPENDS ${NETGEN_DEPENDENCIES}
|
|
|
|
SOURCE_DIR ${PROJECT_SOURCE_DIR}
|
2017-05-30 00:19:34 +05:00
|
|
|
CMAKE_ARGS -DUSE_SUPERBUILD=OFF ${NETGEN_CMAKE_ARGS}
|
2016-12-22 23:12:11 +05:00
|
|
|
INSTALL_COMMAND ""
|
|
|
|
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/netgen
|
2017-01-10 16:39:12 +05:00
|
|
|
BUILD_COMMAND ${NETGEN_BUILD_COMMAND}
|
2016-12-22 23:12:11 +05:00
|
|
|
STEP_TARGETS build
|
|
|
|
)
|
|
|
|
|
2017-01-20 14:16:48 +05:00
|
|
|
# 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
|
2017-05-30 00:19:34 +05:00
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
|
2017-01-20 14:16:48 +05:00
|
|
|
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
|
2017-05-30 00:19:34 +05:00
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
|
2017-01-20 14:16:48 +05:00
|
|
|
DEPENDEES configure # Steps on which this step depends
|
|
|
|
DEPENDERS build # Steps that depend on this step
|
|
|
|
ALWAYS 1 # No stamp file, step always runs
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2017-06-07 13:53:46 +05:00
|
|
|
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build . --target install --config ${CMAKE_BUILD_TYPE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/netgen)")
|
2016-12-22 23:12:11 +05:00
|
|
|
|
|
|
|
add_custom_target(test_netgen
|
|
|
|
${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/netgen
|
|
|
|
--target test
|
|
|
|
--config ${CMAKE_BUILD_TYPE}
|
|
|
|
)
|