diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..9da161df0c4b71173282ae84c3e42d346deb5783 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright 2015 + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..4b8e52b01158d02d2c31a6e62f6179cb6c58094e --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# PRACE HPC Kernels + +This project is part of PRACE CodeVault providing +example codes of common HPC kernels such as dense and sparse linear +algebra, spectral and N-body methods, structured and unstructured +grids, Monte Carlo methods and parallel I/O. The code samples are +published as open source and can be used both for educational purposes +and as parts of real application suites (as permitted by particular +license). + +## How to contribute + +Any contributions (new code samples, bug fixes, improvements etc.) are +warmly welcome. In order to contribute, please follow the standard +Gitlab workflow: + +1. Fork the project into your personal space +2. Create a feature branch +3. Work on your contributions +4. Push the commit(s) to your fork +5. Submit a merge request to the master branch + +## Compilation instructions + +The pre-requisites are: + +* CMake 2.8.10 or higher. CMake >= 3.0.0 if you want to build everything. +* A C++ compiler +* For advanced examples, C++11/14, OpenMP support, MPI, ISPC, CUDA, OpenCL ... + +In order to build the code, follow the typical CMake steps for an +out-of-source build: + +```bash +mkdir build +cd build +cmake .. +make +make install # optional +``` diff --git a/cmake/Modules/CorrectWindowsPaths.cmake b/cmake/Modules/CorrectWindowsPaths.cmake new file mode 100644 index 0000000000000000000000000000000000000000..09bcdd67dcd04fd001d2b7acbd904b5014ebe42b --- /dev/null +++ b/cmake/Modules/CorrectWindowsPaths.cmake @@ -0,0 +1,14 @@ +# CorrectWindowsPaths - this module defines one macro +# +# CONVERT_CYGWIN_PATH( PATH ) +# This uses the command cygpath (provided by cygwin) to convert +# unix-style paths into paths useable by cmake on windows + +macro (CONVERT_CYGWIN_PATH _path) + if (WIN32) + EXECUTE_PROCESS(COMMAND cygpath.exe -m ${${_path}} + OUTPUT_VARIABLE ${_path}) + string (STRIP ${${_path}} ${_path}) + endif (WIN32) +endmacro (CONVERT_CYGWIN_PATH) + diff --git a/cmake/Modules/FindCommon.cmake b/cmake/Modules/FindCommon.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6592f4198925daaed245af44af20b1b884ed2bb3 --- /dev/null +++ b/cmake/Modules/FindCommon.cmake @@ -0,0 +1,68 @@ + +function(clone_source src dst) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${dst} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${CMAKE_CURRENT_BINARY_DIR}/${dst} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${src} + COMMENT "Clone ${src} to ${dst}" + ) +endfunction() + +function(dummy_install target_name lib_name) + install(CODE "MESSAGE(\"${target_name} can only be built with ${lib_name}.\")") +endfunction() + +macro(get_sources_and_options _sources _option_list _option_name) + set( ${_sources} ) + set( ${_option_list} ) + set( _found_options False) + foreach(arg ${ARGN}) + if ("x${arg}" STREQUAL "x${_option_name}") + set (_found_options True) + else() + if (_found_options) + list(APPEND ${_option_list} ${arg}) + else() + list(APPEND ${_sources} ${arg}) + endif() + endif() + endforeach() +endmacro() + +# MACRO picks correct compiler flags. For example +# select_compiler_flags(cxx_flags +# GNU "-std=c++11 -mnative -Wall -Werror" +# Intel "-std=c++11 -axavx,core-avx2" +# CLANG "-std=c++11 -Weverything" +# PGI "-std=c++11" +# ) +macro(select_compiler_flags _flags) + set( ${_flags} ) + + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(_compiler "GNU") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(_compiler "CLANG") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + set(_compiler "CLANG") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + set(_compiler "Intel") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(_compiler "MSCV") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI") + set(_compiler "PGI") + endif() + + set (_found_compiler False) + foreach(arg ${ARGN}) + if ("x${arg}" STREQUAL "x${_compiler}") + set(_found_compiler True) + else() + if (_found_compiler) + set(${_flags} ${arg}) + set(_found_compiler False) + endif() + endif() + endforeach() +endmacro() + diff --git a/cmake/Modules/FindFFTW.cmake b/cmake/Modules/FindFFTW.cmake new file mode 100644 index 0000000000000000000000000000000000000000..7219e09698ffb33be02fada7beb202f6f5b4a9e9 --- /dev/null +++ b/cmake/Modules/FindFFTW.cmake @@ -0,0 +1,67 @@ + +# ================================================================================================== +# This file is part of the CodeVault project. The project is licensed under Apache Version 2.0. +# CodeVault is part of the EU-project PRACE-4IP (WP7.3.C). +# +# Author(s): +# Cedric Nugteren +# +# ================================================================================================== +# +# Defines the following variables: +# FFTW_FOUND Boolean holding whether or not the FFTW3 library was found +# FFTW_INCLUDE_DIRS The FFTW3 include directory +# FFTW_LIBRARIES The FFTW3 library +# +# In case FFTW3 is not installed in the default directory, set the FFTW_ROOT variable to point to +# the root of FFTW3, such that 'fftw3.h' can be found in $FFTW_ROOT/include. This can either be done +# using an environmental variable (e.g. export FFTW_ROOT=/path/to/fftw3) or using a CMake variable +# (e.g. cmake -DFFTW_ROOT=/path/to/fftw3 ..). +# +# ================================================================================================== + +# Sets the possible install locations +set(FFTW_HINTS + ${FFTW_ROOT} + $ENV{FFTW_ROOT} +) +set(FFTW_PATHS + /usr + /usr/local +) + +# Finds the include directories +find_path(FFTW_INCLUDE_DIRS + NAMES fftw3.h + HINTS ${FFTW_HINTS} + PATH_SUFFIXES include api inc include/x86_64 include/x64 + PATHS ${FFTW_PATHS} + DOC "FFTW3 include header fftw3.h" +) +mark_as_advanced(FFTW_INCLUDE_DIRS) + +# Finds the library +find_library(FFTW_LIBRARIES + NAMES fftw3 + HINTS ${FFTW_HINTS} + PATH_SUFFIXES lib lib64 lib/x86_64 lib/x64 lib/x86 lib/Win32 + PATHS ${FFTW_PATHS} + DOC "FFTW3 library" +) +mark_as_advanced(FFTW_LIBRARIES) + +# ================================================================================================== + +# Notification messages +if(NOT FFTW_INCLUDE_DIRS) + message(STATUS "Could NOT find 'fftw3.h', install FFTW3 or set FFTW_ROOT") +endif() +if(NOT FFTW_LIBRARIES) + message(STATUS "Could NOT find the FFTW3 library, install it or set FFTW_ROOT") +endif() + +# Determines whether or not FFTW3 was found +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FFTW DEFAULT_MSG FFTW_INCLUDE_DIRS FFTW_LIBRARIES) + +# ================================================================================================== diff --git a/cmake/Modules/FindISPC.cmake b/cmake/Modules/FindISPC.cmake new file mode 100644 index 0000000000000000000000000000000000000000..1d783cbb4decef6c6d58017a10a08c9896dc0f78 --- /dev/null +++ b/cmake/Modules/FindISPC.cmake @@ -0,0 +1,146 @@ +find_package(Common) + + +SET(ISPC_VERSION_REQUIRED "1.8.2") + +IF (NOT ISPC_EXECUTABLE) + # if ($ENV{ISPC}) + # FIND_PROGRAM(ISPC_EXECUTABLE NAME ispc PATH $ENV{ISPC} DOC "Path to the ISPC executable.") + # endif() + FIND_PROGRAM(ISPC_EXECUTABLE ispc DOC "Path to the ISPC executable.") + IF (NOT ISPC_EXECUTABLE) + MESSAGE(STATUS "Intel SPMD Compiler (ISPC) is not found.") + ELSE() + MESSAGE(STATUS "Found Intel SPMD Compiler (ISPC): ${ISPC_EXECUTABLE}") + set(ISPC_FOUND True) + ENDIF() +ENDIF() + + +if (NOT ISPC_EXECUTABLE) + set(ISPC_FOUND False) +else(NOT ISPC_EXECUTABLE) + set(ISPC_FOUND True) + IF(NOT ISPC_VERSION) + EXECUTE_PROCESS(COMMAND ${ISPC_EXECUTABLE} --version OUTPUT_VARIABLE ISPC_OUTPUT) + STRING(REGEX MATCH " ([0-9]+[.][0-9]+[.][0-9]+)(dev|knl|ptx)? " DUMMY "${ISPC_OUTPUT}") + SET(ISPC_VERSION ${CMAKE_MATCH_1}) + + #IF (ISPC_VERSION VERSION_LESS ISPC_VERSION_REQUIRED) + # MESSAGE(FATAL_ERROR "Need at least version ${ISPC_VERSION_REQUIRED} of Intel SPMD Compiler (ISPC).") + # ENDIF() + MESSAGE(STATUS "Found ISPC version ${ISPC_VERSION}") + + SET(ISPC_VERSION ${ISPC_VERSION} CACHE STRING "ISPC Version") + MARK_AS_ADVANCED(ISPC_VERSION) + MARK_AS_ADVANCED(ISPC_EXECUTABLE) + ENDIF() + + function(ispc_compile _obj_list) + get_sources_and_options(sources compile_flags "COMPILE_FLAGS" ${ARGN}) + + set(__XEON__ True) + + IF (__XEON__) + SET (ISPC_TARGET_EXT ${CMAKE_CXX_OUTPUT_EXTENSION}) + ELSE() + SET (ISPC_TARGET_EXT .cpp) + SET (ISPC_ADDITIONAL_ARGS ${ISPC_ADDITIONAL_ARGS} --opt=force-aligned-memory) + ENDIF() + + IF (CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(ISPC_ARCHITECTURE "x86-64") + ELSE() + SET(ISPC_ARCHITECTURE "x86") + ENDIF() + + SET(ISPC_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR}) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${ISPC_TARGET_DIR}) + + IF(ISPC_INCLUDE_DIR) + STRING(REPLACE ";" ";-I;" ISPC_INCLUDE_DIR_PARMS "${ISPC_INCLUDE_DIR}") + SET(ISPC_INCLUDE_DIR_PARMS "-I" ${ISPC_INCLUDE_DIR_PARMS}) + ENDIF() + + set(___XEON___ True) + IF (__XEON__) + STRING(REPLACE ";" "," ISPC_TARGET_ARGS "${ISPC_TARGETS}") + ELSE() + # SET(ISPC_TARGET_ARGS generic-16) + #SET(ISPC_ADDITIONAL_ARGS ${ISPC_ADDITIONAL_ARGS} --emit-c++ -D__XEON_PHI__ --c++-include-file=${ISPC_DIR}/examples/intrinsics/knc.h)j + ENDIF() + + SET(ISPC_OBJECTS ${${_obj_list}}) + + foreach (src ${sources}) + get_filename_component(fname ${src} NAME_WE) + get_filename_component(dir ${src} PATH) + + IF("${dir}" STREQUAL "") + SET(outdir ${ISPC_TARGET_DIR}) + ELSE("${dir}" STREQUAL "") + SET(outdir ${ISPC_TARGET_DIR}/${dir}) + ENDIF("${dir}" STREQUAL "") + SET(outdirh ${ISPC_TARGET_DIR}) + + SET(deps "") + IF (EXISTS ${outdir}/${fname}.dev.idep) + FILE(READ ${outdir}/${fname}.dev.idep contents) + STRING(REPLACE " " ";" contents "${contents}") + STRING(REPLACE ";" "\\\\;" contents "${contents}") + STRING(REPLACE "\n" ";" contents "${contents}") + FOREACH(dep ${contents}) + IF (EXISTS ${dep}) + SET(deps ${deps} ${dep}) + ENDIF (EXISTS ${dep}) + ENDFOREACH(dep ${contents}) + ENDIF () + + SET(results "${outdir}/${fname}.dev${ISPC_TARGET_EXT}") + + # if we have multiple targets add additional object files + IF (__XEON__) + LIST(LENGTH ISPC_TARGETS NUM_TARGETS) + IF (NUM_TARGETS GREATER 1) + FOREACH(target ${ISPC_TARGETS}) + SET(results ${results} "${outdir}/${fname}.dev_${target}${ISPC_TARGET_EXT}") + ENDFOREACH() + ENDIF() + ENDIF() + + IF (WIN32) + SET(ISPC_ADDITIONAL_ARGS ${ISPC_ADDITIONAL_ARGS} --dllexport) + ELSE() + SET(ISPC_ADDITIONAL_ARGS ${ISPC_ADDITIONAL_ARGS} --pic) + ENDIF() + + separate_arguments(compile_flags) + + ADD_CUSTOM_COMMAND( + OUTPUT ${results} ${outdirh}/${fname}_ispc.h + COMMAND ${CMAKE_COMMAND} -E make_directory ${outdir} + COMMAND ${ISPC_EXECUTABLE} + ${compile_flags} + -I ${CMAKE_CURRENT_SOURCE_DIR} + ${ISPC_INCLUDE_DIR_PARMS} + --arch=${ISPC_ARCHITECTURE} + # --addressing=${EMBREE_ISPC_ADDRESSING} + # -O3 + #--target=${ISPC_TARGET_ARGS} + #--woff + # --opt=fast-math + ${ISPC_ADDITIONAL_ARGS} + -h ${outdirh}/${fname}_ispc.h + -MMM ${outdir}/${fname}.dev.idep + -o ${outdir}/${fname}.dev${ISPC_TARGET_EXT} + ${CMAKE_CURRENT_SOURCE_DIR}/${src} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${deps} + COMMENT "Building ISPC object ${outdir}/${fname}.dev${ISPC_TARGET_EXT}" + ) + + SET(ISPC_OBJECTS ${ISPC_OBJECTS} ${results}) + endforeach() + + set(${_obj_list} ${ISPC_OBJECTS} PARENT_SCOPE) + endfunction() +endif(NOT ISPC_EXECUTABLE) diff --git a/cmake/Modules/FindIntelCompilers.cmake b/cmake/Modules/FindIntelCompilers.cmake new file mode 100644 index 0000000000000000000000000000000000000000..1b407e56404b9a4393217a648571f51e5fda4583 --- /dev/null +++ b/cmake/Modules/FindIntelCompilers.cmake @@ -0,0 +1,54 @@ + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/Languages") +enable_language(ICPC OPTIONAL) +enable_language(IFORT OPTIONAL) + +find_package(Common) + +set(ICPC_FOUND True) +if (${CMAKE_ICPC_COMPILER} STREQUAL "CMAKE_ICPC_COMPILER-NOTFOUND") + set(ICPC_FOUND False) +else() + function(icpc_sources) + get_sources_and_options(sources compile_flags "COMPILE_FLAGS" ${ARGN}) + set_source_files_properties(${sources} PROPERTIES LANGUAGE ICPC) + foreach (file ${sources}) + set_property(SOURCE ${file} APPEND_STRING PROPERTY COMPILE_FLAGS " -I${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_CXX_FLAGS} ${compile_flags} ") + endforeach() + endfunction() + function(icpc_add_executable icpc_target) + get_sources_and_options(sources link_flags "LINK_FLAGS" ${ARGN}) + add_executable(${icpc_target} ${sources}) + set_target_properties(${icpc_target} PROPERTIES LINKER_LANGUAGE ICPC) + set_property(TARGET ${icpc_target} APPEND_STRING PROPERTY LINK_FLAGS " ${link_flags} ") + endfunction() +endif() + +set(IFORT_FOUND True) +if (${CMAKE_IFORT_COMPILER} STREQUAL "CMAKE_IFORT_COMPILER-NOTFOUND") + set(IFORT_FOUND False) +else() + #function(ifort_sources) + #set_source_files_properties(${ARGN} PROPERTIES LANGUAGE IFORT) + #endfunction() + #function(ifort_add_executable ifort_target) + #add_executable(${ifort_target} ${ARGN}) + #set_target_properties(${ifort_target} PROPERTIES LINKER_LANGUAGE IFORT) + # endfunction() + + function(ifort_sources) + get_sources_and_options(sources compile_flags "COMPILE_FLAGS" ${ARGN}) + set_source_files_properties(${sources} PROPERTIES LANGUAGE IFORT) + foreach (file ${sources}) + set_property(SOURCE ${file} APPEND_STRING PROPERTY COMPILE_FLAGS " ${compile_flags} ") + endforeach() + endfunction() + function(ifort_add_executable ifort_target) + get_sources_and_options(sources link_flags "LINK_FLAGS" ${ARGN}) + add_executable(${ifort_target} ${sources}) + set_target_properties(${ifort_target} PROPERTIES LINKER_LANGUAGE IFORT) + set_property(TARGET ${ifort_target} APPEND_STRING PROPERTY LINK_FLAGS " ${link_flags} ") + endfunction() +endif() + + diff --git a/cmake/Modules/FindLibMesh.cmake b/cmake/Modules/FindLibMesh.cmake new file mode 100755 index 0000000000000000000000000000000000000000..91456e209f5b61345d880e0db74cba2cfb35b646 --- /dev/null +++ b/cmake/Modules/FindLibMesh.cmake @@ -0,0 +1,112 @@ +#(C) https://github.com/capitalaslash/cmake-modules/blob/master/FindLibmesh.cmake +# (BSD - License) + +# - Try to find Libmesh +# Once done this will define +# +# LIBMESH_FOUND - Libmesh has been successfully found +# LIBMESH_INCLUDE_DIRS - Libmesh include directories +# LIBMESH_LIBRARIES - Libmesh libraries +# LIBMESH_DEFINITIONS - Libmesh definitions +# LIBMESH_FLAGS - Libmesh flags +# LIBMESH_VERSION_STRING - Libmesh version +# +# Usage: +# find_package(Libmesh) +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE NONE) +endif() +string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UPPER) +if(${BUILD_TYPE_UPPER} MATCHES DEBUG) + set(METHOD dbg) +else() + set(METHOD opt) +endif() +set(METHOD opt) +#message(STATUS "linking against ${METHOD} libmesh library") + +# required for LIBMESH_DEFINITIONS +find_package(PkgConfig REQUIRED) + +set(LIBMESH_DIR LIBMESH_DIR-NOTFOUND CACHE PATH "Libmesh installation directory") + +if(LIBMESH_DIR) + set(ENV{PKG_CONFIG_PATH} ${LIBMESH_DIR}/lib/pkgconfig) + message($ENV{PKG_CONFIG_PATH}) +endif() + +pkg_check_modules(PC_LIBMESH libmesh-${METHOD}) +#message(STATUS "PC_LIBMESH_FOUND = ${PC_LIBMESH_FOUND}") +#message(STATUS "PC_LIBMESH_LIBRARIES = ${PC_LIBMESH_LIBRARIES}") +#message(STATUS "PC_LIBMESH_LIBRARY_DIRS = ${PC_LIBMESH_LIBRARY_DIRS}") + +# distinguish flags and definitions (-D...) +#message(STATUS "PC_LIBMESH_CFLAGS_OTHER = ${PC_LIBMESH_CFLAGS_OTHER}") +foreach(FLAG ${PC_LIBMESH_CFLAGS_OTHER}) + if(${FLAG} MATCHES "^[-][D].+") + set(PC_LIBMESH_CFLAGS_DEFS "${PC_LIBMESH_CFLAGS_DEFS} ${FLAG}") + else() + set(PC_LIBMESH_CFLAGS_FLAGS "${PC_LIBMESH_CFLAGS_FLAGS} ${FLAG}") + endif() +endforeach() +set(LIBMESH_DEFINITIONS ${PC_LIBMESH_CFLAGS_DEFS}) +set(LIBMESH_FLAGS ${PC_LIBMESH_CFLAGS_FLAGS}) + +find_path(LIBMESH_INCLUDE_DIR libmesh/libmesh.h + HINTS ${PC_LIBMESH_INCLUDEDIR} ${PC_LIBMESH_INCLUDE_DIRS} + PATH_SUFFIXES libmesh +) + +find_library(LIBMESH_LIBRARY + NAMES mesh_${METHOD} libmesh + HINTS ${PC_LIBMESH_LIBDIR} ${PC_LIBMESH_LIBARY_DIRS} +) + +set(LIBMESH_LIBRARIES ${LIBMESH_LIBRARY}) +set(LIBMESH_INCLUDE_DIRS ${LIBMESH_INCLUDE_DIR}) + +find_program( LIBMESH_CONFIG_EXECUTABLE + NAMES libmesh-config + HINTS ${LIBMESH_DIR} $ENV{LIBMESH_DIR} + PATH_SUFFIXES bin + DOC "libmesh-config executable" +) +mark_as_advanced( LIBMESH_CONFIG_EXECUTABLE ) + +exec_program( ${LIBMESH_CONFIG_EXECUTABLE} + ARGS --include + OUTPUT_VARIABLE LMC_INC_FLAG + RETURN_VALUE LMC_INC_RET +) +string(REPLACE " " ";" LMC_INC_LIST ${LMC_INC_FLAG}) +foreach( IPATH ${LMC_INC_LIST} ) + string(REGEX REPLACE "^-I" "" IPATH ${IPATH}) + string(REGEX REPLACE "//" "/" IPATH ${IPATH}) + list(APPEND LM_INC ${IPATH}) +endforeach() +set(LIBMESH_INCLUDE_DIRS ${LM_INC}) + +if(PC_LIBMESH_VERSION) + set(LIBMESH_VERSION_STRING ${PC_LIBMESH_VERSION}) +endif() + +# handle the QUIETLY and REQUIRED arguments and set LIBMESH_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libmesh + FOUND_VAR LIBMESH_FOUND + REQUIRED_VARS LIBMESH_LIBRARIES LIBMESH_INCLUDE_DIRS LIBMESH_DEFINITIONS + LIBMESH_FLAGS + VERSION_VAR LIBMESH_VERSION_STRING +) + +mark_as_advanced( + LIBMESH_INCLUDE_DIR + LIBMESH_LIBRARIES + LIBMESH_CONFIG_EXECUTABLE +) \ No newline at end of file diff --git a/cmake/Modules/FindMKL.cmake b/cmake/Modules/FindMKL.cmake new file mode 100644 index 0000000000000000000000000000000000000000..943546d9f3805811493dff167f30d5750fe169c8 --- /dev/null +++ b/cmake/Modules/FindMKL.cmake @@ -0,0 +1,74 @@ +# a simple cmake script to locate Intel Math Kernel Library + +# This script looks for two places: +# - the environment variable MKLROOT +# - the directory /opt/intel/mkl + + +# Stage 1: find the root directory + +set(MKLROOT_PATH $ENV{MKLROOT}) + +if (NOT MKLROOT_PATH) + # try to find at /opt/intel/mkl + + if (EXISTS "/opt/intel/mkl") + set(MKLROOT_PATH "/opt/intel/mkl") + endif (EXISTS "/opt/intel/mkl") +endif (NOT MKLROOT_PATH) + + +# Stage 2: find include path and libraries + +if (MKLROOT_PATH) + # root-path found + + set(EXPECT_MKL_INCPATH "${MKLROOT_PATH}/include") + + if (CMAKE_SYSTEM_NAME MATCHES "Darwin") + set(EXPECT_MKL_LIBPATH "${MKLROOT_PATH}/lib") + endif (CMAKE_SYSTEM_NAME MATCHES "Darwin") + + set(EXPECT_ICC_LIBPATH "$ENV{ICC_LIBPATH}") + + if (CMAKE_SYSTEM_NAME MATCHES "Linux") + if (CMAKE_SIZEOF_VOID_P MATCHES 8) + set(EXPECT_MKL_LIBPATH "${MKLROOT_PATH}/lib/intel64") + else (CMAKE_SIZEOF_VOID_P MATCHES 8) + set(EXPECT_MKL_LIBPATH "${MKLROOT_PATH}/lib/ia32") + endif (CMAKE_SIZEOF_VOID_P MATCHES 8) + endif (CMAKE_SYSTEM_NAME MATCHES "Linux") + + # set include + + if (IS_DIRECTORY ${EXPECT_MKL_INCPATH}) + set(MKL_INCLUDE_DIR ${EXPECT_MKL_INCPATH}) + endif (IS_DIRECTORY ${EXPECT_MKL_INCPATH}) + + if (IS_DIRECTORY ${EXPECT_MKL_LIBPATH}) + set(MKL_LIBRARY_DIR ${EXPECT_MKL_LIBPATH}) + endif (IS_DIRECTORY ${EXPECT_MKL_LIBPATH}) + + # find specific library files + + find_library(LIB_MKL_RT NAMES mkl_rt HINTS ${MKL_LIBRARY_DIR}) + find_library(LIB_PTHREAD NAMES pthread) + +endif (MKLROOT_PATH) + +set(MKL_LIBRARY + ${LIB_MKL_RT} + ${LIB_PTHREAD}) + +# deal with QUIET and REQUIRED argument + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(MKL DEFAULT_MSG + MKL_LIBRARY_DIR + LIB_MKL_RT + LIB_PTHREAD + MKL_INCLUDE_DIR) + +mark_as_advanced(LIB_MKL_RT LIB_PTHREAD MKL_INCLUDE_DIR) + diff --git a/cmake/Modules/FindOpenCL.cmake b/cmake/Modules/FindOpenCL.cmake new file mode 100644 index 0000000000000000000000000000000000000000..02af6d19f251dd5412c203c0deb82e882c97369d --- /dev/null +++ b/cmake/Modules/FindOpenCL.cmake @@ -0,0 +1,74 @@ + +# ================================================================================================== +# This file is part of the CodeVault project. The project is licensed under Apache Version 2.0. +# CodeVault is part of the EU-project PRACE-4IP (WP7.3.C). +# +# Author(s): +# Cedric Nugteren +# +# ================================================================================================== +# +# Defines the following variables: +# OPENCL_FOUND Boolean holding whether or not the OpenCL library was found +# OPENCL_INCLUDE_DIRS The OpenCL include directory +# OPENCL_LIBRARIES The OpenCL library +# +# In case OpenCL is not installed in the default directory, set the OPENCL_ROOT variable to point to +# the root of OpenCL, such that 'OpenCL/cl.h' or 'CL/cl.h' can be found in $OPENCL_ROOT/include. +# This can either be done using an environmental variable (e.g. export OPENCL_ROOT=/path/to/opencl) +# or using a CMake variable (e.g. cmake -DOPENCL_ROOT=/path/to/opencl ..). +# +# ================================================================================================== + +# Sets the possible install locations +set(OPENCL_HINTS + ${OPENCL_ROOT} + $ENV{OPENCL_ROOT} + $ENV{AMDAPPSDKROOT} + $ENV{CUDA_PATH} + $ENV{INTELOCLSDKROOT} + $ENV{NVSDKCOMPUTE_ROOT} + $ENV{ATISTREAMSDKROOT} +) +set(OPENCL_PATHS + /usr/local/cuda + /opt/cuda + /usr + /usr/local +) + +# Finds the include directories +find_path(OPENCL_INCLUDE_DIRS + NAMES OpenCL/cl.h CL/cl.h + HINTS ${OPENCL_HINTS} + PATH_SUFFIXES include OpenCL/common/inc inc include/x86_64 include/x64 + PATHS ${OPENCL_PATHS} + DOC "OpenCL include header OpenCL/cl.h or CL/cl.h" +) +mark_as_advanced(OPENCL_INCLUDE_DIRS) + +# Finds the library +find_library(OPENCL_LIBRARIES + NAMES OpenCL + HINTS ${OPENCL_HINTS} + PATH_SUFFIXES lib lib64 lib/x86_64 lib/x64 lib/x86 lib/Win32 OpenCL/common/lib/x64 + PATHS ${OPENCL_PATHS} + DOC "OpenCL library" +) +mark_as_advanced(OPENCL_LIBRARIES) + +# ================================================================================================== + +# Notification messages +if(NOT OPENCL_INCLUDE_DIRS) + message(STATUS "Could NOT find 'OpenCL/cl.h' or 'CL/cl.h', install OpenCL or set OPENCL_ROOT") +endif() +if(NOT OPENCL_LIBRARIES) + message(STATUS "Could NOT find OpenCL library, install it or set OPENCL_ROOT") +endif() + +# Determines whether or not OpenCL was found +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OpenCL DEFAULT_MSG OPENCL_INCLUDE_DIRS OPENCL_LIBRARIES) + +# ================================================================================================== diff --git a/cmake/Modules/FindPETSc.cmake b/cmake/Modules/FindPETSc.cmake new file mode 100644 index 0000000000000000000000000000000000000000..ac83daed7cba18d511a23b4fb960e2b3c679177d --- /dev/null +++ b/cmake/Modules/FindPETSc.cmake @@ -0,0 +1,329 @@ +# - Try to find PETSc +# Once done this will define +# +# PETSC_FOUND - system has PETSc +# PETSC_INCLUDES - the PETSc include directories +# PETSC_LIBRARIES - Link these to use PETSc +# PETSC_COMPILER - Compiler used by PETSc, helpful to find a compatible MPI +# PETSC_DEFINITIONS - Compiler switches for using PETSc +# PETSC_MPIEXEC - Executable for running MPI programs +# PETSC_VERSION - Version string (MAJOR.MINOR.SUBMINOR) +# +# Usage: +# find_package(PETSc COMPONENTS CXX) - required if build --with-clanguage=C++ --with-c-support=0 +# find_package(PETSc COMPONENTS C) - standard behavior of checking build using a C compiler +# find_package(PETSc) - same as above +# +# Setting these changes the behavior of the search +# PETSC_DIR - directory in which PETSc resides +# PETSC_ARCH - build architecture +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +set(PETSC_VALID_COMPONENTS + C + CXX) + +if(NOT PETSc_FIND_COMPONENTS) + set(PETSC_LANGUAGE_BINDINGS "C") +else() + # Right now, this is designed for compatability with the --with-clanguage option, so + # only allow one item in the components list. + list(LENGTH ${PETSc_FIND_COMPONENTS} components_length) + if(${components_length} GREATER 1) + message(FATAL_ERROR "Only one component for PETSc is allowed to be specified") + endif() + # This is a stub for allowing multiple components should that time ever come. Perhaps + # to also test Fortran bindings? + foreach(component ${PETSc_FIND_COMPONENTS}) + list(FIND PETSC_VALID_COMPONENTS ${component} component_location) + if(${component_location} EQUAL -1) + message(FATAL_ERROR "\"${component}\" is not a valid PETSc component.") + else() + list(APPEND PETSC_LANGUAGE_BINDINGS ${component}) + endif() + endforeach() +endif() + +function (petsc_get_version) + if (EXISTS "${PETSC_DIR}/include/petscversion.h") + file (STRINGS "${PETSC_DIR}/include/petscversion.h" vstrings REGEX "#define PETSC_VERSION_(RELEASE|MAJOR|MINOR|SUBMINOR|PATCH) ") + foreach (line ${vstrings}) + string (REGEX REPLACE " +" ";" fields ${line}) # break line into three fields (the first is always "#define") + list (GET fields 1 var) + list (GET fields 2 val) + set (${var} ${val} PARENT_SCOPE) + set (${var} ${val}) # Also in local scope so we have access below + endforeach () + if (PETSC_VERSION_RELEASE) + set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}p${PETSC_VERSION_PATCH}" PARENT_SCOPE) + else () + # make dev version compare higher than any patch level of a released version + set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}.99" PARENT_SCOPE) + endif () + else () + message (SEND_ERROR "PETSC_DIR can not be used, ${PETSC_DIR}/include/petscversion.h does not exist") + endif () +endfunction () + +find_path (PETSC_DIR include/petsc.h + HINTS ENV PETSC_DIR + PATHS + # Debian paths + /usr/lib/petscdir/3.5.1 /usr/lib/petscdir/3.5 + /usr/lib/petscdir/3.4.2 /usr/lib/petscdir/3.4 + /usr/lib/petscdir/3.3 /usr/lib/petscdir/3.2 /usr/lib/petscdir/3.1 + /usr/lib/petscdir/3.0.0 /usr/lib/petscdir/2.3.3 /usr/lib/petscdir/2.3.2 + # MacPorts path + /opt/local/lib/petsc + $ENV{HOME}/petsc + DOC "PETSc Directory") + +find_program (MAKE_EXECUTABLE NAMES make gmake) + +if (PETSC_DIR AND NOT PETSC_ARCH) + set (_petsc_arches + $ENV{PETSC_ARCH} # If set, use environment variable first + linux-gnu-c-debug linux-gnu-c-opt # Debian defaults + x86_64-unknown-linux-gnu i386-unknown-linux-gnu) + set (petscconf "NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + foreach (arch ${_petsc_arches}) + if (NOT PETSC_ARCH) + find_path (petscconf petscconf.h + HINTS ${PETSC_DIR} + PATH_SUFFIXES ${arch}/include bmake/${arch} + NO_DEFAULT_PATH) + if (petscconf) + set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture") + endif (petscconf) + endif (NOT PETSC_ARCH) + endforeach (arch) + set (petscconf "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE) +endif (PETSC_DIR AND NOT PETSC_ARCH) + +set (petsc_slaves LIBRARIES_SYS LIBRARIES_VEC LIBRARIES_MAT LIBRARIES_DM LIBRARIES_KSP LIBRARIES_SNES LIBRARIES_TS + INCLUDE_DIR INCLUDE_CONF) +include (FindPackageMultipass) +find_package_multipass (PETSc petsc_config_current + STATES DIR ARCH + DEPENDENTS INCLUDES LIBRARIES COMPILER MPIEXEC ${petsc_slaves}) + +# Determine whether the PETSc layout is old-style (through 2.3.3) or +# new-style (>= 3.0.0) +if (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscvariables") # > 3.5 + set (petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules") + set (petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables") +elseif (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h") # > 2.3.3 + set (petsc_conf_rules "${PETSC_DIR}/conf/rules") + set (petsc_conf_variables "${PETSC_DIR}/conf/variables") +elseif (EXISTS "${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h") # <= 2.3.3 + set (petsc_conf_rules "${PETSC_DIR}/bmake/common/rules") + set (petsc_conf_variables "${PETSC_DIR}/bmake/common/variables") +elseif (PETSC_DIR) + message (SEND_ERROR "The pair PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} do not specify a valid PETSc installation") +endif () + +if (petsc_conf_rules AND petsc_conf_variables AND NOT petsc_config_current) + petsc_get_version() + + # Put variables into environment since they are needed to get + # configuration (petscvariables) in the PETSc makefile + set (ENV{PETSC_DIR} "${PETSC_DIR}") + set (ENV{PETSC_ARCH} "${PETSC_ARCH}") + + # A temporary makefile to probe the PETSc configuration + set (petsc_config_makefile "${PROJECT_BINARY_DIR}/Makefile.petsc") + file (WRITE "${petsc_config_makefile}" +"## This file was autogenerated by FindPETSc.cmake +# PETSC_DIR = ${PETSC_DIR} +# PETSC_ARCH = ${PETSC_ARCH} +include ${petsc_conf_rules} +include ${petsc_conf_variables} +show : +\t-@echo -n \${\${VARIABLE}} +") + + macro (PETSC_GET_VARIABLE name var) + set (${var} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) + execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} show VARIABLE=${name} + OUTPUT_VARIABLE ${var} + RESULT_VARIABLE petsc_return) + endmacro (PETSC_GET_VARIABLE) + petsc_get_variable (PETSC_LIB_DIR petsc_lib_dir) + petsc_get_variable (PETSC_EXTERNAL_LIB_BASIC petsc_libs_external) + petsc_get_variable (PETSC_CCPPFLAGS petsc_cpp_line) + petsc_get_variable (PETSC_INCLUDE petsc_include) + petsc_get_variable (PCC petsc_cc) + petsc_get_variable (PCC_FLAGS petsc_cc_flags) + petsc_get_variable (MPIEXEC petsc_mpiexec) + # We are done with the temporary Makefile, calling PETSC_GET_VARIABLE after this point is invalid! + file (REMOVE ${petsc_config_makefile}) + + include (ResolveCompilerPaths) + # Extract include paths and libraries from compile command line + resolve_includes (petsc_includes_all "${petsc_cpp_line}") + + #on windows we need to make sure we're linking against the right + #runtime library + if (WIN32) + if (petsc_cc_flags MATCHES "-MT") + set(using_md False) + foreach(flag_var + CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + set(using_md True) + endif(${flag_var} MATCHES "/MD") + endforeach(flag_var) + if(${using_md} MATCHES "True") + message(WARNING "PETSc was built with /MT, but /MD is currently set. + See http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F") + endif(${using_md} MATCHES "True") + endif (petsc_cc_flags MATCHES "-MT") + endif (WIN32) + + include (CorrectWindowsPaths) + convert_cygwin_path(petsc_lib_dir) + message (STATUS "petsc_lib_dir ${petsc_lib_dir}") + + macro (PETSC_FIND_LIBRARY suffix name) + set (PETSC_LIBRARY_${suffix} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # Clear any stale value, if we got here, we need to find it again + if (WIN32) + set (libname lib${name}) #windows expects "libfoo", linux expects "foo" + else (WIN32) + set (libname ${name}) + endif (WIN32) + find_library (PETSC_LIBRARY_${suffix} NAMES ${libname} HINTS ${petsc_lib_dir} NO_DEFAULT_PATH) + set (PETSC_LIBRARIES_${suffix} "${PETSC_LIBRARY_${suffix}}") + mark_as_advanced (PETSC_LIBRARY_${suffix}) + endmacro (PETSC_FIND_LIBRARY suffix name) + + # Look for petscvec first, if it doesn't exist, we must be using single-library + petsc_find_library (VEC petscvec) + if (PETSC_LIBRARY_VEC) + petsc_find_library (SYS "petscsys;petsc") # libpetscsys is called libpetsc prior to 3.1 (when single-library was introduced) + petsc_find_library (MAT petscmat) + petsc_find_library (DM petscdm) + petsc_find_library (KSP petscksp) + petsc_find_library (SNES petscsnes) + petsc_find_library (TS petscts) + macro (PETSC_JOIN libs deps) + list (APPEND PETSC_LIBRARIES_${libs} ${PETSC_LIBRARIES_${deps}}) + endmacro (PETSC_JOIN libs deps) + petsc_join (VEC SYS) + petsc_join (MAT VEC) + petsc_join (DM MAT) + petsc_join (KSP DM) + petsc_join (SNES KSP) + petsc_join (TS SNES) + petsc_join (ALL TS) + else () + set (PETSC_LIBRARY_VEC "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # There is no libpetscvec + petsc_find_library (SINGLE petsc) + foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) + set (PETSC_LIBRARIES_${pkg} "${PETSC_LIBRARY_SINGLE}") + endforeach () + endif () + if (PETSC_LIBRARY_TS) + message (STATUS "Recognized PETSc install with separate libraries for each package") + else () + message (STATUS "Recognized PETSc install with single library for all packages") + endif () + + include(Check${PETSC_LANGUAGE_BINDINGS}SourceRuns) + macro (PETSC_TEST_RUNS includes libraries runs) + if(${PETSC_LANGUAGE_BINDINGS} STREQUAL "C") + set(_PETSC_ERR_FUNC "CHKERRQ(ierr)") + elseif(${PETSC_LANGUAGE_BINDINGS} STREQUAL "CXX") + set(_PETSC_ERR_FUNC "CHKERRXX(ierr)") + endif() + if (PETSC_VERSION VERSION_GREATER 3.1) + set (_PETSC_TSDestroy "TSDestroy(&ts)") + else () + set (_PETSC_TSDestroy "TSDestroy(ts)") + endif () + + set(_PETSC_TEST_SOURCE " +static const char help[] = \"PETSc test program.\"; +#include +int main(int argc,char *argv[]) { + PetscErrorCode ierr; + TS ts; + + ierr = PetscInitialize(&argc,&argv,0,help);${_PETSC_ERR_FUNC}; + ierr = TSCreate(PETSC_COMM_WORLD,&ts);${_PETSC_ERR_FUNC}; + ierr = TSSetFromOptions(ts);${_PETSC_ERR_FUNC}; + ierr = ${_PETSC_TSDestroy};${_PETSC_ERR_FUNC}; + ierr = PetscFinalize();${_PETSC_ERR_FUNC}; + return 0; +} +") + multipass_source_runs ("${includes}" "${libraries}" "${_PETSC_TEST_SOURCE}" ${runs} "${PETSC_LANGUAGE_BINDINGS}") + if (${${runs}}) + set (PETSC_EXECUTABLE_RUNS "YES" CACHE BOOL + "Can the system successfully run a PETSc executable? This variable can be manually set to \"YES\" to force CMake to accept a given PETSc configuration, but this will almost always result in a broken build. If you change PETSC_DIR, PETSC_ARCH, or PETSC_CURRENT you would have to reset this variable." FORCE) + endif (${${runs}}) + endmacro (PETSC_TEST_RUNS) + + + find_path (PETSC_INCLUDE_DIR petscts.h HINTS "${PETSC_DIR}" PATH_SUFFIXES include NO_DEFAULT_PATH) + find_path (PETSC_INCLUDE_CONF petscconf.h HINTS "${PETSC_DIR}" PATH_SUFFIXES "${PETSC_ARCH}/include" "bmake/${PETSC_ARCH}" NO_DEFAULT_PATH) + mark_as_advanced (PETSC_INCLUDE_DIR PETSC_INCLUDE_CONF) + set (petsc_includes_minimal ${PETSC_INCLUDE_CONF} ${PETSC_INCLUDE_DIR}) + + petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_minimal) + if (petsc_works_minimal) + message (STATUS "Minimal PETSc includes and libraries work. This probably means we are building with shared libs.") + set (petsc_includes_needed "${petsc_includes_minimal}") + else (petsc_works_minimal) # Minimal includes fail, see if just adding full includes fixes it + petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_allincludes) + if (petsc_works_allincludes) # It does, we just need all the includes ( + message (STATUS "PETSc requires extra include paths, but links correctly with only interface libraries. This is an unexpected configuration (but it seems to work fine).") + set (petsc_includes_needed ${petsc_includes_all}) + else (petsc_works_allincludes) # We are going to need to link the external libs explicitly + resolve_libraries (petsc_libraries_external "${petsc_libs_external}") + foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) + list (APPEND PETSC_LIBRARIES_${pkg} ${petsc_libraries_external}) + endforeach (pkg) + petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_alllibraries) + if (petsc_works_alllibraries) + message (STATUS "PETSc only need minimal includes, but requires explicit linking to all dependencies. This is expected when PETSc is built with static libraries.") + set (petsc_includes_needed ${petsc_includes_minimal}) + else (petsc_works_alllibraries) + # It looks like we really need everything, should have listened to Matt + set (petsc_includes_needed ${petsc_includes_all}) + petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_all) + if (petsc_works_all) # We fail anyways + message (STATUS "PETSc requires extra include paths and explicit linking to all dependencies. This probably means you have static libraries and something unexpected in PETSc headers.") + else (petsc_works_all) # We fail anyways + message (STATUS "PETSc could not be used, maybe the install is broken.") + endif (petsc_works_all) + endif (petsc_works_alllibraries) + endif (petsc_works_allincludes) + endif (petsc_works_minimal) + + # We do an out-of-source build so __FILE__ will be an absolute path, hence __INSDIR__ is superfluous + if (${PETSC_VERSION} VERSION_LESS 3.1) + set (PETSC_DEFINITIONS "-D__SDIR__=\"\"" CACHE STRING "PETSc definitions" FORCE) + else () + set (PETSC_DEFINITIONS "-D__INSDIR__=" CACHE STRING "PETSc definitions" FORCE) + endif () + # Sometimes this can be used to assist FindMPI.cmake + set (PETSC_MPIEXEC ${petsc_mpiexec} CACHE FILEPATH "Executable for running PETSc MPI programs" FORCE) + set (PETSC_INCLUDES ${petsc_includes_needed} CACHE STRING "PETSc include path" FORCE) + set (PETSC_LIBRARIES ${PETSC_LIBRARIES_ALL} CACHE STRING "PETSc libraries" FORCE) + set (PETSC_COMPILER ${petsc_cc} CACHE FILEPATH "PETSc compiler" FORCE) + # Note that we have forced values for all these choices. If you + # change these, you are telling the system to trust you that they + # work. It is likely that you will end up with a broken build. + mark_as_advanced (PETSC_INCLUDES PETSC_LIBRARIES PETSC_COMPILER PETSC_DEFINITIONS PETSC_MPIEXEC PETSC_EXECUTABLE_RUNS) +endif () + +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args (PETSc + "PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH." + PETSC_INCLUDES PETSC_LIBRARIES PETSC_EXECUTABLE_RUNS) diff --git a/cmake/Modules/FindPackageMultipass.cmake b/cmake/Modules/FindPackageMultipass.cmake new file mode 100644 index 0000000000000000000000000000000000000000..fbf06a7f0fc3aa20a0387f091eac4f74e7ffdab2 --- /dev/null +++ b/cmake/Modules/FindPackageMultipass.cmake @@ -0,0 +1,106 @@ +# PackageMultipass - this module defines two macros +# +# FIND_PACKAGE_MULTIPASS (Name CURRENT +# STATES VAR0 VAR1 ... +# DEPENDENTS DEP0 DEP1 ...) +# +# This function creates a cache entry _CURRENT which +# the user can set to "NO" to trigger a reconfiguration of the package. +# The first time this function is called, the values of +# _VAR0, ... are saved. If _CURRENT +# is false or if any STATE has changed since the last time +# FIND_PACKAGE_MULTIPASS() was called, then CURRENT will be set to "NO", +# otherwise CURRENT will be "YES". IF not CURRENT, then +# _DEP0, ... will be FORCED to NOTFOUND. +# Example: +# find_path (FOO_DIR include/foo.h) +# FIND_PACKAGE_MULTIPASS (Foo foo_current +# STATES DIR +# DEPENDENTS INCLUDES LIBRARIES) +# if (NOT foo_current) +# # Make temporary files, run programs, etc, to determine FOO_INCLUDES and FOO_LIBRARIES +# endif (NOT foo_current) +# +# MULTIPASS_SOURCE_RUNS (Name INCLUDES LIBRARIES SOURCE RUNS LANGUAGE) +# Always runs the given test, use this when you need to re-run tests +# because parent variables have made old cache entries stale. The LANGUAGE +# variable is either C or CXX indicating which compiler the test should +# use. +# MULTIPASS_C_SOURCE_RUNS (Name INCLUDES LIBRARIES SOURCE RUNS) +# DEPRECATED! This is only included for backwards compatability. Use +# the more general MULTIPASS_SOURCE_RUNS instead. +# Always runs the given test, use this when you need to re-run tests +# because parent variables have made old cache entries stale. + +macro (FIND_PACKAGE_MULTIPASS _name _current) + string (TOUPPER ${_name} _NAME) + set (_args ${ARGV}) + list (REMOVE_AT _args 0 1) + + set (_states_current "YES") + list (GET _args 0 _cmd) + if (_cmd STREQUAL "STATES") + list (REMOVE_AT _args 0) + list (GET _args 0 _state) + while (_state AND NOT _state STREQUAL "DEPENDENTS") + # The name of the stored value for the given state + set (_stored_var PACKAGE_MULTIPASS_${_NAME}_${_state}) + if (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}") + set (_states_current "NO") + endif (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}") + set (${_stored_var} "${${_NAME}_${_state}}" CACHE INTERNAL "Stored state for ${_name}." FORCE) + list (REMOVE_AT _args 0) + list (GET _args 0 _state) + endwhile (_state AND NOT _state STREQUAL "DEPENDENTS") + endif (_cmd STREQUAL "STATES") + + set (_stored ${_NAME}_CURRENT) + if (NOT ${_stored}) + set (${_stored} "YES" CACHE BOOL "Is the configuration for ${_name} current? Set to \"NO\" to reconfigure." FORCE) + set (_states_current "NO") + endif (NOT ${_stored}) + + set (${_current} ${_states_current}) + if (NOT ${_current} AND PACKAGE_MULTIPASS_${_name}_CALLED) + message (STATUS "Clearing ${_name} dependent variables") + # Clear all the dependent variables so that the module can reset them + list (GET _args 0 _cmd) + if (_cmd STREQUAL "DEPENDENTS") + list (REMOVE_AT _args 0) + foreach (dep ${_args}) + set (${_NAME}_${dep} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) + endforeach (dep) + endif (_cmd STREQUAL "DEPENDENTS") + set (${_NAME}_FOUND "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) + endif () + set (PACKAGE_MULTIPASS_${name}_CALLED YES CACHE INTERNAL "Private" FORCE) +endmacro (FIND_PACKAGE_MULTIPASS) + + +macro (MULTIPASS_SOURCE_RUNS includes libraries source runs language) + include (Check${language}SourceRuns) + # This is a ridiculous hack. CHECK_${language}_SOURCE_* thinks that if the + # *name* of the return variable doesn't change, then the test does + # not need to be re-run. We keep an internal count which we + # increment to guarantee that every test name is unique. If we've + # gotten here, then the configuration has changed enough that the + # test *needs* to be rerun. + if (NOT MULTIPASS_TEST_COUNT) + set (MULTIPASS_TEST_COUNT 00) + endif (NOT MULTIPASS_TEST_COUNT) + math (EXPR _tmp "${MULTIPASS_TEST_COUNT} + 1") # Why can't I add to a cache variable? + set (MULTIPASS_TEST_COUNT ${_tmp} CACHE INTERNAL "Unique test ID") + set (testname MULTIPASS_TEST_${MULTIPASS_TEST_COUNT}_${runs}) + set (CMAKE_REQUIRED_INCLUDES ${includes}) + set (CMAKE_REQUIRED_LIBRARIES ${libraries}) + if(${language} STREQUAL "C") + check_c_source_runs ("${source}" ${testname}) + elseif(${language} STREQUAL "CXX") + check_cxx_source_runs ("${source}" ${testname}) + endif() + set (${runs} "${${testname}}") +endmacro (MULTIPASS_SOURCE_RUNS) + +macro (MULTIPASS_C_SOURCE_RUNS includes libraries source runs) + multipass_source_runs("${includes}" "${libraries}" "${source}" ${runs} "C") +endmacro (MULTIPASS_C_SOURCE_RUNS) diff --git a/cmake/Modules/FindclBLAS.cmake b/cmake/Modules/FindclBLAS.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8efbc73e99a57e2093ab9ec43583cc0dacfd75c9 --- /dev/null +++ b/cmake/Modules/FindclBLAS.cmake @@ -0,0 +1,67 @@ +# ================================================================================================== +# This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This +# project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max- +# width of 100 characters per line. +# +# Author(s): +# Cedric Nugteren +# +# ================================================================================================== +# +# Defines the following variables: +# CLBLAS_FOUND Boolean holding whether or not the clBLAS library was found +# CLBLAS_INCLUDE_DIRS The clBLAS include directory +# CLBLAS_LIBRARIES The clBLAS library +# +# In case clBLAS is not installed in the default directory, set the CLBLAS_ROOT variable to point to +# the root of clBLAS, such that 'clBLAS.h' can be found in $CLBLAS_ROOT/include. This can either be +# done using an environmental variable (e.g. export CLBLAS_ROOT=/path/to/clBLAS) or using a CMake +# variable (e.g. cmake -DCLBLAS_ROOT=/path/to/clBLAS ..). +# +# ================================================================================================== + +# Sets the possible install locations +set(CLBLAS_HINTS + ${CLBLAS_ROOT} + $ENV{CLBLAS_ROOT} +) +set(CLBLAS_PATHS + /usr + /usr/local +) + +# Finds the include directories +find_path(CLBLAS_INCLUDE_DIRS + NAMES clBLAS.h + HINTS ${CLBLAS_HINTS} + PATH_SUFFIXES src include inc include/x86_64 include/x64 + PATHS ${CLBLAS_PATHS} + DOC "clBLAS include header clBLAS.h" +) +mark_as_advanced(CLBLAS_INCLUDE_DIRS) + +# Finds the library +find_library(CLBLAS_LIBRARIES + NAMES clBLAS + HINTS ${CLBLAS_HINTS} + PATH_SUFFIXES lib build/library lib64 lib/x86_64 lib/x64 lib/x86 lib/Win32 + PATHS ${CLBLAS_PATHS} + DOC "clBLAS library" +) +mark_as_advanced(CLBLAS_LIBRARIES) + +# ================================================================================================== + +# Notification messages +if(NOT CLBLAS_INCLUDE_DIRS) + message(STATUS "Could NOT find 'clBLAS.h', install clBLAS or set CLBLAS_ROOT") +endif() +if(NOT CLBLAS_LIBRARIES) + message(STATUS "Could NOT find clBLAS library, install it or set CLBLAS_ROOT") +endif() + +# Determines whether or not clBLAS was found +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(clBLAS DEFAULT_MSG CLBLAS_INCLUDE_DIRS CLBLAS_LIBRARIES) + +# ================================================================================================== diff --git a/cmake/Modules/FindclMAGMA.cmake b/cmake/Modules/FindclMAGMA.cmake new file mode 100644 index 0000000000000000000000000000000000000000..7cd28b49d3eacee10a4c357bb154dc5acbaa3d03 --- /dev/null +++ b/cmake/Modules/FindclMAGMA.cmake @@ -0,0 +1,67 @@ +# ================================================================================================== +# This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This +# project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max- +# width of 100 characters per line. +# +# Author(s): +# Mariusz Uchronski +# +# ================================================================================================== +# +# Defines the following variables: +# CLMAGMA_FOUND Boolean holding whether or not the clMAGMA library was found +# CLMAGMA_INCLUDE_DIRS The clMAGMA include directory +# CLMAGMA_LIBRARIES The clMAGMA library +# +# In case clMAGMA is not installed in the default directory, set the CLMAGMA_ROOT variable to point to +# the root of clMAGMA, such that 'magma.h' can be found in $CLMAGMA_ROOT/include. This can either be +# done using an environmental variable (e.g. export CLMAGMA_ROOT=/path/to/clMAGMA) or using a CMake +# variable (e.g. cmake -DCLMAGMA_ROOT=/path/to/clMAGMA ..). +# +# ================================================================================================== + +# Sets the possible install locations +set(CLMAGMA_HINTS + ${CLMAGMA_ROOT} + $ENV{CLMAGMA_ROOT} +) +set(CLMAGMA_PATHS + /usr + /usr/local +) + +# Finds the include directories +find_path(CLMAGMA_INCLUDE_DIRS + NAMES magma.h + HINTS ${CLMAGMA_HINTS} + PATH_SUFFIXES src include inc include/x86_64 include/x64 + PATHS ${CLMAGMA_PATHS} + DOC "clMAGMA include header magma.h" +) +mark_as_advanced(CLMAGMA_INCLUDE_DIRS) + +# Finds the library +find_library(CLMAGMA_LIBRARIES + NAMES clmagma + HINTS ${CLMAGMA_HINTS} + PATH_SUFFIXES lib build/library lib64 lib/x86_64 lib/x64 lib/x86 lib/Win32 + PATHS ${CLMAGMA_PATHS} + DOC "clMAGMA library" +) +mark_as_advanced(CLMAGMA_LIBRARIES) + +# ================================================================================================== + +# Notification messages +if(NOT CLMAGMA_INCLUDE_DIRS) + message(STATUS "Could NOT find 'magma.h', install clMAGMA or set CLMAGMA_ROOT") +endif() +if(NOT CLMAGMA_LIBRARIES) + message(STATUS "Could NOT find clMAGMA library, install it or set CLMAGMA_ROOT") +endif() + +# Determines whether or not clMAGMA was found +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(clMAGMA DEFAULT_MSG CLMAGMA_INCLUDE_DIRS CLMAGMA_LIBRARIES) + +# ================================================================================================== diff --git a/cmake/Modules/Languages/CMakeDetermineICPCCompiler.cmake b/cmake/Modules/Languages/CMakeDetermineICPCCompiler.cmake new file mode 100644 index 0000000000000000000000000000000000000000..726df6e1fe88d8c51963ac824e5e0f833dc0b5e4 --- /dev/null +++ b/cmake/Modules/Languages/CMakeDetermineICPCCompiler.cmake @@ -0,0 +1,64 @@ +# Determine the compiler to use for ICPC programs +# NOTE, a generator may set CMAKE_ICPC_COMPILER before +# loading this file to force a compiler. +# use environment variable ICPC first if defined by user, next use +# the cmake variable CMAKE_GENERATOR_ICPC which can be defined by a generator +# as a default compiler + +IF(NOT CMAKE_ICPC_COMPILER) + + # prefer the environment variable ICPC + IF($ENV{ICPC} MATCHES ".+") + GET_FILENAME_COMPONENT(CMAKE_ICPC_COMPILER_INIT $ENV{ICPC} PROGRAM PROGRAM_ARGS CMAKE_ICPC_FLAGS_ENV_INIT) + IF(CMAKE_ICPC_FLAGS_ENV_INIT) + SET(CMAKE_ICPC_COMPILER_ARG1 "${CMAKE_ICPC_FLAGS_ENV_INIT}" CACHE STRING "First argument to ICPC compiler") + ENDIF(CMAKE_ICPC_FLAGS_ENV_INIT) + IF(EXISTS ${CMAKE_ICPC_COMPILER_INIT}) + ELSE(EXISTS ${CMAKE_ICPC_COMPILER_INIT}) + MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable ICPC:\n$ENV{ICPC}.") + ENDIF(EXISTS ${CMAKE_ICPC_COMPILER_INIT}) + ENDIF($ENV{ICPC} MATCHES ".+") + + # next try prefer the compiler specified by the generator + IF(CMAKE_GENERATOR_ICPC) + IF(NOT CMAKE_ICPC_COMPILER_INIT) + SET(CMAKE_ICPC_COMPILER_INIT ${CMAKE_GENERATOR_ICPC}) + ENDIF(NOT CMAKE_ICPC_COMPILER_INIT) + ENDIF(CMAKE_GENERATOR_ICPC) + + # finally list compilers to try + IF(CMAKE_ICPC_COMPILER_INIT) + SET(CMAKE_ICPC_COMPILER_LIST ${CMAKE_ICPC_COMPILER_INIT}) + ELSE(CMAKE_ICPC_COMPILER_INIT) + SET(CMAKE_ICPC_COMPILER_LIST icpc ) + ENDIF(CMAKE_ICPC_COMPILER_INIT) + + # Find the compiler. + FIND_PROGRAM(CMAKE_ICPC_COMPILER NAMES ${CMAKE_ICPC_COMPILER_LIST} DOC "ICPC compiler") + IF(CMAKE_ICPC_COMPILER_INIT AND NOT CMAKE_ICPC_COMPILER) + SET(CMAKE_ICPC_COMPILER "${CMAKE_ICPC_COMPILER_INIT}" CACHE FILEPATH "ICPC compiler" FORCE) + ENDIF(CMAKE_ICPC_COMPILER_INIT AND NOT CMAKE_ICPC_COMPILER) +ENDIF(NOT CMAKE_ICPC_COMPILER) +MARK_AS_ADVANCED(CMAKE_ICPC_COMPILER) + +GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_ICPC_COMPILER}" PATH) + +# FIND_PROGRAM(GNAT_EXECUTABLE_BUILDER NAMES icpc PATHS ${COMPILER_LOCATION} ) +FIND_PROGRAM(CMAKE_AR NAMES xiar PATHS ${COMPILER_LOCATION} ) + +FIND_PROGRAM(CMAKE_RANLIB NAMES ranlib) +IF(NOT CMAKE_RANLIB) + SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib") +ENDIF(NOT CMAKE_RANLIB) +MARK_AS_ADVANCED(CMAKE_RANLIB) + +# configure variables set in this file for fast reload later on +#CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeICPCCompiler.cmake.in +#message(STATUS "DEBUG: CMAKE_BINARY_DIR = ${CMAKE_BINARY_DIR}") +#message(STATUS "DEBUG: CMAKE_FILES_DIRECTORY = ${CMAKE_FILES_DIRECTORY}") +#message(STATUS "DEBUG: CMAKE_PLATFORM_INFO_DIR = ${CMAKE_PLATFORM_INFO_DIR}") +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/Modules/Languages/CMakeICPCCompiler.cmake.in + "${CMAKE_PLATFORM_INFO_DIR}/CMakeICPCCompiler.cmake" IMMEDIATE) +MARK_AS_ADVANCED(CMAKE_AR) + +SET(CMAKE_ICPC_COMPILER_ENV_VAR "ICPC") diff --git a/cmake/Modules/Languages/CMakeDetermineIFORTCompiler.cmake b/cmake/Modules/Languages/CMakeDetermineIFORTCompiler.cmake new file mode 100644 index 0000000000000000000000000000000000000000..c2a443356ca04c668b8400ec32477df8e4536dca --- /dev/null +++ b/cmake/Modules/Languages/CMakeDetermineIFORTCompiler.cmake @@ -0,0 +1,64 @@ +# Determine the compiler to use for IFORT programs +# NOTE, a generator may set CMAKE_IFORT_COMPILER before +# loading this file to force a compiler. +# use environment variable IFORT first if defined by user, next use +# the cmake variable CMAKE_GENERATOR_IFORT which can be defined by a generator +# as a default compiler + +IF(NOT CMAKE_IFORT_COMPILER) + + # prefer the environment variable IFORT + IF($ENV{IFORT} MATCHES ".+") + GET_FILENAME_COMPONENT(CMAKE_IFORT_COMPILER_INIT $ENV{IFORT} PROGRAM PROGRAM_ARGS CMAKE_IFORT_FLAGS_ENV_INIT) + IF(CMAKE_IFORT_FLAGS_ENV_INIT) + SET(CMAKE_IFORT_COMPILER_ARG1 "${CMAKE_IFORT_FLAGS_ENV_INIT}" CACHE STRING "First argument to IFORT compiler") + ENDIF(CMAKE_IFORT_FLAGS_ENV_INIT) + IF(EXISTS ${CMAKE_IFORT_COMPILER_INIT}) + ELSE(EXISTS ${CMAKE_IFORT_COMPILER_INIT}) + MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable IFORT:\n$ENV{IFORT}.") + ENDIF(EXISTS ${CMAKE_IFORT_COMPILER_INIT}) + ENDIF($ENV{IFORT} MATCHES ".+") + + # next try prefer the compiler specified by the generator + IF(CMAKE_GENERATOR_IFORT) + IF(NOT CMAKE_IFORT_COMPILER_INIT) + SET(CMAKE_IFORT_COMPILER_INIT ${CMAKE_GENERATOR_IFORT}) + ENDIF(NOT CMAKE_IFORT_COMPILER_INIT) + ENDIF(CMAKE_GENERATOR_IFORT) + + # finally list compilers to try + IF(CMAKE_IFORT_COMPILER_INIT) + SET(CMAKE_IFORT_COMPILER_LIST ${CMAKE_IFORT_COMPILER_INIT}) + ELSE(CMAKE_IFORT_COMPILER_INIT) + SET(CMAKE_IFORT_COMPILER_LIST ifort ) + ENDIF(CMAKE_IFORT_COMPILER_INIT) + + # Find the compiler. + FIND_PROGRAM(CMAKE_IFORT_COMPILER NAMES ${CMAKE_IFORT_COMPILER_LIST} DOC "IFORT compiler") + IF(CMAKE_IFORT_COMPILER_INIT AND NOT CMAKE_IFORT_COMPILER) + SET(CMAKE_IFORT_COMPILER "${CMAKE_IFORT_COMPILER_INIT}" CACHE FILEPATH "IFORT compiler" FORCE) + ENDIF(CMAKE_IFORT_COMPILER_INIT AND NOT CMAKE_IFORT_COMPILER) +ENDIF(NOT CMAKE_IFORT_COMPILER) +MARK_AS_ADVANCED(CMAKE_IFORT_COMPILER) + +GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_IFORT_COMPILER}" PATH) + +# FIND_PROGRAM(GNAT_EXECUTABLE_BUILDER NAMES ifort PATHS ${COMPILER_LOCATION} ) +FIND_PROGRAM(CMAKE_AR NAMES xiar PATHS ${COMPILER_LOCATION} ) + +FIND_PROGRAM(CMAKE_RANLIB NAMES ranlib) +IF(NOT CMAKE_RANLIB) + SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib") +ENDIF(NOT CMAKE_RANLIB) +MARK_AS_ADVANCED(CMAKE_RANLIB) + +# configure variables set in this file for fast reload later on +#CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeIFORTCompiler.cmake.in +#message(STATUS "DEBUG: CMAKE_BINARY_DIR = ${CMAKE_BINARY_DIR}") +#message(STATUS "DEBUG: CMAKE_FILES_DIRECTORY = ${CMAKE_FILES_DIRECTORY}") +#message(STATUS "DEBUG: CMAKE_PLATFORM_INFO_DIR = ${CMAKE_PLATFORM_INFO_DIR}") +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/Modules/Languages/CMakeIFORTCompiler.cmake.in + "${CMAKE_PLATFORM_INFO_DIR}/CMakeIFORTCompiler.cmake" IMMEDIATE) +MARK_AS_ADVANCED(CMAKE_AR) + +SET(CMAKE_IFORT_COMPILER_ENV_VAR "IFORT") diff --git a/cmake/Modules/Languages/CMakeICPCCompiler.cmake.in b/cmake/Modules/Languages/CMakeICPCCompiler.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..7002e7ab7e82b03d3f5f55ffb32bbbdf30e68132 --- /dev/null +++ b/cmake/Modules/Languages/CMakeICPCCompiler.cmake.in @@ -0,0 +1,18 @@ +SET(CMAKE_ICPC_COMPILER "@CMAKE_ICPC_COMPILER@") +SET(CMAKE_ICPC_COMPILER_ARG1 "@CMAKE_ICPC_COMPILER_ARG1@") +SET(CMAKE_AR "@CMAKE_AR@") +SET(CMAKE_RANLIB "@CMAKE_RANLIB@") +SET(CMAKE_LINKER "@CMAKE_LINKER@") +SET(CMAKE_ICPC_COMPILER_LOADED 1) + +SET(CMAKE_ICPC_COMPILER_ENV_VAR "ICPC") + +set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) +set(CMAKE_CXX_IGNORE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP) +SET(CMAKE_ICPC_LINKER_PREFERENCE Preferred) +IF(UNIX OR MINGW) + SET(CMAKE_ICPC_OUTPUT_EXTENSION .o) +ELSE(UNIX OR MINGW) + SET(CMAKE_ICPC_OUTPUT_EXTENSION .obj) +ENDIF(UNIX OR MINGW) +SET(CMAKE_ICPC_OUTPUT_EXTENSION_REPLACE 1) diff --git a/cmake/Modules/Languages/CMakeICPCInformation.cmake b/cmake/Modules/Languages/CMakeICPCInformation.cmake new file mode 100644 index 0000000000000000000000000000000000000000..64c64367a3caf069446a17a9ef658a43cb341b73 --- /dev/null +++ b/cmake/Modules/Languages/CMakeICPCInformation.cmake @@ -0,0 +1,196 @@ +# This file sets the basic flags for the ICPC language in CMake. +# It also loads the available platform file for the system-compiler +# if it exists. + +GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_ICPC_COMPILER} NAME_WE) +SET(CMAKE_SYSTEM_AND_ICPC_COMPILER_INFO_FILE + ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) +INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) + +# This should be included before the _INIT variables are +# used to initialize the cache. Since the rule variables +# have if blocks on them, users can still define them here. +# But, it should still be after the platform file so changes can +# be made to those values. + +# set(CMAKE_NEEDS_REQUIRES_STEP_ICPC_FLAG 1) + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE_ICPC) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_ICPC}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_ICPC) + +# Create a set of shared library variable specific to ICPC +# For 90% of the systems, these are the same flags as the C versions +# so if these are not set just copy the flags from the c version + +IF(NOT CMAKE_SHARED_LIBRARY_CREATE_ICPC_FLAGS) + SET(CMAKE_SHARED_LIBRARY_CREATE_ICPC_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_CREATE_ICPC_FLAGS) + +IF(NOT CMAKE_ICPC_COMPILE_OPTIONS_PIC) + SET(CMAKE_ICPC_COMPILE_OPTIONS_PIC ${CMAKE_C_COMPILE_OPTIONS_PIC}) +ENDIF(NOT CMAKE_ICPC_COMPILE_OPTIONS_PIC) + +IF(NOT CMAKE_ICPC_COMPILE_OPTIONS_PIE) + SET(CMAKE_ICPC_COMPILE_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE}) +ENDIF(NOT CMAKE_ICPC_COMPILE_OPTIONS_PIE) + +IF(NOT CMAKE_ICPC_COMPILE_OPTIONS_DLL) + SET(CMAKE_ICPC_COMPILE_OPTIONS_DLL ${CMAKE_C_COMPILE_OPTIONS_DLL}) +ENDIF(NOT CMAKE_ICPC_COMPILE_OPTIONS_DLL) + +IF(NOT CMAKE_SHARED_LIBRARY_ICPC_FLAGS) + SET(CMAKE_SHARED_LIBRARY_ICPC_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_ICPC_FLAGS) + +IF(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_ICPC_FLAGS) + SET(CMAKE_SHARED_LIBRARY_LINK_ICPC_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}) +ENDIF(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_ICPC_FLAGS) + +IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_ICPC_FLAG) + SET(CMAKE_SHARED_LIBRARY_RUNTIME_ICPC_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_ICPC_FLAG) + +IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_ICPC_FLAG_SEP) + SET(CMAKE_SHARED_LIBRARY_RUNTIME_ICPC_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_ICPC_FLAG_SEP) + +IF(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_ICPC_FLAG) + SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_ICPC_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_ICPC_FLAG) + +# repeat for modules +IF(NOT CMAKE_SHARED_MODULE_CREATE_ICPC_FLAGS) + SET(CMAKE_SHARED_MODULE_CREATE_ICPC_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS}) +ENDIF(NOT CMAKE_SHARED_MODULE_CREATE_ICPC_FLAGS) + +IF(NOT CMAKE_SHARED_MODULE_ICPC_FLAGS) + SET(CMAKE_SHARED_MODULE_ICPC_FLAGS ${CMAKE_SHARED_MODULE_C_FLAGS}) +ENDIF(NOT CMAKE_SHARED_MODULE_ICPC_FLAGS) + +IF(NOT CMAKE_SHARED_MODULE_RUNTIME_ICPC_FLAG) + SET(CMAKE_SHARED_MODULE_RUNTIME_ICPC_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG}) +ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_ICPC_FLAG) + +IF(NOT CMAKE_SHARED_MODULE_RUNTIME_ICPC_FLAG_SEP) + SET(CMAKE_SHARED_MODULE_RUNTIME_ICPC_FLAG_SEP ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG_SEP}) +ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_ICPC_FLAG_SEP) + +IF(NOT CMAKE_EXECUTABLE_RUNTIME_ICPC_FLAG) + SET(CMAKE_EXECUTABLE_RUNTIME_ICPC_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_ICPC_FLAG}) +ENDIF(NOT CMAKE_EXECUTABLE_RUNTIME_ICPC_FLAG) + +IF(NOT CMAKE_EXECUTABLE_RUNTIME_ICPC_FLAG_SEP) + SET(CMAKE_EXECUTABLE_RUNTIME_ICPC_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_ICPC_FLAG_SEP}) +ENDIF(NOT CMAKE_EXECUTABLE_RUNTIME_ICPC_FLAG_SEP) + +IF(NOT CMAKE_EXECUTABLE_RPATH_LINK_ICPC_FLAG) + SET(CMAKE_EXECUTABLE_RPATH_LINK_ICPC_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_ICPC_FLAG}) +ENDIF(NOT CMAKE_EXECUTABLE_RPATH_LINK_ICPC_FLAG) + +IF(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_ICPC_WITH_RUNTIME_PATH) + SET(CMAKE_SHARED_LIBRARY_LINK_ICPC_WITH_RUNTIME_PATH ${CMAKE_SHARED_LIBRARY_LINK_C_WITH_RUNTIME_PATH}) +ENDIF(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_ICPC_WITH_RUNTIME_PATH) + +IF(NOT CMAKE_INCLUDE_FLAG_ICPC) + SET(CMAKE_INCLUDE_FLAG_ICPC ${CMAKE_INCLUDE_FLAG_C}) +ENDIF(NOT CMAKE_INCLUDE_FLAG_ICPC) + +IF(NOT CMAKE_INCLUDE_FLAG_SEP_ICPC) + SET(CMAKE_INCLUDE_FLAG_SEP_ICPC ${CMAKE_INCLUDE_FLAG_SEP_C}) +ENDIF(NOT CMAKE_INCLUDE_FLAG_SEP_ICPC) + +# Copy C version of this flag which is normally determined in platform file. +IF(NOT CMAKE_SHARED_LIBRARY_SONAME_ICPC_FLAG) + SET(CMAKE_SHARED_LIBRARY_SONAME_ICPC_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_C_FLAG}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_SONAME_ICPC_FLAG) + +SET(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.") + +SET(CMAKE_ICPC_FLAGS_INIT "$ENV{ICPCFLAGS} ${CMAKE_ICPC_FLAGS_INIT}") +# avoid just having a space as the initial value for the cache +IF(CMAKE_ICPC_FLAGS_INIT STREQUAL " ") + SET(CMAKE_ICPC_FLAGS_INIT) +ENDIF(CMAKE_ICPC_FLAGS_INIT STREQUAL " ") +SET (CMAKE_ICPC_FLAGS "${CMAKE_ICPC_FLAGS_INIT}" CACHE STRING + "Flags for ICPC compiler.") + +INCLUDE(CMakeCommonLanguageInclude) + +# now define the following rule variables + +# CMAKE_ICPC_CREATE_SHARED_LIBRARY +# CMAKE_ICPC_CREATE_SHARED_MODULE +# CMAKE_ICPC_CREATE_STATIC_LIBRARY +# CMAKE_ICPC_COMPILE_OBJECT +# CMAKE_ICPC_LINK_EXECUTABLE + +# variables supplied by the generator at use time +# +# the target without the suffix +# +# +# +# +# + +# ICPC compiler information +# +# +# +# + +# Static library tools +# +# + + +# create a shared C++ library +if(NOT CMAKE_ICPC_CREATE_SHARED_LIBRARY) + set(CMAKE_ICPC_CREATE_SHARED_LIBRARY + " -o ") +endif() + +# create a c++ shared module copy the shared library rule by default +if(NOT CMAKE_ICPC_CREATE_SHARED_MODULE) + set(CMAKE_ICPC_CREATE_SHARED_MODULE ${CMAKE_ICPC_CREATE_SHARED_LIBRARY}) +endif() + + +# Create a static archive incrementally for large object file counts. +# If CMAKE_ICPC_CREATE_STATIC_LIBRARY is set it will override these. +if(NOT DEFINED CMAKE_ICPC_ARCHIVE_CREATE) + set(CMAKE_ICPC_ARCHIVE_CREATE " cq ") +endif() +if(NOT DEFINED CMAKE_ICPC_ARCHIVE_APPEND) + set(CMAKE_ICPC_ARCHIVE_APPEND " q ") +endif() +if(NOT DEFINED CMAKE_ICPC_ARCHIVE_FINISH) + set(CMAKE_ICPC_ARCHIVE_FINISH " ") +endif() + +# compile a C++ file into an object file +if(NOT CMAKE_ICPC_COMPILE_OBJECT) + set(CMAKE_ICPC_COMPILE_OBJECT + " -o -c ") +endif() + +if(NOT CMAKE_ICPC_LINK_EXECUTABLE) + set(CMAKE_ICPC_LINK_EXECUTABLE + " -o ") +endif() + +mark_as_advanced( +CMAKE_VERBOSE_MAKEFILE +CMAKE_ICPC_FLAGS +CMAKE_ICPC_FLAGS_RELEASE +CMAKE_ICPC_FLAGS_RELWITHDEBINFO +CMAKE_ICPC_FLAGS_MINSIZEREL +CMAKE_ICPC_FLAGS_DEBUG) + +set(CMAKE_ICPC_INFORMATION_LOADED 1) + diff --git a/cmake/Modules/Languages/CMakeIFORTCompiler.cmake.in b/cmake/Modules/Languages/CMakeIFORTCompiler.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..45274d2a817048a917f084aa3bfad69bb9051bab --- /dev/null +++ b/cmake/Modules/Languages/CMakeIFORTCompiler.cmake.in @@ -0,0 +1,18 @@ +SET(CMAKE_IFORT_COMPILER "@CMAKE_IFORT_COMPILER@") +SET(CMAKE_IFORT_COMPILER_ARG1 "@CMAKE_IFORT_COMPILER_ARG1@") +SET(CMAKE_AR "@CMAKE_AR@") +SET(CMAKE_RANLIB "@CMAKE_RANLIB@") +SET(CMAKE_LINKER "@CMAKE_LINKER@") +SET(CMAKE_IFORT_COMPILER_LOADED 1) + +SET(CMAKE_IFORT_COMPILER_ENV_VAR "IFORT") + +set(CMAKE_IFORT_IGNORE_FILE_EXTENSIONS f;F;f77;F77;f90;F90;for;For;FOR;f95;F95) +set(CMAKE_IFORT_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) +SET(CMAKE_IFORT_LINKER_PREFERENCE Preferred) +IF(UNIX OR MINGW) + SET(CMAKE_IFORT_OUTPUT_EXTENSION .o) +ELSE(UNIX OR MINGW) + SET(CMAKE_IFORT_OUTPUT_EXTENSION .obj) +ENDIF(UNIX OR MINGW) +SET(CMAKE_IFORT_OUTPUT_EXTENSION_REPLACE 1) diff --git a/cmake/Modules/Languages/CMakeIFORTInformation.cmake b/cmake/Modules/Languages/CMakeIFORTInformation.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e26c536f3ab4e50dc1f76a6b34d78699f53ae424 --- /dev/null +++ b/cmake/Modules/Languages/CMakeIFORTInformation.cmake @@ -0,0 +1,194 @@ +# This file sets the basic flags for the IFORT language in CMake. +# It also loads the available platform file for the system-compiler +# if it exists. + +GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_IFORT_COMPILER} NAME_WE) +SET(CMAKE_SYSTEM_AND_IFORT_COMPILER_INFO_FILE + ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) +INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) + +# This should be included before the _INIT variables are +# used to initialize the cache. Since the rule variables +# have if blocks on them, users can still define them here. +# But, it should still be after the platform file so changes can +# be made to those values. + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE_IFORT) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_IFORT}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_IFORT) + +# Create a set of shared library variable specific to IFORT +# For 90% of the systems, these are the same flags as the C versions +# so if these are not set just copy the flags from the c version + +IF(NOT CMAKE_SHARED_LIBRARY_CREATE_IFORT_FLAGS) + SET(CMAKE_SHARED_LIBRARY_CREATE_IFORT_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_CREATE_IFORT_FLAGS) + +IF(NOT CMAKE_IFORT_COMPILE_OPTIONS_PIC) + SET(CMAKE_IFORT_COMPILE_OPTIONS_PIC ${CMAKE_C_COMPILE_OPTIONS_PIC}) +ENDIF(NOT CMAKE_IFORT_COMPILE_OPTIONS_PIC) + +IF(NOT CMAKE_IFORT_COMPILE_OPTIONS_PIE) + SET(CMAKE_IFORT_COMPILE_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE}) +ENDIF(NOT CMAKE_IFORT_COMPILE_OPTIONS_PIE) + +IF(NOT CMAKE_IFORT_COMPILE_OPTIONS_DLL) + SET(CMAKE_IFORT_COMPILE_OPTIONS_DLL ${CMAKE_C_COMPILE_OPTIONS_DLL}) +ENDIF(NOT CMAKE_IFORT_COMPILE_OPTIONS_DLL) + +IF(NOT CMAKE_SHARED_LIBRARY_IFORT_FLAGS) + SET(CMAKE_SHARED_LIBRARY_IFORT_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_IFORT_FLAGS) + +IF(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_IFORT_FLAGS) + SET(CMAKE_SHARED_LIBRARY_LINK_IFORT_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}) +ENDIF(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_IFORT_FLAGS) + +IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_IFORT_FLAG) + SET(CMAKE_SHARED_LIBRARY_RUNTIME_IFORT_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_IFORT_FLAG) + +IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_IFORT_FLAG_SEP) + SET(CMAKE_SHARED_LIBRARY_RUNTIME_IFORT_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_IFORT_FLAG_SEP) + +IF(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_IFORT_FLAG) + SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_IFORT_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_IFORT_FLAG) + +# repeat for modules +IF(NOT CMAKE_SHARED_MODULE_CREATE_IFORT_FLAGS) + SET(CMAKE_SHARED_MODULE_CREATE_IFORT_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS}) +ENDIF(NOT CMAKE_SHARED_MODULE_CREATE_IFORT_FLAGS) + +IF(NOT CMAKE_SHARED_MODULE_IFORT_FLAGS) + SET(CMAKE_SHARED_MODULE_IFORT_FLAGS ${CMAKE_SHARED_MODULE_C_FLAGS}) +ENDIF(NOT CMAKE_SHARED_MODULE_IFORT_FLAGS) + +IF(NOT CMAKE_SHARED_MODULE_RUNTIME_IFORT_FLAG) + SET(CMAKE_SHARED_MODULE_RUNTIME_IFORT_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG}) +ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_IFORT_FLAG) + +IF(NOT CMAKE_SHARED_MODULE_RUNTIME_IFORT_FLAG_SEP) + SET(CMAKE_SHARED_MODULE_RUNTIME_IFORT_FLAG_SEP ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG_SEP}) +ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_IFORT_FLAG_SEP) + +IF(NOT CMAKE_EXECUTABLE_RUNTIME_IFORT_FLAG) + SET(CMAKE_EXECUTABLE_RUNTIME_IFORT_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_IFORT_FLAG}) +ENDIF(NOT CMAKE_EXECUTABLE_RUNTIME_IFORT_FLAG) + +IF(NOT CMAKE_EXECUTABLE_RUNTIME_IFORT_FLAG_SEP) + SET(CMAKE_EXECUTABLE_RUNTIME_IFORT_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_IFORT_FLAG_SEP}) +ENDIF(NOT CMAKE_EXECUTABLE_RUNTIME_IFORT_FLAG_SEP) + +IF(NOT CMAKE_EXECUTABLE_RPATH_LINK_IFORT_FLAG) + SET(CMAKE_EXECUTABLE_RPATH_LINK_IFORT_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_IFORT_FLAG}) +ENDIF(NOT CMAKE_EXECUTABLE_RPATH_LINK_IFORT_FLAG) + +IF(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_IFORT_WITH_RUNTIME_PATH) + SET(CMAKE_SHARED_LIBRARY_LINK_IFORT_WITH_RUNTIME_PATH ${CMAKE_SHARED_LIBRARY_LINK_C_WITH_RUNTIME_PATH}) +ENDIF(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_IFORT_WITH_RUNTIME_PATH) + +IF(NOT CMAKE_INCLUDE_FLAG_IFORT) + SET(CMAKE_INCLUDE_FLAG_IFORT ${CMAKE_INCLUDE_FLAG_C}) +ENDIF(NOT CMAKE_INCLUDE_FLAG_IFORT) + +IF(NOT CMAKE_INCLUDE_FLAG_SEP_IFORT) + SET(CMAKE_INCLUDE_FLAG_SEP_IFORT ${CMAKE_INCLUDE_FLAG_SEP_C}) +ENDIF(NOT CMAKE_INCLUDE_FLAG_SEP_IFORT) + +# Copy C version of this flag which is normally determined in platform file. +IF(NOT CMAKE_SHARED_LIBRARY_SONAME_IFORT_FLAG) + SET(CMAKE_SHARED_LIBRARY_SONAME_IFORT_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_C_FLAG}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_SONAME_IFORT_FLAG) + +SET(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.") + +SET(CMAKE_IFORT_FLAGS_INIT "$ENV{IFORTFLAGS} ${CMAKE_IFORT_FLAGS_INIT}") +# avoid just having a space as the initial value for the cache +IF(CMAKE_IFORT_FLAGS_INIT STREQUAL " ") + SET(CMAKE_IFORT_FLAGS_INIT) +ENDIF(CMAKE_IFORT_FLAGS_INIT STREQUAL " ") +SET (CMAKE_IFORT_FLAGS "${CMAKE_IFORT_FLAGS_INIT}" CACHE STRING + "Flags for IFORT compiler.") + +INCLUDE(CMakeCommonLanguageInclude) + +# now define the following rule variables + +# CMAKE_IFORT_CREATE_SHARED_LIBRARY +# CMAKE_IFORT_CREATE_SHARED_MODULE +# CMAKE_IFORT_CREATE_STATIC_LIBRARY +# CMAKE_IFORT_COMPILE_OBJECT +# CMAKE_IFORT_LINK_EXECUTABLE + +# variables supplied by the generator at use time +# +# the target without the suffix +# +# +# +# +# + +# IFORT compiler information +# +# +# +# + +# Static library tools +# +# + + +# create a shared C++ library +if(NOT CMAKE_IFORT_CREATE_SHARED_LIBRARY) + set(CMAKE_IFORT_CREATE_SHARED_LIBRARY + " -o ") +endif() + +# create a c++ shared module copy the shared library rule by default +if(NOT CMAKE_IFORT_CREATE_SHARED_MODULE) + set(CMAKE_IFORT_CREATE_SHARED_MODULE ${CMAKE_IFORT_CREATE_SHARED_LIBRARY}) +endif() + + +# Create a static archive incrementally for large object file counts. +# If CMAKE_IFORT_CREATE_STATIC_LIBRARY is set it will override these. +if(NOT DEFINED CMAKE_IFORT_ARCHIVE_CREATE) + set(CMAKE_IFORT_ARCHIVE_CREATE " cq ") +endif() +if(NOT DEFINED CMAKE_IFORT_ARCHIVE_APPEND) + set(CMAKE_IFORT_ARCHIVE_APPEND " q ") +endif() +if(NOT DEFINED CMAKE_IFORT_ARCHIVE_FINISH) + set(CMAKE_IFORT_ARCHIVE_FINISH " ") +endif() + +# compile a C++ file into an object file +if(NOT CMAKE_IFORT_COMPILE_OBJECT) + set(CMAKE_IFORT_COMPILE_OBJECT + " -o -c ") +endif() + +if(NOT CMAKE_IFORT_LINK_EXECUTABLE) + set(CMAKE_IFORT_LINK_EXECUTABLE + " -o ") +endif() + +mark_as_advanced( +CMAKE_VERBOSE_MAKEFILE +CMAKE_IFORT_FLAGS +CMAKE_IFORT_FLAGS_RELEASE +CMAKE_IFORT_FLAGS_RELWITHDEBINFO +CMAKE_IFORT_FLAGS_MINSIZEREL +CMAKE_IFORT_FLAGS_DEBUG) + +set(CMAKE_IFORT_INFORMATION_LOADED 1) + diff --git a/cmake/Modules/Languages/CMakeTestICPCCompiler.cmake b/cmake/Modules/Languages/CMakeTestICPCCompiler.cmake new file mode 100644 index 0000000000000000000000000000000000000000..f46d576679d914e883567cbcfe1ce8bc5903b5f9 --- /dev/null +++ b/cmake/Modules/Languages/CMakeTestICPCCompiler.cmake @@ -0,0 +1,96 @@ +# This file is used by EnableLanguage in cmGlobalGenerator to determine that +# the ICPC builder GNAT_EXECUTABLE_BUILDER = gnatmake can actually compile +# and link the most basic of programs. If not, a fatal error is set and +# cmake stops processing commands and will not generate any makefiles or +# projects. + +function(PrintTestCompilerStatus LANG MSG) + if(CMAKE_GENERATOR MATCHES Make) + message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}") + else() + message(STATUS "Check for working ${LANG} compiler using: ${CMAKE_GENERATOR}${MSG}") + endif() +endfunction() + +unset(CMAKE_ICPC_COMPILER_WORKS CACHE) +if (NOT CMAKE_ICPC_COMPILER_WORKS) + PrintTestCompilerStatus("ICPC" "") + set(test_program "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testICPCCompiler.cxx") + set(test_cmake "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CMakeLists.txt") + file(WRITE ${test_program} + "#ifndef __cplusplus\n" + "# error \"The CMAKE_ICPC_COMPILER is set to a C compiler\"\n" + "#endif\n" + "int main(){return 0;}\n") + FILE(WRITE ${test_cmake} + " + cmake_minimum_required(VERSION 3.0) + set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/Languages) + set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL \"\" FORCE) + project(test ICPC) + set_source_files_properties(${test_program} PROPERTIES LANGUAGE ICPC) + add_executable(testICPCCompiler ${test_program}) + set_target_properties(testICPCCompiler PROPERTIES LINKER_LANGUAGE ICPC) + " + ) + + try_compile(CMAKE_ICPC_COMPILER_WORKS + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + projectName + OUTPUT_VARIABLE __CMAKE_ICPC_COMPILER_OUTPUT + ) + + + # try_compile(CMAKE_ICPC_COMPILER_WORKS ${CMAKE_BINARY_DIR} + # # ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testICPCCompiler.cxx + # ${test_program} + # OUTPUT_VARIABLE __CMAKE_ICPC_COMPILER_OUTPUT) + # message("stt= ${__CMAKE_ICPC_COMPILER_OUTPUT}") + # Move result from cache to normal variable. + set(CMAKE_ICPC_COMPILER_WORKS ${CMAKE_ICPC_COMPILER_WORKS}) + unset(CMAKE_ICPC_COMPILER_WORKS CACHE) + set(ICPC_TEST_WAS_RUN 1) +endif (NOT CMAKE_ICPC_COMPILER_WORKS) + +if(NOT CMAKE_ICPC_COMPILER_WORKS) + PrintTestCompilerStatus("ICPC" " -- broken") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the ICPC compiler works failed with " + "the following output:\n${__CMAKE_ICPC_COMPILER_OUTPUT}\n\n") + message(FATAL_ERROR "The C++ compiler \"${CMAKE_ICPC_COMPILER}\" " + "is not able to compile a simple test program.\nIt fails " + "with the following output:\n ${__CMAKE_ICPC_COMPILER_OUTPUT}\n\n" + "CMake will not be able to correctly generate this project.") +else() + if(ICPC_TEST_WAS_RUN) + PrintTestCompilerStatus("ICPC" " -- works") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the ICPC compiler works passed with " + "the following output:\n${__CMAKE_ICPC_COMPILER_OUTPUT}\n\n") + endif() + + # Try to identify the ABI and configure it into CMakeICPCCompiler.cmake + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) + CMAKE_DETERMINE_COMPILER_ABI(ICPC ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp) + # Try to identify the compiler features + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) + CMAKE_DETERMINE_COMPILE_FEATURES(ICPC) + + # Re-configure to save learned information. + # configure_file( + # ${CMAKE_ROOT}/Modules/CMakeICPCCompiler.cmake.in + # ${CMAKE_PLATFORM_INFO_DIR}/CMakeICPCCompiler.cmake + # @ONLY + # ) + #include(${CMAKE_PLATFORM_INFO_DIR}/CMakeICPCCompiler.cmake) + + if(CMAKE_ICPC_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_ICPC_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_ICPC_ABI_FILES) + endif() +endif() + +unset(__CMAKE_ICPC_COMPILER_OUTPUT) diff --git a/cmake/Modules/Languages/CMakeTestIFORTCompiler.cmake b/cmake/Modules/Languages/CMakeTestIFORTCompiler.cmake new file mode 100644 index 0000000000000000000000000000000000000000..77e3f837159f63fb018dc3007194d8ede5c8b092 --- /dev/null +++ b/cmake/Modules/Languages/CMakeTestIFORTCompiler.cmake @@ -0,0 +1,98 @@ +# This file is used by EnableLanguage in cmGlobalGenerator to determine that +# the IFORT builder GNAT_EXECUTABLE_BUILDER = gnatmake can actually compile +# and link the most basic of programs. If not, a fatal error is set and +# cmake stops processing commands and will not generate any makefiles or +# projects. + +function(PrintTestCompilerStatus LANG MSG) + if(CMAKE_GENERATOR MATCHES Make) + message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}") + else() + message(STATUS "Check for working ${LANG} compiler using: ${CMAKE_GENERATOR}${MSG}") + endif() +endfunction() + +unset(CMAKE_IFORT_COMPILER_WORKS CACHE) +if (NOT CMAKE_IFORT_COMPILER_WORKS) + PrintTestCompilerStatus("IFORT" "") + set(test_program "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testIFORTCompiler.f90") + set(test_cmake "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CMakeLists.txt") + file(WRITE ${test_program} + " + PROGRAM TESTFortran + PRINT *, 'Hello' + END + " + ) + FILE(WRITE ${test_cmake} + " + cmake_minimum_required(VERSION 3.0) + set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/Languages) + set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL \"\" FORCE) + project(test IFORT) + set_source_files_properties(${test_program} PROPERTIES LANGUAGE IFORT) + add_executable(testIFORTCompiler ${test_program}) + set_target_properties(testIFORTCompiler PROPERTIES LINKER_LANGUAGE IFORT) + " + ) + + try_compile(CMAKE_IFORT_COMPILER_WORKS + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + projectName + OUTPUT_VARIABLE __CMAKE_IFORT_COMPILER_OUTPUT + ) + + + # try_compile(CMAKE_IFORT_COMPILER_WORKS ${CMAKE_BINARY_DIR} + # # ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testIFORTCompiler.cxx + # ${test_program} + # OUTPUT_VARIABLE __CMAKE_IFORT_COMPILER_OUTPUT) + # message("stt= ${__CMAKE_IFORT_COMPILER_OUTPUT}") + # Move result from cache to normal variable. + set(CMAKE_IFORT_COMPILER_WORKS ${CMAKE_IFORT_COMPILER_WORKS}) + unset(CMAKE_IFORT_COMPILER_WORKS CACHE) + set(IFORT_TEST_WAS_RUN 1) +endif (NOT CMAKE_IFORT_COMPILER_WORKS) + +if(NOT CMAKE_IFORT_COMPILER_WORKS) + PrintTestCompilerStatus("IFORT" " -- broken") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the IFORT compiler works failed with " + "the following output:\n${__CMAKE_IFORT_COMPILER_OUTPUT}\n\n") + message(FATAL_ERROR "The Intel Fortran compiler \"${CMAKE_IFORT_COMPILER}\" " + "is not able to compile a simple test program.\nIt fails " + "with the following output:\n ${__CMAKE_IFORT_COMPILER_OUTPUT}\n\n" + "CMake will not be able to correctly generate this project.") +else() + if(IFORT_TEST_WAS_RUN) + PrintTestCompilerStatus("IFORT" " -- works") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the IFORT compiler works passed with " + "the following output:\n${__CMAKE_IFORT_COMPILER_OUTPUT}\n\n") + endif() + + # Try to identify the ABI and configure it into CMakeIFORTCompiler.cmake + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) + CMAKE_DETERMINE_COMPILER_ABI(IFORT ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp) + # Try to identify the compiler features + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) + CMAKE_DETERMINE_COMPILE_FEATURES(IFORT) + + # Re-configure to save learned information. + # configure_file( + # ${CMAKE_ROOT}/Modules/CMakeIFORTCompiler.cmake.in + # ${CMAKE_PLATFORM_INFO_DIR}/CMakeIFORTCompiler.cmake + # @ONLY + # ) + #include(${CMAKE_PLATFORM_INFO_DIR}/CMakeIFORTCompiler.cmake) + + if(CMAKE_IFORT_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_IFORT_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_IFORT_ABI_FILES) + endif() +endif() + +unset(__CMAKE_IFORT_COMPILER_OUTPUT) diff --git a/cmake/Modules/ResolveCompilerPaths.cmake b/cmake/Modules/ResolveCompilerPaths.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6610e30ec6d28f16ea58664a120f28ef6f08c3c2 --- /dev/null +++ b/cmake/Modules/ResolveCompilerPaths.cmake @@ -0,0 +1,105 @@ +# ResolveCompilerPaths - this module defines two macros +# +# RESOLVE_LIBRARIES (XXX_LIBRARIES LINK_LINE) +# This macro is intended to be used by FindXXX.cmake modules. +# It parses a compiler link line and resolves all libraries +# (-lfoo) using the library path contexts (-L/path) in scope. +# The result in XXX_LIBRARIES is the list of fully resolved libs. +# Example: +# +# RESOLVE_LIBRARIES (FOO_LIBRARIES "-L/A -la -L/B -lb -lc -ld") +# +# will be resolved to +# +# FOO_LIBRARIES:STRING="/A/liba.so;/B/libb.so;/A/libc.so;/usr/lib/libd.so" +# +# if the filesystem looks like +# +# /A: liba.so libc.so +# /B: liba.so libb.so +# /usr/lib: liba.so libb.so libc.so libd.so +# +# and /usr/lib is a system directory. +# +# Note: If RESOLVE_LIBRARIES() resolves a link line differently from +# the native linker, there is a bug in this macro (please report it). +# +# RESOLVE_INCLUDES (XXX_INCLUDES INCLUDE_LINE) +# This macro is intended to be used by FindXXX.cmake modules. +# It parses a compile line and resolves all includes +# (-I/path/to/include) to a list of directories. Other flags are ignored. +# Example: +# +# RESOLVE_INCLUDES (FOO_INCLUDES "-I/A -DBAR='\"irrelevant -I/string here\"' -I/B") +# +# will be resolved to +# +# FOO_INCLUDES:STRING="/A;/B" +# +# assuming both directories exist. +# Note: as currently implemented, the -I/string will be picked up mistakenly (cry, cry) +include (CorrectWindowsPaths) + +macro (RESOLVE_LIBRARIES LIBS LINK_LINE) + string (REGEX MATCHALL "((-L|-l|-Wl)([^\" ]+|\"[^\"]+\")|[^\" ]+\\.(a|so|dll|lib))" _all_tokens "${LINK_LINE}") + set (_libs_found) + set (_directory_list) + foreach (token ${_all_tokens}) + if (token MATCHES "-L([^\" ]+|\"[^\"]+\")") + # If it's a library path, add it to the list + string (REGEX REPLACE "^-L" "" token ${token}) + string (REGEX REPLACE "//" "/" token ${token}) + convert_cygwin_path(token) + list (APPEND _directory_list ${token}) + elseif (token MATCHES "^(-l([^\" ]+|\"[^\"]+\")|[^\" ]+\\.(a|so|dll|lib))") + # It's a library, resolve the path by looking in the list and then (by default) in system directories + if (WIN32) #windows expects "libfoo", linux expects "foo" + string (REGEX REPLACE "^-l" "lib" token ${token}) + else (WIN32) + string (REGEX REPLACE "^-l" "" token ${token}) + endif (WIN32) + set (_root) + if (token MATCHES "^/") # We have an absolute path + #separate into a path and a library name: + string (REGEX MATCH "[^/]*\\.(a|so|dll|lib)$" libname ${token}) + string (REGEX MATCH ".*[^${libname}$]" libpath ${token}) + convert_cygwin_path(libpath) + set (_directory_list ${_directory_list} ${libpath}) + set (token ${libname}) + endif (token MATCHES "^/") + set (_lib "NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_library (_lib ${token} HINTS ${_directory_list} ${_root}) + if (_lib) + string (REPLACE "//" "/" _lib ${_lib}) + list (APPEND _libs_found ${_lib}) + else (_lib) + message (STATUS "Unable to find library ${token}") + endif (_lib) + endif (token MATCHES "-L([^\" ]+|\"[^\"]+\")") + endforeach (token) + set (_lib "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE) + # only the LAST occurence of each library is required since there should be no circular dependencies + if (_libs_found) + list (REVERSE _libs_found) + list (REMOVE_DUPLICATES _libs_found) + list (REVERSE _libs_found) + endif (_libs_found) + set (${LIBS} "${_libs_found}") +endmacro (RESOLVE_LIBRARIES) + +macro (RESOLVE_INCLUDES INCS COMPILE_LINE) + string (REGEX MATCHALL "-I([^\" ]+|\"[^\"]+\")" _all_tokens "${COMPILE_LINE}") + set (_incs_found "") + foreach (token ${_all_tokens}) + string (REGEX REPLACE "^-I" "" token ${token}) + string (REGEX REPLACE "//" "/" token ${token}) + convert_cygwin_path(token) + if (EXISTS ${token}) + list (APPEND _incs_found ${token}) + else (EXISTS ${token}) + message (STATUS "Include directory ${token} does not exist") + endif (EXISTS ${token}) + endforeach (token) + list (REMOVE_DUPLICATES _incs_found) + set (${INCS} "${_incs_found}") +endmacro (RESOLVE_INCLUDES) diff --git a/cmake/common.cmake b/cmake/common.cmake new file mode 100644 index 0000000000000000000000000000000000000000..18b0f84146fee7c284e5938ebcf2228f45b68156 --- /dev/null +++ b/cmake/common.cmake @@ -0,0 +1,35 @@ + +# ================================================================================================== +# This file is part of the CodeVault project. The project is licensed under Apache Version 2.0. +# CodeVault is part of the EU-project PRACE-4IP (WP7.3.C). +# +# Author(s): +# Cedric Nugteren +# Evghenii Gaburov +# +# ================================================================================================== + +# Includes only once +if (NOT COMMON_CMAKE_SET) + set(COMMON_CMAKE_SET True) + + # ================================================================================================ + + # RPATH settings + set(CMAKE_SKIP_BUILD_RPATH false) # Use, i.e. don't skip the full RPATH for the build tree + set(CMAKE_BUILD_WITH_INSTALL_RPATH false) # When building, don't use the install RPATH already + set(CMAKE_INSTALL_RPATH "") # The RPATH to be used when installing + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH false) # Don't add the automatically determined parts + + # ================================================================================================ + + # Package scripts location + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} + "${CMAKE_CURRENT_LIST_DIR}/Modules/" + "${CMAKE_CURRENT_LIST_DIR}/") + + # ================================================================================================ + +endif() + +# ================================================================================================== diff --git a/cmake/detect_fortran_compiler.cmake b/cmake/detect_fortran_compiler.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a7a46d735c062fc7c762da644dc981436f571f65 --- /dev/null +++ b/cmake/detect_fortran_compiler.cmake @@ -0,0 +1,56 @@ +cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) +cmake_policy(VERSION 2.8.5) + +# This cmake script (when saved as detect_fortran_compiler.cmake) is invoked by: +# +# cmake -P detect_fortran_compiler.cmake +# +# It is written for clarity, not brevity. + +# First make a new directory, so that we don't mess up the current one. +execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory fortran_detection_area + WORKING_DIRECTORY . +) + +# Here, we generate a key file that CMake needs. +execute_process( + COMMAND ${CMAKE_COMMAND} -E echo "enable_language(Fortran OPTIONAL)\n message(\"\${CMAKE_Fortran_COMPILER}\")" + WORKING_DIRECTORY fortran_detection_area + OUTPUT_FILE CMakeLists.txt +) + + +# Have CMake check the basic configuration. The output is +# actually in the form that you posted in your question, but +# instead of displaying it onscreen, we save it to a variable +# so that we can select only parts of it to print later. +execute_process( + COMMAND ${CMAKE_COMMAND} --check-system-vars + OUTPUT_VARIABLE the_output + ERROR_VARIABLE the_error + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY fortran_detection_area +) + +# Eliminate the directory, including all of the files within it that +# CMake created. +execute_process( + COMMAND ${CMAKE_COMMAND} -E remove_directory fortran_detection_area + WORKING_DIRECTORY . +) + +# Here, you have the entire message captured as a variable. +# Uncomment this next line to convince yourself of this. +#message(STATUS "the_output = |${the_output}|.") +#message(STATUS "the_error = |${the_error}|.") + +# Here, we search the message to see if the C++ compiler was found or not, +# and print an arbitrary message accordingly. +string(FIND "${the_error}" "CMAKE_Fortran_COMPILER-NOTFOUND" scan_result) +#message(STATUS "scan_result = |${scan_result}|.") +set(Fortran_COMPILER_FOUND 1) +if(NOT(-1 EQUAL "${scan_result}")) + set(Fortran_COMPILER_FOUND 0) +endif() +