[2997] | 1 | #####
|
---|
[1954] | 2 | # CMakeLists.txt for ASAP module
|
---|
[2997] | 3 | #####
|
---|
[1954] | 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
|
---|
[2972] | 87 | "-pipe -Wall -Wextra -Wno-non-template-friend -Wcast-align -Wno-comment" )
|
---|
[2296] | 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 | coordinates
|
---|
| 193 | fits
|
---|
| 194 | images
|
---|
| 195 | lattices
|
---|
| 196 | measures
|
---|
| 197 | mirlib
|
---|
| 198 | ms
|
---|
| 199 | msfits
|
---|
| 200 | scimath
|
---|
| 201 | scimath_f
|
---|
| 202 | tables )
|
---|
| 203 | set( _casacore_libs "" )
|
---|
| 204 | foreach( _a ${CASACORE_LIBS} )
|
---|
| 205 | set( _libname libcasa_${_a}.${SO} )
|
---|
| 206 | unset( _casacore_lib CACHE )
|
---|
| 207 | find_library( _casacore_lib ${_libname}
|
---|
| 208 | PATHS ${CASACORE_PATHS}
|
---|
| 209 | PATH_SUFFIXES lib64 lib )
|
---|
| 210 | if( _casacore_lib MATCHES "NOTFOUND$" )
|
---|
| 211 | message( FATAL_ERROR "${_libname} could not be found. Please check!" )
|
---|
| 212 | else()
|
---|
| 213 | #list( APPEND _casacore_libs casa_${_a} )
|
---|
| 214 | list( APPEND _casacore_libs ${_casacore_lib} )
|
---|
| 215 | endif()
|
---|
| 216 | endforeach()
|
---|
| 217 | set( CASACORE_LIBRARIES ${_casacore_libs} )
|
---|
| 218 | else()
|
---|
| 219 | # use libcasacore
|
---|
| 220 | set( _libname libcasacore.${SO} )
|
---|
| 221 | find_library( CASACORE_LIBRARIES ${_libname}
|
---|
| 222 | PATHS ${CASACORE_PATHS}
|
---|
| 223 | PATH_SUFFIXES lib64 lib )
|
---|
| 224 | if( CASACORE_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
| 225 | message( FATAL_ERROR "${_libname} could not be found. Please check!" )
|
---|
| 226 | endif()
|
---|
| 227 | set( _includename casa/aipsdef.h )
|
---|
[1972] | 228 | string( REGEX REPLACE /[^/]+/[^/]+/?$ "" _coreroot ${CASACORE_LIBRARIES} )
|
---|
| 229 | find_path( CASACORE_INCLUDE_DIR ${_includename}
|
---|
| 230 | PATHS ${_coreroot}
|
---|
| 231 | PATH_SUFFIXES include include/casacore
|
---|
| 232 | NO_DEFAULT_PATH )
|
---|
[1970] | 233 | find_path( CASACORE_INCLUDE_DIR ${_includename}
|
---|
| 234 | PATHS ${CASACORE_PATHS}
|
---|
| 235 | PATH_SUFFIXES include include/casacore
|
---|
| 236 | NO_DEFAULT_PATH )
|
---|
| 237 | find_path( CASACORE_INCLUDE_DIR ${_includename} )
|
---|
| 238 | if( CASACORE_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
---|
| 239 | message( FATAL_ERROR "${_includename} could not be found. Please check!" )
|
---|
| 240 | endif()
|
---|
| 241 | endif()
|
---|
| 242 | message( STATUS "CASACORE_LIBRARIES = " ${CASACORE_LIBRARIES} )
|
---|
| 243 | message( STATUS "CASACORE_INCLUDE_DIR = " ${CASACORE_INCLUDE_DIR} )
|
---|
| 244 | unset( USE_LIBCASACORE CACHE )
|
---|
| 245 |
|
---|
| 246 |
|
---|
| 247 | #
|
---|
| 248 | # Python
|
---|
| 249 | #
|
---|
| 250 | if( STANDALONE )
|
---|
| 251 | include( FindPythonLibs )
|
---|
| 252 | if( NOT PYTHONLIBS_FOUND )
|
---|
| 253 | message( FATAL_ERROR "Python could not be found. Please check!" )
|
---|
| 254 | endif()
|
---|
| 255 |
|
---|
| 256 | # Define pyroot
|
---|
| 257 | string( REGEX REPLACE "/[^/]+/[^/]+/?$" "" pyroot ${PYTHON_INCLUDE_DIRS} )
|
---|
| 258 |
|
---|
| 259 | # find numpy
|
---|
| 260 | string( REGEX MATCH [0-9].[0-9] PYTHONV ${PYTHON_INCLUDE_DIRS} )
|
---|
| 261 | string( REPLACE "." "" PV ${PYTHONV} )
|
---|
| 262 | find_path( NUMPY_INCLUDE_DIR numpy/npy_interrupt.h
|
---|
| 263 | PATHS
|
---|
[1971] | 264 | ${pyroot}/lib/python${PYTHONV}/site-packages/numpy/core
|
---|
| 265 | ${pyroot}/Library/Frameworks/Python.framework/Versions/${PYTHONV}
|
---|
| 266 | ${pyroot}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core
|
---|
[1970] | 267 | PATH_SUFFIXES include )
|
---|
| 268 | if( NUMPY_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
---|
| 269 | message( FATAL_ERROR "numpy/npy_interrupt.h could not be found. Please check!" )
|
---|
| 270 | endif()
|
---|
| 271 | list( APPEND PYTHON_INCLUDE_DIRS ${NUMPY_INCLUDE_DIR} )
|
---|
| 272 |
|
---|
| 273 | set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS}
|
---|
| 274 | -DPYTHONROOT=\"${pyroot}\"
|
---|
| 275 | -DPYTHONVER=\"${PYTHONV}\"
|
---|
| 276 | -DPYVERSION=${PV} )
|
---|
| 277 | else()
|
---|
[2400] | 278 | # with CASA
|
---|
[1970] | 279 | if( NOT PYTHON_FOUND )
|
---|
| 280 | if ( NOT PYTHON_LIBNAME )
|
---|
[2400] | 281 | #set( _names 2.9 2.8 2.7 2.6 2.5.2 2.5 )
|
---|
[2847] | 282 | set( _names 2.7 2.6 2.5.2 2.5 )
|
---|
[2400] | 283 | # OSX 10.7 has Python2.7 by default. CASA has't yet supported python > 2.6 anyway.
|
---|
[1970] | 284 | # (The library named libpython.2.5.2.dylib seems to exist only in the CASA world.)
|
---|
| 285 | else()
|
---|
| 286 | set( _names ${PYTHON_LIBNAME} )
|
---|
| 287 | endif()
|
---|
| 288 |
|
---|
| 289 | set( _found False )
|
---|
| 290 | foreach( _v ${_names} )
|
---|
| 291 |
|
---|
| 292 | casa_find(
|
---|
[2400] | 293 | PYTHON${_v}
|
---|
| 294 | #PREFIX_HINTS ${PYTHON_ROOT_DIR}
|
---|
[1970] | 295 | LIBS python${_v}
|
---|
| 296 | NO_REQUIRE
|
---|
| 297 | )
|
---|
| 298 |
|
---|
| 299 | if( PYTHON${_v}_FOUND )
|
---|
| 300 | set( PYTHON_LIBNAME ${_v} )
|
---|
| 301 | set( _found True )
|
---|
| 302 | break()
|
---|
| 303 | endif()
|
---|
| 304 |
|
---|
| 305 | endforeach()
|
---|
| 306 |
|
---|
| 307 | if( NOT _found )
|
---|
| 308 | message( FATAL_ERROR "Could not find any PYTHON library with version one of ${_names}. Please check!" )
|
---|
| 309 | endif()
|
---|
| 310 |
|
---|
| 311 | endif()
|
---|
| 312 |
|
---|
| 313 | if( NOT PYTHON_LIBNAME )
|
---|
| 314 | # Found Python, but PYTHON_LIBNAME is undefined, that is impossible.
|
---|
| 315 | 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*\")")
|
---|
| 316 | endif()
|
---|
| 317 |
|
---|
| 318 | string( SUBSTRING ${PYTHON_LIBNAME} 0 3 PYTHONV )
|
---|
| 319 | string( REPLACE "." "" PV ${PYTHONV} )
|
---|
| 320 | set( python_library python${PYTHON_LIBNAME} )
|
---|
| 321 |
|
---|
| 322 | # Form the Python install prefix by stripping away "lib/libpython2.5.2.dylib" (example) from
|
---|
| 323 | # the full python library path
|
---|
| 324 | string( REGEX MATCH "/lib(64)?/lib${python_library}" _match ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
|
---|
| 325 | if( _match )
|
---|
| 326 | string( REGEX REPLACE "/lib(64)?/lib${python_library}.*" "" python_prefix ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
|
---|
| 327 | else()
|
---|
| 328 | # Python library was not in a lib(64) directory!
|
---|
| 329 | message( WARNING "Python library path \"${PYTHON${PYTHON_LIBNAME}_LIBRARIES}\" does not contain \"/lib(64)/lib${python_library}\"" )
|
---|
| 330 | set( python_prefix ${casa_packages} )
|
---|
| 331 | endif()
|
---|
| 332 |
|
---|
[2400] | 333 | #
|
---|
| 334 | # For some unknown reason cmake sets the /usr for Lion
|
---|
| 335 | #
|
---|
| 336 | if( APPLE )
|
---|
| 337 | set( python_prefix ${casa_packages} )
|
---|
| 338 | endif()
|
---|
| 339 |
|
---|
[1970] | 340 | # The python version and prefix is known, do the actual search
|
---|
| 341 | if( NOT PYTHON_FOUND )
|
---|
| 342 | message( STATUS "Looking for PYTHON version ${PYTHONV}.x in ${python_prefix}" )
|
---|
| 343 | endif()
|
---|
| 344 |
|
---|
| 345 | casa_find( PYTHON
|
---|
| 346 | VERSION 2.5 # minimum required
|
---|
| 347 | INCLUDES Python.h
|
---|
| 348 | numpy/npy_interrupt.h # for numpy
|
---|
| 349 | INCLUDES_SUFFIXES python${PYTHONV}
|
---|
| 350 | PREFIX_HINTS
|
---|
| 351 | ${python_prefix}/lib/python${PYTHONV}/site-packages/numpy/core
|
---|
| 352 | ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}
|
---|
| 353 | ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core
|
---|
| 354 | LIBS ${python_library}
|
---|
| 355 | CPP_VERSION PY_VERSION )
|
---|
| 356 |
|
---|
| 357 | # Store PYTHON_LIBNAME in the cache
|
---|
| 358 | set( PYTHON_LIBNAME ${PYTHON_LIBNAME} CACHE STRING "Python major and minor version to use" FORCE )
|
---|
| 359 |
|
---|
| 360 | # Define pyroot to two directory levels above Python.h.
|
---|
| 361 | string( REGEX REPLACE "/[^/]+/[^/]+/?$" "" pyroot ${PYTHON_Python.h} )
|
---|
| 362 |
|
---|
| 363 | set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS}
|
---|
| 364 | -DAIPSROOT=\"${CMAKE_SOURCE_DIR}\"
|
---|
| 365 | -DAIPSARCH=\"${arch}\"
|
---|
| 366 | -DAIPSSITE=\"garching\"
|
---|
| 367 | -DPYTHONROOT=\"${pyroot}\"
|
---|
| 368 | -DPYTHONVER=\"${PYTHONV}\"
|
---|
| 369 | -DPYVERSION=${PV} )
|
---|
| 370 | endif()
|
---|
| 371 | message( STATUS "PYTHON_INCLUDE_DIRS = " ${PYTHON_INCLUDE_DIRS} )
|
---|
| 372 | message( STATUS "PYTHON_LINRARIES = " ${PYTHON_LIBRARIES} )
|
---|
| 373 | message( STATUS "PYTHONV = " ${PYTHONV} )
|
---|
| 374 |
|
---|
| 375 |
|
---|
| 376 | #
|
---|
| 377 | # DL
|
---|
| 378 | #
|
---|
| 379 | set( DL_LIBRARIES ${CMAKE_DL_LIBS} CACHE STRING "dl libraries" FORCE )
|
---|
| 380 | if( DL_LIBRARIES STREQUAL "dl" )
|
---|
| 381 | set( DL_LIBRARIES "-ldl" CACHE STRING "dl libraries" FORCE )
|
---|
| 382 | endif()
|
---|
| 383 | message( STATUS "DL_LIBRARIES = " ${DL_LIBRARIES} )
|
---|
| 384 |
|
---|
| 385 |
|
---|
| 386 | #
|
---|
| 387 | # BLAS
|
---|
| 388 | #
|
---|
| 389 | find_library( BLAS_LIBRARIES libblas.${SO} )
|
---|
| 390 | if ( BLAS_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
| 391 | message( FATAL_ERROR "blas could not be found. Please check!" )
|
---|
| 392 | endif()
|
---|
| 393 | message( STATUS "BLAS_LIBRARIES = " ${BLAS_LIBRARIES} )
|
---|
| 394 |
|
---|
| 395 |
|
---|
| 396 | #
|
---|
| 397 | # LAPACK
|
---|
| 398 | #
|
---|
| 399 | find_library( LAPACK_LIBRARIES liblapack.${SO} )
|
---|
| 400 | if ( LAPACK_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
| 401 | message( FATAL_ERROR "lapack could not be found. Please check!" )
|
---|
| 402 | endif()
|
---|
| 403 | message( STATUS "LAPACK_LIBRARIES = " ${LAPACK_LIBRARIES} )
|
---|
| 404 |
|
---|
| 405 |
|
---|
| 406 | #
|
---|
| 407 | # Boost
|
---|
| 408 | #
|
---|
| 409 | set( boost_components python )
|
---|
[2280] | 410 | if( NOT STANDALONE )
|
---|
| 411 | set( boost_components ${boost_components} system )
|
---|
| 412 | endif()
|
---|
[1970] | 413 | find_package( Boost REQUIRED ${boost_components} )
|
---|
| 414 | if( NOT Boost_FOUND )
|
---|
| 415 | message( FATAL_ERROR "Boost could not be found. Please check!" )
|
---|
| 416 | endif()
|
---|
| 417 | message( STATUS "BOOST_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
|
---|
| 418 | message( STATUS "BOOST_LIBRARIES = " ${Boost_LIBRARIES} )
|
---|
| 419 |
|
---|
| 420 |
|
---|
| 421 | #
|
---|
| 422 | # cfitsio
|
---|
| 423 | #
|
---|
| 424 | if( STANDALONE )
|
---|
| 425 | find_path( CFITSIO_INCLUDE_DIRS fitsio.h
|
---|
| 426 | PATH_SUFFIXES cfitsio )
|
---|
| 427 | if( CFITSIO_INCLUDE_DIRS MATCHES "NOTFOUND$" )
|
---|
| 428 | message( FATAL_ERROR "fitsio.h could not be found. Please check!" )
|
---|
| 429 | endif()
|
---|
[1971] | 430 | string( REGEX REPLACE "/[^/]+/?$" "" CFITSIO_ROOT ${CFITSIO_INCLUDE_DIRS} )
|
---|
| 431 | message( STATUS "CFITSIO_ROOT=" ${CFITSIO_ROOT} )
|
---|
| 432 | find_library( CFITSIO_LIBRARIES libcfitsio.${SO}
|
---|
| 433 | PATHS ${CFITSIO_ROOT}
|
---|
| 434 | PATH_SUFFIXES lib64 lib
|
---|
| 435 | NO_DEFAULT_PATH )
|
---|
| 436 | if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
| 437 | find_library( CFITSIO_LIBRARIES libcfitsio.a
|
---|
| 438 | PATHS ${CFITSIO_ROOT}
|
---|
| 439 | PATH_SUFFIXES lib64 lib
|
---|
| 440 | NO_DEFAULT_PATH )
|
---|
| 441 | endif()
|
---|
[1970] | 442 | find_library( CFITSIO_LIBRARIES libcfitsio.${SO}
|
---|
| 443 | PATHS /usr/local /usr
|
---|
| 444 | PATH_SUFFIXES lib64 lib )
|
---|
| 445 | if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
| 446 | message( FATAL_ERROR "libcfitsio.so could not be found. Please check!" )
|
---|
| 447 | endif()
|
---|
| 448 | else()
|
---|
| 449 | casa_find( CFITSIO
|
---|
| 450 | VERSION 3.006
|
---|
| 451 | INCLUDES fitsio.h fitsio2.h
|
---|
| 452 | INCLUDES_SUFFIXES cfitsio
|
---|
| 453 | LIBS cfitsio
|
---|
| 454 | CPP_VERSION CFITSIO_VERSION
|
---|
| 455 | RUN_VERSION "(ffvers(&v), v)" )
|
---|
| 456 | endif()
|
---|
| 457 | message( STATUS "CFITSIO_INCLUDE_DIRS = " ${CFITSIO_INCLUDE_DIRS} )
|
---|
| 458 | message( STATUS "CFITSIO_LIBRARIES = " ${CFITSIO_LIBRARIES} )
|
---|
| 459 |
|
---|
| 460 |
|
---|
| 461 | #
|
---|
| 462 | # Fortran
|
---|
| 463 | #
|
---|
| 464 | if( NOT FORTRAN_LIBRARIES )
|
---|
| 465 |
|
---|
| 466 | message( STATUS "Looking for Fortran runtime libraries" )
|
---|
| 467 | set( _try ${CMAKE_BINARY_DIR}/try_fortran.cc )
|
---|
| 468 | file( WRITE ${_try}
|
---|
| 469 | "int main() { return 0; }\n"
|
---|
| 470 | )
|
---|
[2931] | 471 |
|
---|
| 472 | execute_process( COMMAND ${CMAKE_Fortran_COMPILER} -print-search-dirs
|
---|
| 473 | 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; break; }} break if $found; } break if $found;}"
|
---|
| 474 | OUTPUT_VARIABLE _gfortran_lib_path
|
---|
| 475 | OUTPUT_STRIP_TRAILING_WHITESPACE )
|
---|
| 476 |
|
---|
[1970] | 477 | if( _gfortran_lib_path )
|
---|
| 478 | try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
|
---|
| 479 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=${_gfortran_lib_path}"
|
---|
| 480 | )
|
---|
| 481 | else()
|
---|
| 482 | try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
|
---|
| 483 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lgfortran"
|
---|
| 484 | )
|
---|
| 485 | endif()
|
---|
| 486 | try_compile( _have_g2c ${CMAKE_BINARY_DIR} ${_try}
|
---|
| 487 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lg2c"
|
---|
| 488 | )
|
---|
| 489 |
|
---|
| 490 | if( _have_gfortran )
|
---|
| 491 | if( _gfortran_lib_path )
|
---|
| 492 | set( FORTRAN_LIBRARIES ${_gfortran_lib_path}
|
---|
| 493 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
| 494 | else()
|
---|
| 495 | set( FORTRAN_LIBRARIES -lgfortran
|
---|
| 496 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
| 497 | endif()
|
---|
| 498 | message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
|
---|
| 499 | elseif( _have_g2c )
|
---|
| 500 | set( FORTRAN_LIBRARIES -lg2c
|
---|
| 501 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
| 502 | message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
|
---|
| 503 | else()
|
---|
| 504 | set( FORTRAN_LIBRARIES ""
|
---|
| 505 | CACHE STRING "Fortran library linker option" FORCE )
|
---|
| 506 | message( STATUS "Looking for Fortran runtime libraries -- <none>" )
|
---|
| 507 | # Not a fatal error because it might work, if all Fortran dependencies were
|
---|
| 508 | # already linked statically to the Fortran runtime...
|
---|
| 509 | endif()
|
---|
| 510 | endif()
|
---|
| 511 |
|
---|
[2830] | 512 | # X11.
|
---|
| 513 | if( NOT APPLE )
|
---|
| 514 | find_package( X11 REQUIRED )
|
---|
| 515 | # Rename
|
---|
| 516 | set( X11_INCLUDE_DIRS ${X11_INCLUDE_DIR} )
|
---|
| 517 | endif()
|
---|
[1970] | 518 |
|
---|
[2830] | 519 | # PGPLOT (FORTRAN plotting package).
|
---|
| 520 | # depends on X11
|
---|
[2833] | 521 | # not require in standalone mode
|
---|
| 522 | if( NOT STANDALONE )
|
---|
[2830] | 523 | if( APPLE )
|
---|
| 524 | set( _deps FORTRAN )
|
---|
| 525 | else()
|
---|
| 526 | set( _deps X11 FORTRAN )
|
---|
| 527 | endif()
|
---|
| 528 | if (CMAKE_SYSTEM MATCHES ^Darwin-11 AND NOT LLVMCOMPILER )
|
---|
| 529 | set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit -lgfortran" )
|
---|
| 530 | else()
|
---|
| 531 | if (APPLE)
|
---|
| 532 | set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit" )
|
---|
| 533 | else()
|
---|
| 534 | set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error" )
|
---|
| 535 | endif()
|
---|
| 536 | endif()
|
---|
| 537 | casa_find( PGPLOT
|
---|
| 538 | VERSION 5.3.1
|
---|
| 539 | PREFIX_HINTS ${PGPLOT_ROOT_DIR}
|
---|
| 540 | INCLUDES cpgplot.h
|
---|
| 541 | LIBS pgplot${pgplot_ext} cpgplot${pgplot_ext}
|
---|
| 542 | DEPENDS ${_deps} )
|
---|
[2833] | 543 |
|
---|
| 544 | add_definitions( -DENABLE_PLOTTER2 )
|
---|
[2830] | 545 | endif()
|
---|
| 546 |
|
---|
[1970] | 547 | #
|
---|
| 548 | # RPFITS
|
---|
| 549 | #
|
---|
| 550 | if ( STANDALONE )
|
---|
| 551 | find_path( RPFITS_INCLUDE_DIRS RPFITS.h
|
---|
| 552 | PATHS /usr/local /usr
|
---|
| 553 | PATH_SUFFIXES include )
|
---|
| 554 | if( RPFITS_INCLUDE_DIRS MATCHES "NOTFOUND$" )
|
---|
| 555 | message( FATAL_ERROR "RPFITS.h could not be found. Please check!" )
|
---|
| 556 | endif()
|
---|
| 557 | find_library( RPFITS_LIBRARIES librpfits.so
|
---|
| 558 | PATHS /usr/local /usr
|
---|
| 559 | PATH_SUFFIXES lib64 lib )
|
---|
| 560 | if( RPFITS_LIBRARIES MATCHES "NOTFOUND$" )
|
---|
| 561 | message( FATAL_ERROR "librpfits.so could not be found. Please check!" )
|
---|
| 562 | endif()
|
---|
| 563 | list( APPEND RPFITS_LIBRARIES ${FORTRAN_LIBRARIES} )
|
---|
| 564 | else()
|
---|
| 565 | casa_find( RPFITS
|
---|
| 566 | VERSION 2.11
|
---|
| 567 | INCLUDES RPFITS.h
|
---|
| 568 | LIBS rpfits
|
---|
| 569 | RUN_VERSION names_.rpfitsversion
|
---|
| 570 | DEPENDS FORTRAN )
|
---|
| 571 | endif()
|
---|
| 572 | message( STATUS "RPFITS_INCLUDE_DIRS = " ${RPFITS_INCLUDE_DIRS} )
|
---|
| 573 | message( STATUS "RPFITS_LIBRARIES = " ${RPFITS_LIBRARIES} )
|
---|
| 574 |
|
---|
| 575 |
|
---|
| 576 | #
|
---|
| 577 | # wcslib
|
---|
| 578 | #
|
---|
| 579 | set( _wcslib libwcs.${SO} )
|
---|
| 580 | set( _wcs_version 4.3 )
|
---|
| 581 | find_library( WCSLIB ${_wcslib}
|
---|
| 582 | PATHS ${WCSLIB_PATHS}
|
---|
| 583 | PATH_SUFFIXES lib64 lib )
|
---|
| 584 | if( WCSLIB MATCHES "NOTFOUND$" )
|
---|
| 585 | message( STATUS "${_wcslib} could not be found." )
|
---|
| 586 | unset( _wcslib CACHE )
|
---|
| 587 | unset( WCSLIB CACHE )
|
---|
| 588 | set( _wcslib libwcs.${_wcs_version}.${SO} )
|
---|
| 589 | message( STATUS "Try to find ${_wcslib}..." )
|
---|
| 590 | find_library( WCSLIB ${_wcslib}
|
---|
| 591 | PATHS ${WCSLIB_PATHS}
|
---|
| 592 | PATH_SUFFIXES lib64 lib )
|
---|
| 593 | if( WCSLIB MATCHES "NOTFOUND$" )
|
---|
| 594 | message( FATAL_ERROR "${_wcslib} could not be found. Please check!" )
|
---|
| 595 | endif()
|
---|
| 596 | endif()
|
---|
| 597 | message( STATUS "WCSLIB = " ${WCSLIB} )
|
---|
| 598 | find_path( WCSLIB_INCLUDE_DIR wcslib/wcs.h
|
---|
| 599 | PATHS ${WCSLIB_PATHS}
|
---|
| 600 | PATH_SUFFIXES include )
|
---|
| 601 | if( WCSLIB_INCLUDE_DIR MATCHES "NOTFOUND$" )
|
---|
| 602 | message( FATAL_ERROR "wcs.h could not be found. Please check!" )
|
---|
| 603 | endif()
|
---|
| 604 | message( STATUS "WCSLIB_INCLUDE_DIR = " ${WCSLIB_INCLUDE_DIR} )
|
---|
| 605 |
|
---|
| 606 |
|
---|
| 607 | #
|
---|
[1957] | 608 | # common include path
|
---|
| 609 | #
|
---|
[1954] | 610 | include_directories( ${CASACORE_INCLUDE_DIR}
|
---|
| 611 | ${Boost_INCLUDE_DIR}
|
---|
[2830] | 612 | ${X11_INCLUDE_DIRS}
|
---|
| 613 | ${PGPLOT_INCLUDE_DIRS}
|
---|
[1962] | 614 | ${PYTHON_INCLUDE_DIRS}
|
---|
[1961] | 615 | ${WCSLIB_INCLUDE_DIR}
|
---|
| 616 | ${CFITSIO_INCLUDE_DIRS}
|
---|
[1962] | 617 | ${RPFITS_INCLUDE_DIRS} )
|
---|
[1954] | 618 |
|
---|
| 619 |
|
---|
[1957] | 620 | #
|
---|
[1954] | 621 | # install directory
|
---|
[1957] | 622 | #
|
---|
[1954] | 623 | set( EXEC_INSTALL_DIR bin )
|
---|
| 624 | set( LIB_INSTALL_DIR lib )
|
---|
[1957] | 625 | set( PYTHON_INSTALL_DIR python/${PYTHONV}/asap )
|
---|
[1954] | 626 | set( SHARED_INSTALL_DIR share/asap )
|
---|
[2088] | 627 |
|
---|
| 628 | #
|
---|
| 629 | # execute getsvnrev.sh to create/update svninfo.txt
|
---|
| 630 | # run chmod to make sure the script has executable
|
---|
| 631 | #
|
---|
| 632 | exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/getsvnrev.sh )
|
---|
| 633 | exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/cmake/exec_getsvnrev.sh )
|
---|
| 634 | exec_program( ${ASAP_SOURCE_DIR}/cmake/exec_getsvnrev.sh ARGS ${ASAP_SOURCE_DIR})
|
---|
| 635 |
|
---|
[1976] | 636 | # Add the modules to be built.
|
---|
| 637 | #
|
---|
| 638 | # Choose to have correct RPATHs both in the build tree and
|
---|
| 639 | # in the install tree (at the cost of having to change the
|
---|
| 640 | # rpath when installing)
|
---|
| 641 | #
|
---|
| 642 | set( CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib )
|
---|
| 643 | set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
---|
| 644 | set( CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib )
|
---|
[1954] | 645 |
|
---|
[2577] | 646 | #
|
---|
| 647 | # PKSMS
|
---|
| 648 | #
|
---|
| 649 | if ( NOT PKSMS )
|
---|
| 650 | add_definitions( -DNOPKSMS )
|
---|
| 651 | endif()
|
---|
[1957] | 652 |
|
---|
| 653 | #
|
---|
| 654 | # libraries and executables
|
---|
| 655 | #
|
---|
[2465] | 656 | set( ASAPPYLIB _asap )
|
---|
[1958] | 657 | set( ASAPLIB asap )
|
---|
[1957] | 658 | set( PYRAPLIB pyrap )
|
---|
| 659 | set( ATNFLIB atnf )
|
---|
| 660 | set( ASAP2TO3 asap2to3 )
|
---|
[2210] | 661 | if ( NOT STANDALONE )
|
---|
[2417] | 662 | # set( ASDM2ASAP_OLD oldasdm2ASAP )
|
---|
[2210] | 663 | set( ASDM2ASAP asdm2ASAP )
|
---|
| 664 | endif()
|
---|
[1957] | 665 |
|
---|
[1966] | 666 | #
|
---|
| 667 | # always install by default
|
---|
| 668 | #
|
---|
| 669 | add_custom_target( inst ALL ${CMAKE_BUILD_TOOL} install/fast )
|
---|
[1957] | 670 |
|
---|
| 671 | #
|
---|
[1954] | 672 | # subdirectories
|
---|
[1957] | 673 | #
|
---|
[1968] | 674 | asap_add_subdirectory()
|
---|