| 1 | ###
|
|---|
| 2 | # CMakeLists.txt for ASAP module
|
|---|
| 3 | ###
|
|---|
| 4 |
|
|---|
| 5 | # minimum requirement for cmake version
|
|---|
| 6 | cmake_minimum_required( VERSION 2.8 )
|
|---|
| 7 |
|
|---|
| 8 | # project name is ASAP
|
|---|
| 9 | project( ASAP )
|
|---|
| 10 |
|
|---|
| 11 | # install directory
|
|---|
| 12 | # set casaroot
|
|---|
| 13 | # the regular expression means '../'
|
|---|
| 14 | # [^ ] Matches any character(s) not inside the brackets
|
|---|
| 15 | # + Matches preceding pattern one or more times
|
|---|
| 16 | # ? Matches preceding pattern zero or once only
|
|---|
| 17 | # $ Mathces at end of a line
|
|---|
| 18 | string( REGEX REPLACE /[^/]+/?$ "" casaroot ${CMAKE_SOURCE_DIR} )
|
|---|
| 19 | message( STATUS "casaroot = " ${casaroot} )
|
|---|
| 20 |
|
|---|
| 21 | # flags
|
|---|
| 22 | set( DEFAULT_CXX_FLAGS
|
|---|
| 23 | "-pipe -Wall -Wextra -Wno-non-template-friend -Wcast-align -Wno-comment" )
|
|---|
| 24 | find_package( OpenMP )
|
|---|
| 25 | if( OPENMP_FOUND )
|
|---|
| 26 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
|
|---|
| 27 | endif()
|
|---|
| 28 |
|
|---|
| 29 | # environment dependent settings
|
|---|
| 30 | if( APPLE )
|
|---|
| 31 | set( SO dylib )
|
|---|
| 32 | if( NOT arch )
|
|---|
| 33 | set( arch darwin )
|
|---|
| 34 | endif()
|
|---|
| 35 | if( CMAKE_SYSTEM MATHCES ^Darwin-10 )
|
|---|
| 36 | if( NOT archflag )
|
|---|
| 37 | if( EXISTS /opt/casa/darwin10-64b )
|
|---|
| 38 | set( archflag x86_64 )
|
|---|
| 39 | elseif( EXISTS /opt/casa/core2-apple-darwin10 )
|
|---|
| 40 | set( archflag i386 )
|
|---|
| 41 | else()
|
|---|
| 42 | set( archflag x86_64 )
|
|---|
| 43 | endif()
|
|---|
| 44 | endif()
|
|---|
| 45 | if( archflag STREQUAL x86_64 )
|
|---|
| 46 | add_definitions( -DAIPS_64B )
|
|---|
| 47 | set( casa_packages /opt/casa/darwin10-64b )
|
|---|
| 48 | else()
|
|---|
| 49 | set( casa_packages /opt/casa/core2-apple-darwin10 )
|
|---|
| 50 | endif()
|
|---|
| 51 | execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version
|
|---|
| 52 | COMMAND head -1
|
|---|
| 53 | COMMAND perl -pe "s|.*?(\\d+\\.\\d+)\\.\\d+$|$1|"
|
|---|
| 54 | OUTPUT_VARIABLE _cxx_version
|
|---|
| 55 | OUTPUT_STRIP_TRAILING_WHITESPACE )
|
|---|
| 56 | if( NOT _cxx_version STREQUAL "4.4" )
|
|---|
| 57 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -arch ${archflag}" )
|
|---|
| 58 | endif()
|
|---|
| 59 | elseif( CMAKE_SYSTEM MATCHES ^Darwin-9 )
|
|---|
| 60 | set( casa_packages /opt/casa/core2-apple-darwin8/3rd-party )
|
|---|
| 61 | endif()
|
|---|
| 62 | elseif( CMAKE_SYSTEM_NAME STREQUAL Linux )
|
|---|
| 63 | set( SO so )
|
|---|
| 64 | add_definitions( -DAIPS_LINUX )
|
|---|
| 65 | if( CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 )
|
|---|
| 66 | set( casa_packages /usr/lib64/casapy )
|
|---|
| 67 | if( NOT arch )
|
|---|
| 68 | set( arch linux_64b )
|
|---|
| 69 | endif()
|
|---|
| 70 | add_definitions( -DAIPS_64B )
|
|---|
| 71 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated" )
|
|---|
| 72 | else()
|
|---|
| 73 | set( casa_packages /usr/lib/casapy )
|
|---|
| 74 | if( NOT arch )
|
|---|
| 75 | set( arch linux_gnu )
|
|---|
| 76 | endif()
|
|---|
| 77 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated -Woverloaded-virtual" )
|
|---|
| 78 | endif()
|
|---|
| 79 | endif()
|
|---|
| 80 | message( STATUS "arch = " ${arch} )
|
|---|
| 81 |
|
|---|
| 82 | # set root directory for installation
|
|---|
| 83 | set( CMAKE_INSTALL_PREFIX ${casaroot}/${arch} )
|
|---|
| 84 | message( STATUS "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX} )
|
|---|
| 85 |
|
|---|
| 86 | # set flags for cpp compiler
|
|---|
| 87 | set( CMAKE_CXX_FLAGS ${DEFAULT_CXX_FLAGS} )
|
|---|
| 88 |
|
|---|
| 89 | #
|
|---|
| 90 | # casacore
|
|---|
| 91 | #
|
|---|
| 92 | if( NOT USE_LIBCASACORE )
|
|---|
| 93 | # use casacore libraries
|
|---|
| 94 | set( _includename aipsdef.h )
|
|---|
| 95 | find_path( CASACORE_INCPATH ${_includename}
|
|---|
| 96 | HINTS ${casaroot}/${arch}/include/
|
|---|
| 97 | PATH_SUFFIXES casacore/casa )
|
|---|
| 98 | if( CASACORE_INCPATH STREQUAL CASACORE_INCPATH-NOTFOUND )
|
|---|
| 99 | message( FATAL_ERROR "${_includename} could not be found. Please check!" )
|
|---|
| 100 | else()
|
|---|
| 101 | string( REGEX REPLACE /[^/]+/?$ "" CASACORE_INCLUDE_DIR ${CASACORE_INCPATH} )
|
|---|
| 102 | endif()
|
|---|
| 103 | set( CASACORE_LIBS casa
|
|---|
| 104 | components
|
|---|
| 105 | coordinates
|
|---|
| 106 | fits
|
|---|
| 107 | images
|
|---|
| 108 | lattices
|
|---|
| 109 | measures
|
|---|
| 110 | mirlib
|
|---|
| 111 | ms
|
|---|
| 112 | msfits
|
|---|
| 113 | scimath
|
|---|
| 114 | scimath_f
|
|---|
| 115 | tables )
|
|---|
| 116 | set( _casacore_libs "" )
|
|---|
| 117 | foreach( _a ${CASACORE_LIBS} )
|
|---|
| 118 | set( _libname libcasa_${_a}.${SO} )
|
|---|
| 119 | unset( _casacore_lib CACHE )
|
|---|
| 120 | find_library( _casacore_lib ${_libname}
|
|---|
| 121 | PATHS ${CMAKE_INSTALL_PREFIX} PATH_SUFFIXES lib )
|
|---|
| 122 | if( NOT _casacore_lib-NOTFOUND )
|
|---|
| 123 | list( APPEND _casacore_libs casa_${_a} )
|
|---|
| 124 | endif()
|
|---|
| 125 | endforeach()
|
|---|
| 126 | set( CASACORE_LIBRARIES ${_casacore_libs} )
|
|---|
| 127 | else()
|
|---|
| 128 | # use libcasacore
|
|---|
| 129 | set( _libname libcasacore.${SO} )
|
|---|
| 130 | find_library( CASACORE_LIBRARIES ${_libname} )
|
|---|
| 131 | if( CASACORE_LIBRARIES STREQUAL CASACORE_LIBRARIES-NOTFOUND )
|
|---|
| 132 | message( FATAL_ERROR "${_libname} could not be found. Please check!" )
|
|---|
| 133 | endif()
|
|---|
| 134 | set( _includename aipsdef.h )
|
|---|
| 135 | find_path( CASACORE_INCPATH ${_includename}
|
|---|
| 136 | PATH_SUFFIXES casacore/casa )
|
|---|
| 137 | if( CASACORE_INCPATH STREQUAL CASACORE_INCPATH-NOTFOUND )
|
|---|
| 138 | message( FATAL_ERROR "${_includename} could not be found. Please check!" )
|
|---|
| 139 | else()
|
|---|
| 140 | string( REGEX REPLACE /[^/]+/?$ "" CASACORE_INCLUDE_DIR ${CASACORE_INCPATH} )
|
|---|
| 141 | endif()
|
|---|
| 142 | endif()
|
|---|
| 143 | message( STATUS "CASACORE_LIBRARIES = " ${CASACORE_LIBRARIES} )
|
|---|
| 144 | message( STATUS "CASACORE_INCLUDE_DIR = " ${CASACORE_INCLUDE_DIR} )
|
|---|
| 145 |
|
|---|
| 146 | #
|
|---|
| 147 | # Python
|
|---|
| 148 | #
|
|---|
| 149 | # tentative
|
|---|
| 150 | set( PYVERSION 2.6 )
|
|---|
| 151 | if (NOT PYTHON_ROOT )
|
|---|
| 152 | set( PYTHON_ROOT ${casa_packages} )
|
|---|
| 153 | endif()
|
|---|
| 154 | find_package( PythonLibs REQUIRED python${PYVERSION} )
|
|---|
| 155 |
|
|---|
| 156 | if( NOT PYTHONLIBS_FOUND )
|
|---|
| 157 | message( FATAL_ERROR "Python could not be found. Please check!" )
|
|---|
| 158 | endif()
|
|---|
| 159 | message( STATUS "PYTHON_INCLUDE_PATH = " ${PYTHON_INCLUDE_PATH} )
|
|---|
| 160 | message( STATUS "PYTHON_LIBRARIES = " ${PYTHON_LIBRARIES} )
|
|---|
| 161 |
|
|---|
| 162 | set( PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_PATH} )
|
|---|
| 163 | find_path( NUMPY_INC_DIR numpy/npy_interrupt.h
|
|---|
| 164 | PATHS ${casa_packages}/lib/python${PYVERSION}/site-packages/numpy/core/include )
|
|---|
| 165 | message( STATUS "NUMPY_INC_DIR = " ${NUMPY_INC_DIR} )
|
|---|
| 166 | if( NOT NUMPY_INC_DIR STREQUAL NUMPY_INC_DIR-NOTFOUND )
|
|---|
| 167 | list( APPEND PYTHON_INCLUDE_DIR ${NUMPY_INC_DIR} )
|
|---|
| 168 | endif()
|
|---|
| 169 | message( STATUS "PYTHON_INCLUDE_DIR = " ${PYTHON_INCLUDE_DIR} )
|
|---|
| 170 |
|
|---|
| 171 | #
|
|---|
| 172 | # Boost
|
|---|
| 173 | #
|
|---|
| 174 | if( NOT BOOST_ROOT )
|
|---|
| 175 | set( BOOST_ROOT ${casa_packages} )
|
|---|
| 176 | endif()
|
|---|
| 177 |
|
|---|
| 178 | set( boost_components regex program_options filesystem )
|
|---|
| 179 | find_package( Boost REQUIRED ${boost_components} )
|
|---|
| 180 |
|
|---|
| 181 | if( NOT Boost_FOUND )
|
|---|
| 182 | message( FATAL_ERROR "Boost could not be found. Please check!" )
|
|---|
| 183 | endif()
|
|---|
| 184 |
|
|---|
| 185 | # For boost >= 1.35, we need to link also to boost-system
|
|---|
| 186 | if( Boost_VERSION GREATER 103499 )
|
|---|
| 187 |
|
|---|
| 188 | # Force redetection by resetting these variables
|
|---|
| 189 | if( NOT Boost_SYSTEM_FOUND )
|
|---|
| 190 | message( STATUS "Boost version (${Boost_VERSION}) is 1.35.0 or newer" )
|
|---|
| 191 | unset( Boost_FOUND )
|
|---|
| 192 | unset( Boost_INCLUDE_DIR CACHE )
|
|---|
| 193 | endif()
|
|---|
| 194 | set( boost_components regex program_options filesystem system )
|
|---|
| 195 | find_package( Boost REQUIRED ${boost_components} )
|
|---|
| 196 |
|
|---|
| 197 | if( NOT Boost_FOUND )
|
|---|
| 198 | message( FATAL_ERROR "Boost-system could not be found. Please check!" )
|
|---|
| 199 | endif()
|
|---|
| 200 | endif()
|
|---|
| 201 |
|
|---|
| 202 | if( NOT Boost_VERSION GREATER 103199 AND NOT CASA_IGNORE_VERSION )
|
|---|
| 203 | message( FATAL_ERROR "Boost version (${Boost_VERSION}) is too old! Must be 103200 (1.32.0) or newer. Please check!" )
|
|---|
| 204 | endif()
|
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 | # include path
|
|---|
| 209 | message( STATUS "Boost_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
|
|---|
| 210 | include_directories( ${CASACORE_INCLUDE_DIR}
|
|---|
| 211 | ${Boost_INCLUDE_DIR}
|
|---|
| 212 | ${PYTHON_INCLUDE_DIR} )
|
|---|
| 213 |
|
|---|
| 214 | # link path
|
|---|
| 215 | set( CASACORE_LIBRARY_DIR ${casaroot}/${arch}/lib )
|
|---|
| 216 | link_directories( ${CASACORE_LIBRARY_DIR} )
|
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 | # install directory
|
|---|
| 220 | set( EXEC_INSTALL_DIR bin )
|
|---|
| 221 | set( LIB_INSTALL_DIR lib )
|
|---|
| 222 | set( PYTHON_INSTALL_DIR python/${PYVERSION}/asap )
|
|---|
| 223 | set( SHARED_INSTALL_DIR share/asap )
|
|---|
| 224 |
|
|---|
| 225 | # subdirectories
|
|---|
| 226 | # asap2to3 apps
|
|---|
| 227 | # libpyrap.so external/libpyrap
|
|---|
| 228 | # libatnf.so external-alma/atnf
|
|---|
| 229 | # _asap.so src
|
|---|
| 230 | # python modules python
|
|---|
| 231 | add_subdirectory( apps )
|
|---|
| 232 | add_subdirectory( external/libpyrap )
|
|---|
| 233 | add_subdirectory( external-alma/atnf )
|
|---|
| 234 | add_subdirectory( src )
|
|---|
| 235 | add_subdirectory( python )
|
|---|
| 236 | add_subdirectory( share )
|
|---|
| 237 |
|
|---|
| 238 |
|
|---|