Changeset 1957


Ignore:
Timestamp:
12/06/10 16:38:24 (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...

Adds wcslib, rpfits, cfitsio libraries.
Includes CASA's cmake modules for searching python, cfitsio, and rpfits.
Update dependency.

Test build and sd regression run.
All sd regressions are passed.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CMakeLists.txt

    r1956 r1957  
    1919message( STATUS "casaroot = " ${casaroot} )
    2020
     21# modules
     22set( CMAKE_MODULE_PATH ${casaroot}/code/install )
     23include( config )
     24include( CASA )
     25
    2126# flags
    2227set( DEFAULT_CXX_FLAGS
    23      "-pipe -Wall -Wextra -Wno-non-template-friend -Wcast-align -Wno-comment" )
     28     "-pipe -Wall -Wextra -Wno-non-template-friend -Wcast-align -Wno-comment -O3" )
    2429find_package( OpenMP )
    2530if( OPENMP_FOUND )
     
    8691# set flags for cpp compiler
    8792set( CMAKE_CXX_FLAGS ${DEFAULT_CXX_FLAGS} )
     93
    8894
    8995#
     
    144150message( STATUS "CASACORE_INCLUDE_DIR = " ${CASACORE_INCLUDE_DIR} )
    145151
     152
    146153#
    147154# Python
    148155#
    149 # tentative
    150 set( PYVERSION 2.6 )
    151 if (NOT PYTHON_ROOT )
    152    set( PYTHON_ROOT ${casa_packages} )
    153 endif()
    154 find_package( PythonLibs REQUIRED python${PYVERSION} )
    155 
    156 if( NOT PYTHONLIBS_FOUND )
    157    message( FATAL_ERROR "Python could not be found. Please check!" )
    158 endif()
    159 message( STATUS "PYTHON_INCLUDE_PATH = " ${PYTHON_INCLUDE_PATH} )
    160 message( STATUS "PYTHON_LIBRARIES = " ${PYTHON_LIBRARIES} )
    161 
    162 set( PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_PATH} )
    163 find_path( NUMPY_INC_DIR numpy/npy_interrupt.h
    164            PATHS ${casa_packages}/lib/python${PYVERSION}/site-packages/numpy/core/include )
    165 message( STATUS "NUMPY_INC_DIR = " ${NUMPY_INC_DIR} )
    166 if( NOT NUMPY_INC_DIR STREQUAL NUMPY_INC_DIR-NOTFOUND )
    167    list( APPEND PYTHON_INCLUDE_DIR ${NUMPY_INC_DIR} )
    168 endif()
     156if( NOT PYTHON_FOUND )
     157
     158  if ( NOT PYTHON_LIBNAME )
     159    set( _names 2.9 2.8 2.7 2.6 2.5.2 2.5 )
     160    # (The library named libpython.2.5.2.dylib seems to exist only in the CASA world.)
     161  else()
     162    set( _names ${PYTHON_LIBNAME} )
     163  endif()
     164
     165  set( _found False )
     166  foreach( _v ${_names} )
     167
     168    casa_find(
     169      PYTHON${_v}
     170      LIBS python${_v}
     171      NO_REQUIRE
     172      )
     173
     174    if( PYTHON${_v}_FOUND )
     175      set( PYTHON_LIBNAME ${_v} )
     176      set( _found True )
     177      break()
     178    endif()
     179
     180  endforeach()
     181 
     182  if( NOT _found )
     183    message( FATAL_ERROR "Could not find any PYTHON library with version one of ${_names}. Please check!" )
     184  endif()
     185
     186endif()
     187
     188if( NOT PYTHON_LIBNAME )
     189  # Found Python, but PYTHON_LIBNAME is undefined, that is impossible.
     190  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*\")")
     191endif()
     192
     193string( SUBSTRING ${PYTHON_LIBNAME} 0 3 PYTHONV )
     194string( REPLACE "." "" PV ${PYTHONV} )
     195set( python_library python${PYTHON_LIBNAME} )
     196
     197# Form the Python install prefix by stripping away "lib/libpython2.5.2.dylib" (example) from
     198# the full python library path
     199string( REGEX MATCH "/lib(64)?/lib${python_library}" _match ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
     200if( _match )
     201  string( REGEX REPLACE "/lib(64)?/lib${python_library}.*" "" python_prefix ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
     202else()
     203  # Python library was not in a lib(64) directory!
     204  message( WARNING "Python library path \"${PYTHON${PYTHON_LIBNAME}_LIBRARIES}\" does not contain \"/lib(64)/lib${python_library}\"" )
     205  set( python_prefix ${casa_packages} )
     206endif()
     207
     208# The python version and prefix is known, do the actual search
     209if( NOT PYTHON_FOUND )
     210  message( STATUS "Looking for PYTHON version ${PYTHONV}.x in ${python_prefix}" )
     211endif()
     212
     213casa_find( PYTHON
     214  VERSION 2.5    # minimum required
     215  INCLUDES Python.h
     216     numpy/npy_interrupt.h   # for numpy
     217  INCLUDES_SUFFIXES python${PYTHONV}
     218  PREFIX_HINTS
     219     ${python_prefix}/lib/python${PYTHONV}/site-packages/numpy/core
     220     ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}
     221     ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core
     222  LIBS ${python_library}
     223  CPP_VERSION PY_VERSION )
     224
     225# Store PYTHON_LIBNAME in the cache
     226set( PYTHON_LIBNAME ${PYTHON_LIBNAME} CACHE STRING "Python major and minor version to use" FORCE )
     227
     228# Define pyroot to two directory levels above Python.h.
     229string( REGEX REPLACE "/[^/]+/[^/]+/?$" "" pyroot ${PYTHON_Python.h} )
     230
    169231message( STATUS "PYTHON_INCLUDE_DIR = " ${PYTHON_INCLUDE_DIR} )
     232message( STATUS "PYTHON_LINRARIES = " ${PYTHON_LIBRARIES} )
     233message( STATUS "PYTHONV = " ${PYTHONV} )
     234
     235set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS}
     236  -DAIPSROOT=\"${CMAKE_SOURCE_DIR}\"
     237  -DAIPSARCH=\"${arch}\"
     238  -DAIPSSITE=\"garching\"
     239  -DPYTHONROOT=\"${pyroot}\"
     240  -DPYTHONVER=\"${PYTHONV}\"
     241  -DPYVERSION=${PV} )
     242
    170243
    171244#
     
    176249endif()
    177250
    178 set( boost_components regex program_options filesystem )
     251set( boost_components python )
    179252find_package( Boost REQUIRED ${boost_components} )
    180 
    181253if( NOT Boost_FOUND )
    182254  message( FATAL_ERROR "Boost could not be found. Please check!" )
    183255endif()
    184 
    185 # For boost >= 1.35, we need to link also to boost-system
    186 if( Boost_VERSION GREATER 103499 )
    187 
    188   # Force redetection by resetting these variables
    189   if( NOT Boost_SYSTEM_FOUND )
    190     message( STATUS "Boost version (${Boost_VERSION}) is 1.35.0 or newer" )
    191     unset( Boost_FOUND )
    192     unset( Boost_INCLUDE_DIR CACHE )
     256message( STATUS "BOOST_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
     257message( STATUS "BOOST_LIBRARIES = " ${Boost_LIBRARIES} )
     258
     259
     260#
     261# cfitsio
     262#
     263casa_find( CFITSIO
     264           VERSION 3.006
     265           INCLUDES fitsio.h fitsio2.h
     266           INCLUDES_SUFFIXES cfitsio
     267           LIBS cfitsio
     268           CPP_VERSION CFITSIO_VERSION
     269           RUN_VERSION "(ffvers(&v), v)" )
     270if( NOT CFITSIO_FOUND )
     271   message( FATAL_ERROR "CFITSIO could not be found. Please check!" )
     272endif()
     273message( STATUS "CFITSIO_INCLUDE_DIRS = " ${CFITSIO_INCLUDE_DIRS} )
     274message( STATUS "CFITSIO_LIBRARIES = " ${CFITSIO_LIBRARIES} )
     275
     276
     277#
     278# wcslib
     279#
     280set( _wcslib libwcs.${SO} )
     281find_library( WCSLIB ${_wcslib}
     282              HINTS /usr/lib64 /usr/lib ${casaroot}/${arch}/lib )
     283if( WCSLIB STREQUAL WCSLIB-NOTFOUND )
     284   message( FATAL_ERROR "${_wcslib} could not be found. Please check!" )
     285endif()
     286message( STATUS "WCSLIB = " ${WCSLIB} )
     287
     288
     289#
     290# RPFITS (Fortran)
     291#
     292if( NOT FORTRAN_LIBRARIES )
     293
     294  message( STATUS "Looking for Fortran runtime libraries" )
     295  set( _try  ${CMAKE_BINARY_DIR}/try_fortran.cc )
     296  file( WRITE ${_try}
     297    "int main() { return 0; }\n"
     298    )
     299 
     300  if( _gfortran_lib_path )
     301    try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
     302      CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=${_gfortran_lib_path}"
     303      )
     304  else()
     305    try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
     306      CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lgfortran"
     307      )
    193308  endif()
    194   set( boost_components regex program_options filesystem system )
    195   find_package( Boost REQUIRED ${boost_components} )
    196 
    197   if( NOT Boost_FOUND )
    198     message( FATAL_ERROR "Boost-system could not be found. Please check!" )
     309  try_compile( _have_g2c ${CMAKE_BINARY_DIR} ${_try}
     310    CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lg2c"
     311    )
     312 
     313  if( _have_gfortran )
     314    if( _gfortran_lib_path )
     315      set( FORTRAN_LIBRARIES ${_gfortran_lib_path}
     316        CACHE STRING "Fortran library linker option" FORCE )
     317    else()
     318      set( FORTRAN_LIBRARIES -lgfortran
     319        CACHE STRING "Fortran library linker option" FORCE )
     320    endif()
     321    message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
     322  elseif( _have_g2c )
     323    set( FORTRAN_LIBRARIES -lg2c
     324      CACHE STRING "Fortran library linker option" FORCE )
     325    message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
     326  else()
     327    set( FORTRAN_LIBRARIES ""
     328      CACHE STRING "Fortran library linker option" FORCE )
     329    message( STATUS "Looking for Fortran runtime libraries -- <none>" )
     330    # Not a fatal error because it might work, if all Fortran dependencies were
     331    # already linked statically to the Fortran runtime...
    199332  endif()
    200 endif()
    201 
    202 if( NOT Boost_VERSION GREATER 103199 AND NOT CASA_IGNORE_VERSION )
    203   message( FATAL_ERROR "Boost version (${Boost_VERSION}) is too old! Must be 103200 (1.32.0) or newer. Please check!" )
    204 endif()
    205 
    206 
    207 
    208 # include path
     333endif()
     334
     335casa_find( RPFITS
     336  VERSION 2.11
     337  INCLUDES RPFITS.h
     338  LIBS rpfits
     339  RUN_VERSION names_.rpfitsversion
     340  DEPENDS FORTRAN
     341)
     342if( NOT RPFITS_FOUND )
     343   message( FATAL_ERROR "${_wcslib} could not be found. Please check!" )
     344endif()
     345message( STATUS "RPFITS_INCLUDE_DIR = " ${RPFITS_INCLUDE_DIR} )
     346message( STATUS "RPFITS_LIBRARIES = " ${RPFITS_LIBRARIES} )
     347
     348
     349#
     350# common include path
     351#
    209352message( STATUS "Boost_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
    210353include_directories( ${CASACORE_INCLUDE_DIR}
     
    212355                     ${PYTHON_INCLUDE_DIR} )
    213356
     357#
    214358# link path
     359#
    215360set( CASACORE_LIBRARY_DIR ${casaroot}/${arch}/lib )
    216361link_directories( ${CASACORE_LIBRARY_DIR} )
    217362
    218363
     364#
    219365# install directory
     366#
    220367set( EXEC_INSTALL_DIR bin )
    221368set( LIB_INSTALL_DIR lib )
    222 set( PYTHON_INSTALL_DIR python/${PYVERSION}/asap )
     369set( PYTHON_INSTALL_DIR python/${PYTHONV}/asap )
    223370set( SHARED_INSTALL_DIR share/asap )
    224371
     372
     373#
     374# libraries and executables
     375#
     376set( ASAPLIB _asap )
     377set( PYRAPLIB pyrap )
     378set( ATNFLIB atnf )
     379set( ASAP2TO3 asap2to3 )
     380
     381
     382#
    225383# subdirectories
    226 #  asap2to3       apps
    227 #  libpyrap.so    external/libpyrap
    228 #  libatnf.so     external-alma/atnf
    229 #  _asap.so       src
    230 #  python modules python
     384#  ASAP2TO3 asap2to3       apps
     385#  PYRAPLIB libpyrap.so    external/libpyrap
     386#  ATNFLIB  libatnf.so     external-alma/atnf
     387#  ASAPLIB  _asap.so       src
     388#  python modules           python
     389#  shared files             share
     390#
    231391add_subdirectory( apps )
    232392add_subdirectory( external/libpyrap )
  • trunk/apps/CMakeLists.txt

    r1954 r1957  
    22# CMakeLists.txt for asap2to3
    33###
    4 
    5 # executable name is asap2to3
    6 set( ASAP2TO3 asap2to3 )
    74
    85# source code
  • trunk/external-alma/atnf/CMakeLists.txt

    r1954 r1957  
    22# CMakeLists.txt for libatnf.so
    33###
    4 
    5 # library name is libatnf.so
    6 set( ATNFLIB atnf )
    74
    85# root for libatnf
     
    1310
    1411# include path
    15 include_directories( ${ATNFROOT} )
    16 #include_directories( ${ATNFDIR}/${PKSIO} )
     12include_directories( ${ATNFROOT}
     13                     ${CFITSIO_INCLUDE_DIR}
     14                     ${RPFITS_INCLUDE_DIR} )
    1715
    1816# link path
     
    2523     ${ATNFDIR}/${PKSIO}/ASTEFXDataset.cc
    2624     ${ATNFDIR}/${PKSIO}/ASTEReader.cc
     25     ${ATNFDIR}/${PKSIO}/ASTEFXReader.cc
    2726     ${ATNFDIR}/${PKSIO}/FITSreader.cc
    2827     ${ATNFDIR}/${PKSIO}/GBTFITSreader.cc
     
    4342     ${ATNFDIR}/${PKSIO}/SDFITSwriter.cc )
    4443add_library( ${ATNFLIB} SHARED ${ATNF_SRCS} )
    45 target_link_libraries( ${ATNFLIB} ${CASACORE_LIBRARIES} )
     44target_link_libraries( ${ATNFLIB}
     45                       ${CASACORE_LIBRARIES}
     46                       ${CFITSIO_LIBRARIES}
     47                       ${RPFITS_LIBRARIES} )
    4648
    4749# install directory
  • trunk/external/libpyrap/CMakeLists.txt

    r1954 r1957  
    22# CMakeLists.txt for libpyrap.so
    33###
    4 
    5 # library name is libpyrap.so
    6 set( PYRAPLIB pyrap )
    74
    85# root for libpyrap
     
    129
    1310# include path
    14 include_directories( ${PYRAPROOT} )
     11include_directories( ${PYRAPROOT}
     12                     ${Boost_INCLUDE_DIR} )
    1513
    1614# link path
     
    2826     ${PYRAPDIR}/${MODULE}/PycRecord.cc
    2927     ${PYRAPDIR}/${MODULE}/PycValueHolder.cc )
     28
    3029add_library( ${PYRAPLIB} SHARED ${PYRAP_SRCS} )
    31 target_link_libraries( ${PYRAPLIB} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${CASACORE_LIBRARIES} )
     30target_link_libraries( ${PYRAPLIB}
     31                       ${Boost_LIBRARIES}
     32                       ${PYTHON_LIBRARIES}
     33                       ${CASACORE_LIBRARIES} )
    3234
    3335# install directory
  • trunk/src/CMakeLists.txt

    r1954 r1957  
    22# CMakeLists.txt for _asap.so
    33###
    4 
    5 # library name is _asap.so
    6 set( ASAPLIB _asap.so )
    74
    85# root for libatnf
     
    118
    129# include path
    13 include_directories( ${SRCDIR} )
    14 include_directories( ${ASAPROOT}/external-alma )
     10include_directories( ${SRCDIR}
     11                     ${Boost_INCLUDE_DIR}
     12                     ${ASAPROOT}/external-alma
     13                     ${ASAPROOT}/external/libpyrap/pyrap-0.3.2 )
    1514
    1615# link path
    1716link_directories( ${SRCDIR} )
     17
     18# use libpyrap
     19add_definitions( -DHAVE_LIBPYRAP )
    1820
    1921# source files for libpyrap
     
    7375
    7476add_library( ${ASAPLIB} SHARED ${ASAP_SRCS} ${ASAP_PYSRCS} )
     77
     78# library name must be _asap.so
    7579set_target_properties( ${ASAPLIB}
    7680                       PROPERTIES
    77                        PREFIX ""
    78                        SUFFIX "" )
    79 target_link_libraries( ${ASAPLIB} pyrap atnf ${CASACORE_LIBRARIES} )
     81                       PREFIX "" )
     82
     83target_link_libraries( ${ASAPLIB}
     84                       ${Boost_LIBRARIES}
     85                       ${PYRAPLIB}
     86                       ${ATNFLIB}
     87                       ${CASACORE_LIBRARIES}
     88                       ${WCSLIB} )
    8089
    8190# install directory
Note: See TracChangeset for help on using the changeset viewer.