added cmake master

This commit is contained in:
Faruk D 2018-02-26 15:22:26 +01:00
parent 62bbf236a1
commit 0afd92f34a
6 changed files with 682 additions and 0 deletions

153
CMakeLists.txt Normal file
View File

@ -0,0 +1,153 @@
#cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.1.3)
enable_language(CXX)
#--------------------------------------- project
project (SageCal)
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 1)
set(PROJECT_VERSION_PATCH 0)
set(PROJECT_VERSION_REVISION 1)
set(PROJECT_VERSION
"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
message(STATUS "\n############################\n# Building SageCal v${PROJECT_VERSION}\n############################")
include(CheckCXXCompilerFlag)
include(CheckCCompilerFlag)
include(CheckFunctionExists)
#--------------------------------------- paths
SET(MAINFOLDER ${PROJECT_SOURCE_DIR})
SET(EXECUTABLE_OUTPUT_PATH "${MAINFOLDER}/dist/bin")
SET(LIBRARY_OUTPUT_PATH "${MAINFOLDER}/dist/lib")
# Load CMAKE configuration from environment variables
set( CMAKE_MODULE_PATH $ENV{CMAKE_MODULE_PATH} )
set( CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH} )
#--------------------------------------- cmake modules
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/CMakeModules)
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/findFFTW/")
#--------------------------------------- user options
# TODO: check MPI and CUDA flags!
option (ENABLE_MPI "Enable MPI support" OFF)
option (ENABLE_CUDA "Enable CUDA support" OFF)
# TODO: add MPI option
# if(ENABLE_MPI)
# set (USE_THREADS YES)
# find_package (OpenMP)
# if (OPENMP_FOUND)
# if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qopenmp")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qopenmp")
# else( )
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# endif( )
# else (OPENMP_FOUND)
# message(WARNING "Cannot fullfill ENABLE_MPI, compiler does not support it")
# endif (OPENMP_FOUND)
# endif(ENABLE_MPI)
#--------------------------------------- rpath setup for libraries
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
# libsynthesis has mix of C++ and Fortran which is not handled well by
# versions before 2.8.
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
if(NOT LIB_EXTRA_SYNTHESIS)
set(LIB_EXTRA_SYNTHESIS gfortran)
endif(NOT LIB_EXTRA_SYNTHESIS)
endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
#--------------------------------------- SageCal dependencies
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
message(STATUS "\n############################\n# Searching Sagecal dependencies\n############################")
# casacore
find_package(CasaCore REQUIRED)
message(STATUS "Found CasaCore: ${xtensor_INCLUDE_DIRS}")
include_directories(${CASACORE_INCLUDE_DIR})
#cfitsio
find_package(CfitsIO REQUIRED)
message(STATUS "Found CfitsIO: ${CFITSIO_INCLUDE_DIR}")
include_directories(${CFITSIO_INCLUDE_DIR})
#lapack
find_package(LAPACK REQUIRED)
message(STATUS "Found LAPACK: ${LAPACK_INCLUDE_DIR}")
include_directories(${LAPACK_INCLUDE_DIR})
#wcslib
find_package(WcsLib REQUIRED)
message(STATUS "Found LAPACK: ${WCSLIB_INCLUDE_DIR}")
include_directories(${WCSLIB_INCLUDE_DIR})
#blas
find_package(BLAS REQUIRED)
message(STATUS "Found BLAS: ${BLAS_INCLUDE_DIR}")
include_directories(${BLAS_INCLUDE_DIR})
#gfortran
find_package(GFortranLibs REQUIRED)
message(STATUS "Found GFORTRAN: ${GFORTRAN_INCLUDE_DIR}")
include_directories(${GFORTRAN_INCLUDE_DIR})
#glib
pkg_check_modules(GLIB_PKG glib-2.0)
if (GLIB_PKG_FOUND)
message(STATUS "Found GLIB: ${GLIB_PKG_INCLUDE_DIRS}")
include_directories(${GLIB_PKG_INCLUDE_DIRS})
endif()
#--------------------------------------- summary
message(STATUS "\n############################\n# Package summary\n############################")
message (STATUS "CMAKE_SYSTEM .......... = ${CMAKE_SYSTEM}")
message (STATUS "CMAKE_BUILD_TYPE ...... = ${CMAKE_BUILD_TYPE}")
message (STATUS "BUILD_SHARED_LIBS ..... = ${BUILD_SHARED_LIBS}")
message (STATUS "CMAKE_INSTALL_NAME_DIR = ${CMAKE_INSTALL_NAME_DIR}")
message (STATUS "ENABLE_MPI ............ = ${ENABLE_MPI}")
message (STATUS "USE_STACKTRACE ........ = ${USE_STACKTRACE}")
message (STATUS "CMAKE_CXX_COMPILER .... = ${CMAKE_CXX_COMPILER}")
message (STATUS "CMAKE_CXX_FLAGS ....... = ${CMAKE_CXX_FLAGS}")
message (STATUS "BLAS-LIBS ............. = ${BLAS_LIBRARIES}")
message (STATUS "GLIB-INC .............. = ${GLIB_PKG_INCLUDE_DIRS}")
message (STATUS "GLIB-LIBS ............. = ${GLIB_PKG_LIBRARIES}")
message (STATUS "LAPACK-INC ............ = ${LAPACK_INCLUDE_DIR}")
message (STATUS "LAPACK-LIBS ........... = ${LAPACK_LIBRARIES}")
message (STATUS "GFORTRAN-INC ......... = ${GFORTRAN_INCLUDE_DIR}")
message (STATUS "GFORTRAN-LIBS ......... = ${LIBGFORTRAN_LIBRARIES}")
message (STATUS "CFITSIO-INC .......... = ${CFITSIO_INCLUDE_DIR}")
message (STATUS "CFITSIO-LIBS .......... = ${CFITSIO_LIBRARIES}")
#--------------------------------------- build parameters for all targets
set (CMAKE_CXX_FLAGS "-Wall -g -pg -Wextra -std=c++11 -W -Wpointer-arith -Woverloaded-virtual -Wwrite-strings -pedantic -Wno-long-long -O3 -ansi -fPIC -fpermissive -fno-omit-frame-pointer -DNDEBUG -fno-inline-functions -fno-inline-functions-called-once -fno-optimize-sibling-calls")
#--------------------------------------- include directories
# FIXME: add sub-cmake files
#add_subdirectory(src)

View File

@ -0,0 +1,249 @@
# $Id: FindCasacore.cmake 14552 2009-11-26 16:12:40Z loose $
#
# - Try to find Casacore include dirs and libraries
# Usage:
# find_package(Casacore [REQUIRED] [COMPONENTS components...])
# Valid components are:
# casa, scimath_f, scimath, tables, measures, lattices,
# fits, ms, coordinates, msfits, mirlib, images
#
# Note that most components are dependent on other (more basic) components.
# In that case, it suffices to specify the "top-level" components; dependent
# components will be searched for automatically.
#
# Here's the dependency tree:
# scimath_f -> casa
# scimath -> scimath_f
# tables -> casa
# measures -> scimath, tables
# lattices -> scimath, tables
# fits -> measures
# ms -> measures
# coordinates -> fits
# msfits -> fits, ms
# images -> mirlib, lattices
#
# Variables used by this module:
# CASACORE_ROOT_DIR - Casacore root directory.
#
# Variables defined by this module:
# CASACORE_FOUND - System has Casacore, which means that the
# include dir was found, as well as all
# libraries specified (not cached)
# CASACORE_INCLUDE_DIR - Casacore include directory (cached)
# CASACORE_INCLUDE_DIRS - Casacore include directories (not cached)
# identical to CASACORE_INCLUDE_DIR
# CASACORE_LIBRARIES - The Casacore libraries (not cached)
# CASA_${COMPONENT}_LIBRARY - The absolute path of Casacore library
# "component" (cached)
# HAVE_AIPSPP - True if system has Casacore (cached)
# for backward compatibility with AIPS++
# HAVE_CASACORE - True if system has Casacore (cached)
# identical to CASACORE_FOUND
#
# ATTENTION: The component names need to be in lower case, just as the
# casacore library names. However, the CMake variables use all upper case.
#
#
# Copyright (C) 2008-2009
# ASTRON (Netherlands Foundation for Research in Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# - casacore_resolve_dependencies(_result)
#
# Resolve the Casacore library dependencies for the given components.
# The list of dependent libraries will be returned in the variable result.
# It is sorted from least dependent to most dependent library, so it can be
# directly fed to the linker.
#
# Usage: casacore_resolve_dependencies(result components...)
#
macro(casacore_resolve_dependencies _result)
set(${_result} ${ARGN})
set(_index 0)
# Do a breadth-first search through the dependency graph; append to the
# result list the dependent components for each item in that list.
# Duplicates will be removed later.
while(1)
list(LENGTH ${_result} _length)
if(NOT _index LESS _length)
break()
endif(NOT _index LESS _length)
list(GET ${_result} ${_index} item)
list(APPEND ${_result} ${Casacore_${item}_DEPENDENCIES})
math(EXPR _index "${_index}+1")
endwhile(1)
# Remove all duplicates in the current result list, while retaining only the
# last of each duplicate.
list(REVERSE ${_result})
list(REMOVE_DUPLICATES ${_result})
list(REVERSE ${_result})
endmacro(casacore_resolve_dependencies _result)
# - casacore_find_library(_name)
#
# Search for the library ${_name}.
# If library is found, add it to CASACORE_LIBRARIES; if not, add ${_name}
# to CASACORE_MISSING_COMPONENTS and set CASACORE_FOUND to false.
#
# Usage: casacore_find_library(name)
#
macro(casacore_find_library _name)
string(TOUPPER ${_name} _NAME)
find_library(${_NAME}_LIBRARY ${_name}
HINTS ${CASACORE_ROOT_DIR} PATH_SUFFIXES lib)
mark_as_advanced(${_NAME}_LIBRARY)
if(${_NAME}_LIBRARY)
list(APPEND CASACORE_LIBRARIES ${${_NAME}_LIBRARY})
else(${_NAME}_LIBRARY)
set(CASACORE_FOUND FALSE)
list(APPEND CASACORE_MISSING_COMPONENTS ${_name})
endif(${_NAME}_LIBRARY)
endmacro(casacore_find_library _name)
# - casacore_find_package(_name)
#
# Search for the package ${_name}.
# If the package is found, add the contents of ${_name}_INCLUDE_DIRS to
# CASACORE_INCLUDE_DIRS and ${_name}_LIBRARIES to CASACORE_LIBRARIES.
#
# If Casacore itself is required, then, strictly speaking, the packages it
# requires must be present. However, when linking against static libraries
# they may not be needed. One can override the REQUIRED setting by switching
# CASACORE_MAKE_REQUIRED_EXTERNALS_OPTIONAL to ON. Beware that this might cause
# compile and/or link errors.
#
# Usage: casacore_find_package(name [REQUIRED])
#
macro(casacore_find_package _name)
if("${ARGN}" MATCHES "^REQUIRED$" AND
Casacore_FIND_REQUIRED AND
NOT CASACORE_MAKE_REQUIRED_EXTERNALS_OPTIONAL)
find_package(${_name} REQUIRED)
else()
find_package(${_name})
endif()
if(${_name}_FOUND)
list(APPEND CASACORE_INCLUDE_DIRS ${${_name}_INCLUDE_DIRS})
list(APPEND CASACORE_LIBRARIES ${${_name}_LIBRARIES})
endif(${_name}_FOUND)
endmacro(casacore_find_package _name)
# Define the Casacore components.
set(Casacore_components
casa
coordinates
fits
images
lattices
measures
mirlib
ms
msfits
scimath
scimath_f
tables
)
# Define the Casacore components' inter-dependencies.
set(Casacore_coordinates_DEPENDENCIES fits)
set(Casacore_fits_DEPENDENCIES measures)
set(Casacore_images_DEPENDENCIES lattices mirlib)
set(Casacore_lattices_DEPENDENCIES scimath tables)
set(Casacore_measures_DEPENDENCIES scimath tables)
set(Casacore_ms_DEPENDENCIES measures)
set(Casacore_msfits_DEPENDENCIES fits ms)
set(Casacore_scimath_DEPENDENCIES scimath_f)
set(Casacore_scimath_f_DEPENDENCIES casa)
set(Casacore_tables_DEPENDENCIES casa)
# Initialize variables.
set(CASACORE_FOUND FALSE)
set(CASACORE_DEFINITIONS)
set(CASACORE_LIBRARIES)
set(CASACORE_MISSING_COMPONENTS)
# Search for the header file first. Note that casacore installs the header
# files in ${prefix}/include/casacore, instead of ${prefix}/include.
if(NOT CASACORE_INCLUDE_DIR)
find_path(CASACORE_INCLUDE_DIR casacore/casa/aips.h
HINTS ${CASACORE_ROOT_DIR} PATH_SUFFIXES include)
mark_as_advanced(CASACORE_INCLUDE_DIR)
endif(NOT CASACORE_INCLUDE_DIR)
if(NOT CASACORE_INCLUDE_DIR)
set(CASACORE_ERROR_MESSAGE "Casacore: unable to find the header file casa/aips.h.\nPlease set CASACORE_ROOT_DIR to the root directory containing Casacore.")
else(NOT CASACORE_INCLUDE_DIR)
# We've found the header file; let's continue.
set(CASACORE_FOUND TRUE)
set(CASACORE_INCLUDE_DIRS ${CASACORE_INCLUDE_DIR} ${CASACORE_INCLUDE_DIR}/casacore)
# If the user specified components explicity, use that list; otherwise we'll
# assume that the user wants to use all components.
if(NOT Casacore_FIND_COMPONENTS)
set(Casacore_FIND_COMPONENTS ${Casacore_components})
endif(NOT Casacore_FIND_COMPONENTS)
# Get a list of all dependent Casacore libraries that need to be found.
casacore_resolve_dependencies(_find_components ${Casacore_FIND_COMPONENTS})
# Find the library for each component, and handle external dependencies
foreach(_comp ${_find_components})
casacore_find_library(casa_${_comp})
if(${_comp} STREQUAL casa)
casacore_find_package(HDF5)
casacore_find_library(m)
list(APPEND CASACORE_LIBRARIES ${CMAKE_DL_LIBS})
elseif(${_comp} STREQUAL coordinates)
casacore_find_package(WcsLib REQUIRED)
elseif(${_comp} STREQUAL fits)
casacore_find_package(CfitsIO REQUIRED)
elseif(${_comp} STREQUAL scimath_f)
casacore_find_package(LAPACK REQUIRED)
endif(${_comp} STREQUAL casa)
endforeach(_comp ${_find_components})
endif(NOT CASACORE_INCLUDE_DIR)
# Set HAVE_CASACORE; and HAVE_AIPSPP (for backward compatibility with AIPS++).
if(CASACORE_FOUND)
set(HAVE_CASACORE TRUE CACHE INTERNAL "Define if Casacore is installed")
set(HAVE_AIPSPP TRUE CACHE INTERNAL "Define if AIPS++/Casacore is installed")
endif(CASACORE_FOUND)
# Compose diagnostic message if not all necessary components were found.
if(CASACORE_MISSING_COMPONENTS)
set(CASACORE_ERROR_MESSAGE "Casacore: the following components could not be found:\n ${CASACORE_MISSING_COMPONENTS}")
endif(CASACORE_MISSING_COMPONENTS)
# Print diagnostics.
if(CASACORE_FOUND)
if(NOT Casacore_FIND_QUIETLY)
message(STATUS "Found the following Casacore components: ")
foreach(comp ${_find_components})
message(STATUS " ${comp}")
endforeach(comp ${_find_components})
endif(NOT Casacore_FIND_QUIETLY)
else(CASACORE_FOUND)
if(Casacore_FIND_REQUIRED)
message(FATAL_ERROR "${CASACORE_ERROR_MESSAGE}")
else(Casacore_FIND_REQUIRED)
message(STATUS "${CASACORE_ERROR_MESSAGE}")
endif(Casacore_FIND_REQUIRED)
endif(CASACORE_FOUND)

View File

@ -0,0 +1,74 @@
# - Try to find CFITSIO.
# Variables used by this module:
# CFITSIO_ROOT_DIR - CFITSIO root directory
# Variables defined by this module:
# CFITSIO_FOUND - system has CFITSIO
# CFITSIO_INCLUDE_DIR - the CFITSIO include directory (cached)
# CFITSIO_INCLUDE_DIRS - the CFITSIO include directories
# (identical to CFITSIO_INCLUDE_DIR)
# CFITSIO_LIBRARY - the CFITSIO library (cached)
# CFITSIO_LIBRARIES - the CFITSIO libraries
# (identical to CFITSIO_LIBRARY)
# CFITSIO_VERSION_STRING the found version of CFITSIO, padded to 3 digits
# Copyright (C) 2009
# ASTRON (Netherlands Institute for Radio Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This file is part of the LOFAR software suite.
# The LOFAR software suite is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# The LOFAR software suite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
#
# $Id$
if(NOT CFITSIO_FOUND)
find_path(CFITSIO_INCLUDE_DIR fitsio.h
HINTS ${CFITSIO_ROOT_DIR} PATH_SUFFIXES include include/cfitsio
include/libcfitsio0)
if(CFITSIO_INCLUDE_DIR)
FILE(READ "${CFITSIO_INCLUDE_DIR}/fitsio.h" CFITSIO_H)
set(CFITSIO_VERSION_REGEX ".*#define CFITSIO_VERSION[^0-9]*([0-9]+)\\.([0-9]+).*")
if ("${CFITSIO_H}" MATCHES ${CFITSIO_VERSION_REGEX})
# Pad CFITSIO minor version to three digit because 3.181 is older than 3.35
STRING(REGEX REPLACE ${CFITSIO_VERSION_REGEX}
"\\1.\\200" CFITSIO_VERSION_STRING "${CFITSIO_H}")
STRING(SUBSTRING ${CFITSIO_VERSION_STRING} 0 5 CFITSIO_VERSION_STRING)
STRING(REGEX REPLACE "^([0-9]+)[.]([0-9]+)" "\\1" CFITSIO_VERSION_MAJOR ${CFITSIO_VERSION_STRING})
# CFITSIO_VERSION_MINOR will contain 80 for 3.08, 181 for 3.181 and 200 for 3.2
STRING(REGEX REPLACE "^([0-9]+)[.]0*([0-9]+)" "\\2" CFITSIO_VERSION_MINOR ${CFITSIO_VERSION_STRING})
else ()
set(CFITSIO_VERSION_STRING "Unknown")
endif()
endif(CFITSIO_INCLUDE_DIR)
find_library(CFITSIO_LIBRARY cfitsio
HINTS ${CFITSIO_ROOT_DIR} PATH_SUFFIXES lib)
find_library(M_LIBRARY m)
mark_as_advanced(CFITSIO_INCLUDE_DIR CFITSIO_LIBRARY M_LIBRARY)
if(CMAKE_VERSION VERSION_LESS "2.8.3")
find_package_handle_standard_args(CFITSIO DEFAULT_MSG
CFITSIO_LIBRARY M_LIBRARY CFITSIO_INCLUDE_DIR)
else ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CFITSIO
REQUIRED_VARS CFITSIO_LIBRARY M_LIBRARY CFITSIO_INCLUDE_DIR
VERSION_VAR CFITSIO_VERSION_STRING)
endif ()
set(CFITSIO_INCLUDE_DIRS ${CFITSIO_INCLUDE_DIR})
set(CFITSIO_LIBRARIES ${CFITSIO_LIBRARY} ${M_LIBRARY})
endif(NOT CFITSIO_FOUND)

View File

@ -0,0 +1,143 @@
#.rst:
# FindGFortranLibs
# --------
#
# Find gcc Fortran compiler & library paths
#
# The module defines the following variables:
#
# ::
#
#
# GFORTRANLIBS_FOUND - true if system has gfortran
# LIBGFORTRAN_LIBRARIES - path to libgfortran
# LIBQUADMATH_LIBRARIES - path to libquadmath
# GFORTRAN_LIBARIES_DIR - directory containing libgfortran, libquadmath
# GFORTRAN_INCLUDE_DIR - directory containing gfortran/gcc headers
# LIBGOMP_LIBRARIES - path to libgomp
# LIBGOMP_INCLUDE_DIR - directory containing omp.h header
# GFORTRAN_VERSION_STRING - version of gfortran found
#
set(CMAKE_REQUIRED_QUIET ${LIBIOMP_FIND_QUIETLY})
if(NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Looking for gfortran related libraries...")
endif()
enable_language(Fortran)
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
# Basically, call "gfortran -v" to dump compiler info to the string
# GFORTRAN_VERBOSE_STR, which will be used to get necessary paths
message(STATUS "Extracting library and header information by calling 'gfortran -v'...")
execute_process(COMMAND "${CMAKE_Fortran_COMPILER}" "-v" ERROR_VARIABLE
GFORTRAN_VERBOSE_STR RESULT_VARIABLE FLAG)
# For debugging
message(STATUS "'gfortran -v' returned:")
message(STATUS "${GFORTRAN_VERBOSE_STR}")
# Detect gfortran version
string(REGEX MATCH "gcc version [^\t\n ]+" GFORTRAN_VER_STR "${GFORTRAN_VERBOSE_STR}")
string(REGEX REPLACE "gcc version ([^\t\n ]+)" "\\1" GFORTRAN_VERSION_STRING "${GFORTRAN_VER_STR}")
message(STATUS "Detected gfortran version ${GFORTRAN_VERSION_STRING}")
unset(GFORTRAN_VER_STR)
set(MATCH_REGEX "[^\t\n ]+[\t\n ]+")
set(REPLACE_REGEX "([^\t\n ]+)")
# Find architecture for compiler
string(REGEX MATCH "Target: [^\t\n ]+"
GFORTRAN_ARCH_STR "${GFORTRAN_VERBOSE_STR}")
message(STATUS "Architecture string: ${GFORTRAN_ARCH_STR}")
string(REGEX REPLACE "Target: ([^\t\n ]+)" "\\1"
GFORTRAN_ARCH "${GFORTRAN_ARCH_STR}")
message(STATUS "Detected gfortran architecture: ${GFORTRAN_ARCH}")
unset(GFORTRAN_ARCH_STR)
# Find install prefix, if it exists; if not, use default
string(REGEX MATCH "--prefix=[^\t\n ]+[\t\n ]+"
GFORTRAN_PREFIX_STR "${GFORTRAN_VERBOSE_STR}")
if(NOT GFORTRAN_PREFIX_STR)
message(STATUS "Detected default gfortran prefix")
set(GFORTRAN_PREFIX_DIR "/usr/local") # default prefix for gcc install
else()
string(REGEX REPLACE "--prefix=([^\t\n ]+)" "\\1"
GFORTRAN_PREFIX_DIR "${GFORTRAN_PREFIX_STR}")
endif()
message(STATUS "Detected gfortran prefix: ${GFORTRAN_PREFIX_DIR}")
unset(GFORTRAN_PREFIX_STR)
# Find install exec-prefix, if it exists; if not, use default
string(REGEX MATCH "--exec-prefix=[^\t\n ]+[\t\n ]+" "\\1"
GFORTRAN_EXEC_PREFIX_STR "${GFORTRAN_VERBOSE_STR}")
if(NOT GFORTRAN_EXEC_PREFIX_STR)
message(STATUS "Detected default gfortran exec-prefix")
set(GFORTRAN_EXEC_PREFIX_DIR "${GFORTRAN_PREFIX_DIR}")
else()
string(REGEX REPLACE "--exec-prefix=([^\t\n ]+)" "\\1"
GFORTRAN_EXEC_PREFIX_DIR "${GFORTRAN_EXEC_PREFIX_STR}")
endif()
message(STATUS "Detected gfortran exec-prefix: ${GFORTRAN_EXEC_PREFIX_DIR}")
UNSET(GFORTRAN_EXEC_PREFIX_STR)
# Find library directory and include directory, if library directory specified
string(REGEX MATCH "--libdir=[^\t\n ]+"
GFORTRAN_LIB_DIR_STR "${GFORTRAN_VERBOSE_STR}")
if(NOT GFORTRAN_LIB_DIR_STR)
message(STATUS "Found --libdir flag -- not found")
message(STATUS "Using default gfortran library & include directory paths")
set(GFORTRAN_LIBRARIES_DIR
"${GFORTRAN_EXEC_PREFIX_DIR}/lib/gcc/${GFORTRAN_ARCH}/${GFORTRAN_VERSION_STRING}")
string(CONCAT GFORTRAN_INCLUDE_DIR "${GFORTRAN_LIBRARIES_DIR}" "/include")
else()
message(STATUS "Found --libdir flag -- yes")
string(REGEX REPLACE "--libdir=([^\t\n ]+)" "\\1"
GFORTRAN_LIBRARIES_DIR "${GFORTRAN_LIB_DIR_STR}")
string(CONCAT GFORTRAN_INCLUDE_DIR "${GFORTRAN_LIBRARIES_DIR}" "/gcc/" "${GFORTRAN_ARCH}" "/" "${GFORTRAN_VERSION_STRING}" "/include")
endif()
message(STATUS "gfortran libraries path: ${GFORTRAN_LIBRARIES_DIR}")
message(STATUS "gfortran include path dir: ${GFORTRAN_INCLUDE_DIR}")
unset(GFORTRAN_LIB_DIR_STR)
# There are lots of other build options for gcc & gfortran. For now, the
# options implemented above should cover a lot of common use cases.
# Clean up be deleting the output string from "gfortran -v"
unset(GFORTRAN_VERBOSE_STR)
# Find paths for libgfortran, libquadmath, libgomp
# libgomp needed for OpenMP support without Clang
find_library(LIBGFORTRAN_LIBRARIES NAMES gfortran libgfortran
HINTS ${GFORTRAN_LIBRARIES_DIR})
find_library(LIBQUADMATH_LIBRARIES NAMES quadmath libquadmath
HINTS ${GFORTRAN_LIBRARIES_DIR})
find_library(LIBGOMP_LIBRARIES NAMES gomp libgomp
HINTS ${GFORTRAN_LIBRARIES_DIR})
# Find OpenMP headers
find_path(LIBGOMP_INCLUDE_DIR NAMES omp.h HINTS ${GFORTRAN_INCLUDE_DIR})
else()
message(STATUS "CMAKE_Fortran_COMPILER_ID does not match 'GNU'!")
endif()
include(FindPackageHandleStandardArgs)
# Required: libgfortran, libquadmath, path for gfortran libraries
# Optional: libgomp, path for OpenMP headers, path for gcc/gfortran headers
find_package_handle_standard_args(GFortranLibs
REQUIRED_VARS LIBGFORTRAN_LIBRARIES LIBQUADMATH_LIBRARIES GFORTRAN_LIBRARIES_DIR
VERSION_VAR GFORTRAN_VERSION_STRING)
if(GFORTRANLIBS_FOUND)
message(STATUS "Looking for gfortran libraries -- found")
message(STATUS "gfortran version: ${GFORTRAN_VERSION_STRING}")
else()
message(STATUS "Looking for gfortran libraries -- not found")
endif()
mark_as_advanced(LIBGFORTRAN_LIBRARIES LIBQUADMATH_LIBRARIES
LIBGOMP_LIBRARIES LIBGOMP_INCLUDE_DIR
GFORTRAN_LIBRARIES_DIR GFORTRAN_INCLUDE_DIR)
# FindGFortranLIBS.cmake ends here

View File

@ -0,0 +1,51 @@
# $Id: FindWCSLIB.cmake 13814 2009-08-20 11:55:06Z loose $
#
# Copyright (C) 2008-2009
# ASTRON (Netherlands Foundation for Research in Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Try to find WCSLIB.
#
# Variables used by this module:
# WCSLIB_ROOT_DIR - WCSLIB root directory
#
# Variables defined by this module:
# WCSLIB_FOUND - system has WCSLIB
# WCSLIB_INCLUDE_DIR - the WCSLIB include directory (cached)
# WCSLIB_INCLUDE_DIRS - the WCSLIB include directories
# (identical to WCSLIB_INCLUDE_DIR)
# WCSLIB_LIBRARY - the WCSLIB library (cached)
# WCSLIB_LIBRARIES - the WCSLIB libraries
# (identical to WCSLIB_LIBRARY)
if(NOT WCSLIB_FOUND)
find_path(WCSLIB_INCLUDE_DIR wcslib/wcs.h
HINTS ${WCSLIB_ROOT_DIR} PATH_SUFFIXES include)
find_library(WCSLIB_LIBRARY wcs
HINTS ${WCSLIB_ROOT_DIR} PATH_SUFFIXES lib)
find_library(M_LIBRARY m)
mark_as_advanced(WCSLIB_INCLUDE_DIR WCSLIB_LIBRARY M_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WCSLIB DEFAULT_MSG
WCSLIB_LIBRARY M_LIBRARY WCSLIB_INCLUDE_DIR)
set(WCSLIB_INCLUDE_DIRS ${WCSLIB_INCLUDE_DIR})
set(WCSLIB_LIBRARIES ${WCSLIB_LIBRARY} ${M_LIBRARY})
endif(NOT WCSLIB_FOUND)

View File

@ -16,10 +16,22 @@ vr 2 dec 2016 23:07:19 CET
-- Intel MKL and other libraries
- Get the source for SAGECal : git clone git://git.code.sf.net/p/sagecal/code sagecal-code
## Via Anaconda
```
conda install -c conda-forge casacore==2.4.1
```
## 2 The basic way to build is
1.a) go to ./src/lib and run make (which will create libsagecal.a)
1.b) go to ./src/MS and run make (which will create the executable)
```
mkdir build && cd build
cmake .. -DCASACORE_ROOT_DIR=/opt/soft/casacore/
```
## 3 Build settings
In ./src/lib and ./src/MS you MUST edit the Makefiles to suit your system. Some common items to edit are: