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