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

workflow cpp code: add option to support OpenMP #88

Open
fnrizzi opened this issue Feb 4, 2022 · 0 comments
Open

workflow cpp code: add option to support OpenMP #88

fnrizzi opened this issue Feb 4, 2022 · 0 comments

Comments

@fnrizzi
Copy link
Member

fnrizzi commented Feb 4, 2022

cmake_minimum_required(VERSION 3.16.0)
project(pdaCodeWorkFlow CXX)

#=====================================================================
# we need c++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# test if compiler supports standard
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORT_CPP14)
if(NOT COMPILER_SUPPORT_CPP14)
  message(FATAL_ERROR "Compiler does not support -std=c++14. This is required.")
endif()

#=====================================================================
# guard against in-source builds
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
  message(FATAL_ERROR "In-source builds are not allowed.
    Please make a new directory (e.g. build directory) and run CMake from there.")
endif()

# default to release if build type is empty
if (NOT CMAKE_BUILD_TYPE)
  message(STATUS "${CMAKE_BUILD_TYPE} is not specified, defaulting to Release.")
  set(CMAKE_BUILD_TYPE "Release")
endif()

# convert cmake build type to lower string
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower)
if( NOT cmake_build_type_tolower STREQUAL "debug"
    AND NOT cmake_build_type_tolower STREQUAL "release")
  message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\".
    Allowed values are Debug, Release (case-insensitive).")
endif()

#=====================================================================

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-yaml-cpp-0.7.0)

find_package(OpenMP)
if(NOT OpenMP_CXX_FOUND)
  message(FATAL_ERROR "You enabled OpenMP but I cannot find it")
endif()

include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}/../../include
  ${CMAKE_CURRENT_SOURCE_DIR}/../../tpls/eigen/eigen3
  ${CMAKE_CURRENT_SOURCE_DIR}/../../tpls/pressio/include
  ${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-yaml-cpp-0.7.0/include
  )

add_compile_definitions(PRESSIODEMOAPPS_ENABLE_OPENMP)
set(exename pdaExeWf)
add_executable(${exename} ${CMAKE_CURRENT_SOURCE_DIR}/main.cc)
target_link_libraries(${exename} PRIVATE yaml-cpp OpenMP::OpenMP_CXX)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant