Ignore:
Timestamp:
12/16/10 16:27:11 (13 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-2668

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Refactoring.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cmake/withcasa.cmake

    r1968 r1970  
    33###
    44
    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 )
    225
    236# install directory
     
    3619include( CASA )
    3720
    38 # flags
    39 set( DEFAULT_CXX_FLAGS
    40      "-pipe -Wall -Wextra -Wno-non-template-friend -Wcast-align -Wno-comment -O3" )
    41 find_package( OpenMP )
    42 if( OPENMP_FOUND )
    43    set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
    44 endif()
    45 
    46 set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS}
    47   -DCASA_USECASAPATH
    48   -DCASACORE_NEEDS_RETHROW
    49   -DAIPS_STDLIB
    50   -DAIPS_AUTO_STL
    51   -D_GNU_SOURCE )
    52 
    53 if( CMAKE_SYSTEM_NAME STREQUAL Linux )
    54   set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS}
    55     -D_FILE_OFFSET_BITS=64
    56     -D_LARGEFILE_SOURCE
    57     )
    58 endif()
    59 
    60 add_definitions( ${CASACORE_DEFINITIONS} )
    61 
    6221# environment dependent settings
    63 message( STATUS "CMAKE_SYSTEM = " ${CMAKE_SYSTEM} )
    6422if( APPLE )
    65    set( SO dylib )
    6623   if( NOT arch )
    6724      set( arch darwin )
     
    7835      endif()
    7936      if( archflag STREQUAL x86_64 )
    80          add_definitions( -DAIPS_64B )
    8137         set( casa_packages /opt/casa/darwin10-64b )
    8238      else()
    8339         set( casa_packages /opt/casa/core2-apple-darwin10 )
    84       endif()
    85       execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version
    86                        COMMAND head -1
    87                        COMMAND perl -pe "s|.*?(\\d+\\.\\d+)\\.\\d+$|$1|"
    88                        OUTPUT_VARIABLE _cxx_version
    89                        OUTPUT_STRIP_TRAILING_WHITESPACE )
    90       if( NOT _cxx_version STREQUAL "4.4" )
    91          set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -arch ${archflag}" )
    9240      endif()
    9341   elseif( CMAKE_SYSTEM MATCHES ^Darwin-9 )
     
    9543   endif()         
    9644elseif( CMAKE_SYSTEM_NAME STREQUAL Linux )
    97    set( SO so )
    98    add_definitions( -DAIPS_LINUX )
    9945   if( CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 )
    10046      set( casa_packages /usr/lib64/casapy )
     
    10248         set( arch linux_64b )
    10349      endif()
    104       add_definitions( -DAIPS_64B )
    105       set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated" )
    10650   else()
    10751      set( casa_packages /usr/lib/casapy )
     
    10953         set( arch linux_gnu )
    11054      endif()
    111       set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated -Woverloaded-virtual" )
    11255   endif()
    11356endif()
     
    11659# set root directory for installation
    11760set( CMAKE_INSTALL_PREFIX ${casaroot}/${arch} )
    118 message( STATUS "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX} )
    119 
    120 # set flags for cpp compiler
    121 set( CMAKE_CXX_FLAGS ${DEFAULT_CXX_FLAGS} )
    122 
    123 
    124 #
    125 # DL
    126 #
    127 set( DL_LIBRARIES ${CMAKE_DL_LIBS} CACHE STRING "dl libraries" FORCE )
    128 if( DL_LIBRARIES STREQUAL "dl" )
    129   set( DL_LIBRARIES "-ldl" CACHE STRING "dl libraries" FORCE )
    130 endif()
    131 message( STATUS "DL_LIBRARIES = " ${DL_LIBRARIES} )
    132 
    133 
    134 #
    135 # BLAS
    136 #
    137 find_library( BLAS_LIBRARIES libblas.${SO} )
    138 if ( BLAS_LIBRARIES MATCHES "NOTFOUND$" )
    139    message( FATAL_ERROR "blas could not be found. Please check!" )
    140 endif()
    141 message( STATUS "BLAS_LIBRARIES = " ${BLAS_LIBRARIES} )
    142 
    143 
    144 #
    145 # LAPACK
    146 #
    147 find_library( LAPACK_LIBRARIES liblapack.${SO} )
    148 if ( LAPACK_LIBRARIES MATCHES "NOTFOUND$" )
    149    message( FATAL_ERROR "lapack could not be found. Please check!" )
    150 endif()
    151 message( STATUS "LAPACK_LIBRARIES = " ${LAPACK_LIBRARIES} )
    15261
    15362
     
    15564# casacore
    15665#
    157 unset( CASACORE_INCLUDE_DIR CACHE )
    158 unset( CASACORE_LIBRARIES CACHE )
    159 if( NOT USE_LIBCASACORE )
    160    # use casacore libraries
    161    set( _includename casa/aipsdef.h )
    162    find_path( CASACORE_INCLUDE_DIR ${_includename}
    163               HINTS ${casaroot}/${arch}/include/
    164               PATH_SUFFIXES casacore )
    165    if( CASACORE_INCLUDE_DIR MATCHES "NOTFOUND$" )
    166      message( FATAL_ERROR "${_includename} could not be found. Please check!" )
    167    endif()
    168    set( CASACORE_LIBS casa
    169                       components
    170                       coordinates
    171                       fits
    172                       images
    173                       lattices
    174                       measures
    175                       mirlib
    176                       ms
    177                       msfits
    178                       scimath
    179                       scimath_f
    180                       tables )
    181    set( _casacore_libs "" )
    182    foreach( _a ${CASACORE_LIBS} )
    183       set( _libname libcasa_${_a}.${SO} )
    184       unset( _casacore_lib CACHE )
    185       find_library( _casacore_lib ${_libname}
    186                     PATHS ${CMAKE_INSTALL_PREFIX} PATH_SUFFIXES lib )
    187       if( _casacore_lib MATCHES "NOTFOUND$" )
    188          message( FATAL_ERROR "${_libname} could not be found. Please check!" )
    189       else()
    190          #list( APPEND _casacore_libs casa_${_a} )
    191          list( APPEND _casacore_libs ${_casacore_lib} )
    192       endif()
    193    endforeach()
    194    set( CASACORE_LIBRARIES ${_casacore_libs} )
    195 else()
    196    # use libcasacore
    197    set( _libname libcasacore.${SO} )
    198    find_library( CASACORE_LIBRARIES ${_libname} )
    199    if( CASACORE_LIBRARIES MATCHES "NOTFOUND$" )
    200       message( FATAL_ERROR "${_libname} could not be found. Please check!" )
    201    endif()
    202    set( _includename casa/aipsdef.h )
    203    find_path( CASACORE_INCLUDE_DIR ${_includename}
    204               PATH_SUFFIXES casacore )
    205    if( CASACORE_INCLUDE_DIR MATCHES "NOTFOUND$" )
    206      message( FATAL_ERROR "${_includename} could not be found. Please check!" )
    207    endif()
    208 endif()
    209 message( STATUS "CASACORE_LIBRARIES = " ${CASACORE_LIBRARIES} )
    210 message( STATUS "CASACORE_INCLUDE_DIR = " ${CASACORE_INCLUDE_DIR} )
    211 unset( USE_LIBCASACORE CACHE )
    212 
    213 #
    214 # Python
    215 #
    216 if( NOT PYTHON_FOUND )
    217 
    218   if ( NOT PYTHON_LIBNAME )
    219     set( _names 2.9 2.8 2.7 2.6 2.5.2 2.5 )
    220     # (The library named libpython.2.5.2.dylib seems to exist only in the CASA world.)
    221   else()
    222     set( _names ${PYTHON_LIBNAME} )
    223   endif()
    224 
    225   set( _found False )
    226   foreach( _v ${_names} )
    227 
    228     casa_find(
    229       PYTHON${_v}
    230       LIBS python${_v}
    231       NO_REQUIRE
    232       )
    233 
    234     if( PYTHON${_v}_FOUND )
    235       set( PYTHON_LIBNAME ${_v} )
    236       set( _found True )
    237       break()
    238     endif()
    239 
    240   endforeach()
    241  
    242   if( NOT _found )
    243     message( FATAL_ERROR "Could not find any PYTHON library with version one of ${_names}. Please check!" )
    244   endif()
    245 
    246 endif()
    247 
    248 if( NOT PYTHON_LIBNAME )
    249   # Found Python, but PYTHON_LIBNAME is undefined, that is impossible.
    250   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*\")")
    251 endif()
    252 
    253 string( SUBSTRING ${PYTHON_LIBNAME} 0 3 PYTHONV )
    254 string( REPLACE "." "" PV ${PYTHONV} )
    255 set( python_library python${PYTHON_LIBNAME} )
    256 
    257 # Form the Python install prefix by stripping away "lib/libpython2.5.2.dylib" (example) from
    258 # the full python library path
    259 string( REGEX MATCH "/lib(64)?/lib${python_library}" _match ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
    260 if( _match )
    261   string( REGEX REPLACE "/lib(64)?/lib${python_library}.*" "" python_prefix ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
    262 else()
    263   # Python library was not in a lib(64) directory!
    264   message( WARNING "Python library path \"${PYTHON${PYTHON_LIBNAME}_LIBRARIES}\" does not contain \"/lib(64)/lib${python_library}\"" )
    265   set( python_prefix ${casa_packages} )
    266 endif()
    267 
    268 # The python version and prefix is known, do the actual search
    269 if( NOT PYTHON_FOUND )
    270   message( STATUS "Looking for PYTHON version ${PYTHONV}.x in ${python_prefix}" )
    271 endif()
    272 
    273 casa_find( PYTHON
    274   VERSION 2.5    # minimum required
    275   INCLUDES Python.h
    276      numpy/npy_interrupt.h   # for numpy
    277   INCLUDES_SUFFIXES python${PYTHONV}
    278   PREFIX_HINTS
    279      ${python_prefix}/lib/python${PYTHONV}/site-packages/numpy/core
    280      ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}
    281      ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core
    282   LIBS ${python_library}
    283   CPP_VERSION PY_VERSION )
    284 
    285 # Store PYTHON_LIBNAME in the cache
    286 set( PYTHON_LIBNAME ${PYTHON_LIBNAME} CACHE STRING "Python major and minor version to use" FORCE )
    287 
    288 # Define pyroot to two directory levels above Python.h.
    289 string( REGEX REPLACE "/[^/]+/[^/]+/?$" "" pyroot ${PYTHON_Python.h} )
    290 
    291 message( STATUS "PYTHON_INCLUDE_DIRS = " ${PYTHON_INCLUDE_DIRS} )
    292 message( STATUS "PYTHON_LINRARIES = " ${PYTHON_LIBRARIES} )
    293 message( STATUS "PYTHONV = " ${PYTHONV} )
    294 
    295 set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS}
    296   -DAIPSROOT=\"${CMAKE_SOURCE_DIR}\"
    297   -DAIPSARCH=\"${arch}\"
    298   -DAIPSSITE=\"garching\"
    299   -DPYTHONROOT=\"${pyroot}\"
    300   -DPYTHONVER=\"${PYTHONV}\"
    301   -DPYVERSION=${PV} )
     66set( CASACORE_PATHS "${casaroot}/${arch};/usr/local;/usr" )
    30267
    30368
     
    30974endif()
    31075
    311 set( boost_components python )
    312 find_package( Boost REQUIRED ${boost_components} )
    313 if( NOT Boost_FOUND )
    314   message( FATAL_ERROR "Boost could not be found. Please check!" )
    315 endif()
    316 message( STATUS "BOOST_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
    317 message( STATUS "BOOST_LIBRARIES = " ${Boost_LIBRARIES} )
    318 
    319 
    320 #
    321 # cfitsio
    322 #
    323 casa_find( CFITSIO
    324            VERSION 3.006
    325            INCLUDES fitsio.h fitsio2.h
    326            INCLUDES_SUFFIXES cfitsio
    327            LIBS cfitsio
    328            CPP_VERSION CFITSIO_VERSION
    329            RUN_VERSION "(ffvers(&v), v)" )
    330 #if( NOT CFITSIO_FOUND )
    331 #   message( FATAL_ERROR "CFITSIO could not be found. Please check!" )
    332 #endif()
    333 message( STATUS "CFITSIO_INCLUDE_DIRS = " ${CFITSIO_INCLUDE_DIRS} )
    334 message( STATUS "CFITSIO_LIBRARIES = " ${CFITSIO_LIBRARIES} )
    335 
    33676
    33777#
    33878# wcslib
    33979#
    340 set( _wcslib libwcs.${SO} )
    341 set( _wcs_version 4.3 )
    342 find_library( WCSLIB ${_wcslib}
    343               HINTS /usr/lib64 /usr/lib ${casaroot}/${arch}/lib )
    344 if( WCSLIB MATCHES "NOTFOUND$" )
    345    message( STATUS "${_wcslib} could not be found." )
    346    unset( _wcslib CACHE )
    347    unset( WCSLIB CACHE )
    348    set( _wcslib libwcs.${_wcs_version}.${SO} )
    349    message( STATUS "Try to find ${_wcslib}..." )
    350    find_library( WCSLIB ${_wcslib}
    351                  HINTS /usr/lib64 /usr/lib ${casaroot}/${arch}/lib )
    352    if( WCSLIB MATCHES "NOTFOUND$" )
    353       message( FATAL_ERROR "${_wcslib} could not be found. Please check!" )
    354    endif()
    355 endif()
    356 message( STATUS "WCSLIB = " ${WCSLIB} )
    357 find_path( WCSLIB_INCLUDE_DIR wcslib/wcs.h
    358            HINTS /usr/include ${casaroot}/${arch}/include )
    359 if( WCSLIB_INCLUDE_DIR MATCHES "NOTFOUND$" )
    360    message( FATAL_ERROR "wcs.h could not be found. Please check!" )
    361 endif()
    362 message( STATUS "WCSLIB_INCLUDE_DIR = " ${WCSLIB_INCLUDE_DIR} )
     80set( WCSLIB_PATHS "${casaroot}/${arch};/usr/local;/usr" )
    36381
    364 
    365 #
    366 # RPFITS (Fortran)
    367 #
    368 if( NOT FORTRAN_LIBRARIES )
    369 
    370   message( STATUS "Looking for Fortran runtime libraries" )
    371   set( _try  ${CMAKE_BINARY_DIR}/try_fortran.cc )
    372   file( WRITE ${_try}
    373     "int main() { return 0; }\n"
    374     )
    375  
    376   if( _gfortran_lib_path )
    377     try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
    378       CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=${_gfortran_lib_path}"
    379       )
    380   else()
    381     try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
    382       CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lgfortran"
    383       )
    384   endif()
    385   try_compile( _have_g2c ${CMAKE_BINARY_DIR} ${_try}
    386     CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lg2c"
    387     )
    388  
    389   if( _have_gfortran )
    390     if( _gfortran_lib_path )
    391       set( FORTRAN_LIBRARIES ${_gfortran_lib_path}
    392         CACHE STRING "Fortran library linker option" FORCE )
    393     else()
    394       set( FORTRAN_LIBRARIES -lgfortran
    395         CACHE STRING "Fortran library linker option" FORCE )
    396     endif()
    397     message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
    398   elseif( _have_g2c )
    399     set( FORTRAN_LIBRARIES -lg2c
    400       CACHE STRING "Fortran library linker option" FORCE )
    401     message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
    402   else()
    403     set( FORTRAN_LIBRARIES ""
    404       CACHE STRING "Fortran library linker option" FORCE )
    405     message( STATUS "Looking for Fortran runtime libraries -- <none>" )
    406     # Not a fatal error because it might work, if all Fortran dependencies were
    407     # already linked statically to the Fortran runtime...
    408   endif()
    409 endif()
    410 
    411 casa_find( RPFITS
    412   VERSION 2.11
    413   INCLUDES RPFITS.h
    414   LIBS rpfits
    415   RUN_VERSION names_.rpfitsversion
    416   DEPENDS FORTRAN
    417 )
    418 #if( NOT RPFITS_FOUND )
    419 #   message( FATAL_ERROR "rpfits could not be found. Please check!" )
    420 #endif()
    421 message( STATUS "RPFITS_INCLUDE_DIRS = " ${RPFITS_INCLUDE_DIRS} )
    422 message( STATUS "RPFITS_LIBRARIES = " ${RPFITS_LIBRARIES} )
    42382
    42483#
Note: See TracChangeset for help on using the changeset viewer.