Commit 3e649927 authored by Burlen Loring's avatar Burlen Loring

Python bindings

This patch adds Python bindings to SENSEI.

* Flatten nested namespaces to only 1 level deep
* Update to ADIOS 1.11
* SWIG Python bindings and CMake driver code
* Use interface libraries for dependencies
* export targets and generate a working SENSEIConfig.cmake
* CMake find modules for Libsim, NumPy, and mpi4py
* Newton Python miniapp demonstrating use of SENSEI from Python
* Warning cleanup
* VTKPosthocIO analysis adaptor, writes any VTK dataset to either ".pvd"
  or ".visit" format. Can be used to generate representative data for
  configuring Catalyst and Libsim configs.
* Add a method to the Catalyst adaptor to configure a pipeline from
  Catalyst Python script. Before this was in ConfigurableAnalysis.
* Enable point meshes in the Libsim adaptor
* Update the read me
parent fc3ba8c8
*.sw[a-z]
......@@ -7,8 +7,8 @@
# [REQUIRED] # Fail with an error if ADIOS or a required
# # component is not found
# [QUIET] # ...
# [COMPONENTS <...>] # Compiled in components: fortran, readonly,
# sequential (all are case insentative)
# [COMPONENTS <...>] # Compiled in components: fortran, readonly,
# sequential (all are case insentative)
# )
#
# Module that finds the includes and libraries for a working ADIOS install.
......@@ -85,7 +85,6 @@
###############################################################################
# Required cmake version
###############################################################################
cmake_minimum_required(VERSION 2.8.5)
......@@ -99,11 +98,11 @@ if(ADIOS_FIND_COMPONENTS)
foreach(COMP ${ADIOS_FIND_COMPONENTS})
string(TOLOWER ${COMP} comp)
if(comp STREQUAL "fortran")
set(OPTLIST ${OPTLIST} f)
set(OPTLIST "${OPTLIST}f")
elseif(comp STREQUAL "readonly")
set(OPTLIST ${OPTLIST} r)
set(OPTLIST "${OPTLIST}r")
elseif(comp STREQUAL "sequential")
set(OPTLIST ${OPTLIST} s)
set(OPTLIST "${OPTLIST}s")
else()
message("ADIOS component ${COMP} is not supported. Please use fortran, readonly, or sequential")
endif()
......@@ -119,7 +118,8 @@ set(ADIOS_FOUND TRUE)
# check the ADIOS_ROOT hint and the normal PATH
find_file(ADIOS_CONFIG
NAME adios_config
PATHS $ENV{ADIOS_ROOT}/bin $ENV{ADIOS_DIR}/bin $ENV{INSTALL_PREFIX}/bin $ENV{PATH})
PATHS ${ADIOS_ROOT}bin ${ADIOS_DIR}/bin $ENV{ADIOS_ROOT}/bin $ENV{ADIOS_DIR}/bin
$ENV{INSTALL_PREFIX}/bin $ENV{PATH})
if(ADIOS_CONFIG)
message(STATUS "Found 'adios_config': ${ADIOS_CONFIG}")
......@@ -171,43 +171,20 @@ if(ADIOS_FOUND)
# different sources (quite unlikely)
# http://www.cmake.org/pipermail/cmake/2008-November/025128.html
set(ADIOS_LIBRARY_DIRS "")
string(REGEX MATCHALL "-L([A-Za-z_0-9/\\.-]+)" _ADIOS_LIBDIRS "${ADIOS_LINKFLAGS}")
string(REGEX MATCHALL " -L([A-Za-z_0-9/\\.-]+)" _ADIOS_LIBDIRS " ${ADIOS_LINKFLAGS}")
foreach(_LIBDIR ${_ADIOS_LIBDIRS})
string(REPLACE "-L" "" _LIBDIR ${_LIBDIR})
string(REPLACE " -L" "" _LIBDIR ${_LIBDIR})
list(APPEND ADIOS_LIBRARY_DIRS ${_LIBDIR})
endforeach()
# we could append ${CMAKE_PREFIX_PATH} now but that is not really necessary
#message(STATUS "ADIOS DIRS to look for libs: ${ADIOS_LIBRARY_DIRS}")
# parse all -lname libraries and find an absolute path for them. we can't just
# look for "-l" because the following library /usr/lib/x86_64-linux-gnu/libm.a
# matches that but isn't what is looked for. First we look for " -l" and later
# look for "-l" at the beginning of a line.
string(REGEX MATCHALL " -l([A-Za-z_0-9\\.-]+)" _ADIOS_LIBS "${ADIOS_LINKFLAGS}")
# parse all -lname libraries and find an absolute path for them
string(REGEX MATCHALL " -l([A-Za-z_0-9\\.-]+)" _ADIOS_LIBS " ${ADIOS_LINKFLAGS}")
foreach(_LIB ${_ADIOS_LIBS})
string(REPLACE " -l" "" _LIB ${_LIB})
# find static lib: absolute path in -L then default
find_library(_LIB_DIR NAMES ${_LIB} PATHS ${ADIOS_LIBRARY_DIRS})
# found?
if(_LIB_DIR)
message(STATUS "Found ${_LIB} in ${_LIB_DIR}")
list(APPEND ADIOS_LIBRARIES "${_LIB_DIR}")
else(_LIB_DIR)
set(ADIOS_FOUND FALSE)
message(STATUS "ADIOS: Could NOT find library '${_LIB}'")
endif(_LIB_DIR)
# clean cached var
unset(_LIB_DIR CACHE)
unset(_LIB_DIR)
endforeach()
string(REGEX MATCHALL "^-l([A-Za-z_0-9\\.-]+)" _ADIOS_LIBS "${ADIOS_LINKFLAGS}")
foreach(_LIB ${_ADIOS_LIBS})
string(REPLACE "-l" "" _LIB ${_LIB})
# find static lib: absolute path in -L then default
find_library(_LIB_DIR NAMES ${_LIB} PATHS ${ADIOS_LIBRARY_DIRS} CMAKE_FIND_ROOT_PATH_BOTH)
......@@ -233,7 +210,7 @@ if(ADIOS_FOUND)
execute_process(COMMAND ${ADIOS_CONFIG} -v
OUTPUT_VARIABLE ADIOS_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif(ADIOS_FOUND)
# unset checked variables if not found
......
#
## Copyright 2003 Sandia Coporation
## Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
## license for use of this work by or on behalf of the U.S. Government.
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that this Notice and any statement
## of authorship are reproduced on all copies.
#
# $Id: FindIceT.cmake,v 1.2 2007-02-22 18:25:27 kmorel Exp $
#
# Find an IceT installation or build tree.
#
# The following variables are set if IceT is found. If IceT is not found,
# ICET_FOUND is set to false.
#
# ICET_FOUND - Set to true when IceT is found.
# ICET_USE_FILE - CMake source file to setup a project to use IceT
# ICET_CORE_LIBS - List of core IceT libraries that all IceT apps need.
# ICET_MPI_LIBS - List of libraries for using IceT with MPI (not
# including MPI itself).
# ICET_MAJOR_VERSION - The IceT major version number.
# ICET_MINOR_VERSION - The IceT minor version number.
# ICET_PATCH_VERSION - The IceT patch version number.
#
# The following variables are also set, but their use is handled for you
# when including ICET_USE_FILE.
#
# ICET_INCLUDE_DIRS - Include directories for IceT headers.
# ICET_LIBRARY_DIRS - Link directories for IceT libraries.
#
# The following cache entries must be set by the user to locate IceT:
#
# ICET_DIR - The directory containing ICETConfig.cmake.
#
SET(ICET_DIR_DESCRIPTION "directory containing ICETConfig.cmake. This is either the root of the build tree, or PREFIX/lib for an installation.")
SET(ICET_DIR_MESSAGE "IceT not found. Set ICET_DIR to the ${ICET_DIR_DESCRIPTION}")
IF (NOT ICET_DIR)
# Get the system search path as a list.
IF(UNIX)
STRING(REGEX MATCHALL "[^:]+" ICET_DIR_SEARCH1 "$ENV{PATH}")
ELSE(UNIX)
STRING(REGEX REPLACE "\\\\" "/" ICET_DIR_SEARCH1 "$ENV{PATH}")
ENDIF(UNIX)
STRING(REGEX REPLACE "/;" ";" ICET_DIR_SEARCH2 "${ICET_DIR_SEARCH1}")
# Construct a set of paths relative to the system search path.
SET(ICET_DIR_SEARCH "")
FOREACH(dir ${ICET_DIR_SEARCH2})
SET(ICET_DIR_SEARCH ${ICET_DIR_SEARCH} "${dir}/../lib")
ENDFOREACH(dir)
FIND_PATH(ICET_DIR ICETConfig.cmake
# Look in places relative to the system executable search path.
${ICET_DIR_SEARCH}
# Look in standard UNIX install locations.
/usr/local/lib
/usr/lib
# Look in standard Win32 install locations.
"C:/Program Files/IceT/lib"
# Give documentation to user in case we can't find it.
DOC "The ${ICET_DIR_DESCRIPTION}")
ENDIF (NOT ICET_DIR)
# If IceT was found, load the configuration file to get the rest of the
# settings.
IF(ICET_DIR)
# Make sure the ICETConfig.cmake file exists in the directory provided.
IF(EXISTS ${ICET_DIR}/ICETConfig.cmake)
# We found IceT. Load the settings.
SET(ICET_FOUND 1)
INCLUDE(${ICET_DIR}/ICETConfig.cmake)
ELSE(EXISTS ${ICET_DIR}/ICETConfig.cmake)
# We did not find IceT.
SET(ICET_FOUND 0)
ENDIF(EXISTS ${ICET_DIR}/ICETConfig.cmake)
ELSE(ICET_DIR)
# We did not find IceT.
SET(ICET_FOUND 0)
ENDIF(ICET_DIR)
#-----------------------------------------------------------------------------
IF(NOT ICET_FOUND)
# IceT not found, explain to the user how to specify its location.
IF(NOT ICET_FIND_QUIETLY)
MESSAGE(${ICET_DIR_MESSAGE})
ENDIF(NOT ICET_FIND_QUIETLY)
ENDIF(NOT ICET_FOUND)
# - Find libsim
# Find the native libsim includes and library
#
# set VISIT_DIR to the install/arch directory
# For example on my workstation, I use
# -DVISIT_DIR=/work/SENSEI/visit-install/2.13.0/linux-x86_64/
#
# LIBSIM_INCLUDE_DIR - user modifiable choice of where libsim headers are
# LIBSIM_LIBRARY - user modifiable choice of where libsim libraries are
#
# This module returns these variables for the rest of the project to use.
#
# LIBSIM_FOUND - True if libsim found including required interfaces(see below)
# LIBSIM_LIBRARIES - All libsim related libraries.
# LIBSIM_INCLUDE_DIRS - All directories to include.
#
if(LIBSIM_INCLUDE_DIR AND LIBSIM_LIBRARY)
set(LIBSIM_FIND_QUIETLY TRUE)
endif()
if(LIBSIM_DIR AND NOT VISIT_DIR)
set(VISIT_DIR "${LIBSIM_DIR}/../..")
endif()
# pick up third party
set(LIBSIM_THIRD_PARTY)
list (FIND Libsim_FIND_COMPONENTS VTK tmp)
if (${tmp} GREATER -1)
find_package(VTK)
list(APPEND LIBSIM_THIRD_PARTY ${VTK_LIBRARIES})
endif()
list (FIND Libsim_FIND_COMPONENTS IceT tmp)
if (${tmp} GREATER -1)
find_package(IceT)
list(APPEND LIBSIM_THIRD_PARTY ${ICET_LIBRARIES})
endif()
# lib
if(VISIT_DIR)
find_library(LIBSIM_LIBRARY NAMES simV2
PATHS "${VISIT_DIR}/libsim/V2/lib"
NO_DEFAULT_PATH)
endif()
find_library(LIBSIM_LIBRARY NAMES simV2
PATHS ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
find_library(LIBSIM_LIBRARY NAMES simV2)
mark_as_advanced(LIBSIM_LIBRARY)
set(LIBSIM_LIBRARIES ${LIBSIM_LIBRARY} ${LIBSIM_THIRD_PARTY})
# header
if(VISIT_DIR)
find_path(LIBSIM_INCLUDE_DIR VisItControlInterface_V2.h
PATHS "${VISIT_DIR}/libsim/V2/include" NO_DEFAULT_PATH)
endif()
get_filename_component(LIBSIM_LIBRARY_DIR
${LIBSIM_LIBRARY} DIRECTORY)
find_path(LIBSIM_INCLUDE_DIR VisItControlInterface_V2.h
PATHS "${LIBSIM_LIBRARY_DIR}/../include"
NO_DEFAULT_PATH)
find_path(LIBSIM_INCLUDE_DIR VisItControlInterface_V2.h)
mark_as_advanced(LIBSIM_INCLUDE_DIR)
set(LIBSIM_INCLUDE_DIRS ${LIBSIM_INCLUDE_DIR})
set(err_msg "Failed to locate libsim in VISIT_DIR=\"${VISIT_DIR}\"")
# validate
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBSIM
${err_msg} LIBSIM_LIBRARIES LIBSIM_INCLUDE_DIRS)
#*****************************************************************************
# FindMpi4Py
#
# Check if mpi4py is installed and configure c-api includes
#
# This module defines
# MPI4PY_FOUND, set TRUE if mpi4py and c-api are available
# MPI4PY_INCLUDE_DIR, where to find c-api headers
# MPI4PY_VERSION, mpi4py release version
set(_TMP_PY_OUTPUT)
set(_TMP_PY_RETURN)
exec_program("${PYTHON_EXECUTABLE}"
ARGS "-c 'import mpi4py; print mpi4py.get_include()'"
OUTPUT_VARIABLE _TMP_PY_OUTPUT
RETURN_VALUE _TMP_PY_RETURN)
set(MPI4PY_INCLUDE_FOUND FALSE)
if(NOT _TMP_PY_RETURN AND EXISTS "${_TMP_PY_OUTPUT}")
set(MPI4PY_INCLUDE_FOUND TRUE)
else()
set(_TMP_PY_OUTPUT)
endif()
set(MPI4PY_INCLUDE_DIR "${_TMP_PY_OUTPUT}" CACHE PATH
"mpi4py include directories")
set(_TMP_PY_OUTPUT)
set(_TMP_PY_RETURN)
exec_program("${PYTHON_EXECUTABLE}"
ARGS "-c 'import mpi4py; print mpi4py.__version__'"
OUTPUT_VARIABLE _TMP_PY_OUTPUT
RETURN_VALUE _TMP_PY_RETURN)
set(MPI4PY_VERSION_FOUND FALSE)
if(NOT _TMP_PY_RETURN)
set(MPI4PY_VERSION_FOUND TRUE)
else()
set(_TMP_PY_OUTPUT)
endif()
set(MPI4PY_VERSION "${_TMP_PY_OUTPUT}" CACHE STRING
"mpi4py version string")
if (NOT ${QUIET})
message(STATUS "MPI4PY_INCLUDE_DIR=${MPI4PY_INCLUDE_DIR}")
message(STATUS "MPI4PY_VERSION=${MPI4PY_VERSION}")
endif()
mark_as_advanced(MPI4PY_INCLUDE_DIR MPI4PY_VERSION)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MPI4PY DEFAULT_MSG
MPI4PY_INCLUDE_FOUND MPI4PY_VERSION_FOUND)
#*****************************************************************************
# FindNumpy
#
# Check if numpy is installed and configure c-api includes
#
# This module defines
# NUMPY_FOUND, set TRUE if numpy and c-api are available
# NUMPY_INCLUDE_DIR, where to find c-api headers
# NUMPY_VERSION, numpy release version
set(_TMP_PY_OUTPUT)
set(_TMP_PY_RETURN)
exec_program("${PYTHON_EXECUTABLE}"
ARGS "-c 'import numpy; print numpy.get_include()'"
OUTPUT_VARIABLE _TMP_PY_OUTPUT
RETURN_VALUE _TMP_PY_RETURN)
set(NUMPY_INCLUDE_FOUND FALSE)
if(NOT _TMP_PY_RETURN AND EXISTS "${_TMP_PY_OUTPUT}")
set(NUMPY_INCLUDE_FOUND TRUE)
else()
set(_TMP_PY_OUTPUT)
endif()
set(NUMPY_INCLUDE_DIR "${_TMP_PY_OUTPUT}" CACHE PATH
"numpy include directory")
set(_TMP_PY_OUTPUT)
set(_TMP_PY_RETURN)
exec_program("${PYTHON_EXECUTABLE}"
ARGS "-c 'import numpy; print numpy.version.version'"
OUTPUT_VARIABLE _TMP_PY_OUTPUT
RETURN_VALUE _TMP_PY_RETURN)
set(NUMPY_VERSION_FOUND FALSE)
if(NOT _TMP_PY_RETURN)
set(NUMPY_VERSION_FOUND TRUE)
else()
set(_TMP_PY_OUTPUT)
endif()
set(NUMPY_VERSION "${_TMP_PY_OUTPUT}" CACHE STRING
"numpy version string")
if (NOT ${QUIET})
message(STATUS "NUMPY_INCLUDE_DIR=${NUMPY_INCLUDE_DIR}")
message(STATUS "NUMPY_VERSION=${NUMPY_VERSION}")
endif()
mark_as_advanced(NUMPY_INCLUDE_DIR NUMPY_VERSION)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NUMPY DEFAULT_MSG
NUMPY_INCLUDE_FOUND NUMPY_VERSION_FOUND)
set(SENSEI_BUILD_DIR "@CMAKE_BINARY_DIR@")
set(SENSEI_SOURCE_DIR "@CMAKE_SOURCE_DIR@")
set(SENSEI_LIBS ${SENSEI_BUILD_DIR}/lib/libsensei.a ${SENSEI_BUILD_DIR}/lib/libpugixml.a ${SENSEI_BUILD_DIR}/lib/libutil.a ${SENSEI_BUILD_DIR}/lib/libtimer.a ${SENSEI_BUILD_DIR}/lib/libArrayIO.a )
set(SENSEI_INCLUDE_DIRS ${SENSEI_SOURCE_DIR}/sensei ${SENSEI_SOURCE_DIR}/utils)
set(SENSEI_VERSION "@SENSEI_VERSION@")
set(SENSEI_VERSION_MAJOR "@SENSEI_VERSION_MAJOR@")
set(SENSEI_VERSION_MINOR "@SENSEI_VERSION_MINOR@")
set(SENSEI_VERSION_PATCH "@SENSEI_VERSION_PATCH@")
set(SENSEI_VERSION_DEVEL "@SENSEI_VERSION_DEVEL@")
set(VTK_DIR "@VTK_DIR@")
if(NOT SENSEI_DIR)
if(@SENSEI_BUILD@)
set(SENSEI_DIR "@CMAKE_BINARY_DIR@")
else()
set(SENSEI_DIR "@CMAKE_INSTALL_PREFIX@")
endif()
endif()
list(APPEND CMAKE_MODULE_PATH "${SENSEI_DIR}")
set(LIBSIM_ENABLED @LIBSIM_ENABLED@)
set(LIBSIM_DIR "@LIBSIM_ENABLED@")
set(SENSEI_LIB_TYPE STATIC)
if(@BUILD_SHARED_LIBS@)
set(SENSEI_LIB_TYPE SHARED)
endif()
if (@BUILD_STATIC_EXECS@)
set(BUILD_SHARED_LIBS OFF FORCE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
set(LINK_SEARCH_START_STATIC TRUE)
set(LINK_SEARCH_END_STATIC TRUE)
endif()
set(ENABLE_SENSEI @ENABLE_SENSEI@)
set(ENABLE_PYTHON @ENABLE_PYTHON@)
set(ENABLE_CATALYST @ENABLE_CATALYST@)
set(ENABLE_CATALYST_PYTHON @ENABLE_CATALYST_PYTHON@)
set(ENABLE_LIBSIM @ENABLE_LIBSIM@)
set(ENABLE_ADIOS @ENABLE_ADIOS@)
set(ENABLE_VTK_GENERIC_ARRAYS @ENABLE_VTK_GENERIC_ARRAYS@)
set(ENABLE_VTK_XMLP @ENABLE_VTK_XMLP@)
if (NOT CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "@CMAKE_CXX_FLAGS@"
CACHE STRING "sensei build defaults"
FORCE)
endif()
if(ENABLE_CATALYST)
if(NOT ParaView_DIR)
set(ParaView_DIR "@ParaView_DIR@")
find_package(ParaView REQUIRED)
endif()
else()
if(NOT VTK_DIR)
set(VTK_DIR "@VTK_DIR@")
endif()
find_package(VTK REQUIRED)
endif()
include(thread)
include(mpi)
include(vtk)
include(timer)
include(pugixml)
include(ArrayIO)
include(timer)
include(diy)
include(grid)
if(ENABLE_PYTHON)
include(python)
endif()
if(ENABLE_LIBSIM)
include(libsim)
endif()
if(ENABLE_ADIOS)
include(adios)
endif()
include(sensei)
find_package(ADIOS 1.9 REQUIRED)
add_library(adios INTERFACE)
target_link_libraries(adios INTERFACE ${ADIOS_LIBRARIES})
target_include_directories(adios SYSTEM INTERFACE ${ADIOS_INCLUDE_DIRS})
if(ADIOS_DEFINITIONS)
target_compile_definitions(adios INTERFACE ${ADIOS_DEFINITIONS})
if(ENABLE_ADIOS)
find_package(ADIOS REQUIRED)
add_library(adios INTERFACE)
target_link_libraries(adios INTERFACE ${ADIOS_LIBRARIES})
target_include_directories(adios SYSTEM INTERFACE ${ADIOS_INCLUDE_DIRS})
if(ADIOS_DEFINITIONS)
target_compile_definitions(adios INTERFACE ${ADIOS_DEFINITIONS})
endif()
install(TARGETS adios EXPORT adios)
install(EXPORT adios DESTINATION lib/cmake EXPORT_LINK_INTERFACE_LIBRARIES)
endif()
option(BUILD_SHARED_LIBS OFF "Build shared libraries by default")
option(BUILD_STATIC_EXECS OFF "Link executables statically")
if (BUILD_STATIC_EXECS)
set(BUILD_SHARED_LIBS OFF FORCE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
set(LINK_SEARCH_START_STATIC TRUE)
set(LINK_SEARCH_END_STATIC TRUE)
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release"
CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
if (NOT MSVC)
if (NOT CMAKE_CXX_FLAGS)
set(tmp "-fPIC -std=c++11 -Wall -Wextra")
if (BUILD_STATIC_EXECS)
set(tmp "${tmp} -static -static-libgcc -static-libstdc++ -pthread -Wl,-Bstatic")
endif()
if ((APPLE) AND ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
set(tmp "${tmp} -stdlib=libc++")
endif()
if ("${CMAKE_BUILD_TYPE}" MATCHES "Release")
set(tmp "${tmp} -O3 -march=native -mtune=native")
endif()
set(CMAKE_CXX_FLAGS "${tmp}"
CACHE STRING "SENSEI build defaults"
FORCE)
endif()
endif()
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
message(STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
message(STATUS "BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}")
message(STATUS "BUILD_STATIC_EXECS=${BUILD_STATIC_EXECS}")
if (ENABLE_CATALYST)
set(SENSEI_PV_COMPONENTS vtkPVCatalyst vtkPVServerManagerRendering)
if(ENABLE_CATALYST_PYTHON)
list(APPEND SENSEI_PV_COMPONENTS vtkPVPythonCatalyst)
endif()
find_package(ParaView COMPONENTS ${SENSEI_VTK_COMPONENTS}
${SENSEI_PV_COMPONENTS})
if(NOT ParaView_FOUND)
message(FATAL_ERROR "Catalyst analysis components require Catalyst build"
"(or install directory. Please set ParaView_DIR to point to " "directory"
"containing `ParaViewConfig.cmake`.")
endif()
add_library(vtk INTERFACE)
target_link_libraries(vtk INTERFACE ${VTK_LIBRARIES})
target_include_directories(vtk SYSTEM INTERFACE ${PARAVIEW_INCLUDE_DIRS})
target_compile_definitions(vtk INTERFACE ${VTK_DEFINITIONS})
install(TARGETS vtk EXPORT vtk)
install(EXPORT vtk DESTINATION lib/cmake EXPORT_LINK_INTERFACE_LIBRARIES)
endif()
configure_file(senseiConfig.h.in senseiConfig.h)
install(FILES ${CMAKE_BINARY_DIR}/senseiConfig.h DESTINATION include)
set(SENSEI_BUILD OFF)
configure_file(CMake/SENSEIConfig.cmake.in lib/cmake/SENSEIConfig.cmake @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/lib/cmake/SENSEIConfig.cmake DESTINATION lib/cmake)
find_package(LIBSIM REQUIRED)
add_library(libsim INTERFACE)
target_link_libraries(libsim INTERFACE ${LIBSIM_STATIC_PAR_LIBRARIES})
target_include_directories(libsim SYSTEM INTERFACE ${LIBSIM_INCLUDE_DIR})
if(ENABLE_LIBSIM)
find_package(LIBSIM REQUIRED)
add_library(libsim INTERFACE)
target_link_libraries(libsim INTERFACE ${LIBSIM_LIBRARIES})
target_include_directories(libsim SYSTEM INTERFACE ${LIBSIM_INCLUDE_DIRS})
install(TARGETS libsim EXPORT libsim)
install(EXPORT libsim DESTINATION lib/cmake EXPORT_LINK_INTERFACE_LIBRARIES)
endif()
#------------------------------------------------------------------------------
# Since we need MPI left and right, this makes it easier to deal with MPI.
find_package(MPI REQUIRED)
add_library(mpi INTERFACE)
target_include_directories(mpi
SYSTEM INTERFACE ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
target_compile_definitions(mpi
INTERFACE ${MPI_C_COMPILE_FLAGS} ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(mpi
INTERFACE ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
#if(MPI_C_LINK_FLAGS OR MPI_CXX_LINK_FLAGS)
# set_target_properties(mpi
# PROPERTIES LINK_FLAGS ${MPI_C_LINK_FLAGS} ${MPI_CXX_LINK_FLAGS})
#endif()
target_include_directories(mpi SYSTEM INTERFACE ${MPI_C_INCLUDE_PATH}
${MPI_CXX_INCLUDE_PATH})
target_compile_definitions(mpi INTERFACE ${MPI_C_COMPILE_FLAGS}
${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(mpi INTERFACE ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
install(TARGETS mpi EXPORT mpi)
install(EXPORT mpi DESTINATION lib/cmake EXPORT_LINK_INTERFACE_LIBRARIES)
option(ENABLE_SENSEI "Enable Sensei infrastucture" ON)
cmake_dependent_option(ENABLE_PYTHON
"Enable Python binding to Sensei infrastucture" OFF
"ENABLE_SENSEI" OFF)
cmake_dependent_option(ENABLE_VTK_GENERIC_ARRAYS
"VTK build has Generic arrays" OFF
"ENABLE_SENSEI" OFF)
cmake_dependent_option(ENABLE_CATALYST
"Enable analysis methods that use Catalyst" OFF
"ENABLE_SENSEI" OFF)
cmake_dependent_option(ENABLE_CATALYST_PYTHON
"Enable analysis methods that use Catalyst Python scripts" OFF
"ENABLE_CATALYST" OFF)
cmake_dependent_option(ENABLE_ADIOS
"Enable analysis methods that use ADIOS" OFF
"ENABLE_SENSEI" OFF)
cmake_dependent_option(ENABLE_LIBSIM
"Enable analysis methods that use Libsim" OFF
"ENABLE_SENSEI" OFF)
cmake_dependent_option(ENABLE_VTK_XMLP
"Enable use of vtk parallel I/O" OFF
"ENABLE_SENSEI" OFF)
option(ENABLE_PARALLEL3D "Enable Parallel3D miniapp" ON)
option(ENABLE_OSCILLATORS "Enable Oscillators miniapp" ON)
message(STATUS "ENABLE_SENSEI=${ENABLE_SENSEI}")
message(STATUS "ENABLE_PYTHON=${ENABLE_PYTHON}")
message(STATUS "ENABLE_VTK_GENERIC_ARRAYS=${ENABLE_VTK_GENERIC_ARRAYS}")
message(STATUS "ENABLE_CATALYST=${ENABLE_CATALYST}")
message(STATUS "ENABLE_CATALYST_PYTHON=${ENABLE_CATALYST}")
message(STATUS "ENABLE_ADIOS=${ENABLE_ADIOS}")
message(STATUS "ENABLE_LIBSIM=${ENABLE_LIBSIM}")
message(STATUS "ENABLE_VTK_XMLP=${ENABLE_VTK_XMLP}")
message(STATUS "ENABLE_PARALLEL3D=${ENABLE_PARALLEL3D}")
message(STATUS "ENABLE_OSCILLATORS=${ENABLE_OSCILLATORS}")
if (ENABLE_PYTHON)
find_package(PythonInterp REQUIRED)
if(PYTHONINTERP_FOUND)
find_program(PYTHON_CONFIG_EXECUTABLE python-config)
if (NOT PYTHON_CONFIG_EXECUTABLE)
message(SEND_ERROR "python-config executable is required.")
endif()
execute_process(COMMAND ${PYTHON_CONFIG_EXECUTABLE} --prefix
OUTPUT_VARIABLE python_prefix OUTPUT_STRIP_TRAILING_WHITESPACE)
set(PYTHON_INCLUDE_DIR ${python_prefix}/include/python2.7)
if (EXISTS ${python_prefix}/lib/libpython2.7${CMAKE_SHARED_LIBRARY_SUFFIX})
set(PYTHON_LIBRARY ${python_prefix}/lib/libpython2.7${CMAKE_SHARED_LIBRARY_SUFFIX})
elseif (EXISTS ${python_prefix}/lib64/libpython2.7${CMAKE_SHARED_LIBRARY_SUFFIX})
set(PYTHON_LIBRARY ${python_prefix}/lib64/libpython2.7${CMAKE_SHARED_LIBRARY_SUFFIX})
elseif (EXISTS ${python_prefix}/lib/x86_64-linux-gnu/libpython2.7${CMAKE_SHARED_LIBRARY_SUFFIX})
set(PYTHON_LIBRARY ${python_prefix}/lib/x86_64-linux-gnu/libpython2.7${CMAKE_SHARED_LIBRARY_SUFFIX})
else()
message(SEND_ERROR "Failed to locate Python library for ${python_prefix}")
endif()
endif()
find_package(PythonLibs REQUIRED)
find_package(NUMPY REQUIRED)
find_program(swig_cmd NAMES swig swig3.0)
if (swig_cmd-NOTFOUND)
message(SEND_ERROR "Failed to locate swig")
endif()
find_package(MPI4PY REQUIRED)
add_library(python INTERFACE)
target_include_directories(python INTERFACE ${PYTHON_INCLUDE_PATH} ${MPI4PY_INCLUDE_DIR})
target_link_libraries(python INTERFACE ${PYTHON_LIBRARIES} vtk)
install(TARGETS python EXPORT python)
install(EXPORT python DESTINATION lib/cmake EXPORT_LINK_INTERFACE_LIBRARIES)
function(depend_swig input output)
set(input_file ${CMAKE_CURRENT_SOURCE_DIR}/${input})
set(output_file ${CMAKE_CURRENT_BINARY_DIR}/${output})
# custom command to update the dependency file
add_custom_command(
OUTPUT ${output_file}
COMMAND ${swig_cmd} -c++ -python -MM
-I${MPI4PY_INCLUDE_DIR} -I${CMAKE_BINARY_DIR}
-I${CMAKE_CURRENT_BINARY_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}
-I${CMAKE_SOURCE_DIR}/sensei
${input_file} | sed -e 's/[[:space:]\\]\\{1,\\}//g' -e '1,2d' -e '/senseiConfig\\.h/d' > ${output_file}
MAIN_DEPENDENCY ${input_file}
COMMENT "Generating dependency file for ${input}...")
# bootstrap the dependency list
message(STATUS "Generating initial dependency list for ${input}")
execute_process(
COMMAND ${swig_cmd} -c++ -python -MM
-I${MPI4PY_INCLUDE_DIR} -I${CMAKE_BINARY_DIR}
-I${CMAKE_CURRENT_BINARY_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}
-I${CMAKE_SOURCE_DIR}/sensei -DSWIG_BOOTSTRAP
${input_file}
COMMAND sed -e s/[[:space:]\\]\\{1,\\}//g -e 1,2d -e /senseiConfig\\.h/d
OUTPUT_FILE ${output_file})
endfunction()
function(wrap_swig input output depend)
set(input_file ${CMAKE_CURRENT_SOURCE_DIR}/${input})
set(output_file ${CMAKE_CURRENT_BINARY_DIR}/${output})
set(depend_file ${CMAKE_CURRENT_BINARY_DIR}/${depend})
file(STRINGS ${depend_file} depends)
add_custom_command(
OUTPUT ${output_file}
COMMAND ${swig_cmd} -c++ -python -w341,325,401,504
-DSWIG_TYPE_TABLE=senseiPython
-I${MPI4PY_INCLUDE_DIR} -I${CMAKE_BINARY_DIR}
-I${CMAKE_CURRENT_BINARY_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}
-I${CMAKE_SOURCE_DIR}/sensei
-o ${output_file} ${input_file}
MAIN_DEPENDENCY ${input_file}
DEPENDS ${depend_file} ${depends}
COMMENT "Generating python bindings for ${input}...")
endfunction()
endif()
find_package(Threads)