Newer
Older
include(FetchContent)
option(USE_NETCDF "NetCDF build in mode" OFF)
option(USE_SFX "Build with new sfx module" ON)
option(USE_CONFIG_PARSER "Build config parser" ON)
#set new directories
if(NOT USE_NETCDF)
add_definitions(-DOBL_EXCLUDE_NETCDF)
endif(NOT USE_NETCDF)
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} )
else()
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif(BUILD_DOC)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules/)
obl_init.f90
obl_bc.f90
obl_pph.f90
obl_pph_dyn.f90
obl_run_kato.f90
obl_run_papa_fluxes.f90
obl_run_papa_meteo.f90
vermix_inmom.f90
set(HEADERS
obl_def.fi
)
#Compilation keys
if (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
target_compile_options(obl PRIVATE $<$<COMPILE_LANGUAGE:Fortran>: -cpp -O2>)
elseif (CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
target_compile_options(obl PRIVATE $<$<COMPILE_LANGUAGE:Fortran>: -cpp -O2>)
endif ()
IF (USE_SFX)
#fetch sfx model
FetchContent_Declare(
inmcm60_sfx
GIT_REPOSITORY http://tesla.parallel.ru/inmcm-mirror/sfx.git
GIT_TAG origin/main)
FetchContent_MakeAvailable(inmcm60_sfx)
FetchContent_GetProperties(inmcm60_sfx)
if(NOT inmcm60_sfx_POPULATED)
FetchContent_Populate(sfx_lib)
add_subdirectory(${inmcm60_sfx_SOURCE_DIR} ${inmcm60_sfx_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
add_definitions(-DUSE_SFX)
if(USE_CONFIG)
add_definitions(-DUSE_CONFIG_PARSER)
endif (USE_CONFIG)
target_link_libraries(obl PRIVATE sfx_lib)
else ()
if(USE_CONFIG)
message(ERROR "Config can be only used with new sfx enabled")
endif (USE_CONFIG)
endif (USE_SFX)
if(USE_NETCDF)
#NetCDF handling
execute_process (
COMMAND bash -c "nf-config --fflags | grep -Eo '^[^ ]+' | tr -d '\n'"
OUTPUT_VARIABLE netcdf_inc
)
cmake_path(SET netcfd_inc_dir " ${netcdf_inc}" )
message("CMake path is ${netcdf_inc}")
target_compile_options(obl PRIVATE ${netcdf_inc})
include_directories(${netcdf_inc})
COMMAND bash -c "nf-config --flibs | tr -d '\n'"
OUTPUT_VARIABLE temp
)
separate_arguments(netcdff_libs UNIX_COMMAND "${temp}")
execute_process (
COMMAND bash -c "nc-config --libs | tr -d '\n'"
OUTPUT_VARIABLE temp
)
separate_arguments(netcdf_libs UNIX_COMMAND "${temp}")
execute_process (
COMMAND bash -c "nc-config --all | grep -Eo '\-\-static.*' | cut -d ' ' -f10- | tr -d '\n'"
OUTPUT_VARIABLE temp
)
separate_arguments(netcdf_static UNIX_COMMAND "${temp}")
#target_include_directories(lib_scm_io PRIVATE ${netCDF_INCLUDE_DIR})
target_link_options(obl PRIVATE ${netcdff_libs})
target_link_options(obl PRIVATE ${netcdf_libs})
target_link_options(obl PRIVATE ${netcdf_static})
endif(USE_NETCDF)
add_custom_command(
TARGET obl POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/meteo-init/
${CMAKE_CURRENT_BINARY_DIR}/meteo-init/)
add_custom_command(
TARGET obl POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/meteo-forcing/
${CMAKE_CURRENT_BINARY_DIR}/meteo-forcing/)