Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PUMLcube #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions pumlcube/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.10)

# set the project name
project(pumlcube)

# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

cmake_policy(SET CMP0074 NEW)


add_executable(pumlcube src/main.cpp)

#logging
set(LOG_LEVEL "info" CACHE STRING "Log level for the code")
set(LOG_LEVEL_OPTIONS "debug" "info" "warning" "error")
set_property(CACHE LOG_LEVEL PROPERTY STRINGS ${LOG_LEVEL_OPTIONS})
if("${LOG_LEVEL}" STREQUAL "debug")
target_compile_definitions(pumlcube PUBLIC LOG_LEVEL=3)
elseif("${LOG_LEVEL}" STREQUAL "info")
target_compile_definitions(pumlcube PUBLIC LOG_LEVEL=2)
elseif("${LOG_LEVEL}" STREQUAL "warning")
target_compile_definitions(pumlcube PUBLIC LOG_LEVEL=1)
elseif("${LOG_LEVEL}" STREQUAL "error")
target_compile_definitions(pumlcube PUBLIC LOG_LEVEL=0)
endif()

#build and link libraries and executable
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

find_package(HDF5 REQUIRED
COMPONENTS C HL)
target_include_directories(pumlcube PUBLIC ${HDF5_INCLUDE_DIRS})
target_link_libraries(pumlcube PUBLIC ${HDF5_C_HL_LIBRARIES} ${HDF5_C_LIBRARIES})

find_package(MPI REQUIRED)
target_link_libraries(pumlcube PUBLIC MPI::MPI_CXX)

find_package(OpenMP REQUIRED)
target_link_libraries(pumlcube PUBLIC OpenMP::OpenMP_CXX)

#add some compiler specific flags
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC
target_compile_options(pumlcube PUBLIC -fopenmp -pedantic $<$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:C>>:-Wall -Wextra -Wno-unused-parameter -Wno-unknown-pragmas>)
target_link_libraries(pumlcube PUBLIC "-fopenmp")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
target_compile_options(pumlcube PUBLIC -qopenmp -pedantic $<$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:C>>:-Wall -w3 -diag-disable:remark>)
target_link_libraries(pumlcube PUBLIC "-qopenmp")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp=libomp -Wall -Wextra -pedantic")
endif()

target_include_directories(pumlcube PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/submodules)
Loading