2020-08-14 10:12:43 -03:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
2020-07-30 12:58:49 -03:00
|
|
|
|
2020-07-31 13:21:02 -03:00
|
|
|
project(amun
|
|
|
|
VERSION 1.0
|
|
|
|
DESCRIPTION "AMUN Code - a code to perform numerical simulations in astrophysics"
|
2020-08-15 16:25:12 -03:00
|
|
|
HOMEPAGE_URL "https://amuncode.org"
|
2020-07-31 13:21:02 -03:00
|
|
|
LANGUAGES Fortran
|
|
|
|
)
|
2020-07-30 12:58:49 -03:00
|
|
|
|
|
|
|
enable_language(Fortran)
|
|
|
|
|
|
|
|
set(default_build_type "Release")
|
|
|
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
|
|
|
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
|
|
|
STRING "Choose the type of build." FORCE)
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
|
2021-02-04 17:36:37 -03:00
|
|
|
add_compile_options("$<$<CONFIG:RELEASE>:-march=native;-pipe;-fno-tree-vectorize;-fno-unsafe-math-optimizations;-frounding-math;-fsignaling-nans;-finline-limit=10000;-fdiagnostics-color=always>")
|
2021-11-03 12:41:19 -03:00
|
|
|
add_compile_options("$<$<CONFIG:DEBUG>:-Og;-pedantic;-fcheck=all;-W;-Wall;-Wno-unused-dummy-argument>")
|
2020-07-30 12:58:49 -03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
|
2020-08-23 20:23:04 -03:00
|
|
|
add_compile_options("$<$<CONFIG:RELEASE>:-xHost;-fp-model=source;-heap-arrays;-ip;-unroll-aggressive;-simd;-qopt-prefetch;-use-intel-optimized-headers;-finline-limit=1000;-fno-omit-frame-pointer>")
|
|
|
|
add_compile_options("$<$<CONFIG:DEBUG>:-O>")
|
|
|
|
add_compile_options(-assume byterecl)
|
2020-07-30 12:58:49 -03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI")
|
|
|
|
add_compile_options("$<$<CONFIG:RELEASE>:-fastsse;-O4;-Mvect=simd;-Minline=maxsize:1000>")
|
|
|
|
add_compile_options("$<$<CONFIG:DEBUG>:-O;-Minfo=all>")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
file(GLOB_RECURSE sources sources/*.F90)
|
|
|
|
add_executable(amun.x ${sources})
|
|
|
|
|
|
|
|
option(ENABLE_3D "Enables 3D domains" OFF)
|
|
|
|
if(ENABLE_3D)
|
|
|
|
target_compile_definitions(amun.x PRIVATE NDIMS=3)
|
|
|
|
else()
|
|
|
|
target_compile_definitions(amun.x PRIVATE NDIMS=2)
|
|
|
|
endif()
|
|
|
|
|
2021-09-12 12:02:04 -03:00
|
|
|
option(ENABLE_HDF5 "Enable HDF5 support" OFF)
|
2020-07-30 12:58:49 -03:00
|
|
|
if(ENABLE_HDF5)
|
|
|
|
find_package(HDF5 COMPONENTS Fortran)
|
|
|
|
if(HDF5_Fortran_FOUND)
|
|
|
|
include_directories(${HDF5_Fortran_INCLUDE_DIRS})
|
|
|
|
target_compile_definitions(amun.x PRIVATE HDF5)
|
|
|
|
target_link_libraries(amun.x ${HDF5_Fortran_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(ENABLE_MPI "Enable MPI support" ON)
|
|
|
|
if(ENABLE_MPI)
|
|
|
|
find_package(MPI COMPONENTS Fortran)
|
|
|
|
if(MPI_Fortran_FOUND)
|
|
|
|
include_directories(${MPI_Fortran_INCLUDE_DIRS})
|
|
|
|
target_compile_definitions(amun.x PRIVATE MPI)
|
|
|
|
target_link_libraries(amun.x ${MPI_Fortran_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-12-07 10:37:56 -03:00
|
|
|
option(ENABLE_OMP "Enable OpenMP support" ON)
|
|
|
|
if(ENABLE_OMP)
|
|
|
|
find_package(OpenMP COMPONENTS Fortran)
|
|
|
|
if(OpenMP_Fortran_FOUND)
|
|
|
|
include_directories(${OpenMP_Fortran_INCLUDE_DIRS})
|
|
|
|
target_compile_options(amun.x PRIVATE "${OpenMP_Fortran_FLAGS}")
|
|
|
|
target_link_libraries(amun.x ${OpenMP_Fortran_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-07-30 12:58:49 -03:00
|
|
|
option(ENABLE_SIGNALS "Enables signal handler support" ON)
|
|
|
|
if(ENABLE_SIGNALS)
|
|
|
|
target_compile_definitions(amun.x PRIVATE SIGNALS)
|
|
|
|
endif()
|
2020-08-10 16:48:31 -03:00
|
|
|
|
|
|
|
option(ENABLE_ZSTD "Enable Zstandard compression support" ON)
|
|
|
|
if(ENABLE_ZSTD)
|
|
|
|
include(FindPkgConfig)
|
|
|
|
pkg_search_module(ZSTD QUIET libzstd)
|
|
|
|
if(ZSTD_FOUND)
|
|
|
|
target_compile_definitions(amun.x PRIVATE ZSTD)
|
|
|
|
target_link_libraries(amun.x ${ZSTD_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-08-11 15:28:20 -03:00
|
|
|
|
|
|
|
option(ENABLE_LZ4 "Enable LZ4 compression support" ON)
|
|
|
|
if(ENABLE_LZ4)
|
|
|
|
include(FindPkgConfig)
|
|
|
|
pkg_search_module(LZ4 QUIET liblz4)
|
|
|
|
if(LZ4_FOUND)
|
|
|
|
target_compile_definitions(amun.x PRIVATE LZ4)
|
|
|
|
target_link_libraries(amun.x ${LZ4_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-08-13 15:42:07 -03:00
|
|
|
|
|
|
|
option(ENABLE_LZMA "Enable LZMA compression support" ON)
|
|
|
|
if(ENABLE_LZMA)
|
|
|
|
include(FindPkgConfig)
|
|
|
|
pkg_search_module(LZMA QUIET liblzma)
|
|
|
|
if(LZMA_FOUND)
|
|
|
|
target_compile_definitions(amun.x PRIVATE LZMA)
|
|
|
|
target_link_libraries(amun.x ${LZMA_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-11-18 23:15:51 -03:00
|
|
|
|
|
|
|
option(ENABLE_XXHASH "Enable system's XXHASH library" ON)
|
|
|
|
if(ENABLE_XXHASH)
|
|
|
|
include(FindPkgConfig)
|
|
|
|
pkg_search_module(XXHASH QUIET libxxhash)
|
|
|
|
if(XXHASH_FOUND)
|
|
|
|
target_compile_definitions(amun.x PRIVATE XXHASH)
|
|
|
|
target_link_libraries(amun.x ${XXHASH_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|