Skip to content
Snippets Groups Projects
DetectOptions.cmake 3.71 KiB
Newer Older
#------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0.  See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#

# We'll need to install the private find modules to ensure our import libs
# are properly resovled
set(adios2_find_modules)

# This file contains the option and dependency logic.  The configuration
# options are designed to be tertiary: ON, OFF, or AUTO.  If AUTO, we try to
# determine if dependencies are available and enable the option if we find
# them, otherwise we disable it.  If explicitly ON then a failure to find
# dependencies is an error,

# BZip2
if(ADIOS2_USE_BZip2 STREQUAL AUTO)
  find_package(BZip2 REQUIRED)
endif()
if(BZIP2_FOUND)
if(ADIOS2_USE_ZFP STREQUAL AUTO)
  find_package(ZFP REQUIRED)
endif()
if(ZFP_FOUND)
set(mpi_find_components C)

# Fortran
if(ADIOS2_USE_Fortran STREQUAL AUTO)
  # Currently auto-detection for language support does not work in CMake.  See
  # documentation for the "enable_language" command
  message(WARN "Auto-detection of Fortran is not currently supported; Disabling")
  #enable_language(Fortran OPTIONAL)
elseif(ADIOS2_USE_Fortran)
  enable_language(Fortran)
endif()
if(CMAKE_Fortran_COMPILER_LOADED)
  set(ADIOS2_HAVE_Fortran TRUE)
  list(APPEND mpi_find_components Fortran)
endif()

if(ADIOS2_USE_MPI STREQUAL AUTO)
  find_package(MPI COMPONENTS ${mpi_find_components})
  find_package(MPI COMPONENTS ${mpi_find_components} REQUIRED)
if(SHARED_LIBS_SUPPORTED AND NOT MSVC)
if(ADIOS2_USE_ZeroMQ STREQUAL AUTO)
  find_package(ZeroMQ REQUIRED)
endif()
if(ZeroMQ_FOUND)
if(ADIOS2_USE_HDF5 STREQUAL AUTO)
  find_package(HDF5 COMPONENTS C)
  find_package(HDF5 REQUIRED COMPONENTS C)
endif()
if(HDF5_FOUND AND
   ((ADIOS2_HAVE_MPI AND HDF5_IS_PARALLEL) OR
    NOT (ADIOS2_HAVE_MPI OR HDF5_IS_PARALLEL)))
if(NOT ADIOS2_HAVE_MPI)
  set(adios1_find_args COMPONENTS sequential)
endif()
if(ADIOS2_USE_ADIOS1 STREQUAL AUTO)
  find_package(ADIOS1 1.12.0 ${adios1_find_args})
  find_package(ADIOS1 1.12.0 REQUIRED ${adios1_find_args})
# Use the FindPythonLibsNew from pybind11
list(INSERT CMAKE_MODULE_PATH 0
  "${ADIOS2_SOURCE_DIR}/thirdparty/pybind11/pybind11/tools"
)
if(ADIOS2_USE_Python)
  if(NOT (ADIOS2_USE_Python STREQUAL AUTO))
    set(python_find_args REQUIRED)
  endif()
  if(SHARED_LIBS_SUPPORTED AND ADIOS2_ENABLE_PIC)
    set(Python_ADDITIONAL_VERSIONS "3;2.7"
      CACHE STRING "Python versions to search for"
    )
    mark_as_advanced(Python_ADDITIONAL_VERSIONS)
    list(APPEND python_find_args COMPONENTS Interp Libs numpy)
    if(ADIOS2_HAVE_MPI)
      list(APPEND python_find_args "mpi4py\\\;mpi4py/mpi4py.h")
    find_package(PythonFull ${python_find_args})
endif()
if(PythonFull_FOUND)
  set(ADIOS2_HAVE_Python ON)
if(UNIX)
  include(CheckSymbolExists)
  CHECK_SYMBOL_EXISTS(shmget "sys/ipc.h;sys/shm.h" HAVE_shmget)
  if(HAVE_shmget)
    set(ADIOS2_HAVE_SysVShMem ON)
  else()
    set(ADIOS2_HAVE_SysVShMem OFF)
  endif()
else()
  set(ADIOS2_HAVE_SysVShMem OFF)

# Multithreading
find_package(Threads REQUIRED)