[1968] | 1 | ### |
---|
| 2 | # CMakeLists.txt for standalone build |
---|
| 3 | ### |
---|
| 4 | |
---|
| 5 | # Define compiler paths on OSX 10.5. This must be done before invoking project() |
---|
| 6 | if( APPLE ) |
---|
| 7 | if( EXISTS /opt/casa/core2-apple-darwin8/3rd-party/bin/gfortran ) |
---|
| 8 | set( CMAKE_Fortran_COMPILER /opt/casa/core2-apple-darwin8/3rd-party/bin/gfortran ) |
---|
| 9 | set( CMAKE_CXX_COMPILER /opt/casa/core2-apple-darwin8/3rd-party/bin/g++ ) |
---|
| 10 | elseif( EXISTS /opt/local/bin/gfortran ) |
---|
| 11 | set( CMAKE_Fortran_COMPILER /opt/local/bin/gfortran ) |
---|
| 12 | elseif( EXISTS /opt/local/bin/gfortran-mp-4.4 ) |
---|
| 13 | set( CMAKE_Fortran_COMPILER /opt/local/bin/gfortran-mp-4.4 ) |
---|
| 14 | if( EXISTS /opt/local/bin/g++-mp-4.4 ) |
---|
| 15 | set( CMAKE_CXX_COMPILER /opt/local/bin/g++-mp-4.4 ) |
---|
| 16 | endif() |
---|
| 17 | endif() |
---|
| 18 | endif() |
---|
| 19 | |
---|
| 20 | # project name is ASAP |
---|
| 21 | project( ASAP ) |
---|
| 22 | |
---|
| 23 | # flags |
---|
| 24 | set( DEFAULT_CXX_FLAGS |
---|
| 25 | "-pipe -Wall -Wextra -Wno-non-template-friend -Wcast-align -Wno-comment -O3" ) |
---|
| 26 | find_package( OpenMP ) |
---|
| 27 | if( OPENMP_FOUND ) |
---|
| 28 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" ) |
---|
| 29 | endif() |
---|
| 30 | |
---|
| 31 | set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS} |
---|
| 32 | -DCASA_USECASAPATH |
---|
| 33 | -DCASACORE_NEEDS_RETHROW |
---|
| 34 | -DAIPS_STDLIB |
---|
| 35 | -DAIPS_AUTO_STL |
---|
| 36 | -D_GNU_SOURCE ) |
---|
| 37 | |
---|
| 38 | if( CMAKE_SYSTEM_NAME STREQUAL Linux ) |
---|
| 39 | set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS} |
---|
| 40 | -D_FILE_OFFSET_BITS=64 |
---|
| 41 | -D_LARGEFILE_SOURCE |
---|
| 42 | ) |
---|
| 43 | endif() |
---|
| 44 | |
---|
| 45 | add_definitions( ${CASACORE_DEFINITIONS} ) |
---|
| 46 | |
---|
| 47 | # environment dependent settings |
---|
| 48 | message( STATUS "CMAKE_SYSTEM = " ${CMAKE_SYSTEM} ) |
---|
| 49 | if( APPLE ) |
---|
| 50 | set( SO dylib ) |
---|
| 51 | if( CMAKE_SYSTEM MATCHES ^Darwin-10 ) |
---|
| 52 | if( NOT archflag ) |
---|
| 53 | if( EXISTS /opt/casa/darwin10-64b ) |
---|
| 54 | set( archflag x86_64 ) |
---|
| 55 | elseif( EXISTS /opt/casa/core2-apple-darwin10 ) |
---|
| 56 | set( archflag i386 ) |
---|
| 57 | else() |
---|
| 58 | set( archflag x86_64 ) |
---|
| 59 | endif() |
---|
| 60 | endif() |
---|
| 61 | if( archflag STREQUAL x86_64 ) |
---|
| 62 | add_definitions( -DAIPS_64B ) |
---|
| 63 | set( casa_packages /opt/casa/darwin10-64b ) |
---|
| 64 | else() |
---|
| 65 | set( casa_packages /opt/casa/core2-apple-darwin10 ) |
---|
| 66 | endif() |
---|
| 67 | execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version |
---|
| 68 | COMMAND head -1 |
---|
| 69 | COMMAND perl -pe "s|.*?(\\d+\\.\\d+)\\.\\d+$|$1|" |
---|
| 70 | OUTPUT_VARIABLE _cxx_version |
---|
| 71 | OUTPUT_STRIP_TRAILING_WHITESPACE ) |
---|
| 72 | if( NOT _cxx_version STREQUAL "4.4" ) |
---|
| 73 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -arch ${archflag}" ) |
---|
| 74 | endif() |
---|
| 75 | elseif( CMAKE_SYSTEM MATCHES ^Darwin-9 ) |
---|
| 76 | set( casa_packages /opt/casa/core2-apple-darwin8/3rd-party ) |
---|
| 77 | endif() |
---|
| 78 | elseif( CMAKE_SYSTEM_NAME STREQUAL Linux ) |
---|
| 79 | set( SO so ) |
---|
| 80 | add_definitions( -DAIPS_LINUX ) |
---|
| 81 | if( CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 ) |
---|
| 82 | set( casa_packages /usr/lib64/casapy ) |
---|
| 83 | add_definitions( -DAIPS_64B ) |
---|
| 84 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated" ) |
---|
| 85 | else() |
---|
| 86 | set( casa_packages /usr/lib/casapy ) |
---|
| 87 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated -Woverloaded-virtual" ) |
---|
| 88 | endif() |
---|
| 89 | endif() |
---|
| 90 | |
---|
| 91 | message( STATUS "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX} ) |
---|
| 92 | |
---|
| 93 | # set flags for cpp compiler |
---|
| 94 | set( CMAKE_CXX_FLAGS ${DEFAULT_CXX_FLAGS} ) |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | # |
---|
| 98 | # DL |
---|
| 99 | # |
---|
| 100 | set( DL_LIBRARIES ${CMAKE_DL_LIBS} CACHE STRING "dl libraries" FORCE ) |
---|
| 101 | if( DL_LIBRARIES STREQUAL "dl" ) |
---|
| 102 | set( DL_LIBRARIES "-ldl" CACHE STRING "dl libraries" FORCE ) |
---|
| 103 | endif() |
---|
| 104 | message( STATUS "DL_LIBRARIES = " ${DL_LIBRARIES} ) |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | # |
---|
| 108 | # BLAS |
---|
| 109 | # |
---|
| 110 | find_library( BLAS_LIBRARIES libblas.${SO} ) |
---|
| 111 | if ( BLAS_LIBRARIES MATCHES "NOTFOUND$" ) |
---|
| 112 | message( FATAL_ERROR "blas could not be found. Please check!" ) |
---|
| 113 | endif() |
---|
| 114 | message( STATUS "BLAS_LIBRARIES = " ${BLAS_LIBRARIES} ) |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | # |
---|
| 118 | # LAPACK |
---|
| 119 | # |
---|
| 120 | find_library( LAPACK_LIBRARIES liblapack.${SO} ) |
---|
| 121 | if ( LAPACK_LIBRARIES MATCHES "NOTFOUND$" ) |
---|
| 122 | message( FATAL_ERROR "lapack could not be found. Please check!" ) |
---|
| 123 | endif() |
---|
| 124 | message( STATUS "LAPACK_LIBRARIES = " ${LAPACK_LIBRARIES} ) |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | # |
---|
| 128 | # casacore |
---|
| 129 | # |
---|
| 130 | # always use libcasacore.so |
---|
| 131 | set( USE_LIBCASACORE ON ) |
---|
| 132 | unset( CASACORE_INCLUDE_DIR CACHE ) |
---|
| 133 | unset( CASACORE_LIBRARIES CACHE ) |
---|
| 134 | if( USE_LIBCASACORE ) |
---|
| 135 | # use libcasacore |
---|
| 136 | set( _libname libcasacore.${SO} ) |
---|
| 137 | find_library( CASACORE_LIBRARIES ${_libname} ) |
---|
| 138 | if( CASACORE_LIBRARIES MATCHES "NOTFOUND$" ) |
---|
| 139 | message( FATAL_ERROR "${_libname} could not be found. Please check!" ) |
---|
| 140 | endif() |
---|
| 141 | set( _includename casa/aipsdef.h ) |
---|
| 142 | find_path( CASACORE_INCLUDE_DIR ${_includename} |
---|
| 143 | PATH_SUFFIXES casacore ) |
---|
| 144 | if( CASACORE_INCLUDE_DIR MATCHES "NOTFOUND$" ) |
---|
| 145 | message( FATAL_ERROR "${_includename} could not be found. Please check!" ) |
---|
| 146 | endif() |
---|
| 147 | else() |
---|
| 148 | # use casacore libraries |
---|
| 149 | set( _includename casa/aipsdef.h ) |
---|
| 150 | find_path( CASACORE_INCLUDE_DIR ${_includename} |
---|
| 151 | PATH_SUFFIXES casacore ) |
---|
| 152 | if( CASACORE_INCLUDE_DIR MATCHES "NOTFOUND$" ) |
---|
| 153 | message( FATAL_ERROR "${_includename} could not be found. Please check!" ) |
---|
| 154 | endif() |
---|
| 155 | set( CASACORE_LIBS casa |
---|
| 156 | components |
---|
| 157 | coordinates |
---|
| 158 | fits |
---|
| 159 | images |
---|
| 160 | lattices |
---|
| 161 | measures |
---|
| 162 | mirlib |
---|
| 163 | ms |
---|
| 164 | msfits |
---|
| 165 | scimath |
---|
| 166 | scimath_f |
---|
| 167 | tables ) |
---|
| 168 | set( _casacore_libs "" ) |
---|
| 169 | foreach( _a ${CASACORE_LIBS} ) |
---|
| 170 | set( _libname libcasa_${_a}.${SO} ) |
---|
| 171 | unset( _casacore_lib CACHE ) |
---|
| 172 | find_library( _casacore_lib ${_libname} |
---|
| 173 | PATHS ${CMAKE_INSTALL_PREFIX} PATH_SUFFIXES lib ) |
---|
| 174 | if( _casacore_lib MATCHES "NOTFOUND$" ) |
---|
| 175 | message( FATAL_ERROR "${_libname} could not be found. Please check!" ) |
---|
| 176 | else() |
---|
| 177 | #list( APPEND _casacore_libs casa_${_a} ) |
---|
| 178 | list( APPEND _casacore_libs ${_casacore_lib} ) |
---|
| 179 | endif() |
---|
| 180 | endforeach() |
---|
| 181 | set( CASACORE_LIBRARIES ${_casacore_libs} ) |
---|
| 182 | endif() |
---|
| 183 | message( STATUS "CASACORE_LIBRARIES = " ${CASACORE_LIBRARIES} ) |
---|
| 184 | message( STATUS "CASACORE_INCLUDE_DIR = " ${CASACORE_INCLUDE_DIR} ) |
---|
| 185 | unset( USE_LIBCASACORE CACHE ) |
---|
| 186 | |
---|
| 187 | # |
---|
| 188 | # Python |
---|
| 189 | # |
---|
| 190 | include( FindPythonLibs ) |
---|
| 191 | if( NOT PYTHONLIBS_FOUND ) |
---|
| 192 | message( FATAL_ERROR "Python could not be found. Please check!" ) |
---|
| 193 | endif() |
---|
| 194 | |
---|
| 195 | # find numpy |
---|
| 196 | string( REGEX MATCH [0-9].[0-9] PYTHONV ${PYTHON_INCLUDE_DIRS} ) |
---|
| 197 | set( PYTHON_PREFIX ${PYTHON_INCLUDE_DIRS}/../.. ) |
---|
| 198 | find_path( NUMPY_INCLUDE_DIR numpy/npy_interrupt.h |
---|
| 199 | HINTS |
---|
| 200 | ${PYTHON_PREFIX}/lib/python${PYTHONV}/site-packages/numpy/core |
---|
| 201 | ${PYTHON_PREFIX}/Library/Frameworks/Python.framework/Versions/${PYTHONV} |
---|
| 202 | ${PYTHON_PREFIX}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core |
---|
| 203 | PATH_SUFFIXES include ) |
---|
| 204 | if( NUMPY_INCLUDE_DIR MATCHES "NOTFOUND$" ) |
---|
| 205 | message( FATAL_ERROR "numpy/npy_interrupt.h could not be found. Please check!" ) |
---|
| 206 | endif() |
---|
| 207 | list( APPEND PYTHON_INCLUDE_DIRS ${NUMPY_INCLUDE_DIR} ) |
---|
| 208 | |
---|
| 209 | message( STATUS "PYTHON_INCLUDE_DIRS = " ${PYTHON_INCLUDE_DIRS} ) |
---|
| 210 | message( STATUS "PYTHON_LINRARIES = " ${PYTHON_LIBRARIES} ) |
---|
| 211 | message( STATUS "PYTHONV = " ${PYTHONV} ) |
---|
| 212 | |
---|
| 213 | set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS} |
---|
| 214 | -DPYTHONROOT=\"${pyroot}\" |
---|
| 215 | -DPYTHONVER=\"${PYTHONV}\" |
---|
| 216 | -DPYVERSION=${PYTHONV} ) |
---|
| 217 | |
---|
| 218 | |
---|
| 219 | # |
---|
| 220 | # Boost |
---|
| 221 | # |
---|
| 222 | set( boost_components python ) |
---|
| 223 | find_package( Boost REQUIRED ${boost_components} ) |
---|
| 224 | if( NOT Boost_FOUND ) |
---|
| 225 | message( FATAL_ERROR "Boost could not be found. Please check!" ) |
---|
| 226 | endif() |
---|
| 227 | message( STATUS "BOOST_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} ) |
---|
| 228 | message( STATUS "BOOST_LIBRARIES = " ${Boost_LIBRARIES} ) |
---|
| 229 | |
---|
| 230 | |
---|
| 231 | # |
---|
| 232 | # cfitsio |
---|
| 233 | # |
---|
| 234 | find_path( CFITSIO_INCLUDE_DIRS fitsio.h |
---|
| 235 | PATH_SUFFIXES cfitsio ) |
---|
| 236 | if( CFITSIO_INCLUDE_DIRS MATCHES "NOTFOUND$" ) |
---|
| 237 | message( FATAL_ERROR "fitsio.h could not be found. Please check!" ) |
---|
| 238 | endif() |
---|
| 239 | find_library( CFITSIO_LIBRARIES libcfitsio.${SO} |
---|
| 240 | HINTS /usr/local /usr |
---|
| 241 | PATH_SUFFIXES lib64 lib ) |
---|
| 242 | if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" ) |
---|
| 243 | message( FATAL_ERROR "libcfitsio.so could not be found. Please check!" ) |
---|
| 244 | endif() |
---|
| 245 | message( STATUS "CFITSIO_INCLUDE_DIRS = " ${CFITSIO_INCLUDE_DIRS} ) |
---|
| 246 | message( STATUS "CFITSIO_LIBRARIES = " ${CFITSIO_LIBRARIES} ) |
---|
| 247 | |
---|
| 248 | |
---|
| 249 | # |
---|
| 250 | # wcslib |
---|
| 251 | # |
---|
| 252 | set( _wcslib libwcs.${SO} ) |
---|
| 253 | set( _wcs_version 4.3 ) |
---|
| 254 | find_library( WCSLIB ${_wcslib} |
---|
| 255 | HINTS /usr/lib64 /usr/lib ) |
---|
| 256 | if( WCSLIB MATCHES "NOTFOUND$" ) |
---|
| 257 | message( STATUS "${_wcslib} could not be found." ) |
---|
| 258 | unset( _wcslib CACHE ) |
---|
| 259 | unset( WCSLIB CACHE ) |
---|
| 260 | set( _wcslib libwcs.${_wcs_version}.${SO} ) |
---|
| 261 | message( STATUS "Try to find ${_wcslib}..." ) |
---|
| 262 | find_library( WCSLIB ${_wcslib} |
---|
| 263 | HINTS /usr/local /usr |
---|
| 264 | PATH_SUFFIXES lib64 lib ) |
---|
| 265 | if( WCSLIB MATCHES "NOTFOUND$" ) |
---|
| 266 | message( FATAL_ERROR "${_wcslib} could not be found. Please check!" ) |
---|
| 267 | endif() |
---|
| 268 | endif() |
---|
| 269 | message( STATUS "WCSLIB = " ${WCSLIB} ) |
---|
| 270 | find_path( WCSLIB_INCLUDE_DIR wcslib/wcs.h |
---|
| 271 | HINTS /usr/local /usr |
---|
| 272 | PATH_SUFFIXES include ) |
---|
| 273 | if( WCSLIB_INCLUDE_DIR MATCHES "NOTFOUND$" ) |
---|
| 274 | message( FATAL_ERROR "wcs.h could not be found. Please check!" ) |
---|
| 275 | endif() |
---|
| 276 | message( STATUS "WCSLIB_INCLUDE_DIR = " ${WCSLIB_INCLUDE_DIR} ) |
---|
| 277 | |
---|
| 278 | |
---|
| 279 | # |
---|
| 280 | # RPFITS (Fortran) |
---|
| 281 | # |
---|
| 282 | if( NOT FORTRAN_LIBRARIES ) |
---|
| 283 | |
---|
| 284 | message( STATUS "Looking for Fortran runtime libraries" ) |
---|
| 285 | set( _try ${CMAKE_BINARY_DIR}/try_fortran.cc ) |
---|
| 286 | file( WRITE ${_try} |
---|
| 287 | "int main() { return 0; }\n" |
---|
| 288 | ) |
---|
| 289 | |
---|
| 290 | if( _gfortran_lib_path ) |
---|
| 291 | try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try} |
---|
| 292 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=${_gfortran_lib_path}" |
---|
| 293 | ) |
---|
| 294 | else() |
---|
| 295 | try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try} |
---|
| 296 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lgfortran" |
---|
| 297 | ) |
---|
| 298 | endif() |
---|
| 299 | try_compile( _have_g2c ${CMAKE_BINARY_DIR} ${_try} |
---|
| 300 | CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lg2c" |
---|
| 301 | ) |
---|
| 302 | |
---|
| 303 | if( _have_gfortran ) |
---|
| 304 | if( _gfortran_lib_path ) |
---|
| 305 | set( FORTRAN_LIBRARIES ${_gfortran_lib_path} |
---|
| 306 | CACHE STRING "Fortran library linker option" FORCE ) |
---|
| 307 | else() |
---|
| 308 | set( FORTRAN_LIBRARIES -lgfortran |
---|
| 309 | CACHE STRING "Fortran library linker option" FORCE ) |
---|
| 310 | endif() |
---|
| 311 | message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" ) |
---|
| 312 | elseif( _have_g2c ) |
---|
| 313 | set( FORTRAN_LIBRARIES -lg2c |
---|
| 314 | CACHE STRING "Fortran library linker option" FORCE ) |
---|
| 315 | message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" ) |
---|
| 316 | else() |
---|
| 317 | set( FORTRAN_LIBRARIES "" |
---|
| 318 | CACHE STRING "Fortran library linker option" FORCE ) |
---|
| 319 | message( STATUS "Looking for Fortran runtime libraries -- <none>" ) |
---|
| 320 | # Not a fatal error because it might work, if all Fortran dependencies were |
---|
| 321 | # already linked statically to the Fortran runtime... |
---|
| 322 | endif() |
---|
| 323 | endif() |
---|
| 324 | |
---|
| 325 | find_path( RPFITS_INCLUDE_DIRS RPFITS.h |
---|
| 326 | HINTS /usr/local /usr |
---|
| 327 | PATH_SUFFIXES include ) |
---|
| 328 | if( RPFITS_INCLUDE_DIRS MATCHES "NOTFOUND$" ) |
---|
| 329 | message( FATAL_ERROR "RPFITS.h could not be found. Please check!" ) |
---|
| 330 | endif() |
---|
| 331 | find_library( RPFITS_LIBRARIES librpfits.so |
---|
| 332 | HINTS /usr/local /usr |
---|
| 333 | PATH_SUFFIXES lib64 lib ) |
---|
| 334 | if( RPFITS_LIBRARIES MATCHES "NOTFOUND$" ) |
---|
| 335 | message( FATAL_ERROR "librpfits.so could not be found. Please check!" ) |
---|
| 336 | endif() |
---|
| 337 | |
---|
| 338 | list( APPEND RPFITS_LIBRARIES ${FORTRAN_LIBRARIES} ) |
---|
| 339 | message( STATUS "RPFITS_INCLUDE_DIRS = " ${RPFITS_INCLUDE_DIRS} ) |
---|
| 340 | message( STATUS "RPFITS_LIBRARIES = " ${RPFITS_LIBRARIES} ) |
---|
| 341 | |
---|
| 342 | # |
---|
| 343 | # subdirectories |
---|
| 344 | # ASAP2TO3 asap2to3 apps |
---|
| 345 | # PYRAPLIB libpyrap.so external/libpyrap |
---|
| 346 | # ATNFLIB libatnf.so external/atnf |
---|
| 347 | # ASAPLIB _asap.so src |
---|
| 348 | # python modules python |
---|
| 349 | # shared files share |
---|
| 350 | # executables bin |
---|
| 351 | # |
---|
| 352 | macro( asap_add_subdirectory ) |
---|
| 353 | add_subdirectory( apps ) |
---|
| 354 | add_subdirectory( external/libpyrap ) |
---|
| 355 | add_subdirectory( external/atnf ) |
---|
| 356 | add_subdirectory( src ) |
---|
| 357 | add_subdirectory( python ) |
---|
| 358 | add_subdirectory( share ) |
---|
| 359 | add_subdirectory( bin ) |
---|
| 360 | endmacro( asap_add_subdirectory ) |
---|