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