Skip to content

Commit

Permalink
whoops forgot cmake directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Dpgibney committed Dec 8, 2017
1 parent 5e29b2d commit 30d46dd
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
75 changes: 75 additions & 0 deletions cmake/autocmake_omp.cmake
@@ -0,0 +1,75 @@
# Downloaded from
# https://github.com/coderefinery/autocmake/blob/master/modules/omp.cmake
# * moved option up
# * toggled option default to ON
# * reorganized logic for Fortran + C/CXX, see https://github.com/coderefinery/autocmake/issues/177

#.rst:
#
# Enables OpenMP support.
#
# Variables used::
#
# ENABLE_OPENMP
# OPENMP_FOUND
#
# Variables modified (provided the corresponding language is enabled)::
#
# CMAKE_Fortran_FLAGS
# CMAKE_C_FLAGS
# CMAKE_CXX_FLAGS
#
# autocmake.yml configuration::
#
# docopt: "--omp Enable OpenMP parallelization [default: False]."
# define: "'-DENABLE_OPENMP={0}'.format(arguments['--omp'])"

if(ENABLE_OPENMP)

if(NOT OPENMP_FOUND)
find_package(OpenMP)
endif()

if(OPENMP_FOUND)
add_definitions(-DHAVE_OPENMP)
if(DEFINED CMAKE_C_COMPILER_ID)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
endif()
if(DEFINED CMAKE_CXX_COMPILER_ID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
if(DEFINED CMAKE_Fortran_COMPILER_ID)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
endif()
if(DEFINED CMAKE_CUDA_COMPILER_ID)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler='-fPIC -fopenmp' ${OpenMP_CUDA_FLAGS}")
endif()
endif()

if(DEFINED CMAKE_Fortran_COMPILER_ID AND NOT DEFINED OpenMP_Fortran_FLAGS)
# we do this in a pedestrian way because the Fortran support is relatively recent
if(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenmp")
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
if(WIN32)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Qopenmp")
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" AND
"${CMAKE_Fortran_COMPILER_VERSION}" VERSION_LESS "15.0.0.20140528")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -openmp")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qopenmp")
endif()
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES PGI)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp")
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES XL)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qsmp")
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES Cray)
# do nothing in this case
endif()
set(OPENMP_FOUND TRUE)
endif()
endif()
55 changes: 55 additions & 0 deletions cmake/gpu_dfccConfig.cmake.in
@@ -0,0 +1,55 @@
# gpu_dfccConfig.cmake
# -----------------------
#
# gpu_dfcc cmake module.
# This module sets the following variables in your project::
#
# gpu_dfcc_FOUND - true if gpu_dfcc and all required components found on the system
# gpu_dfcc_VERSION - gpu_dfcc version in format Major.Minor.Release
# gpu_dfcc_LIBRARIES - gpu_dfcc library to link against.
# gpu_dfcc_LIBRARY - same as LIBRARIES
#
#
# Available components: None
#
#
# Exported targets::
#
# If gpu_dfcc is found, this module defines the following :prop_tgt:`IMPORTED`
# target. ::
#
# gpu_dfcc::gpu_dfcc - the main gpu_dfcc library
#
#
# Suggested usage::
#
# find_package(gpu_dfcc)
# find_package(gpu_dfcc 0.5 EXACT CONFIG REQUIRED)
#
#
# The following variables can be set to guide the search for this package::
#
# gpu_dfcc_DIR - CMake variable, set to directory containing this Config file
# CMAKE_PREFIX_PATH - CMake variable, set to root directory of this package
## PATH - environment variable, set to bin directory of this package
# CMAKE_DISABLE_FIND_PACKAGE_gpu_dfcc - CMake variable, disables
# find_package(gpu_dfcc) when not REQUIRED, perhaps to force internal build

@PACKAGE_INIT@

set(PN gpu_dfcc)

check_required_components(${PN})

#-----------------------------------------------------------------------------
# Don't include targets if this file is being picked up by another
# project which has already built this as a subproject
#-----------------------------------------------------------------------------
if(NOT TARGET ${PN}::gpu_dfcc)
include("${CMAKE_CURRENT_LIST_DIR}/${PN}Targets.cmake")

get_property(_loc TARGET ${PN}::gpu_dfcc PROPERTY LOCATION)
set(${PN}_LIBRARY ${_loc})
set(${PN}_LIBRARIES ${_loc})
endif()

0 comments on commit 30d46dd

Please sign in to comment.