Last active
August 13, 2019 09:13
-
-
Save veggiesaurus/e92a21dda300cfbd5684d891e7565d79 to your computer and use it in GitHub Desktop.
Modified CMake config for building imageanalysis with minimal dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CASA - Common Astronomy Software Applications | |
# Copyright (C) 2010 by ESO (in the framework of the ALMA collaboration) | |
# Copyright (C) 2010-2013 Associated Universities, Inc. Washington DC, USA. | |
# | |
# This file is part of CASA. | |
# | |
# 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 3 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, see <http://www.gnu.org/licenses/>. | |
# | |
cmake_minimum_required( VERSION 2.8 ) | |
# ccache use is optional | |
option( UseCcache OFF ) | |
if (UseCcache) | |
message (STATUS "Searching for ccache.") | |
find_program(CCACHE_FOUND ccache) | |
if(CCACHE_FOUND) | |
message (STATUS "Ccache found.") | |
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) | |
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) | |
endif(CCACHE_FOUND) | |
endif() | |
add_definitions ("-DUseCasacoreNamespace") | |
add_definitions ("-DWITHOUT_BOOST") | |
add_definitions(-DUSE_THREADS) # new casacore requirement: | |
# https://github.com/casacore/casacore/commit/2184df898452e1de695a04eb2e785419f707434c | |
set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/install ) | |
execute_process( COMMAND svn info | |
RESULT_VARIABLE SVNINFOSTATUS | |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | |
) | |
message("SVNINFOSTATUS: ${SVNINFOSTATUS}") | |
if(${SVNINFOSTATUS} STREQUAL "0") | |
message("Running svn scripts.") | |
set( CASA_svngen ${CMAKE_SOURCE_DIR}/install/generate-svninfo ) | |
execute_process( COMMAND ${CASA_svngen} -revision url=${CMAKE_SOURCE_DIR} | |
OUTPUT_VARIABLE SVNREVISION | |
OUTPUT_STRIP_TRAILING_WHITESPACE | |
) | |
execute_process( COMMAND ${CASA_svngen} -date url=${CMAKE_SOURCE_DIR} | |
OUTPUT_VARIABLE SVNDATE | |
OUTPUT_STRIP_TRAILING_WHITESPACE | |
) | |
execute_process( COMMAND ${CASA_svngen} -url url=${CMAKE_SOURCE_DIR} | |
OUTPUT_VARIABLE CASASRCURL | |
OUTPUT_STRIP_TRAILING_WHITESPACE | |
) | |
else () | |
message("Couldn't detect svn. Not running svn scripts.") | |
endif () | |
include( config ) | |
include( ui ) | |
include( target ) | |
include( CASA ) | |
set( CASA_VERSION_MAJOR 5 ) | |
set( CASA_VERSION_MINOR 7 ) | |
set( CASA_VERSION_PATCH 0 ) | |
set( CASA_VERSION_FEATURE 0 CACHE STRING "feature version" ) | |
set( CASA_VERSION_DESC "" ) | |
# CASA/ALMA/VLA etc... | |
set( CASA_VARIANT "" ) | |
if( CASA_VERSION_FEATURE STREQUAL "0" ) | |
execute_process( COMMAND svn info | |
RESULT_VARIABLE SVNINFOSTATUS | |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) | |
### hash-bound git will need another solution | |
if ( ${SVNINFOSTATUS} STREQUAL "0" ) | |
execute_process( COMMAND svnversion | |
OUTPUT_VARIABLE SUBVERSION_REVISION | |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | |
OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
execute_process( COMMAND curl --silent https://svn.cv.nrao.edu/cgi-bin/casa-version-match?rev=${SUBVERSION_REVISION} | |
COMMAND perl -pe "s|^\\d+\\.\\d+\\.(\\d+)\\s+\\d+\n*$|$1|" | |
OUTPUT_VARIABLE CASA_VERSION_FEATURE | |
OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
else( ) | |
execute_process( COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/install/resolvegitrevision.pl | |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | |
OUTPUT_VARIABLE CASA_VERSION_FEATURE_AND_BRANCH_TAG # Getting a list | |
OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
message("resolvegitrevision: ${CASA_VERSION_FEATURE_AND_BRANCH_TAG}") | |
list(LENGTH CASA_VERSION_FEATURE_AND_BRANCH_TAG len) | |
message(STATUS "len = ${len}") | |
list ( GET CASA_VERSION_FEATURE_AND_BRANCH_TAG 0 CASA_VERSION_FEATURE) | |
list ( GET CASA_VERSION_FEATURE_AND_BRANCH_TAG 1 BRANCH_TAG) | |
list ( GET CASA_VERSION_FEATURE_AND_BRANCH_TAG 2 CASA_VARIANT) | |
message("CASA_VERSION_FEATURE: ${CASA_VERSION_FEATURE}") | |
message("CASA_VERSION_DESC: ${BRANCH_TAG}") | |
message("CASA_VARIANT: ${CASA_VARIANT}") | |
set(CASA_VERSION_DESC " ${BRANCH_TAG}") | |
endif( ) | |
endif( ) | |
set( CASA_API_VERSION "${CASA_VERSION_MAJOR}.${CASA_VERSION_MINOR}.${CASA_VERSION_PATCH}-${CASA_VERSION_FEATURE}" ) | |
string(TIMESTAMP COMPILE_TIME "%Y-%m-%d %H:%M:%S UTC" UTC) | |
### | |
### default name for casa-maintained dbus C++ library... (but could also be called just "dbus-cpp") | |
### | |
if( APPLE ) | |
set( dbus-cpp-library-name casa-dbus-cpp ) | |
else( ) | |
set( dbus-cpp-library-name casa-dbus-cpp casa-dbus ) | |
endif( ) | |
### | |
### by default, look for Qt4 in the standard places... (with casa01-* RPMs and linux, we avoid system places)... | |
### | |
set( qt4 system-qt ) | |
enable_language (Fortran) | |
# Define compiler paths on OSX 10.5. This must be done before invoking project() | |
if( APPLE ) | |
set( SO dylib ) | |
if( EXISTS ${CMAKE_Fortran_COMPILER}) | |
message(STATUS "Use " ${CMAKE_Fortran_COMPILER}) | |
elseif( EXISTS /opt/casa/core2-apple-darwin8/3rd-party/bin/gfortran ) | |
set( CMAKE_Fortran_COMPILER /opt/casa/core2-apple-darwin8/3rd-party/bin/gfortran ) | |
set( CMAKE_CXX_COMPILER /opt/casa/core2-apple-darwin8/3rd-party/bin/g++ ) | |
elseif( EXISTS /opt/local/bin/gfortran ) | |
set( CMAKE_Fortran_COMPILER /opt/local/bin/gfortran ) | |
elseif( EXISTS /opt/local/bin/gfortran-mp-4.2 ) | |
set( CMAKE_Fortran_COMPILER /opt/local/bin/gfortran-mp-4.2 ) | |
elseif( EXISTS /opt/local/bin/gfortran-mp-4.4 ) | |
set( CMAKE_Fortran_COMPILER /opt/local/bin/gfortran-mp-4.4 ) | |
if( EXISTS /opt/local/bin/g++-mp-4.4 ) | |
set( CMAKE_CXX_COMPILER /opt/local/bin/g++-mp-4.4 ) | |
endif() | |
endif() | |
else() | |
set( SO so ) | |
endif() | |
project( CASA C CXX Fortran ) | |
# C is enabled because | |
# - FindQt4.cmake requires it (bug) | |
# - ccmtools uses the C preprocessor | |
if( CMAKE_Fortran_COMPILER STREQUAL CMAKE_Fortran_COMPILER-NOTFOUND ) | |
message( FATAL_ERROR "Could not find fortran compiler. Please check!" ) | |
endif() | |
casa_always_install() | |
# | |
# Build options | |
# | |
# force searching for libcasacore instead of libcasa_* | |
if( NOT USE_LIBCASACORE ) | |
set( USE_LIBCASACORE False ) | |
endif() | |
# Build type (None, Release, Debug, RelWithDebInfo, MinSizeRel). | |
if( NOT CMAKE_BUILD_TYPE ) | |
set( CMAKE_BUILD_TYPE RelWithDebInfo ) | |
endif() | |
# Build CrashReporter by default | |
if( NOT DEFINED UseCrashReporter) | |
set( UseCrashReporter 1 ) | |
endif() | |
if( CMAKE_BUILD_TYPE STREQUAL Debug ) | |
add_definitions( -DAIPS_DEBUG ) | |
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") | |
set( CMAKE_CXX_FLAGS_DEBUG "-O0 -fno-omit-frame-pointer" ) | |
else( ) | |
set( CMAKE_CXX_FLAGS_DEBUG "-ggdb3 -O0 -fno-omit-frame-pointer" ) | |
endif( ) | |
endif() | |
if( INTERACTIVE_ITERATION ) | |
add_definitions( -DINTERACTIVE_ITERATION ) | |
endif() | |
include( UsePrivatePath ) | |
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR CMAKE_INSTALL_PREFIX MATCHES ".*/linux[^/]*$" OR CMAKE_INSTALL_PREFIX MATCHES ".*/darwin[^/]*$") | |
string( REGEX REPLACE /[^/]+/?$ "" casaroot ${CMAKE_SOURCE_DIR} CACHE ) | |
message("using traditional configuration where casaroot != install prefix:") | |
message(" casaroot = ${casaroot}") | |
message(" CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}") | |
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.in ${CMAKE_CURRENT_SOURCE_DIR}/VERSION ) | |
else( ) | |
set( casaroot ${CMAKE_INSTALL_PREFIX} CACHE PATH "casa install/destroot directory" FORCE ) | |
message("using modern configuraiton where casaroot and install prefix are the same:") | |
message(" casaroot = ${casaroot}") | |
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.in ${casaroot}/VERSION ) | |
endif( ) | |
#string ( REGEX REPLACE /\\/\\.\\./ "" casaroot ${casaroot} ) | |
# | |
# aipshosts is supported for backwards compatibility | |
# | |
if( NOT arch AND EXISTS ${casaroot}/aipshosts ) | |
message( WARNING "Found ${casaroot}/aipshosts. You probably don't need this file unless you need to build multiple architectures. If you remove aipshosts the name of the installation directory will be automatically set based on this machine's architecture, or defined by the cmake command line option -Darch=<arch name>. Specifying on the command line will override the aipshosts entry." ) | |
execute_process( COMMAND uname -n | |
COMMAND awk -F. "{print $1}" | |
OUTPUT_VARIABLE _host OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
execute_process( COMMAND egrep "^[\ ]*${_host}[\ \t]*" ${casaroot}/aipshosts | |
COMMAND awk "{print $2}" | |
OUTPUT_VARIABLE _a | |
OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
if( _a ) | |
set( arch ${_a} ) | |
endif() | |
endif() | |
set( CMAKE_CXX_FLAGS_PROFILE "-g -O2 -pg -fprofile-arcs" ) | |
# On Linux x86_64 add the (gcc specific) -fno-omit-frame-pointer | |
# flag to debug builds | |
if( CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 ) | |
foreach( _c CXX C FORTRAN ) | |
set( CMAKE_${_c}_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer") | |
set( CMAKE_${_c}_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer") | |
endforeach() | |
endif() | |
if (CMAKE_CROSSCOMPILING) | |
dump( CMAKE_HOST_SYSTEM ) | |
endif() | |
dump( CMAKE_SYSTEM | |
CMAKE_SYSTEM_PROCESSOR | |
CMAKE_GENERATOR | |
CMAKE_BUILD_TYPE ) | |
set( BUILD_SHARED_LIBS ON ) | |
if( APPLE ) | |
set( DEFAULT_CXX_FLAGS "-pipe -Wall -Wextra -Wno-comment" ) | |
else () | |
set( DEFAULT_CXX_FLAGS "-pipe -Wall -Wextra -Wno-comment" ) | |
endif() | |
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") | |
set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wcast-align" ) | |
if (NOT APPLE) | |
set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-non-template-friend" ) | |
endif( ) | |
endif( ) | |
if ( NOT UseCrashReporter OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") | |
set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -DNO_CRASH_REPORTER" ) | |
endif( ) | |
set( DEFAULT_C_FLAGS "-pipe -Wall -Wextra -Wcast-align -Wno-comment" ) | |
include(CheckCXXCompilerFlag) | |
include(CheckCCompilerFlag) | |
check_cxx_compiler_flag(-std=c++11 HAS_CXX11) | |
if (HAS_CXX11) | |
set(DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -std=c++11") | |
else() | |
message( FATAL_ERROR "Building requires a c++11 compatible compiler" ) | |
endif() | |
# use faster fortran rules for complex operations, removes restoring complex | |
# infinities if naive computation results in NAN + NAN * I | |
check_cxx_compiler_flag(-fcx-fortran-rules HAS_GXX_FORTRAN_RULES) | |
check_c_compiler_flag(-fcx-fortran-rules HAS_GCC_FORTRAN_RULES) | |
# added before cmake flags so it can be disabled with | |
# -fno-cx-fortran-rules for testing | |
if (HAS_GXX_FORTRAN_RULES) | |
set(DEFAULT_CXX_FLAGS "-fcx-fortran-rules ${DEFAULT_CXX_FLAGS}") | |
endif() | |
if (HAS_GCC_FORTRAN_RULES) | |
set(DEFAULT_C_FLAGS "-fcx-fortran-rules ${DEFAULT_C_FLAGS}") | |
endif() | |
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") | |
## setting intel libraries with e.g. | |
## | |
## find_library( INTEL_IRNG irng HINTS ${INTEL_PATH} ) | |
## | |
## causes CMAKE to substitute fully qualified paths which makes | |
## python shared object unrelocatable in the case of libirng.so | |
## | |
get_filename_component(INTEL_PATH ${CMAKE_CXX_COMPILER} DIRECTORY) | |
set(INTEL_LIB_PATH ${INTEL_PATH}/../lib/intel64) | |
set(INTEL_LIBS -limf -lsvml -lirng -lintlc -lifport -lifcore -liomp5) | |
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,${INTEL_LIB_PATH}") | |
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath,${INTEL_LIB_PATH}") | |
endif() | |
# OpenMP | |
find_package( OpenMP ) | |
if( OPENMP_FOUND ) | |
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") | |
set(DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -qopenmp") | |
set(DEFAULT_C_FLAGS "${DEFAULT_C_FLAGS} -qopenmp") | |
else( ) | |
set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" ) | |
set( DEFAULT_C_FLAGS "${DEFAULT_C_FLAGS} ${OpenMP_C_FLAGS}" ) | |
endif() | |
endif() | |
# For CalLibrary parser | |
find_package (FLEX REQUIRED) | |
find_package (BISON REQUIRED) | |
# Test driver which requires that test programs are up-to-date | |
# before running. (The built-in "test" does not.) | |
add_custom_target( check ${CMAKE_CTEST_COMMAND} ) | |
enable_testing() | |
set( CASA_assay ${CMAKE_SOURCE_DIR}/install/assay ) | |
### | |
### we need to distinguish between different libgfortran versions on RHEL5... | |
### we have old libraries which are linked against the system fortran... which | |
### uses libgfortran.so.1 while the RedHat Dev Toolset compilers include | |
### libgfortran.so.3... even if we use the old gfortran (/usr/bin/gfortran) | |
### and -lgfortran we ALWAYS get libgfortran.so.3 because it is being linked | |
### into libraries and executables via the newer developer toolset gcc/g++... | |
### | |
execute_process( COMMAND ${CMAKE_Fortran_COMPILER} -print-search-dirs | |
COMMAND perl -e "$found = 0; while(<>) { s|\n||g; if( m|^libraries:\\s*=(.*?$)| ) { foreach $d (split(':',$1) ) { if ( -e \"$d/libgfortran${CMAKE_SHARED_LIBRARY_SUFFIX}\" ) { print \"$d/libgfortran${CMAKE_SHARED_LIBRARY_SUFFIX}\"; $found = 1; last; }} last if $found; } last if $found;}" | |
OUTPUT_VARIABLE _gfortran_lib_path | |
OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
message( STATUS "$_gfortran_lib_path = ${_gfortran_lib_path}" ) | |
# | |
# Define paths for development packages. | |
# Check for unresolved symbols at link time. | |
# Set compiler flags. | |
# | |
if( APPLE ) | |
set( CMAKE_Fortran_FLAGS -fno-second-underscore ) | |
### look for dynamic libgfortran | |
if( NOT _gfortran_lib_path ) | |
execute_process( COMMAND ${CMAKE_Fortran_COMPILER} -print-search-dirs | |
COMMAND perl -e "$found = 0; while(<>) { s|\n||g; if( m|^libraries:\\s*=(.*?$)| ) { foreach $d (split(':',$1) ) { if ( -e \"$d/libgfortran${CMAKE_SHARED_LIBRARY_SUFFIX}\" ) { print \"$d/libgfortran${CMAKE_SHARED_LIBRARY_SUFFIX}\"; $found = 1; last; }} last if $found; } last if $found;}" | |
OUTPUT_VARIABLE _gfortran_lib_path | |
OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
endif() | |
### look for static libgfortran | |
if( NOT _gfortran_lib_path ) | |
execute_process( COMMAND ${CMAKE_Fortran_COMPILER} -print-search-dirs | |
COMMAND perl -e "$found = 0; while(<>) { s|\n||g; if( m|^libraries:\\s*=(.*?$)| ) { foreach $d (split(':',$1) ) { if ( -e \"$d/libgfortran.a\" ) { print \"$d/libgfortran.a\"; $found = 1; last; }} last if $found; } last if $found;}" | |
OUTPUT_VARIABLE _gfortran_lib_path | |
OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
endif( ) | |
if( CMAKE_SYSTEM MATCHES ^Darwin-9 ) | |
set( casa_packages /opt/casa/core2-apple-darwin8/3rd-party ) | |
if( DEFINED ENV{LDFLAGS} ) | |
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error $ENV{LDFLAGS}" ) | |
else( ) | |
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error" ) | |
endif( ) | |
if( NOT arch ) | |
set( arch darwin ) | |
endif() | |
elseif( CMAKE_SYSTEM MATCHES ^Darwin-1[0-9]) | |
if( NOT arch ) | |
set( arch darwin64 ) | |
endif() | |
if( NOT archflag ) | |
set( archflag x86_64 ) | |
if( EXISTS /opt/casa/darwin11 ) | |
set( archflag x86_64 ) | |
if( EXISTS /opt/casa/darwin10-64b ) | |
set( archflag x86_64 ) | |
elseif( EXISTS /opt/casa/core2-apple-darwin10 ) | |
set( archflag i386 ) | |
else() | |
## Apple no longer supplies fortran compilers, checking for x86_64 with fortran | |
## compiler will be a good indication if x86_64 is available or not... | |
execute_process( COMMAND ${CMAKE_Fortran_COMPILER} -print-libgcc-file-name | |
COMMAND perl -e "while(<>){ print if s|^.*?(x86_64).*|$1| }" | |
OUTPUT_VARIABLE archflag | |
OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
if( NOT archflag ) | |
set( archflag x86_64 ) | |
endif() | |
endif() | |
endif() | |
if( archflag STREQUAL x86_64 ) | |
if(CMAKE_SYSTEM MATCHES ^Darwin-11) | |
set ( casa_packages /opt/casa/darwin11 ) | |
elseif(CMAKE_SYSTEM MATCHES ^Darwin-12) | |
set ( casa_packages /opt/casa/01 ) | |
elseif( EXISTS /opt/casa/02) | |
set ( casa_packages /opt/casa/02 ) | |
else() | |
set ( casa_packages /opt/casa/01 ) | |
endif() | |
message( "-- CMAKE_SYSTEM : ${CMAKE_SYSTEM}" ) | |
message( "-- casa_packages set to : ${casa_packages}" ) | |
add_definitions( -DAIPS_64B ) | |
endif() | |
else() | |
set( casa_packages /opt/casa/core2-apple-darwin10 ) | |
endif() | |
execute_process( COMMAND ${CMAKE_Fortran_COMPILER} --version | |
COMMAND head -1 | |
COMMAND perl -pe "s|.*?(\\d+\\.\\d+)\\.\\d+$|$1|" | |
OUTPUT_VARIABLE _gfortran_version | |
OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
execute_process( COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine | |
COMMAND head -1 | |
COMMAND perl -pe "s|.*?(\\d+\\.\\d+)\\.\\d+$|$1|" | |
OUTPUT_VARIABLE _gcc_machine | |
OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version | |
COMMAND head -1 | |
COMMAND perl -pe "s|.*?(\\d+\\.\\d+)\\.\\d+$|$1|" | |
OUTPUT_VARIABLE _cxx_version | |
OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
message( STATUS "$_gfortran_version = ${_gfortran_version}" ) | |
message( STATUS "$_gcc_machine = ${_gcc_machine}" ) | |
message( STATUS "cxxversion (${_cxx_version})" ) | |
if( NOT _gfortran_version STREQUAL "4.4" AND NOT _gfortran_version STREQUAL "4.2" AND NOT LLVMCOMPILER ) | |
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" ) | |
if( DEFINED ENV{LDFLAGS} ) | |
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit -lgfortran $ENV{LDFLAGS}") | |
else( ) | |
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit -lgfortran") | |
endif( ) | |
else() | |
if( DEFINED ENV{LDFLAGS} ) | |
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit $ENV{LDFLAGS}" ) | |
else( ) | |
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit" ) | |
endif( ) | |
endif() | |
# Which part of CASA needs -framework AppKit to run? This should probably *not* be added | |
# as a generic linker flag. | |
if( NOT _cxx_version STREQUAL "4.4" ) | |
set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS}" ) | |
endif() | |
else() | |
message( WARNING "Unsupported Mac: ${CMAKE_SYSTEM}" ) | |
endif() | |
if( NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" ) | |
if( _cxx_version STREQUAL "4.4" ) | |
set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -dynamic -mtune=nocona -ftree-vectorize -mfpmath=sse" ) | |
else() | |
# set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -dynamic -mtune=nocona -ftree-vectorize -mfpmath=sse -fasm-blocks" ) | |
set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -dynamic -mtune=nocona -ftree-vectorize -mfpmath=sse" ) | |
endif() | |
endif() | |
# find_program( DBUS_FLAVOR_dbuspp-xml2cpp_EXECUTABLE dbuspp-xml2cpp PATHS ${casa_packages}/bin /opt/local/bin /usr/local/bin ) | |
# if ( ${DBUS_FLAVOR_dbuspp-xml2cpp_EXECUTABLE} MATCHES "NOTFOUND$" ) | |
# set( dbusxx dbus-c++ ) | |
# else( ) | |
# set( dbusxx dbus-cpp ) | |
# add_definitions( -DDBUS_CPP ) | |
# STRING( REGEX REPLACE "(^.*)/bin.*" "\\1" dbus-root-path ${DBUS_FLAVOR_dbuspp-xml2cpp_EXECUTABLE} ) | |
# if( EXISTS ${dbus-root-path}/lib/dbus-1.0 ) | |
# set( dbus-arch-path-guess ${dbus-root-path}/lib/dbus-1.0 ) | |
# endif( ) | |
# if( EXISTS ${dbus-root-path}/lib/libdbus-cpp.dylib ) | |
# if( APPLE ) | |
# set( dbus-cpp-library-name dbus-cpp ) | |
# else( ) | |
# set( dbus-cpp-library-name casa-dbus-cpp casa-dbus ) | |
# endif( ) | |
# endif( ) | |
# endif( ) | |
elseif( CMAKE_SYSTEM_NAME STREQUAL Linux ) | |
if( DEFINED ENV{LDFLAGS} ) | |
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined $ENV{LDFLAGS} -Wl,-rpath,${INTEL_LIB_PATH}") | |
else( ) | |
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined -Wl,-rpath,${INTEL_LIB_PATH}") | |
endif( ) | |
if( CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 ) | |
if ( EXISTS /opt/casa/02/bin/python ) | |
set( casa_packages /opt/casa/02 ) | |
set( dbusxx dbus-cpp ) | |
add_definitions( -DDBUS_CPP ) | |
if ( EXISTS /opt/casa/02/bin/qmake ) | |
## RHEL6 | |
set( qt4 casa-qt ) | |
else( ) | |
## RHEL7 | |
set( qt4 system-qt ) | |
# on RHEL7 we use the system libdbus*, here we assume | |
# that on RHEL6 the third party packages will continue | |
# to be installed in /usr/lib64/casa/02... (on RHEL6 | |
# we continue to use libcasa-dbus in preference to | |
# the system libdbus... | |
set( dbus-cpp-library-name casa-dbus-cpp ) | |
endif( ) | |
elseif ( EXISTS /usr/lib64/casa/01/bin/qmake ) | |
set( casa_packages /usr/lib64/casa/01 ) | |
set( dbusxx dbus-cpp ) | |
add_definitions( -DDBUS_CPP ) | |
set( qt4 casa-qt ) | |
elseif( EXISTS /opt/casa/01/bin/python2.7 ) | |
set( casa_packages /opt/casa/01 ) | |
set( dbusxx dbus-cpp ) | |
add_definitions( -DDBUS_CPP ) | |
set( qt4 system-qt ) | |
# on RHEL7 we use the system libdbus*, here we assume | |
# that on RHEL6 the third party packages will continue | |
# to be installed in /usr/lib64/casa/01... (on RHEL6 | |
# we continue to use libcasa-dbus in preference to | |
# the system libdbus... | |
set( dbus-cpp-library-name casa-dbus-cpp ) | |
else( ) | |
set( dbusxx dbus-c++ ) | |
set( casa_packages /usr/lib64/casapy ) | |
set( qt4 system-qt ) | |
endif( ) | |
if( NOT arch ) | |
set( arch linux_64b ) | |
endif() | |
set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated" ) | |
else() | |
set( casa_packages /usr/lib/casapy ) | |
if( NOT arch ) | |
set( arch linux_gnu ) | |
endif() | |
set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated -Woverloaded-virtual" ) | |
set( dbusxx dbus-c++ ) | |
set( casa_packages /usr/lib/casapy ) | |
set( qt4 system-qt ) | |
set( python_version 2.7 ) | |
endif() | |
else() | |
message( WARNING "Unsupported system: ${CMAKE_SYSTEM_NAME}" ) | |
endif() | |
set( CMAKE_MODULE_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} ) | |
if( NOT CMAKE_CXX_FLAGS ) | |
set( CMAKE_CXX_FLAGS "${DEFAULT_CXX_FLAGS} ${EXTRA_CXX_FLAGS}" ) | |
endif() | |
if( NOT CMAKE_C_FLAGS ) | |
set( CMAKE_C_FLAGS "${DEFAULT_C_FLAGS} ${EXTRA_C_FLAGS}" ) | |
endif() | |
if( NOT RE_CMAKE ) | |
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | |
set( CMAKE_INSTALL_PREFIX ${casaroot}/${arch} CACHE PATH "casa architecture directory" FORCE ) | |
set( casaroot ${casaroot} CACHE PATH "toplevel casa directory" FORCE ) | |
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | |
endif() | |
dump( casaroot ) | |
dump( CMAKE_INSTALL_PREFIX ) | |
SET(NO_SOVERSION FALSE CACHE BOOL "do not add version information to shared libraries") | |
if( NOT NO_SOVERSION ) | |
set( epochdelta 1385614800 ) | |
if ( EXISTS ${CMAKE_INSTALL_PREFIX}/${arch}/casa_sover.txt ) | |
execute_process( COMMAND perl -e "while (<>) { chomp and print if (! m/^\#/ ) }" ${CMAKE_INSTALL_PREFIX}/${arch}/casa_sover.txt | |
OUTPUT_VARIABLE __casa_soversion ) | |
elseif( EXISTS ${CMAKE_INSTALL_PREFIX}/casa_sover.txt ) | |
execute_process( COMMAND perl -e "while (<>) { chomp and print if (! m/^#/ ) }" ${CMAKE_INSTALL_PREFIX}/casa_sover.txt | |
OUTPUT_VARIABLE __casa_soversion ) | |
else( ) | |
execute_process( COMMAND perl -e "$t=time( )-${epochdelta};$z=$t & 0xff; $y=($t>>8)&0xff; $x=($t>>16)&0xffff; print \"$x.$y.$z\"" | |
OUTPUT_VARIABLE __casa_soversion ) | |
endif( ) | |
set(casa_soversion ${__casa_soversion} CACHE STRING "version for shared objects") | |
message( STATUS "Shared object version number ${casa_soversion}" ) | |
else( ) | |
message( STATUS "User disabled shared library versioning" ) | |
endif( ) | |
if( NOT RE_CMAKE ) | |
if (casaroot STREQUAL CMAKE_INSTALL_PREFIX) | |
# Create a top-level AND lower-level casainit.sh all in one... | |
file( WRITE ${casaroot}/casainit.sh | |
"# Generated by CMake from code/CMakeLists.txt. Do not edit.\n" | |
"# Usage: source casainit.sh\n" | |
"export CASA_INSTALLATION_TYPE=\"developer-environment\"\n" | |
"\n" | |
"a_root=${casaroot}\n" | |
"a_host=`uname -n | awk -F. '{ print $1 }'`\n" | |
"a_temp=\"\"\n" | |
"a_arch=\"\"\n" | |
"if [ -f \"$a_root/aipshosts\" ]\n" | |
"then\n" | |
" a_temp=`egrep \"^[ ]*$a_host[ ]\" \"$a_root/aipshosts\"`\n" | |
" a_arch=`/bin/echo $a_temp | awk '{ print $2 }'`\n" | |
"fi\n" | |
"export CASAPATH=\"${casaroot} ${arch}\"\n" | |
"export PATH=${CMAKE_INSTALL_PREFIX}/bin:${casa_packages}/bin:$PATH\n" | |
) | |
file( WRITE ${casaroot}/casainit.csh | |
"# Generated by CMake from code/CMakeLists.txt. Do not edit.\n" | |
"# Usage: source casainit.csh\n" | |
"setenv CASA_INSTALLATION_TYPE \"developer-environment\"\n" | |
"\n" | |
"set a_root=\"${casaroot}\"\n" | |
"set a_host=`uname -n | awk -F. '{ print $1 }'`\n" | |
"set a_temp=\"\"\n" | |
"set a_arch=\"\"\n" | |
"if ( -f \"$a_root/aipshosts\" ) then\n" | |
" set a_temp = `egrep \"^[ ]*\${a_host}[ ]\" \"$a_root/aipshosts\"`\n" | |
" set a_arch = `/bin/echo $a_temp | awk '{ print $2 }'`\n" | |
"endif\n" | |
"setenv CASAPATH \"${casaroot} ${arch}\"\n" | |
"setenv PATH ${CMAKE_INSTALL_PREFIX}/bin:${casa_packages}/bin:$PATH\n" | |
) | |
else( ) | |
# | |
# Create casainit.(c)sh | |
# The environment defined here is not needed at build time, but at runtime. | |
# The definitions are architecture dependent, hence put them in the install directory | |
# | |
file( WRITE ${CMAKE_INSTALL_PREFIX}/casainit.sh | |
"# Usage: source casainit.sh\n" | |
"# Generated by CMake from code/CMakeLists.txt. Do not edit.\n" | |
" export CASAPATH=\"${casaroot} ${arch}\"\n" | |
" export PATH=${CMAKE_INSTALL_PREFIX}/bin:${casa_packages}/bin:$PATH\n" | |
) | |
file( WRITE ${CMAKE_INSTALL_PREFIX}/casainit.csh | |
"# Usage: source casainit.csh\n" | |
"# Generated by CMake from code/CMakeLists.txt. Do not edit.\n" | |
" setenv CASAPATH \"${casaroot} ${arch}\"\n" | |
" setenv PATH ${CMAKE_INSTALL_PREFIX}/bin:${casa_packages}/bin:$PATH\n" | |
) | |
# Create a top-level casainit.sh which sources the <arch>/casainit.sh | |
# that belongs to this build. | |
file( WRITE ${casaroot}/casainit.sh | |
"# Usage: cd ..; source casainit.sh\n" | |
"# Generated by CMake from code/CMakeLists.txt. Do not edit.\n" | |
"export CASA_INSTALLATION_TYPE=\"developer-environment\"\n" | |
"\n" | |
"a_root=${casaroot}\n" | |
"a_host=`uname -n | awk -F. '{ print $1 }'`\n" | |
"a_temp=\"\"\n" | |
"a_arch=\"\"\n" | |
"if [ -f \"$a_root/aipshosts\" ]\n" | |
"then\n" | |
" a_temp=`egrep \"^[ ]*$a_host[ ]\" \"$a_root/aipshosts\"`\n" | |
" a_arch=`/bin/echo $a_temp | awk '{ print $2 }'`\n" | |
"fi\n" | |
"if [ \"$a_arch\" = \"\" ]\n" | |
"then\n" | |
" source ${CMAKE_INSTALL_PREFIX}/casainit.sh\n" | |
"else\n" | |
" source $a_root/$a_arch/casainit.sh\n" | |
"fi\n" | |
) | |
file( WRITE ${casaroot}/casainit.csh | |
"# Usage: cd ..; source casainit.csh\n" | |
"# Generated by CMake from code/CMakeLists.txt. Do not edit.\n" | |
"setenv CASA_INSTALLATION_TYPE \"developer-environment\"\n" | |
"\n" | |
"set a_root=\"${casaroot}\"\n" | |
"set a_host=`uname -n | awk -F. '{ print $1 }'`\n" | |
"set a_temp=\"\"\n" | |
"set a_arch=\"\"\n" | |
"if ( -f \"$a_root/aipshosts\" ) then\n" | |
" set a_temp = `egrep \"^[ ]*\${a_host}[ ]\" \"$a_root/aipshosts\"`\n" | |
" set a_arch = `/bin/echo $a_temp | awk '{ print $2 }'`\n" | |
"endif\n" | |
"if ( \"$a_arch\" == \"\" ) then\n" | |
" source ${CMAKE_INSTALL_PREFIX}/casainit.csh\n" | |
"else\n" | |
" source $a_root/$a_arch/casainit.csh\n" | |
"endif\n" | |
) | |
endif( ) | |
endif( ) | |
set( RE_CMAKE "YES" CACHE STRING "are we rerunning cmake?" FORCE ) | |
# | |
# Targets for creating doxygen documentation | |
# | |
# Use htlatex, do not support latex2html | |
find_program( LATEX2HTML_CONVERTER NAMES htlatex ) | |
set( LATEX2HTML_OPTIONS "htcasa,section+,next,p-width,5" | |
CACHE STRING "LATEX2HTML_CONVERTER options" ) | |
# Use pdflatex | |
find_program( PDFLATEX_COMPILER NAMES pdflatex ) | |
#set( LATEX2PDF_OPTIONS "htcasa,section+,next,p-width,3" | |
#CACHE STRING "LATEX2PDF_CONVERTER options" ) | |
set( CASA_DOC_DIR ${casaroot}/docs ) # Where to put documentation | |
find_package( Doxygen ) | |
if( DOXYGEN_FOUND ) | |
add_custom_target( doc_doxy | |
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/install/docutils/doxygen.cfg | |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | |
) | |
else() | |
add_custom_target( doc_doxy | |
COMMAND echo "doxygen was not found." | |
) | |
endif() | |
# Choose to have correct RPATHs both in the build tree and | |
# in the install tree (at the cost of having to change the | |
# rpath when installing) | |
set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${INTEL_LIB_PATH}:arbitraryExtraPaddingToAllowForRpathGrowth" ) | |
set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | |
set( CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib ) | |
set( PREFIX ${casaroot} CACHE PATH "toplevel casa directory" FORCE ) | |
set( INCLUDE ${CMAKE_INSTALL_PREFIX}/include CACHE PATH "casa include file install directory" FORCE ) | |
set( LDDPATH "" CACHE STRING "path for (DY)LD_LIBRARY_PATH" FORCE ) | |
set( LDDPRELOAD "" CACHE STRING "libraries to be pre-loaded at runtime" FORCE ) | |
set( LIBVERSION ${casa_soversion} CACHE STRING "shared library version number" FORCE ) | |
configure_file( ${CMAKE_SOURCE_DIR}/install/casa-config.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/casa-config @ONLY ) | |
file( COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/casa-config | |
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin | |
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE | |
GROUP_READ GROUP_EXECUTE | |
WORLD_READ WORLD_EXECUTE ) | |
# Preprocessor definitions | |
add_definitions( | |
# seen in CASA code | |
-DAIPS_HAS_QWT | |
# seen nowhere | |
# -DHAVE_QT4 | |
# -DAIPS_USEATM # only in synthesis test | |
) | |
if( CMAKE_SYSTEM_NAME STREQUAL Linux ) | |
add_definitions( -DAIPS_LINUX ) | |
if( CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 ) | |
add_definitions( | |
-DAIPS_64B | |
) | |
else() | |
# Linux, 32 bit | |
endif() | |
elseif( CMAKE_SYSTEM_NAME STREQUAL Darwin ) | |
add_definitions( | |
-DAIPS_DARWIN | |
) | |
else( | |
message( WARNING "Not on Linux nor Darwin!" ) | |
) | |
endif() | |
include( TestBigEndian ) | |
test_big_endian( is_big_endian ) | |
if( NOT is_big_endian ) | |
add_definitions( | |
-DAIPS_LITTLE_ENDIAN | |
) | |
endif() | |
# | |
# External packages | |
# | |
# Perl | |
find_package( Perl ) | |
# CFITSIO | |
casa_find( CFITSIO | |
VERSION 3.006 | |
INCLUDES fitsio.h fitsio2.h | |
INCLUDES_SUFFIXES cfitsio | |
LIBS cfitsio | |
PREFIX_HINTS ${CFITSIO_ROOT_DIR} | |
CPP_VERSION CFITSIO_VERSION | |
RUN_VERSION "(ffvers(&v), v)" ) | |
# X11. | |
if( NOT APPLE ) | |
find_package( X11 REQUIRED ) | |
# Rename | |
set( X11_INCLUDE_DIRS ${X11_INCLUDE_DIR} ) | |
endif() | |
# Since we are using the C++ linker, the Fortran runtime libraries must be explicitly | |
# linked in. | |
if( CMAKE_SYSTEM_NAME STREQUAL Linux AND EXISTS ${_gfortran_lib_path} ) | |
# SET(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES ${_gfortran_lib_path}) | |
# SET(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "") | |
message( STATUS "not setting CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES to a fully qualified path because cmake (on RHEL7 anyway) just changes it back to something like -lgfortran anyway..." ) | |
endif( ) | |
if( NOT FORTRAN_LIBRARIES ) | |
message( STATUS "Looking for Fortran runtime libraries" ) | |
set( _try ${CMAKE_BINARY_DIR}/try_fortran.cc ) | |
file( WRITE ${_try} | |
"int main() { return 0; }\n" | |
) | |
if( _gfortran_lib_path ) | |
try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try} | |
CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=${_gfortran_lib_path}" | |
) | |
else() | |
try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try} | |
CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lgfortran" | |
) | |
endif() | |
try_compile( _have_g2c ${CMAKE_BINARY_DIR} ${_try} | |
CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lg2c" | |
) | |
if( _have_gfortran ) | |
if( _gfortran_lib_path ) | |
set( FORTRAN_LIBRARIES ${_gfortran_lib_path} | |
CACHE STRING "Fortran library linker option" FORCE ) | |
else() | |
set( FORTRAN_LIBRARIES -lgfortran | |
CACHE STRING "Fortran library linker option" FORCE ) | |
endif() | |
message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" ) | |
elseif( _have_g2c ) | |
set( FORTRAN_LIBRARIES -lg2c | |
CACHE STRING "Fortran library linker option" FORCE ) | |
message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" ) | |
else() | |
set( FORTRAN_LIBRARIES "" | |
CACHE STRING "Fortran library linker option" FORCE ) | |
message( STATUS "Looking for Fortran runtime libraries -- <none>" ) | |
# Not a fatal error because it might work, if all Fortran dependencies were | |
# already linked statically to the Fortran runtime... | |
endif() | |
endif() | |
# PGPLOT (FORTRAN plotting package). | |
# depends on X11 | |
if( NOT SKIP_PGPLOT ) | |
if( APPLE ) | |
set( _deps FORTRAN ) | |
else() | |
set( _deps X11 FORTRAN ) | |
endif() | |
if (CMAKE_SYSTEM MATCHES ^Darwin-11 AND NOT LLVMCOMPILER ) | |
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit -lgfortran" ) | |
else() | |
if (APPLE) | |
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit" ) | |
else() | |
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined -Wl,error" ) | |
endif() | |
endif() | |
casa_find( PGPLOT | |
VERSION 5.3.1 | |
PREFIX_HINTS ${PGPLOT_ROOT_DIR} | |
INCLUDES cpgplot.h | |
LIBS pgplot${pgplot_ext} cpgplot${pgplot_ext} | |
DEPENDS ${_deps} ) | |
endif() | |
# WCSLIB | |
if( NOT SKIP_PGPLOT ) | |
casa_find( WCSLIB | |
VERSION 4.3 | |
PREFIX_HINTS ${WCSLIB_ROOT_DIR} | |
INCLUDES wcslib/wcsconfig.h | |
LIBS wcs | |
pgsbox${pgplot_ext} | |
# WCSLIB does "#define WCSLIB_VERSION 4.3.4" without quotes, | |
# hence "cout << WCSLIB_VERSION" would not work. The following | |
# code makes a string out of WCSLIB_VERSION. | |
CPP_VERSION "\"\"; | |
#define CASA_STRINGIFY(x) #x | |
#define CASA_TOSTRING(x) CASA_STRINGIFY(x) | |
std::cout << CASA_TOSTRING(WCSLIB_VERSION)" | |
DEFINITIONS -DSIGNBIT | |
DEPENDS PGPLOT ) | |
else() | |
casa_find( WCSLIB | |
VERSION 4.3 | |
PREFIX_HINTS ${WCSLIB_ROOT_DIR} | |
INCLUDES wcslib/wcsconfig.h | |
LIBS wcs | |
# WCSLIB does "#define WCSLIB_VERSION 4.3.4" without quotes, | |
# hence "cout << WCSLIB_VERSION" would not work. The following | |
# code makes a string out of WCSLIB_VERSION. | |
CPP_VERSION "\"\"; | |
#define CASA_STRINGIFY(x) #x | |
#define CASA_TOSTRING(x) CASA_STRINGIFY(x) | |
std::cout << CASA_TOSTRING(WCSLIB_VERSION)" | |
DEFINITIONS -DSIGNBIT ) | |
endif() | |
# FFTW | |
# Does not provide its version number in a header nor | |
# in the library, which is a pity because CASACore needs | |
# version >= 3.2.2 and is subject to a bug in fftw 3.2.1 | |
casa_find( FFTW3 | |
PREFIX_HINTS ${FFTW3_ROOT_DIR} | |
INCLUDES fftw3.h | |
LIBS fftw3_threads fftw3f_threads fftw3f fftw3 ) | |
if( ${arch} STREQUAL "darwin" ) | |
message(STATUS "prefix yes") | |
find_package (BLAS REQUIRED) | |
find_package (LAPACK REQUIRED) | |
else() | |
message(STATUS "prefix no") | |
# BLAS | |
casa_find( BLAS | |
LIBS blas ) | |
# LAPACK | |
casa_find( LAPACK | |
LIBS lapack | |
DEPENDS BLAS ) | |
endif() | |
# DL | |
set( DL_LIBRARIES ${CMAKE_DL_LIBS} CACHE STRING "dl libraries" FORCE ) | |
if( DL_LIBRARIES STREQUAL "dl" ) | |
set( DL_LIBRARIES "-ldl" CACHE STRING "dl libraries" FORCE ) | |
endif() | |
# CASACore | |
# - Some header files exported by CASACore include WCSLIB headers | |
# - CASACore header files declare symbols which are defined in LAPACK and BLAS | |
# - There are several, incompatible, ways of building CASACore. | |
if( EXISTS ${CMAKE_INSTALL_PREFIX}/lib/libcasacore.dylib OR | |
EXISTS ${CMAKE_INSTALL_PREFIX}/lib/libcasacore.so OR | |
EXISTS ${CMAKE_INSTALL_PREFIX}/lib64/libcasacore.so OR USE_LIBCASACORE ) | |
set( casacore_libs casacore ) | |
## | |
## by default the GNUmakefile for casacore installs include | |
## files into ${casaroot}. | |
## | |
set( casacore_prefix ${CMAKE_INSTALL_PREFIX}/.. ) | |
else() | |
if( EXISTS ${CMAKE_INSTALL_PREFIX}/../include/casacore/casa/BasicMath.h ) | |
set( casacore_prefix ${CMAKE_INSTALL_PREFIX}/.. ) | |
endif() | |
set( casacore_libs | |
casa_casa | |
casa_coordinates | |
casa_fits | |
casa_images | |
casa_lattices | |
casa_measures | |
casa_mirlib | |
casa_ms | |
casa_msfits | |
casa_scimath | |
casa_scimath_f | |
casa_tables ) | |
endif() | |
casa_find( CASACORE | |
VERSION 2.0.2 | |
PREFIX_HINTS ${CASACORE_ROOT_DIR} | |
DEFINITIONS "-DUseCasacoreNamespace" | |
INCLUDES casa/aips.h | |
casa/version.h | |
INCLUDES_SUFFIXES casacore | |
LIBS ${casacore_libs} | |
PREFIX_HINTS ${casacore_prefix} | |
CPP_VERSION CASACORE_VERSION | |
RUN_VERSION "casacore::getVersionCASA()" | |
DEPENDS LAPACK CFITSIO WCSLIB FFTW3 DL) | |
# Listing explicitly CASACore's dependency libraries is not necessary if the CASACore libraries | |
# were built with correct linking information, which they are not. | |
set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS} | |
-DCASA_USECASAPATH | |
-DCASACORE_NEEDS_RETHROW | |
-DAIPS_STDLIB | |
-DAIPS_AUTO_STL | |
-D_GNU_SOURCE ) | |
if( CMAKE_SYSTEM_NAME STREQUAL Linux ) | |
set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS} | |
-D_FILE_OFFSET_BITS=64 | |
-D_LARGEFILE_SOURCE | |
) | |
endif() | |
option(USE_MPI "Use MPI compiler" NO) | |
set( CASAMPI "" ) | |
if (USE_MPI) | |
find_package(MPI) | |
if( MPI_CXX_FOUND ) | |
set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS} | |
-DHAVE_MPI | |
) | |
set( CASAMPI "MPI" ) | |
endif() | |
endif() | |
# ALMAWVR | |
if( USE_ALMAWVR ) | |
message(STATUS "Directive USE_ALMAWVR is deprecated and no longer needed.") | |
message(STATUS "Will use CASA-internal version of BNMIN1 ...") | |
endif() | |
casa_find( GSLCBLAS | |
LIBS gslcblas ) | |
casa_find( GSL | |
LIBS gsl | |
DEPENDS GSLCBLAS | |
) | |
# | |
# gsl drags in dependencencies on atlas libraries, if they are not explicitly | |
# referenced, loading is left until runtime based upon transitive dependencies. | |
# This thwarts creation of a cleanly relocatable distribution. | |
# | |
if(CMAKE_SYSTEM_NAME STREQUAL Linux AND GSL_LIBRARIES) | |
if(EXISTS "/usr/lib64/atlas/libsatlas.so") | |
set( GSL_LIBRARIES "${GSL_LIBRARIES};/usr/lib64/atlas/libsatlas.so" ) | |
endif( ) | |
endif( ) | |
## ATM | |
#casa_find( ATM | |
# VERSION 0.5 | |
# INCLUDES ATMEnumerations.h ATMVersion.h | |
# INCLUDES_SUFFIXES ATM | |
# LIBS aatm | |
# CPP_VERSION ATM_VERSION | |
# RUN_VERSION "atm::getVersion()" | |
# PREFIX_HINTS ${ATM_ROOT_DIR} | |
#) | |
# XML2 | |
casa_find( LIBXML2 | |
VERSION 2.6.16 | |
PREFIX_HINTS ${LIBXML2_ROOT_DIR} | |
INCLUDES libxml/xmlversion.h | |
INCLUDES_SUFFIXES libxml2 | |
LIBS xml2 | |
CPP_VERSION LIBXML_DOTTED_VERSION | |
RUN_VERSION "LIBXML_DOTTED_VERSION; LIBXML_TEST_VERSION;" | |
) | |
# XSLT | |
casa_find( LIBXSLT | |
VERSION 1.1.17 | |
PREFIX_HINTS ${LIBXSLT_ROOT_DIR} | |
INCLUDES libxslt/xsltconfig.h | |
INCLUDES_SUFFIXES libxslt | |
LIBS xslt | |
CPP_VERSION LIBXSLT_DOTTED_VERSION | |
RUN_VERSION "LIBXSLT_DOTTED_VERSION; LIBXSLT_VERSION;" | |
) | |
# Do not reuse FindLibXml2.cmake, except this excerpt | |
IF (NOT WIN32) | |
# use pkg-config to get the directories and then use these values | |
# in the FIND_PATH() and FIND_LIBRARY() calls | |
FIND_PACKAGE(PkgConfig) | |
PKG_CHECK_MODULES(PC_LIBXML libxml-2.0) | |
SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} ${PC_LIBXML_CFLAGS_OTHER}) | |
ENDIF (NOT WIN32) | |
#GSL | |
find_package ( GSL 1.13) | |
if( NOT GSL_FOUND ) | |
message (WARNING "GSL package not found") | |
endif ( NOT GSL_FOUND ) | |
set( DL_LIBRARIES ${CMAKE_DL_LIBS} ) | |
########################### | |
# # | |
# Google Test Installtion # | |
# # | |
########################### | |
include (GoogleTestInstall) | |
######################### | |
# # | |
# Breakpad Installation # | |
# # | |
######################### | |
if (UseCrashReporter AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") | |
include (BreakpadInstall) | |
endif( ) | |
### | |
casa_config_end() | |
# The modules must be defined in dependency order! | |
# This will set up include paths, and which libraries to link to | |
# for linux RPM & binary distros libgraphics contains pgplot (linked in)... | |
if( APPLE ) | |
casa_add_module( graphics CASACORE PGPLOT WCSLIB ) | |
else() | |
if( NOT SKIP_PGPLOT ) | |
casa_add_module( graphics CASACORE PGPLOT X11 WCSLIB ) | |
else() | |
casa_add_module( graphics CASACORE X11 WCSLIB ) | |
endif() | |
endif() | |
casa_add_module( casatools CASACORE ) | |
casa_add_module( stdcasa CASACORE ) | |
casa_add_module( components stdcasa casatools CASACORE GSL ) | |
casa_add_module( imageanalysis CASACORE components) | |
#casa_add_module( alma_v3 CASACORE LIBXML2 LIBXSLT synthesis) | |
# | |
# ASAP's build depends on something called a makedefs file. Fake one of those. | |
# | |
# Get library paths from the first of the rpfits/cfitsio library full paths. | |
list( GET RPFITS_LIBRARIES 0 rpfits_lib ) | |
get_filename_component(rpfitslibd ${rpfits_lib} PATH) | |
list( GET CFITSIO_LIBRARIES 0 cfitsio_lib ) | |
get_filename_component(cfitsiolibd ${cfitsio_lib} PATH) | |
set( _cc "" ) | |
foreach( _c ${CASACORE_LIBRARIES} ) | |
if( _c MATCHES Framework ) | |
# skip | |
else() | |
set( _cc "${_cc} ${_c}" ) | |
endif() | |
endforeach() | |
get_property( MYDEFINES DIRECTORY PROPERTY COMPILE_DEFINITIONS ) | |
# convert semicolons to -Dmydefine... | |
set( _dd "" ) | |
foreach( _d ${MYDEFINES} ) | |
set( _dd "${_dd} -D${_d}" ) | |
endforeach() | |
file( WRITE ${CMAKE_INSTALL_PREFIX}/makedefs | |
"# This file exists only for ASAP\n" | |
CXXFLAGS = \"${CMAKE_CXX_FLAGS}\"\n | |
COPTFLAGS = \"${_dd}\"\n | |
LD_FLAGS = \"${CMAKE_SHARED_LINKER_FLAGS}\"\n | |
COREINCD = ${CASACORE_casa/aips.h}\n | |
CORELIB = ${_cc}\n | |
WCSLIBLIB = ${WCSLIB_wcs}\n | |
WCSLIBLIBD = .\n | |
RPFITSLIBD = ${rpfitslibd}\n | |
CFITSIOLIBD = ${cfitsiolibd}\n | |
CFITSIOINCD = ${CFITSIO_INCLUDE_DIRS}\n | |
eval_vars :\n | |
\t@\ echo\ \"$(foreach\ V,$(VARS),$V=\\\"$($V)\\\")\ \;\ export\ $(VARS)\"\n | |
) | |
add_subdirectory( doc/userman ) | |
# All documentation | |
add_custom_target( doc DEPENDS userman_html userman_pdf) | |
#add_custom_target( doc ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment