cmake_minimum_required(VERSION 3.0) option(INCLUDE_CUDA "GPU build in mode" OFF) option(INCLUDE_CXX "CXX build in mode" OFF) option(BUILD_DOC "Build documentation" OFF) option(SFX_CHECK_NAN "Build documentation" OFF) project(INMCM_sfx) enable_language(Fortran) if(BUILD_DOC) 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) endif(BUILD_DOC) if (SFX_CHECK_NAN) add_definitions(-DSFX_CHECK_NAN) endif () 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 srcF/sfx_io.f90 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 srcF/sfx_most.f90 srcF/sfx_most_param.f90 srcF/sfx_sheba.f90 srcF/sfx_sheba_param.f90 srcF/sfx_fc_wrapper.F90 ) set(HEADERS_F includeF/sfx_def.fi ) if(INCLUDE_CXX) set(SOURCES_C srcC/sfx_call_cxx.c ) set(SOURCES_CXX srcCXX/sfx_surface.cpp srcCXX/sfx_esm.cpp srcCXX/sfx_compute_esm.cpp srcCXX/sfx_sheba.cpp srcCXX/sfx_compute_sheba.cpp srcCXX/sfx_call_class_func.cpp ) set(HEADERS_CXX includeCXX/sfx_surface.h includeCXX/sfx_esm.h includeCXX/sfx_compute_esm.h includeCXX/sfx_sheba.h includeCXX/sfx_compute_sheba.h includeCXX/sfx_call_class_func.h ) endif(INCLUDE_CXX) if(INCLUDE_CUDA) set(SOURCES_CU srcCU/sfx_surface.cu srcCU/sfx_compute_esm.cu srcCU/sfx_compute_sheba.cu ) set(HEADERS_CU includeCU/sfx_surface.cuh includeCU/sfx_compute_esm.cuh includeCU/sfx_compute_sheba.cuh ) endif(INCLUDE_CUDA) if(INCLUDE_CXX OR INCLUDE_CUDA) set(MEMPROC_SOURCES_CXX srcCXX/sfx_memory_processing.cpp ) set(MEMPROC_HEADERS_CXX includeCXX/sfx_memory_processing.h includeCXX/sfx_template_parameters.h ) if(INCLUDE_CUDA) set(MEMPROC_SOURCES_CU srcCU/sfx_memory_processing.cu ) set(MEMPROC_HEADERS_CU includeCU/sfx_memory_processing.cuh ) endif(INCLUDE_CUDA) endif(INCLUDE_CXX OR INCLUDE_CUDA) 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 ") set(CMAKE_Fortran_FLAGS " -g -fbacktrace -ffpe-trap=zero,overflow,underflow -cpp ") if(INCLUDE_CXX OR INCLUDE_CUDA) set(CMAKE_CXX_FLAGS " -g -Wunused-variable ") set(CMAKE_C_FLAGS " -g ") set(CMAKE_CUDA_FLAGS " -g ") endif(INCLUDE_CXX OR INCLUDE_CUDA) add_subdirectory(parser/) add_executable(drag ${SOURCES}) add_definitions(${RUN_MACRO}) set_property(TARGET drag PROPERTY LINKER_LANGUAGE Fortran) target_include_directories(drag PUBLIC ${CMAKE_BINARY_DIR}/modules/) target_link_libraries(drag parser_F parser_CXX) #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)