Skip to content
Snippets Groups Projects
CMakeLists.txt 3.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • 数学の武士's avatar
    数学の武士 committed
    cmake_minimum_required(VERSION 3.0)
    
    option(INCLUDE_CUDA "GPU build in mode"    OFF)
    option(INCLUDE_CXX  "CXX build in mode"    OFF)
    
    数学の武士's avatar
    数学の武士 committed
    option(BUILD_DOC    "Build documentation"    OFF)
    
    数学の武士's avatar
    数学の武士 committed
    option(SFX_CHECK_NAN    "Build documentation"    OFF)
    
    数学の武士's avatar
    数学の武士 committed
    
    
    数学の武士's avatar
    数学の武士 committed
    project(INMCM_sfx)
    enable_language(Fortran)
    
    数学の武士's avatar
    数学の武士 committed
    
    
    数学の武士's avatar
    数学の武士 committed
    if(BUILD_DOC)
    
    数学の武士's avatar
    数学の武士 committed
        find_package(Doxygen)
        if (DOXYGEN_FOUND)
            set(DOXYGEN_IN ../doxygen/config)    # doxygen config file
    
            # option ALL allows to build the docs together with the code
            add_custom_target( doc_doxygen ALL
                COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_IN}
                WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) # WORKING_DIRECTORY: Execute the command with the given current working directory. If it is a relative path it will be interpreted relative to the build tree directory corresponding to the current source directory.
        else()
        message("Doxygen need to be installed to generate the doxygen documentation")
        endif (DOXYGEN_FOUND)
    
    数学の武士's avatar
    数学の武士 committed
    endif(BUILD_DOC)
    
    if (SFX_CHECK_NAN)
        add_definitions(-DSFX_CHECK_NAN)
    endif ()
    
    数学の武士's avatar
    数学の武士 committed
    
    if(INCLUDE_CXX)
        set(RUN_MACRO -DINCLUDE_CXX)
    endif(INCLUDE_CXX)
    
    if(INCLUDE_CUDA)
        enable_language(CUDA)
        find_package(CUDA REQUIRED)
        include_directories(${CUDA_INCLUDE_DIRS})
        set(RUN_MACRO -DINCLUDE_CUDA)
        set(INCLUDE_CXX ON)
    endif(INCLUDE_CUDA)
    
    if(INCLUDE_CXX)
        enable_language(C)
        enable_language(CXX)
        set(CMAKE_CXX_STANDARD 11)
    endif(INCLUDE_CXX)
    
    set(SOURCES_F 
    
    数学の武士's avatar
    数学の武士 committed
        srcF/sfx_io.f90
    
    数学の武士's avatar
    数学の武士 committed
        srcF/sfx_data.f90
        srcF/sfx_common.f90
        srcF/sfx_esm.f90 
        srcF/sfx_esm_param.f90
        srcF/sfx_log.f90
        srcF/sfx_log_param.f90
        srcF/sfx_main.f90
        srcF/sfx_phys_const.f90
        srcF/sfx_surface.f90
    
    数学の武士's avatar
    数学の武士 committed
        srcF/sfx_fc_wrapper.F90
    
    数学の武士's avatar
    数学の武士 committed
    )
    
    
    数学の武士's avatar
    数学の武士 committed
    set(HEADERS_F
    
    数学の武士's avatar
    .  
    数学の武士 committed
        includeF/sfx_def.fi
    )
    
    
    数学の武士's avatar
    数学の武士 committed
    if(INCLUDE_CXX)
        set(SOURCES_C 
    
    数学の武士's avatar
    数学の武士 committed
            srcC/sfx_call_cxx.c
    
    数学の武士's avatar
    数学の武士 committed
        )
    
        set(SOURCES_CXX 
    
    数学の武士's avatar
    数学の武士 committed
                srcCXX/sfx_flux.cpp
                srcCXX/sfx_flux_compute_func.cpp
                srcCXX/sfx_call_class_func.cpp
    
    数学の武士's avatar
    数学の武士 committed
        )
        set(HEADERS_CXX 
    
    数学の武士's avatar
    数学の武士 committed
                includeCXX/sfx_flux.h
                includeCXX/sfx_flux_compute_func.h
                includeCXX/sfx_call_class_func.h
    
    数学の武士's avatar
    数学の武士 committed
            )
    endif(INCLUDE_CXX)
    
    if(INCLUDE_CUDA)
        set(SOURCES_CU 
    
    数学の武士's avatar
    数学の武士 committed
            srcCU/sfx_flux_compute_func.cu
    
    数学の武士's avatar
    数学の武士 committed
        )
        set(HEADERS_CU
    
    数学の武士's avatar
    数学の武士 committed
            includeCU/sfx_flux_compute_func.cuh
    
    数学の武士's avatar
    数学の武士 committed
        )
    endif(INCLUDE_CUDA)
    
    
    数学の武士's avatar
    .  
    数学の武士 committed
    if(INCLUDE_CXX OR INCLUDE_CUDA)
    
    数学の武士's avatar
    数学の武士 committed
        set(MEMPROC_SOURCES_CXX
    
    数学の武士's avatar
    数学の武士 committed
            srcCXX/sfx_memory_processing.cpp
    
    数学の武士's avatar
    .  
    数学の武士 committed
        )
    
    数学の武士's avatar
    数学の武士 committed
        set(MEMPROC_HEADERS_CXX
    
    数学の武士's avatar
    数学の武士 committed
            includeCXX/sfx_memory_processing.h
            includeCXX/sfx_template_parameters.h
    
    数学の武士's avatar
    .  
    数学の武士 committed
        )
    
    数学の武士's avatar
    数学の武士 committed
    
    
    数学の武士's avatar
    .  
    数学の武士 committed
        if(INCLUDE_CUDA)
    
    数学の武士's avatar
    数学の武士 committed
            set(MEMPROC_SOURCES_CU
    
    数学の武士's avatar
    数学の武士 committed
                srcCU/sfx_memory_processing.cu
    
    数学の武士's avatar
    .  
    数学の武士 committed
            )
            set(MEMPROC_HEADERS_CU
    
    数学の武士's avatar
    数学の武士 committed
                includeCU/sfx_memory_processing.cuh
    
    数学の武士's avatar
    .  
    数学の武士 committed
            )
        endif(INCLUDE_CUDA)
    endif(INCLUDE_CXX OR INCLUDE_CUDA)
    
    数学の武士's avatar
    数学の武士 committed
    
    
    数学の武士's avatar
    .  
    数学の武士 committed
    set(SOURCES ${MEMPROC_HEADERS_CU} ${MEMPROC_SOURCES_CU} ${MEMPROC_HEADERS_CXX} ${MEMPROC_SOURCES_CXX} ${HEADERS_CU} ${SOURCES_CU} ${HEADERS_CXX} ${SOURCES_CXX} ${SOURCES_C} ${HEADERS_F} ${SOURCES_F})
    
    set(CMAKE_Fortran_FLAGS " -cpp ")
    
    数学の武士's avatar
    数学の武士 committed
    add_executable(drag ${SOURCES})
    add_definitions(${RUN_MACRO})
    
    数学の武士's avatar
    数学の武士 committed
    set_property(TARGET drag PROPERTY LINKER_LANGUAGE Fortran)
    
    #copy data on post build
    add_custom_command(
            TARGET drag POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy_directory
            ${CMAKE_SOURCE_DIR}/data
            ${CMAKE_CURRENT_BINARY_DIR}/data)