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