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