Skip to content
Snippets Groups Projects
Select Git revision
  • c84436fd7b69f93739c03dfaf2cc9ac4c34b4ad3
  • master default protected
  • arbitrary-cut-order
  • staggered-max
  • unifed-object
  • no_Amalgamated
  • standard_stb
  • parallel_doc_fix
  • release_0.9.3
  • cmake_mpich_tests
  • update_install
  • external_VORO
  • cmake_add_soversion
  • iterative_method
  • cmake_install
  • fixes_042023
  • tensor_max
  • personal/schulz3/tensor_max
  • releases/v0.9
  • ForceBasedDevel
  • refactor
  • v0.9.3
  • v0.9.2
  • v0.9.1
  • v0.9.0
  • v0.9.0-rc2
26 results

CMakeLists.txt

  • CMakeLists.txt 4.10 KiB
    cmake_minimum_required (VERSION 3.14)
    
    option(CM_ALL_VTK_OUTPUT "VTK output routine" OFF)
    option(CM_ALL_VORONOI "Voronoi-based loadbalancing scheme (requires Voro++)" OFF)
    option(CM_ALL_FORTRAN "VTK output routine" OFF)
    option(CM_ALL_DEBUG "Enable debug information" OFF)
    option(CM_ALL_USE_F08 "Use some Fortran 2008 features (mpi_f08)" OFF)
    option(CM_ALL_FORTRAN_ERROR_ABORT "Abort on any error when using the
    Fortran interface" OFF)
    option(CM_ALL_TESTS "Enables test suite" OFF)
    option(CM_ALL_AUTO_DOC "Enables creation of auto-documentation")
    
    # leading and trailing whitespace should be silently ignored
    # thanks to an old FindMPI script
    cmake_policy(SET CMP0004 OLD)
    
    enable_language(CXX)
    enable_language(C)
    
    if (CM_ALL_USE_F08)
        if (NOT CM_ALL_FORTRAN)
            message(FATAL_ERROR "Flag for Fortran 08 MPI interface set, while Fortran interface is not enabled!")
        endif (CM_ALL_FORTRAN)
    endif (CM_ALL_USE_F08)
    
    if (CM_ALL_FORTRAN)
        enable_language(Fortran)
    # todo(s.schulz): This should be extended for other compilers, if they
    #                 support standard checking. The Intel Fortran compiler
    #                 does not.
        if(CM_ALL_USE_F08)
            add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<Fortran_COMPILER_ID:GNU>>:-std=f2008>)
        else()
            add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<Fortran_COMPILER_ID:GNU>>:-std=f2003>)
        endif()
        add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<Fortran_COMPILER_ID:GNU>>:-fbacktrace>)
        add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<Fortran_COMPILER_ID:Intel>>:-traceback>)
    endif (CM_ALL_FORTRAN)
    
    # set standards compliance flags
    set(CMAKE_CXX_STANDARD 11)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_CXX_EXTENSIONS OFF)
    if (CM_ALL_FORTRAN)
        add_compile_options("$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:Fortran>,$<Fortran_COMPILER_ID:GNU>>:-Wall;-Wextra>")
    endif (CM_ALL_FORTRAN)
    add_compile_options("$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:GNU>>:-Wall;-Wextra>")
    add_compile_options("$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:GNU>>:-Wall;-Wextra>")
    
    project(ALL
        VERSION "0.1.0"
        DESCRIPTION "A Loadbalacing Library"
        HOMEPAGE_URL "localhost")
    
    # add custom find-scripts to module path
    set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
    
    if (CM_ALL_FORTRAN)
        find_package(MPI REQUIRED COMPONENTS CXX Fortran)
    else()
        find_package(MPI REQUIRED COMPONENTS CXX)
    endif (CM_ALL_FORTRAN)
    
    
    if(CM_ALL_VTK_OUTPUT)
        message("Using VTK output")
        find_package(VTK REQUIRED COMPONENTS
            vtkCommonCore
            vtkCommonDataModel
            vtkFiltersProgrammable
            vtkIOParallelXML
            vtkIOXML
            vtkParallelMPI
        )
        if(NOT VTK_FOUND)
            message(FATAL_ERROR "VTK not found, help CMake to find it by setting VTK_LIBRARY and VTK_INCLUDE_DIR")
        endif()
        # todo(s.schulz): this can be replaced from 3.12 onwards with add_compile_definitions
        add_compile_options("-DALL_VTK_OUTPUT")
    endif(CM_ALL_VTK_OUTPUT)
    
    if (CM_ALL_DEBUG)
        message("Using ALL debug information")
        add_compile_options("-DALL_DEBUG_ENABLED")
    endif(CM_ALL_DEBUG)
    
    if(CM_ALL_FORTRAN_ERROR_ABORT)
        add_compile_options("-DALL_FORTRAN_ERROR_ABORT")
    endif()
    
    if(CM_ALL_USE_F08 AND MPI_Fortran_HAVE_F08_MODULE)
        add_compile_options("-DALL_USE_F08")
    elseif(CM_ALL_USE_F08 AND NOT MPI_Fortran_HAVE_F08_MODULE)
        message(FATAL_ERROR "Fortran 2008 MPI chosen, but MPI installation does not support the Fortran 2008 modules")
    endif(CM_ALL_USE_F08 AND MPI_Fortran_HAVE_F08_MODULE)
    
    if(CM_ALL_VORONOI)
        message(STATUS "compiling voro++ version in contrib/voro++")
        add_subdirectory(contrib/voro++)
        set(CM_ALL_VORO_INC ../contrib/voro++/include)
        set(CM_ALL_VORO_LIB "-L../contrib/voro++/src -lvoro")
        add_compile_options("-DALL_VORONOI_ACTIVE")
    endif()
    
    set(STB_INCLUDE_DIR ../contrib/stb)
    
    add_subdirectory(src)
    add_subdirectory(example)
    
    if (CM_ALL_TESTS)
        enable_testing()
        include(FindPackageHandleStandardArgs)
        add_subdirectory(tests)
    endif(CM_ALL_TESTS)
    
    if(CM_ALL_AUTO_DOC)
        add_subdirectory("docs")
    endif(CM_ALL_AUTO_DOC)
    
    # vim: sw=4 ts=4 et