[1954] | 1 | ###
|
---|
| 2 | # CMakeLists.txt for ASAP module
|
---|
| 3 | ###
|
---|
| 4 |
|
---|
| 5 | # minimum requirement for cmake version
|
---|
| 6 | cmake_minimum_required( VERSION 2.8 )
|
---|
| 7 |
|
---|
[1968] | 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} )
|
---|
[1958] | 17 |
|
---|
[1970] | 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 |
|
---|
[1960] | 102 | #
|
---|
[1968] | 103 | # mode specific settings
|
---|
[1960] | 104 | #
|
---|
[1968] | 105 | # STANDALONE=ON standalone build
|
---|
| 106 | # STANDALONE=OFF build with casa
|
---|
[1954] | 107 | #
|
---|
[1968] | 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 )
|
---|
[1956] | 112 | else()
|
---|
[1968] | 113 | include( withcasa )
|
---|
[1956] | 114 | endif()
|
---|
[1954] | 115 |
|
---|
[1970] | 116 | message( STATUS "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX} )
|
---|
[1957] | 117 |
|
---|
[1970] | 118 |
|
---|
[1954] | 119 | #
|
---|
[1970] | 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 )
|
---|
[1972] | 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 )
|
---|
[1970] | 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
|
---|
[1971] | 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
|
---|
[1970] | 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 | find_package( Boost REQUIRED ${boost_components} )
|
---|
| 345 | if( NOT Boost_FOUND )
|
---|
| 346 | message( FATAL_ERROR "Boost could not be found. Please check!" )
|
---|
| 347 | endif()
|
---|
| 348 | message( STATUS "BOOST_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
|
---|
| 349 | message( STATUS "BOOST_LIBRARIES = " ${Boost_LIBRARIES} )
|
---|
| 350 |
|
---|
| 351 |
|
---|
| 352 | #
|
---|
| 353 | # cfitsio
|
---|
| 354 | #
|
---|
| 355 | if( STANDALONE )
|
---|
| 356 | find_path( CFITSIO_INCLUDE_DIRS fitsio.h
|
---|
| 357 | PATH_SUFFIXES cfitsio )
|
---|
| 358 | if( CFITSIO_INCLUDE_DIRS MATCHES "NOTFOUND$" )
|
---|
| 359 | message( FATAL_ERROR "fitsio.h could not be found. Please check!" )
|
---|
| 360 | endif()
|
---|
[1971] | 361 | string( REGEX REPLACE "/[^/]+/?$" "" CFITSIO_ROOT ${CFITSIO_INCLUDE_DIRS} )
|
---|
| 362 | message( STATUS "CFITSIO_ROOT=" ${CFITSIO_ROOT} )
|
---|
| 363 | find_library( CFITSIO_LIBRARIES libcfitsio.${SO}
|
---|
| 364 | PATHS ${CFITSIO_ROOT}
|
---|
| 365 | PATH_SUFFIXES lib64 lib
|
---|
| 366 | NO_DEFAULT_PATH )
|
---|
| 367 | if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
| 368 | find_library( CFITSIO_LIBRARIES libcfitsio.a
|
---|
| 369 | PATHS ${CFITSIO_ROOT}
|
---|
| 370 | PATH_SUFFIXES lib64 lib
|
---|
| 371 | NO_DEFAULT_PATH )
|
---|
| 372 | endif()
|
---|
[1970] | 373 | find_library( CFITSIO_LIBRARIES libcfitsio.${SO}
|
---|
| 374 | PATHS /usr/local /usr
|
---|
| 375 | PATH_SUFFIXES lib64 lib )
|
---|
| 376 | if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
| 377 | message( FATAL_ERROR "libcfitsio.so could not be found. Please check!" )
|
---|
| 378 | endif()
|
---|
| 379 | else()
|
---|
| 380 | casa_find( CFITSIO
|
---|
| 381 | VERSION 3.006
|
---|
| 382 | INCLUDES fitsio.h fitsio2.h
|
---|
| 383 | INCLUDES_SUFFIXES cfitsio
|
---|
| 384 | LIBS cfitsio
|
---|
| 385 | CPP_VERSION CFITSIO_VERSION
|
---|
| 386 | RUN_VERSION "(ffvers(&v), v)" )
|
---|
| 387 | endif()
|
---|
| 388 | message( STATUS "CFITSIO_INCLUDE_DIRS = " ${CFITSIO_INCLUDE_DIRS} )
|
---|
| 389 | message( STATUS "CFITSIO_LIBRARIES = " ${CFITSIO_LIBRARIES} )
|
---|
| 390 |
|
---|
| 391 |
|
---|
| 392 | #
|
---|
| 393 | # Fortran
|
---|
| 394 | #
|
---|
| 395 | if( NOT FORTRAN_LIBRARIES )
|
---|
| 396 |
|
---|
| 397 | message( STATUS "Looking for Fortran runtime libraries" )
|
---|
| 398 | set( _try ${CMAKE_BINARY_DIR}/try_fortran.cc )
|
---|
| 399 | file( WRITE ${_try}
|
---|
| 400 | "int main() { return 0; }\n"
|
---|
| 401 | )
|
---|
| 402 |
|
---|
| 403 | if( _gfortran_lib_path )
|
---|
| 404 | try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
|
---|
| 405 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=${_gfortran_lib_path}"
|
---|
| 406 | )
|
---|
| 407 | else()
|
---|
| 408 | try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
|
---|
| 409 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lgfortran"
|
---|
| 410 | )
|
---|
| 411 | endif()
|
---|
| 412 | try_compile( _have_g2c ${CMAKE_BINARY_DIR} ${_try}
|
---|
| 413 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lg2c"
|
---|
| 414 | )
|
---|
| 415 |
|
---|
| 416 | if( _have_gfortran )
|
---|
| 417 | if( _gfortran_lib_path )
|
---|
| 418 | set( FORTRAN_LIBRARIES ${_gfortran_lib_path}
|
---|
| 419 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
| 420 | else()
|
---|
| 421 | set( FORTRAN_LIBRARIES -lgfortran
|
---|
| 422 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
| 423 | endif()
|
---|
| 424 | message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
|
---|
| 425 | elseif( _have_g2c )
|
---|
| 426 | set( FORTRAN_LIBRARIES -lg2c
|
---|
| 427 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
| 428 | message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
|
---|
| 429 | else()
|
---|
| 430 | set( FORTRAN_LIBRARIES ""
|
---|
| 431 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
| 432 | message( STATUS "Looking for Fortran runtime libraries -- <none>" )
|
---|
| 433 | # Not a fatal error because it might work, if all Fortran dependencies were
|
---|
| 434 | # already linked statically to the Fortran runtime...
|
---|
| 435 | endif()
|
---|
| 436 | endif()
|
---|
| 437 |
|
---|
| 438 |
|
---|
| 439 | #
|
---|
| 440 | # RPFITS
|
---|
| 441 | #
|
---|
| 442 | if ( STANDALONE )
|
---|
| 443 | find_path( RPFITS_INCLUDE_DIRS RPFITS.h
|
---|
| 444 | PATHS /usr/local /usr
|
---|
| 445 | PATH_SUFFIXES include )
|
---|
| 446 | if( RPFITS_INCLUDE_DIRS MATCHES "NOTFOUND$" )
|
---|
| 447 | message( FATAL_ERROR "RPFITS.h could not be found. Please check!" )
|
---|
| 448 | endif()
|
---|
| 449 | find_library( RPFITS_LIBRARIES librpfits.so
|
---|
| 450 | PATHS /usr/local /usr
|
---|
| 451 | PATH_SUFFIXES lib64 lib )
|
---|
| 452 | if( RPFITS_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
| 453 | message( FATAL_ERROR "librpfits.so could not be found. Please check!" )
|
---|
| 454 | endif()
|
---|
| 455 | list( APPEND RPFITS_LIBRARIES ${FORTRAN_LIBRARIES} )
|
---|
| 456 | else()
|
---|
| 457 | casa_find( RPFITS
|
---|
| 458 | VERSION 2.11
|
---|
| 459 | INCLUDES RPFITS.h
|
---|
| 460 | LIBS rpfits
|
---|
| 461 | RUN_VERSION names_.rpfitsversion
|
---|
| 462 | DEPENDS FORTRAN )
|
---|
| 463 | endif()
|
---|
| 464 | message( STATUS "RPFITS_INCLUDE_DIRS = " ${RPFITS_INCLUDE_DIRS} )
|
---|
| 465 | message( STATUS "RPFITS_LIBRARIES = " ${RPFITS_LIBRARIES} )
|
---|
| 466 |
|
---|
| 467 |
|
---|
| 468 | #
|
---|
| 469 | # wcslib
|
---|
| 470 | #
|
---|
| 471 | set( _wcslib libwcs.${SO} )
|
---|
| 472 | set( _wcs_version 4.3 )
|
---|
| 473 | find_library( WCSLIB ${_wcslib}
|
---|
| 474 | PATHS ${WCSLIB_PATHS}
|
---|
| 475 | PATH_SUFFIXES lib64 lib )
|
---|
| 476 | if( WCSLIB MATCHES "NOTFOUND$" )
|
---|
| 477 | message( STATUS "${_wcslib} could not be found." )
|
---|
| 478 | unset( _wcslib CACHE )
|
---|
| 479 | unset( WCSLIB CACHE )
|
---|
| 480 | set( _wcslib libwcs.${_wcs_version}.${SO} )
|
---|
| 481 | message( STATUS "Try to find ${_wcslib}..." )
|
---|
| 482 | find_library( WCSLIB ${_wcslib}
|
---|
| 483 | PATHS ${WCSLIB_PATHS}
|
---|
| 484 | PATH_SUFFIXES lib64 lib )
|
---|
| 485 | if( WCSLIB MATCHES "NOTFOUND$" )
|
---|
| 486 | message( FATAL_ERROR "${_wcslib} could not be found. Please check!" )
|
---|
| 487 | endif()
|
---|
| 488 | endif()
|
---|
| 489 | message( STATUS "WCSLIB = " ${WCSLIB} )
|
---|
| 490 | find_path( WCSLIB_INCLUDE_DIR wcslib/wcs.h
|
---|
| 491 | PATHS ${WCSLIB_PATHS}
|
---|
| 492 | PATH_SUFFIXES include )
|
---|
| 493 | if( WCSLIB_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
---|
| 494 | message( FATAL_ERROR "wcs.h could not be found. Please check!" )
|
---|
| 495 | endif()
|
---|
| 496 | message( STATUS "WCSLIB_INCLUDE_DIR = " ${WCSLIB_INCLUDE_DIR} )
|
---|
| 497 |
|
---|
| 498 |
|
---|
| 499 | #
|
---|
[1957] | 500 | # common include path
|
---|
| 501 | #
|
---|
[1954] | 502 | include_directories( ${CASACORE_INCLUDE_DIR}
|
---|
| 503 | ${Boost_INCLUDE_DIR}
|
---|
[1962] | 504 | ${PYTHON_INCLUDE_DIRS}
|
---|
[1961] | 505 | ${WCSLIB_INCLUDE_DIR}
|
---|
| 506 | ${CFITSIO_INCLUDE_DIRS}
|
---|
[1962] | 507 | ${RPFITS_INCLUDE_DIRS} )
|
---|
[1954] | 508 |
|
---|
| 509 |
|
---|
[1957] | 510 | #
|
---|
[1954] | 511 | # install directory
|
---|
[1957] | 512 | #
|
---|
[1954] | 513 | set( EXEC_INSTALL_DIR bin )
|
---|
| 514 | set( LIB_INSTALL_DIR lib )
|
---|
[1957] | 515 | set( PYTHON_INSTALL_DIR python/${PYTHONV}/asap )
|
---|
[1954] | 516 | set( SHARED_INSTALL_DIR share/asap )
|
---|
[2088] | 517 |
|
---|
| 518 | #
|
---|
| 519 | # execute getsvnrev.sh to create/update svninfo.txt
|
---|
| 520 | # run chmod to make sure the script has executable
|
---|
| 521 | #
|
---|
| 522 | exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/getsvnrev.sh )
|
---|
| 523 | exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/cmake/exec_getsvnrev.sh )
|
---|
| 524 | exec_program( ${ASAP_SOURCE_DIR}/cmake/exec_getsvnrev.sh ARGS ${ASAP_SOURCE_DIR})
|
---|
| 525 |
|
---|
[1976] | 526 | # Add the modules to be built.
|
---|
| 527 | #
|
---|
| 528 | # Choose to have correct RPATHs both in the build tree and
|
---|
| 529 | # in the install tree (at the cost of having to change the
|
---|
| 530 | # rpath when installing)
|
---|
| 531 | #
|
---|
| 532 | set( CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib )
|
---|
| 533 | set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
---|
| 534 | set( CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib )
|
---|
[1954] | 535 |
|
---|
[1957] | 536 |
|
---|
[1976] | 537 |
|
---|
[1957] | 538 | #
|
---|
| 539 | # libraries and executables
|
---|
| 540 | #
|
---|
[1958] | 541 | set( ASAPLIB asap )
|
---|
[1957] | 542 | set( PYRAPLIB pyrap )
|
---|
| 543 | set( ATNFLIB atnf )
|
---|
| 544 | set( ASAP2TO3 asap2to3 )
|
---|
[2210] | 545 | if ( NOT STANDALONE )
|
---|
| 546 | set( ASDM2ASAP asdm2ASAP )
|
---|
| 547 | endif()
|
---|
[1957] | 548 |
|
---|
[1966] | 549 | #
|
---|
| 550 | # always install by default
|
---|
| 551 | #
|
---|
| 552 | add_custom_target( inst ALL ${CMAKE_BUILD_TOOL} install/fast )
|
---|
[1957] | 553 |
|
---|
| 554 | #
|
---|
[1954] | 555 | # subdirectories
|
---|
[1957] | 556 | #
|
---|
[1968] | 557 | asap_add_subdirectory()
|
---|