| 1 | ###
|
|---|
| 2 | # CMakeLists.txt for ASAP module
|
|---|
| 3 | ###
|
|---|
| 4 |
|
|---|
| 5 | # minimum requirement for cmake version
|
|---|
| 6 | cmake_minimum_required( VERSION 2.8 )
|
|---|
| 7 |
|
|---|
| 8 | # options
|
|---|
| 9 | option( USE_LIBCASACORE
|
|---|
| 10 | "set ON to use libcasacore.so instead of libcasa_*.so"
|
|---|
| 11 | OFF )
|
|---|
| 12 | option( STANDALONE
|
|---|
| 13 | "set ON to build standalone mode"
|
|---|
| 14 | OFF )
|
|---|
| 15 | message( STATUS "USE_LIBCASACORE = " ${USE_LIBCASACORE} )
|
|---|
| 16 | message( STATUS "STANDALONE = " ${STANDALONE} )
|
|---|
| 17 |
|
|---|
| 18 | # Define compiler paths on OSX 10.5. This must be done before invoking project()
|
|---|
| 19 | if( APPLE )
|
|---|
| 20 | if( EXISTS /opt/casa/core2-apple-darwin8/3rd-party/bin/gfortran )
|
|---|
| 21 | set( CMAKE_Fortran_COMPILER /opt/casa/core2-apple-darwin8/3rd-party/bin/gfortran )
|
|---|
| 22 | set( CMAKE_CXX_COMPILER /opt/casa/core2-apple-darwin8/3rd-party/bin/g++ )
|
|---|
| 23 | elseif( EXISTS /opt/local/bin/gfortran )
|
|---|
| 24 | set( CMAKE_Fortran_COMPILER /opt/local/bin/gfortran )
|
|---|
| 25 | elseif( EXISTS /opt/local/bin/gfortran-mp-4.4 )
|
|---|
| 26 | set( CMAKE_Fortran_COMPILER /opt/local/bin/gfortran-mp-4.4 )
|
|---|
| 27 | if( EXISTS /opt/local/bin/g++-mp-4.4 )
|
|---|
| 28 | set( CMAKE_CXX_COMPILER /opt/local/bin/g++-mp-4.4 )
|
|---|
| 29 | endif()
|
|---|
| 30 | endif()
|
|---|
| 31 | endif()
|
|---|
| 32 |
|
|---|
| 33 | # project name is ASAP
|
|---|
| 34 | project( ASAP )
|
|---|
| 35 |
|
|---|
| 36 | # flags
|
|---|
| 37 | set( DEFAULT_CXX_FLAGS
|
|---|
| 38 | "-pipe -Wall -Wextra -Wno-non-template-friend -Wcast-align -Wno-comment -O3" )
|
|---|
| 39 | find_package( OpenMP )
|
|---|
| 40 | if( OPENMP_FOUND )
|
|---|
| 41 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
|
|---|
| 42 | endif()
|
|---|
| 43 |
|
|---|
| 44 | set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS}
|
|---|
| 45 | -DCASA_USECASAPATH
|
|---|
| 46 | -DCASACORE_NEEDS_RETHROW
|
|---|
| 47 | -DAIPS_STDLIB
|
|---|
| 48 | -DAIPS_AUTO_STL
|
|---|
| 49 | -D_GNU_SOURCE )
|
|---|
| 50 |
|
|---|
| 51 | if( CMAKE_SYSTEM_NAME STREQUAL Linux )
|
|---|
| 52 | set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS}
|
|---|
| 53 | -D_FILE_OFFSET_BITS=64
|
|---|
| 54 | -D_LARGEFILE_SOURCE
|
|---|
| 55 | )
|
|---|
| 56 | endif()
|
|---|
| 57 |
|
|---|
| 58 | add_definitions( ${CASACORE_DEFINITIONS} )
|
|---|
| 59 |
|
|---|
| 60 | # set flags for cpp compiler
|
|---|
| 61 | set( CMAKE_CXX_FLAGS ${DEFAULT_CXX_FLAGS} )
|
|---|
| 62 |
|
|---|
| 63 | # environment dependent settings
|
|---|
| 64 | message( STATUS "CMAKE_SYSTEM = " ${CMAKE_SYSTEM} )
|
|---|
| 65 | message( STATUS "CMAKE_SYSTEM_PROCESSOR = " ${CMAKE_SYSTEM_PROCESSOR} )
|
|---|
| 66 | if( APPLE )
|
|---|
| 67 | set( SO dylib )
|
|---|
| 68 | if( CMAKE_SYSTEM MATCHES ^Darwin-10 )
|
|---|
| 69 | if( NOT archflag )
|
|---|
| 70 | if( EXISTS /opt/casa/darwin10-64b )
|
|---|
| 71 | set( archflag x86_64 )
|
|---|
| 72 | elseif( EXISTS /opt/casa/core2-apple-darwin10 )
|
|---|
| 73 | set( archflag i386 )
|
|---|
| 74 | else()
|
|---|
| 75 | set( archflag x86_64 )
|
|---|
| 76 | endif()
|
|---|
| 77 | endif()
|
|---|
| 78 | if( archflag STREQUAL x86_64 )
|
|---|
| 79 | add_definitions( -DAIPS_64B )
|
|---|
| 80 | endif()
|
|---|
| 81 | execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version
|
|---|
| 82 | COMMAND head -1
|
|---|
| 83 | COMMAND perl -pe "s|.*?(\\d+\\.\\d+)\\.\\d+$|$1|"
|
|---|
| 84 | OUTPUT_VARIABLE _cxx_version
|
|---|
| 85 | OUTPUT_STRIP_TRAILING_WHITESPACE )
|
|---|
| 86 | if( NOT _cxx_version STREQUAL "4.4" )
|
|---|
| 87 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -arch ${archflag}" )
|
|---|
| 88 | endif()
|
|---|
| 89 | endif()
|
|---|
| 90 | elseif( CMAKE_SYSTEM_NAME STREQUAL Linux )
|
|---|
| 91 | set( SO so )
|
|---|
| 92 | add_definitions( -DAIPS_LINUX )
|
|---|
| 93 | if( CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 )
|
|---|
| 94 | add_definitions( -DAIPS_64B )
|
|---|
| 95 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated" )
|
|---|
| 96 | else()
|
|---|
| 97 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated -Woverloaded-virtual" )
|
|---|
| 98 | endif()
|
|---|
| 99 | endif()
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 | #
|
|---|
| 103 | # mode specific settings
|
|---|
| 104 | #
|
|---|
| 105 | # STANDALONE=ON standalone build
|
|---|
| 106 | # STANDALONE=OFF build with casa
|
|---|
| 107 | #
|
|---|
| 108 | set( CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake" )
|
|---|
| 109 | message( STATUS "CMAKE_MODULE_PATH = " ${CMAKE_MODULE_PATH} )
|
|---|
| 110 | if( STANDALONE )
|
|---|
| 111 | include( standalone )
|
|---|
| 112 | else()
|
|---|
| 113 | include( withcasa )
|
|---|
| 114 | endif()
|
|---|
| 115 |
|
|---|
| 116 | message( STATUS "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX} )
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | #
|
|---|
| 120 | # casacore
|
|---|
| 121 | #
|
|---|
| 122 | unset( CASACORE_INCLUDE_DIR CACHE )
|
|---|
| 123 | unset( CASACORE_LIBRARIES CACHE )
|
|---|
| 124 | if( NOT USE_LIBCASACORE )
|
|---|
| 125 | # use casacore libraries
|
|---|
| 126 | set( _includename casa/aipsdef.h )
|
|---|
| 127 | find_path( CASACORE_INCLUDE_DIR ${_includename}
|
|---|
| 128 | PATHS ${CASACORE_PATHS}
|
|---|
| 129 | PATH_SUFFIXES include include/casacore
|
|---|
| 130 | NO_DEFAULT_PATH )
|
|---|
| 131 | find_path( CASACORE_INCLUDE_DIR ${_includename} )
|
|---|
| 132 | if( CASACORE_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
|---|
| 133 | message( FATAL_ERROR "${_includename} could not be found. Please check!" )
|
|---|
| 134 | endif()
|
|---|
| 135 | set( CASACORE_LIBS casa
|
|---|
| 136 | components
|
|---|
| 137 | coordinates
|
|---|
| 138 | fits
|
|---|
| 139 | images
|
|---|
| 140 | lattices
|
|---|
| 141 | measures
|
|---|
| 142 | mirlib
|
|---|
| 143 | ms
|
|---|
| 144 | msfits
|
|---|
| 145 | scimath
|
|---|
| 146 | scimath_f
|
|---|
| 147 | tables )
|
|---|
| 148 | set( _casacore_libs "" )
|
|---|
| 149 | foreach( _a ${CASACORE_LIBS} )
|
|---|
| 150 | set( _libname libcasa_${_a}.${SO} )
|
|---|
| 151 | unset( _casacore_lib CACHE )
|
|---|
| 152 | find_library( _casacore_lib ${_libname}
|
|---|
| 153 | PATHS ${CASACORE_PATHS}
|
|---|
| 154 | PATH_SUFFIXES lib64 lib )
|
|---|
| 155 | if( _casacore_lib MATCHES "NOTFOUND$" )
|
|---|
| 156 | message( FATAL_ERROR "${_libname} could not be found. Please check!" )
|
|---|
| 157 | else()
|
|---|
| 158 | #list( APPEND _casacore_libs casa_${_a} )
|
|---|
| 159 | list( APPEND _casacore_libs ${_casacore_lib} )
|
|---|
| 160 | endif()
|
|---|
| 161 | endforeach()
|
|---|
| 162 | set( CASACORE_LIBRARIES ${_casacore_libs} )
|
|---|
| 163 | else()
|
|---|
| 164 | # use libcasacore
|
|---|
| 165 | set( _libname libcasacore.${SO} )
|
|---|
| 166 | find_library( CASACORE_LIBRARIES ${_libname}
|
|---|
| 167 | PATHS ${CASACORE_PATHS}
|
|---|
| 168 | PATH_SUFFIXES lib64 lib )
|
|---|
| 169 | if( CASACORE_LIBRARIES MATCHES "NOTFOUND$" )
|
|---|
| 170 | message( FATAL_ERROR "${_libname} could not be found. Please check!" )
|
|---|
| 171 | endif()
|
|---|
| 172 | set( _includename casa/aipsdef.h )
|
|---|
| 173 | string( REGEX REPLACE /[^/]+/[^/]+/?$ "" _coreroot ${CASACORE_LIBRARIES} )
|
|---|
| 174 | find_path( CASACORE_INCLUDE_DIR ${_includename}
|
|---|
| 175 | PATHS ${_coreroot}
|
|---|
| 176 | PATH_SUFFIXES include include/casacore
|
|---|
| 177 | NO_DEFAULT_PATH )
|
|---|
| 178 | find_path( CASACORE_INCLUDE_DIR ${_includename}
|
|---|
| 179 | PATHS ${CASACORE_PATHS}
|
|---|
| 180 | PATH_SUFFIXES include include/casacore
|
|---|
| 181 | NO_DEFAULT_PATH )
|
|---|
| 182 | find_path( CASACORE_INCLUDE_DIR ${_includename} )
|
|---|
| 183 | if( CASACORE_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
|---|
| 184 | message( FATAL_ERROR "${_includename} could not be found. Please check!" )
|
|---|
| 185 | endif()
|
|---|
| 186 | endif()
|
|---|
| 187 | message( STATUS "CASACORE_LIBRARIES = " ${CASACORE_LIBRARIES} )
|
|---|
| 188 | message( STATUS "CASACORE_INCLUDE_DIR = " ${CASACORE_INCLUDE_DIR} )
|
|---|
| 189 | unset( USE_LIBCASACORE CACHE )
|
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 | #
|
|---|
| 193 | # Python
|
|---|
| 194 | #
|
|---|
| 195 | if( STANDALONE )
|
|---|
| 196 | include( FindPythonLibs )
|
|---|
| 197 | if( NOT PYTHONLIBS_FOUND )
|
|---|
| 198 | message( FATAL_ERROR "Python could not be found. Please check!" )
|
|---|
| 199 | endif()
|
|---|
| 200 |
|
|---|
| 201 | # Define pyroot
|
|---|
| 202 | string( REGEX REPLACE "/[^/]+/[^/]+/?$" "" pyroot ${PYTHON_INCLUDE_DIRS} )
|
|---|
| 203 |
|
|---|
| 204 | # find numpy
|
|---|
| 205 | string( REGEX MATCH [0-9].[0-9] PYTHONV ${PYTHON_INCLUDE_DIRS} )
|
|---|
| 206 | string( REPLACE "." "" PV ${PYTHONV} )
|
|---|
| 207 | find_path( NUMPY_INCLUDE_DIR numpy/npy_interrupt.h
|
|---|
| 208 | PATHS
|
|---|
| 209 | ${pyroot}/lib/python${PYTHONV}/site-packages/numpy/core
|
|---|
| 210 | ${pyroot}/Library/Frameworks/Python.framework/Versions/${PYTHONV}
|
|---|
| 211 | ${pyroot}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core
|
|---|
| 212 | PATH_SUFFIXES include )
|
|---|
| 213 | if( NUMPY_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
|---|
| 214 | message( FATAL_ERROR "numpy/npy_interrupt.h could not be found. Please check!" )
|
|---|
| 215 | endif()
|
|---|
| 216 | list( APPEND PYTHON_INCLUDE_DIRS ${NUMPY_INCLUDE_DIR} )
|
|---|
| 217 |
|
|---|
| 218 | set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS}
|
|---|
| 219 | -DPYTHONROOT=\"${pyroot}\"
|
|---|
| 220 | -DPYTHONVER=\"${PYTHONV}\"
|
|---|
| 221 | -DPYVERSION=${PV} )
|
|---|
| 222 | else()
|
|---|
| 223 | if( NOT PYTHON_FOUND )
|
|---|
| 224 | if ( NOT PYTHON_LIBNAME )
|
|---|
| 225 | set( _names 2.9 2.8 2.7 2.6 2.5.2 2.5 )
|
|---|
| 226 | # (The library named libpython.2.5.2.dylib seems to exist only in the CASA world.)
|
|---|
| 227 | else()
|
|---|
| 228 | set( _names ${PYTHON_LIBNAME} )
|
|---|
| 229 | endif()
|
|---|
| 230 |
|
|---|
| 231 | set( _found False )
|
|---|
| 232 | foreach( _v ${_names} )
|
|---|
| 233 |
|
|---|
| 234 | casa_find(
|
|---|
| 235 | PYTHON${_v}
|
|---|
| 236 | LIBS python${_v}
|
|---|
| 237 | NO_REQUIRE
|
|---|
| 238 | )
|
|---|
| 239 |
|
|---|
| 240 | if( PYTHON${_v}_FOUND )
|
|---|
| 241 | set( PYTHON_LIBNAME ${_v} )
|
|---|
| 242 | set( _found True )
|
|---|
| 243 | break()
|
|---|
| 244 | endif()
|
|---|
| 245 |
|
|---|
| 246 | endforeach()
|
|---|
| 247 |
|
|---|
| 248 | if( NOT _found )
|
|---|
| 249 | message( FATAL_ERROR "Could not find any PYTHON library with version one of ${_names}. Please check!" )
|
|---|
| 250 | endif()
|
|---|
| 251 |
|
|---|
| 252 | endif()
|
|---|
| 253 |
|
|---|
| 254 | if( NOT PYTHON_LIBNAME )
|
|---|
| 255 | # Found Python, but PYTHON_LIBNAME is undefined, that is impossible.
|
|---|
| 256 | message( FATAL_ERROR "The variable PYTHON_LIBNAME is undefined. Most likely, CMake's cache is out of date and you need to redetect your PYTHON installation (\"cmake -U PYTHON*\")")
|
|---|
| 257 | endif()
|
|---|
| 258 |
|
|---|
| 259 | string( SUBSTRING ${PYTHON_LIBNAME} 0 3 PYTHONV )
|
|---|
| 260 | string( REPLACE "." "" PV ${PYTHONV} )
|
|---|
| 261 | set( python_library python${PYTHON_LIBNAME} )
|
|---|
| 262 |
|
|---|
| 263 | # Form the Python install prefix by stripping away "lib/libpython2.5.2.dylib" (example) from
|
|---|
| 264 | # the full python library path
|
|---|
| 265 | string( REGEX MATCH "/lib(64)?/lib${python_library}" _match ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
|
|---|
| 266 | if( _match )
|
|---|
| 267 | string( REGEX REPLACE "/lib(64)?/lib${python_library}.*" "" python_prefix ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
|
|---|
| 268 | else()
|
|---|
| 269 | # Python library was not in a lib(64) directory!
|
|---|
| 270 | message( WARNING "Python library path \"${PYTHON${PYTHON_LIBNAME}_LIBRARIES}\" does not contain \"/lib(64)/lib${python_library}\"" )
|
|---|
| 271 | set( python_prefix ${casa_packages} )
|
|---|
| 272 | endif()
|
|---|
| 273 |
|
|---|
| 274 | # The python version and prefix is known, do the actual search
|
|---|
| 275 | if( NOT PYTHON_FOUND )
|
|---|
| 276 | message( STATUS "Looking for PYTHON version ${PYTHONV}.x in ${python_prefix}" )
|
|---|
| 277 | endif()
|
|---|
| 278 |
|
|---|
| 279 | casa_find( PYTHON
|
|---|
| 280 | VERSION 2.5 # minimum required
|
|---|
| 281 | INCLUDES Python.h
|
|---|
| 282 | numpy/npy_interrupt.h # for numpy
|
|---|
| 283 | INCLUDES_SUFFIXES python${PYTHONV}
|
|---|
| 284 | PREFIX_HINTS
|
|---|
| 285 | ${python_prefix}/lib/python${PYTHONV}/site-packages/numpy/core
|
|---|
| 286 | ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}
|
|---|
| 287 | ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core
|
|---|
| 288 | LIBS ${python_library}
|
|---|
| 289 | CPP_VERSION PY_VERSION )
|
|---|
| 290 |
|
|---|
| 291 | # Store PYTHON_LIBNAME in the cache
|
|---|
| 292 | set( PYTHON_LIBNAME ${PYTHON_LIBNAME} CACHE STRING "Python major and minor version to use" FORCE )
|
|---|
| 293 |
|
|---|
| 294 | # Define pyroot to two directory levels above Python.h.
|
|---|
| 295 | string( REGEX REPLACE "/[^/]+/[^/]+/?$" "" pyroot ${PYTHON_Python.h} )
|
|---|
| 296 |
|
|---|
| 297 | set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS}
|
|---|
| 298 | -DAIPSROOT=\"${CMAKE_SOURCE_DIR}\"
|
|---|
| 299 | -DAIPSARCH=\"${arch}\"
|
|---|
| 300 | -DAIPSSITE=\"garching\"
|
|---|
| 301 | -DPYTHONROOT=\"${pyroot}\"
|
|---|
| 302 | -DPYTHONVER=\"${PYTHONV}\"
|
|---|
| 303 | -DPYVERSION=${PV} )
|
|---|
| 304 | endif()
|
|---|
| 305 | message( STATUS "PYTHON_INCLUDE_DIRS = " ${PYTHON_INCLUDE_DIRS} )
|
|---|
| 306 | message( STATUS "PYTHON_LINRARIES = " ${PYTHON_LIBRARIES} )
|
|---|
| 307 | message( STATUS "PYTHONV = " ${PYTHONV} )
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 | #
|
|---|
| 311 | # DL
|
|---|
| 312 | #
|
|---|
| 313 | set( DL_LIBRARIES ${CMAKE_DL_LIBS} CACHE STRING "dl libraries" FORCE )
|
|---|
| 314 | if( DL_LIBRARIES STREQUAL "dl" )
|
|---|
| 315 | set( DL_LIBRARIES "-ldl" CACHE STRING "dl libraries" FORCE )
|
|---|
| 316 | endif()
|
|---|
| 317 | message( STATUS "DL_LIBRARIES = " ${DL_LIBRARIES} )
|
|---|
| 318 |
|
|---|
| 319 |
|
|---|
| 320 | #
|
|---|
| 321 | # BLAS
|
|---|
| 322 | #
|
|---|
| 323 | find_library( BLAS_LIBRARIES libblas.${SO} )
|
|---|
| 324 | if ( BLAS_LIBRARIES MATCHES "NOTFOUND$" )
|
|---|
| 325 | message( FATAL_ERROR "blas could not be found. Please check!" )
|
|---|
| 326 | endif()
|
|---|
| 327 | message( STATUS "BLAS_LIBRARIES = " ${BLAS_LIBRARIES} )
|
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 | #
|
|---|
| 331 | # LAPACK
|
|---|
| 332 | #
|
|---|
| 333 | find_library( LAPACK_LIBRARIES liblapack.${SO} )
|
|---|
| 334 | if ( LAPACK_LIBRARIES MATCHES "NOTFOUND$" )
|
|---|
| 335 | message( FATAL_ERROR "lapack could not be found. Please check!" )
|
|---|
| 336 | endif()
|
|---|
| 337 | message( STATUS "LAPACK_LIBRARIES = " ${LAPACK_LIBRARIES} )
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 | #
|
|---|
| 341 | # Boost
|
|---|
| 342 | #
|
|---|
| 343 | set( boost_components python )
|
|---|
| 344 | if( NOT STANDALONE )
|
|---|
| 345 | set( boost_components ${boost_components} system )
|
|---|
| 346 | endif()
|
|---|
| 347 | find_package( Boost REQUIRED ${boost_components} )
|
|---|
| 348 | if( NOT Boost_FOUND )
|
|---|
| 349 | message( FATAL_ERROR "Boost could not be found. Please check!" )
|
|---|
| 350 | endif()
|
|---|
| 351 | message( STATUS "BOOST_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
|
|---|
| 352 | message( STATUS "BOOST_LIBRARIES = " ${Boost_LIBRARIES} )
|
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 | #
|
|---|
| 356 | # cfitsio
|
|---|
| 357 | #
|
|---|
| 358 | if( STANDALONE )
|
|---|
| 359 | find_path( CFITSIO_INCLUDE_DIRS fitsio.h
|
|---|
| 360 | PATH_SUFFIXES cfitsio )
|
|---|
| 361 | if( CFITSIO_INCLUDE_DIRS MATCHES "NOTFOUND$" )
|
|---|
| 362 | message( FATAL_ERROR "fitsio.h could not be found. Please check!" )
|
|---|
| 363 | endif()
|
|---|
| 364 | string( REGEX REPLACE "/[^/]+/?$" "" CFITSIO_ROOT ${CFITSIO_INCLUDE_DIRS} )
|
|---|
| 365 | message( STATUS "CFITSIO_ROOT=" ${CFITSIO_ROOT} )
|
|---|
| 366 | find_library( CFITSIO_LIBRARIES libcfitsio.${SO}
|
|---|
| 367 | PATHS ${CFITSIO_ROOT}
|
|---|
| 368 | PATH_SUFFIXES lib64 lib
|
|---|
| 369 | NO_DEFAULT_PATH )
|
|---|
| 370 | if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" )
|
|---|
| 371 | find_library( CFITSIO_LIBRARIES libcfitsio.a
|
|---|
| 372 | PATHS ${CFITSIO_ROOT}
|
|---|
| 373 | PATH_SUFFIXES lib64 lib
|
|---|
| 374 | NO_DEFAULT_PATH )
|
|---|
| 375 | endif()
|
|---|
| 376 | find_library( CFITSIO_LIBRARIES libcfitsio.${SO}
|
|---|
| 377 | PATHS /usr/local /usr
|
|---|
| 378 | PATH_SUFFIXES lib64 lib )
|
|---|
| 379 | if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" )
|
|---|
| 380 | message( FATAL_ERROR "libcfitsio.so could not be found. Please check!" )
|
|---|
| 381 | endif()
|
|---|
| 382 | else()
|
|---|
| 383 | casa_find( CFITSIO
|
|---|
| 384 | VERSION 3.006
|
|---|
| 385 | INCLUDES fitsio.h fitsio2.h
|
|---|
| 386 | INCLUDES_SUFFIXES cfitsio
|
|---|
| 387 | LIBS cfitsio
|
|---|
| 388 | CPP_VERSION CFITSIO_VERSION
|
|---|
| 389 | RUN_VERSION "(ffvers(&v), v)" )
|
|---|
| 390 | endif()
|
|---|
| 391 | message( STATUS "CFITSIO_INCLUDE_DIRS = " ${CFITSIO_INCLUDE_DIRS} )
|
|---|
| 392 | message( STATUS "CFITSIO_LIBRARIES = " ${CFITSIO_LIBRARIES} )
|
|---|
| 393 |
|
|---|
| 394 |
|
|---|
| 395 | #
|
|---|
| 396 | # Fortran
|
|---|
| 397 | #
|
|---|
| 398 | if( NOT FORTRAN_LIBRARIES )
|
|---|
| 399 |
|
|---|
| 400 | message( STATUS "Looking for Fortran runtime libraries" )
|
|---|
| 401 | set( _try ${CMAKE_BINARY_DIR}/try_fortran.cc )
|
|---|
| 402 | file( WRITE ${_try}
|
|---|
| 403 | "int main() { return 0; }\n"
|
|---|
| 404 | )
|
|---|
| 405 |
|
|---|
| 406 | if( _gfortran_lib_path )
|
|---|
| 407 | try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
|
|---|
| 408 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=${_gfortran_lib_path}"
|
|---|
| 409 | )
|
|---|
| 410 | else()
|
|---|
| 411 | try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
|
|---|
| 412 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lgfortran"
|
|---|
| 413 | )
|
|---|
| 414 | endif()
|
|---|
| 415 | try_compile( _have_g2c ${CMAKE_BINARY_DIR} ${_try}
|
|---|
| 416 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lg2c"
|
|---|
| 417 | )
|
|---|
| 418 |
|
|---|
| 419 | if( _have_gfortran )
|
|---|
| 420 | if( _gfortran_lib_path )
|
|---|
| 421 | set( FORTRAN_LIBRARIES ${_gfortran_lib_path}
|
|---|
| 422 | CACHE STRING "Fortran library linker option" FORCE )
|
|---|
| 423 | else()
|
|---|
| 424 | set( FORTRAN_LIBRARIES -lgfortran
|
|---|
| 425 | CACHE STRING "Fortran library linker option" FORCE )
|
|---|
| 426 | endif()
|
|---|
| 427 | message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
|
|---|
| 428 | elseif( _have_g2c )
|
|---|
| 429 | set( FORTRAN_LIBRARIES -lg2c
|
|---|
| 430 | CACHE STRING "Fortran library linker option" FORCE )
|
|---|
| 431 | message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
|
|---|
| 432 | else()
|
|---|
| 433 | set( FORTRAN_LIBRARIES ""
|
|---|
| 434 | CACHE STRING "Fortran library linker option" FORCE )
|
|---|
| 435 | message( STATUS "Looking for Fortran runtime libraries -- <none>" )
|
|---|
| 436 | # Not a fatal error because it might work, if all Fortran dependencies were
|
|---|
| 437 | # already linked statically to the Fortran runtime...
|
|---|
| 438 | endif()
|
|---|
| 439 | endif()
|
|---|
| 440 |
|
|---|
| 441 |
|
|---|
| 442 | #
|
|---|
| 443 | # RPFITS
|
|---|
| 444 | #
|
|---|
| 445 | if ( STANDALONE )
|
|---|
| 446 | find_path( RPFITS_INCLUDE_DIRS RPFITS.h
|
|---|
| 447 | PATHS /usr/local /usr
|
|---|
| 448 | PATH_SUFFIXES include )
|
|---|
| 449 | if( RPFITS_INCLUDE_DIRS MATCHES "NOTFOUND$" )
|
|---|
| 450 | message( FATAL_ERROR "RPFITS.h could not be found. Please check!" )
|
|---|
| 451 | endif()
|
|---|
| 452 | find_library( RPFITS_LIBRARIES librpfits.so
|
|---|
| 453 | PATHS /usr/local /usr
|
|---|
| 454 | PATH_SUFFIXES lib64 lib )
|
|---|
| 455 | if( RPFITS_LIBRARIES MATCHES "NOTFOUND$" )
|
|---|
| 456 | message( FATAL_ERROR "librpfits.so could not be found. Please check!" )
|
|---|
| 457 | endif()
|
|---|
| 458 | list( APPEND RPFITS_LIBRARIES ${FORTRAN_LIBRARIES} )
|
|---|
| 459 | else()
|
|---|
| 460 | casa_find( RPFITS
|
|---|
| 461 | VERSION 2.11
|
|---|
| 462 | INCLUDES RPFITS.h
|
|---|
| 463 | LIBS rpfits
|
|---|
| 464 | RUN_VERSION names_.rpfitsversion
|
|---|
| 465 | DEPENDS FORTRAN )
|
|---|
| 466 | endif()
|
|---|
| 467 | message( STATUS "RPFITS_INCLUDE_DIRS = " ${RPFITS_INCLUDE_DIRS} )
|
|---|
| 468 | message( STATUS "RPFITS_LIBRARIES = " ${RPFITS_LIBRARIES} )
|
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 | #
|
|---|
| 472 | # wcslib
|
|---|
| 473 | #
|
|---|
| 474 | set( _wcslib libwcs.${SO} )
|
|---|
| 475 | set( _wcs_version 4.3 )
|
|---|
| 476 | find_library( WCSLIB ${_wcslib}
|
|---|
| 477 | PATHS ${WCSLIB_PATHS}
|
|---|
| 478 | PATH_SUFFIXES lib64 lib )
|
|---|
| 479 | if( WCSLIB MATCHES "NOTFOUND$" )
|
|---|
| 480 | message( STATUS "${_wcslib} could not be found." )
|
|---|
| 481 | unset( _wcslib CACHE )
|
|---|
| 482 | unset( WCSLIB CACHE )
|
|---|
| 483 | set( _wcslib libwcs.${_wcs_version}.${SO} )
|
|---|
| 484 | message( STATUS "Try to find ${_wcslib}..." )
|
|---|
| 485 | find_library( WCSLIB ${_wcslib}
|
|---|
| 486 | PATHS ${WCSLIB_PATHS}
|
|---|
| 487 | PATH_SUFFIXES lib64 lib )
|
|---|
| 488 | if( WCSLIB MATCHES "NOTFOUND$" )
|
|---|
| 489 | message( FATAL_ERROR "${_wcslib} could not be found. Please check!" )
|
|---|
| 490 | endif()
|
|---|
| 491 | endif()
|
|---|
| 492 | message( STATUS "WCSLIB = " ${WCSLIB} )
|
|---|
| 493 | find_path( WCSLIB_INCLUDE_DIR wcslib/wcs.h
|
|---|
| 494 | PATHS ${WCSLIB_PATHS}
|
|---|
| 495 | PATH_SUFFIXES include )
|
|---|
| 496 | if( WCSLIB_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
|---|
| 497 | message( FATAL_ERROR "wcs.h could not be found. Please check!" )
|
|---|
| 498 | endif()
|
|---|
| 499 | message( STATUS "WCSLIB_INCLUDE_DIR = " ${WCSLIB_INCLUDE_DIR} )
|
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 | #
|
|---|
| 503 | # common include path
|
|---|
| 504 | #
|
|---|
| 505 | include_directories( ${CASACORE_INCLUDE_DIR}
|
|---|
| 506 | ${Boost_INCLUDE_DIR}
|
|---|
| 507 | ${PYTHON_INCLUDE_DIRS}
|
|---|
| 508 | ${WCSLIB_INCLUDE_DIR}
|
|---|
| 509 | ${CFITSIO_INCLUDE_DIRS}
|
|---|
| 510 | ${RPFITS_INCLUDE_DIRS} )
|
|---|
| 511 |
|
|---|
| 512 |
|
|---|
| 513 | #
|
|---|
| 514 | # install directory
|
|---|
| 515 | #
|
|---|
| 516 | set( EXEC_INSTALL_DIR bin )
|
|---|
| 517 | set( LIB_INSTALL_DIR lib )
|
|---|
| 518 | set( PYTHON_INSTALL_DIR python/${PYTHONV}/asap )
|
|---|
| 519 | set( SHARED_INSTALL_DIR share/asap )
|
|---|
| 520 |
|
|---|
| 521 | #
|
|---|
| 522 | # execute getsvnrev.sh to create/update svninfo.txt
|
|---|
| 523 | # run chmod to make sure the script has executable
|
|---|
| 524 | #
|
|---|
| 525 | exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/getsvnrev.sh )
|
|---|
| 526 | exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/cmake/exec_getsvnrev.sh )
|
|---|
| 527 | exec_program( ${ASAP_SOURCE_DIR}/cmake/exec_getsvnrev.sh ARGS ${ASAP_SOURCE_DIR})
|
|---|
| 528 |
|
|---|
| 529 | # Add the modules to be built.
|
|---|
| 530 | #
|
|---|
| 531 | # Choose to have correct RPATHs both in the build tree and
|
|---|
| 532 | # in the install tree (at the cost of having to change the
|
|---|
| 533 | # rpath when installing)
|
|---|
| 534 | #
|
|---|
| 535 | set( CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib )
|
|---|
| 536 | set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|---|
| 537 | set( CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib )
|
|---|
| 538 |
|
|---|
| 539 |
|
|---|
| 540 |
|
|---|
| 541 | #
|
|---|
| 542 | # libraries and executables
|
|---|
| 543 | #
|
|---|
| 544 | set( ASAPLIB asap )
|
|---|
| 545 | set( PYRAPLIB pyrap )
|
|---|
| 546 | set( ATNFLIB atnf )
|
|---|
| 547 | set( ASAP2TO3 asap2to3 )
|
|---|
| 548 | if ( NOT STANDALONE )
|
|---|
| 549 | set( ASDM2ASAP_OLD oldasdm2ASAP )
|
|---|
| 550 | set( ASDM2ASAP asdm2ASAP )
|
|---|
| 551 | endif()
|
|---|
| 552 |
|
|---|
| 553 | #
|
|---|
| 554 | # always install by default
|
|---|
| 555 | #
|
|---|
| 556 | add_custom_target( inst ALL ${CMAKE_BUILD_TOOL} install/fast )
|
|---|
| 557 |
|
|---|
| 558 | #
|
|---|
| 559 | # subdirectories
|
|---|
| 560 | #
|
|---|
| 561 | asap_add_subdirectory()
|
|---|