Changeset 1970 for trunk


Ignore:
Timestamp:
12/16/10 16:27:11 (14 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.


Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/CMakeLists.txt

    r1968 r1970  
    1616message( STATUS "STANDALONE = " ${STANDALONE} )
    1717
     18# Define compiler paths on OSX 10.5. This must be done before invoking project()
     19if( APPLE )
     20    if( EXISTS            /opt/casa/core2-apple-darwin8/3rd-party/bin/gfortran )
     21        set( CMAKE_Fortran_COMPILER /opt/casa/core2-apple-darwin8/3rd-party/bin/gfortran )
     22        set( CMAKE_CXX_COMPILER     /opt/casa/core2-apple-darwin8/3rd-party/bin/g++ )
     23    elseif( EXISTS        /opt/local/bin/gfortran )
     24        set( CMAKE_Fortran_COMPILER /opt/local/bin/gfortran )
     25    elseif( EXISTS        /opt/local/bin/gfortran-mp-4.4 )
     26        set( CMAKE_Fortran_COMPILER /opt/local/bin/gfortran-mp-4.4 )
     27        if( EXISTS /opt/local/bin/g++-mp-4.4 )
     28            set( CMAKE_CXX_COMPILER /opt/local/bin/g++-mp-4.4 )
     29        endif()
     30    endif()
     31endif()
     32
     33# project name is ASAP
     34project( ASAP )
     35
     36# flags
     37set( DEFAULT_CXX_FLAGS
     38     "-pipe -Wall -Wextra -Wno-non-template-friend -Wcast-align -Wno-comment -O3" )
     39find_package( OpenMP )
     40if( OPENMP_FOUND )
     41   set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
     42endif()
     43
     44set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS}
     45  -DCASA_USECASAPATH
     46  -DCASACORE_NEEDS_RETHROW
     47  -DAIPS_STDLIB
     48  -DAIPS_AUTO_STL
     49  -D_GNU_SOURCE )
     50
     51if( CMAKE_SYSTEM_NAME STREQUAL Linux )
     52  set( CASACORE_DEFINITIONS ${CASACORE_DEFINITIONS}
     53    -D_FILE_OFFSET_BITS=64
     54    -D_LARGEFILE_SOURCE
     55    )
     56endif()
     57
     58add_definitions( ${CASACORE_DEFINITIONS} )
     59
     60# set flags for cpp compiler
     61set( CMAKE_CXX_FLAGS ${DEFAULT_CXX_FLAGS} )
     62
     63# environment dependent settings
     64message( STATUS "CMAKE_SYSTEM = " ${CMAKE_SYSTEM} )
     65message( STATUS "CMAKE_SYSTEM_PROCESSOR = " ${CMAKE_SYSTEM_PROCESSOR} )
     66if( APPLE )
     67   set( SO dylib )
     68   if( CMAKE_SYSTEM MATCHES ^Darwin-10 )
     69      if( NOT archflag )
     70         if( EXISTS /opt/casa/darwin10-64b )
     71            set( archflag x86_64 )
     72         elseif( EXISTS /opt/casa/core2-apple-darwin10 )
     73            set( archflag i386 )
     74         else()
     75            set( archflag x86_64 )
     76         endif()
     77      endif()
     78      if( archflag STREQUAL x86_64 )
     79         add_definitions( -DAIPS_64B )
     80      endif()
     81      execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version
     82                       COMMAND head -1
     83                       COMMAND perl -pe "s|.*?(\\d+\\.\\d+)\\.\\d+$|$1|"
     84                       OUTPUT_VARIABLE _cxx_version
     85                       OUTPUT_STRIP_TRAILING_WHITESPACE )
     86      if( NOT _cxx_version STREQUAL "4.4" )
     87         set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -arch ${archflag}" )
     88      endif()
     89   endif()         
     90elseif( CMAKE_SYSTEM_NAME STREQUAL Linux )
     91   set( SO so )
     92   add_definitions( -DAIPS_LINUX )
     93   if( CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 )
     94      add_definitions( -DAIPS_64B )
     95      set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated" )
     96   else()
     97      set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated -Woverloaded-virtual" )
     98   endif()
     99endif()
     100
     101
    18102#
    19103# mode specific settings
     
    30114endif()
    31115
     116message( STATUS "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX} )
     117
     118
     119#
     120# casacore
     121#
     122unset( CASACORE_INCLUDE_DIR CACHE )
     123unset( CASACORE_LIBRARIES CACHE )
     124if( NOT USE_LIBCASACORE )
     125   # use casacore libraries
     126   set( _includename casa/aipsdef.h )
     127   find_path( CASACORE_INCLUDE_DIR ${_includename}
     128              PATHS ${CASACORE_PATHS}
     129              PATH_SUFFIXES include include/casacore
     130              NO_DEFAULT_PATH )
     131   find_path( CASACORE_INCLUDE_DIR ${_includename} )
     132   if( CASACORE_INCLUDE_DIR MATCHES "NOTFOUND$" )
     133     message( FATAL_ERROR "${_includename} could not be found. Please check!" )
     134   endif()
     135   set( CASACORE_LIBS casa
     136                      components
     137                      coordinates
     138                      fits
     139                      images
     140                      lattices
     141                      measures
     142                      mirlib
     143                      ms
     144                      msfits
     145                      scimath
     146                      scimath_f
     147                      tables )
     148   set( _casacore_libs "" )
     149   foreach( _a ${CASACORE_LIBS} )
     150      set( _libname libcasa_${_a}.${SO} )
     151      unset( _casacore_lib CACHE )
     152      find_library( _casacore_lib ${_libname}
     153                    PATHS ${CASACORE_PATHS}
     154                    PATH_SUFFIXES lib64 lib )
     155      if( _casacore_lib MATCHES "NOTFOUND$" )
     156         message( FATAL_ERROR "${_libname} could not be found. Please check!" )
     157      else()
     158         #list( APPEND _casacore_libs casa_${_a} )
     159         list( APPEND _casacore_libs ${_casacore_lib} )
     160      endif()
     161   endforeach()
     162   set( CASACORE_LIBRARIES ${_casacore_libs} )
     163else()
     164   # use libcasacore
     165   set( _libname libcasacore.${SO} )
     166   find_library( CASACORE_LIBRARIES ${_libname}
     167                 PATHS ${CASACORE_PATHS}
     168                 PATH_SUFFIXES lib64 lib )
     169   if( CASACORE_LIBRARIES MATCHES "NOTFOUND$" )
     170      message( FATAL_ERROR "${_libname} could not be found. Please check!" )
     171   endif()
     172   set( _includename casa/aipsdef.h )
     173   find_path( CASACORE_INCLUDE_DIR ${_includename}
     174              PATHS ${CASACORE_PATHS}
     175              PATH_SUFFIXES include include/casacore
     176              NO_DEFAULT_PATH )
     177   find_path( CASACORE_INCLUDE_DIR ${_includename} )
     178   if( CASACORE_INCLUDE_DIR MATCHES "NOTFOUND$" )
     179     message( FATAL_ERROR "${_includename} could not be found. Please check!" )
     180   endif()
     181endif()
     182message( STATUS "CASACORE_LIBRARIES = " ${CASACORE_LIBRARIES} )
     183message( STATUS "CASACORE_INCLUDE_DIR = " ${CASACORE_INCLUDE_DIR} )
     184unset( USE_LIBCASACORE CACHE )
     185
     186
     187#
     188# Python
     189#
     190if( STANDALONE )
     191   include( FindPythonLibs )
     192   if( NOT PYTHONLIBS_FOUND )
     193      message( FATAL_ERROR "Python could not be found. Please check!" )
     194   endif()
     195
     196   # Define pyroot
     197   string( REGEX REPLACE "/[^/]+/[^/]+/?$" "" pyroot ${PYTHON_INCLUDE_DIRS} )
     198
     199   # find numpy
     200   string( REGEX MATCH [0-9].[0-9] PYTHONV ${PYTHON_INCLUDE_DIRS} )
     201   string( REPLACE "." "" PV ${PYTHONV} )
     202   set( PYTHON_PREFIX ${PYTHON_INCLUDE_DIRS}/../.. )
     203   find_path( NUMPY_INCLUDE_DIR numpy/npy_interrupt.h
     204              PATHS
     205                 ${PYTHON_PREFIX}/lib/python${PYTHONV}/site-packages/numpy/core
     206                 ${PYTHON_PREFIX}/Library/Frameworks/Python.framework/Versions/${PYTHONV}
     207                 ${PYTHON_PREFIX}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core
     208              PATH_SUFFIXES include )
     209   if( NUMPY_INCLUDE_DIR MATCHES "NOTFOUND$" )
     210      message( FATAL_ERROR "numpy/npy_interrupt.h could not be found. Please check!" )
     211   endif()
     212   list( APPEND PYTHON_INCLUDE_DIRS ${NUMPY_INCLUDE_DIR} )
     213
     214   set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS}
     215      -DPYTHONROOT=\"${pyroot}\"
     216      -DPYTHONVER=\"${PYTHONV}\"
     217      -DPYVERSION=${PV} )
     218else()
     219   if( NOT PYTHON_FOUND )
     220      if ( NOT PYTHON_LIBNAME )
     221         set( _names 2.9 2.8 2.7 2.6 2.5.2 2.5 )
     222         # (The library named libpython.2.5.2.dylib seems to exist only in the CASA world.)
     223      else()
     224         set( _names ${PYTHON_LIBNAME} )
     225      endif()
     226
     227      set( _found False )
     228      foreach( _v ${_names} )
     229
     230         casa_find(
     231            PYTHON${_v}
     232            LIBS python${_v}
     233            NO_REQUIRE
     234         )
     235
     236         if( PYTHON${_v}_FOUND )
     237            set( PYTHON_LIBNAME ${_v} )
     238            set( _found True )
     239            break()
     240         endif()
     241
     242      endforeach()
     243 
     244      if( NOT _found )
     245         message( FATAL_ERROR "Could not find any PYTHON library with version one of ${_names}. Please check!" )
     246      endif()
     247
     248   endif()
     249
     250   if( NOT PYTHON_LIBNAME )
     251      # Found Python, but PYTHON_LIBNAME is undefined, that is impossible.
     252      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*\")")
     253   endif()
     254
     255   string( SUBSTRING ${PYTHON_LIBNAME} 0 3 PYTHONV )
     256   string( REPLACE "." "" PV ${PYTHONV} )
     257   set( python_library python${PYTHON_LIBNAME} )
     258
     259   # Form the Python install prefix by stripping away "lib/libpython2.5.2.dylib" (example) from
     260   # the full python library path
     261   string( REGEX MATCH "/lib(64)?/lib${python_library}" _match ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
     262   if( _match )
     263      string( REGEX REPLACE "/lib(64)?/lib${python_library}.*" "" python_prefix ${PYTHON${PYTHON_LIBNAME}_LIBRARIES} )
     264   else()
     265      # Python library was not in a lib(64) directory!
     266      message( WARNING "Python library path \"${PYTHON${PYTHON_LIBNAME}_LIBRARIES}\" does not contain \"/lib(64)/lib${python_library}\"" )
     267      set( python_prefix ${casa_packages} )
     268   endif()
     269
     270   # The python version and prefix is known, do the actual search
     271   if( NOT PYTHON_FOUND )
     272      message( STATUS "Looking for PYTHON version ${PYTHONV}.x in ${python_prefix}" )
     273   endif()
     274
     275   casa_find( PYTHON
     276      VERSION 2.5    # minimum required
     277      INCLUDES Python.h
     278         numpy/npy_interrupt.h   # for numpy
     279      INCLUDES_SUFFIXES python${PYTHONV}
     280      PREFIX_HINTS
     281         ${python_prefix}/lib/python${PYTHONV}/site-packages/numpy/core
     282         ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}
     283         ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core
     284      LIBS ${python_library}
     285      CPP_VERSION PY_VERSION )
     286
     287   # Store PYTHON_LIBNAME in the cache
     288   set( PYTHON_LIBNAME ${PYTHON_LIBNAME} CACHE STRING "Python major and minor version to use" FORCE )
     289
     290   # Define pyroot to two directory levels above Python.h.
     291   string( REGEX REPLACE "/[^/]+/[^/]+/?$" "" pyroot ${PYTHON_Python.h} )
     292
     293   set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS}
     294      -DAIPSROOT=\"${CMAKE_SOURCE_DIR}\"
     295      -DAIPSARCH=\"${arch}\"
     296      -DAIPSSITE=\"garching\"
     297      -DPYTHONROOT=\"${pyroot}\"
     298      -DPYTHONVER=\"${PYTHONV}\"
     299      -DPYVERSION=${PV} )
     300endif()
     301message( STATUS "PYTHON_INCLUDE_DIRS = " ${PYTHON_INCLUDE_DIRS} )
     302message( STATUS "PYTHON_LINRARIES = " ${PYTHON_LIBRARIES} )
     303message( STATUS "PYTHONV = " ${PYTHONV} )
     304
     305
     306#
     307# DL
     308#
     309set( DL_LIBRARIES ${CMAKE_DL_LIBS} CACHE STRING "dl libraries" FORCE )
     310if( DL_LIBRARIES STREQUAL "dl" )
     311  set( DL_LIBRARIES "-ldl" CACHE STRING "dl libraries" FORCE )
     312endif()
     313message( STATUS "DL_LIBRARIES = " ${DL_LIBRARIES} )
     314
     315
     316#
     317# BLAS
     318#
     319find_library( BLAS_LIBRARIES libblas.${SO} )
     320if ( BLAS_LIBRARIES MATCHES "NOTFOUND$" )
     321   message( FATAL_ERROR "blas could not be found. Please check!" )
     322endif()
     323message( STATUS "BLAS_LIBRARIES = " ${BLAS_LIBRARIES} )
     324
     325
     326#
     327# LAPACK
     328#
     329find_library( LAPACK_LIBRARIES liblapack.${SO} )
     330if ( LAPACK_LIBRARIES MATCHES "NOTFOUND$" )
     331   message( FATAL_ERROR "lapack could not be found. Please check!" )
     332endif()
     333message( STATUS "LAPACK_LIBRARIES = " ${LAPACK_LIBRARIES} )
     334
     335
     336#
     337# Boost
     338#
     339set( boost_components python )
     340find_package( Boost REQUIRED ${boost_components} )
     341if( NOT Boost_FOUND )
     342  message( FATAL_ERROR "Boost could not be found. Please check!" )
     343endif()
     344message( STATUS "BOOST_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
     345message( STATUS "BOOST_LIBRARIES = " ${Boost_LIBRARIES} )
     346
     347
     348#
     349# cfitsio
     350#
     351if( STANDALONE )
     352   find_path( CFITSIO_INCLUDE_DIRS fitsio.h
     353              PATH_SUFFIXES cfitsio )
     354   if( CFITSIO_INCLUDE_DIRS MATCHES "NOTFOUND$" )
     355      message( FATAL_ERROR "fitsio.h could not be found. Please check!" )
     356   endif()
     357   find_library( CFITSIO_LIBRARIES libcfitsio.${SO}
     358                 PATHS /usr/local /usr
     359                 PATH_SUFFIXES lib64 lib )
     360   if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" )
     361      message( FATAL_ERROR "libcfitsio.so could not be found. Please check!" )
     362   endif()
     363else()
     364   casa_find( CFITSIO
     365              VERSION 3.006
     366              INCLUDES fitsio.h fitsio2.h
     367              INCLUDES_SUFFIXES cfitsio
     368              LIBS cfitsio
     369              CPP_VERSION CFITSIO_VERSION
     370              RUN_VERSION "(ffvers(&v), v)" )
     371endif()
     372message( STATUS "CFITSIO_INCLUDE_DIRS = " ${CFITSIO_INCLUDE_DIRS} )
     373message( STATUS "CFITSIO_LIBRARIES = " ${CFITSIO_LIBRARIES} )
     374
     375
     376#
     377# Fortran
     378#
     379if( NOT FORTRAN_LIBRARIES )
     380
     381  message( STATUS "Looking for Fortran runtime libraries" )
     382  set( _try  ${CMAKE_BINARY_DIR}/try_fortran.cc )
     383  file( WRITE ${_try}
     384    "int main() { return 0; }\n"
     385    )
     386 
     387  if( _gfortran_lib_path )
     388    try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
     389      CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=${_gfortran_lib_path}"
     390      )
     391  else()
     392    try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
     393      CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lgfortran"
     394      )
     395  endif()
     396  try_compile( _have_g2c ${CMAKE_BINARY_DIR} ${_try}
     397    CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lg2c"
     398    )
     399 
     400  if( _have_gfortran )
     401    if( _gfortran_lib_path )
     402      set( FORTRAN_LIBRARIES ${_gfortran_lib_path}
     403        CACHE STRING "Fortran library linker option" FORCE )
     404    else()
     405      set( FORTRAN_LIBRARIES -lgfortran
     406        CACHE STRING "Fortran library linker option" FORCE )
     407    endif()
     408    message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
     409  elseif( _have_g2c )
     410    set( FORTRAN_LIBRARIES -lg2c
     411      CACHE STRING "Fortran library linker option" FORCE )
     412    message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
     413  else()
     414    set( FORTRAN_LIBRARIES ""
     415      CACHE STRING "Fortran library linker option" FORCE )
     416    message( STATUS "Looking for Fortran runtime libraries -- <none>" )
     417    # Not a fatal error because it might work, if all Fortran dependencies were
     418    # already linked statically to the Fortran runtime...
     419  endif()
     420endif()
     421
     422
     423#
     424# RPFITS
     425#
     426if ( STANDALONE )
     427   find_path( RPFITS_INCLUDE_DIRS RPFITS.h
     428              PATHS /usr/local /usr
     429              PATH_SUFFIXES include )
     430   if( RPFITS_INCLUDE_DIRS MATCHES "NOTFOUND$" )
     431      message( FATAL_ERROR "RPFITS.h could not be found. Please check!" )
     432   endif()
     433   find_library( RPFITS_LIBRARIES librpfits.so
     434                 PATHS /usr/local /usr
     435                 PATH_SUFFIXES lib64 lib )
     436   if( RPFITS_LIBRARIES MATCHES "NOTFOUND$" )
     437      message( FATAL_ERROR "librpfits.so could not be found. Please check!" )
     438   endif()
     439   list( APPEND RPFITS_LIBRARIES ${FORTRAN_LIBRARIES} )
     440else()
     441   casa_find( RPFITS
     442              VERSION 2.11
     443              INCLUDES RPFITS.h
     444              LIBS rpfits
     445              RUN_VERSION names_.rpfitsversion
     446              DEPENDS FORTRAN )
     447endif()
     448message( STATUS "RPFITS_INCLUDE_DIRS = " ${RPFITS_INCLUDE_DIRS} )
     449message( STATUS "RPFITS_LIBRARIES = " ${RPFITS_LIBRARIES} )
     450
     451
     452#
     453# wcslib
     454#
     455set( _wcslib libwcs.${SO} )
     456set( _wcs_version 4.3 )
     457find_library( WCSLIB ${_wcslib}
     458              PATHS ${WCSLIB_PATHS}
     459              PATH_SUFFIXES lib64 lib )
     460if( WCSLIB MATCHES "NOTFOUND$" )
     461   message( STATUS "${_wcslib} could not be found." )
     462   unset( _wcslib CACHE )
     463   unset( WCSLIB CACHE )
     464   set( _wcslib libwcs.${_wcs_version}.${SO} )
     465   message( STATUS "Try to find ${_wcslib}..." )
     466   find_library( WCSLIB ${_wcslib}
     467                 PATHS ${WCSLIB_PATHS}
     468                 PATH_SUFFIXES lib64 lib )
     469   if( WCSLIB MATCHES "NOTFOUND$" )
     470      message( FATAL_ERROR "${_wcslib} could not be found. Please check!" )
     471   endif()
     472endif()
     473message( STATUS "WCSLIB = " ${WCSLIB} )
     474find_path( WCSLIB_INCLUDE_DIR wcslib/wcs.h
     475           PATHS ${WCSLIB_PATHS}
     476           PATH_SUFFIXES include )
     477if( WCSLIB_INCLUDE_DIR MATCHES "NOTFOUND$" )
     478   message( FATAL_ERROR "wcs.h could not be found. Please check!" )
     479endif()
     480message( STATUS "WCSLIB_INCLUDE_DIR = " ${WCSLIB_INCLUDE_DIR} )
     481
    32482
    33483#
  • trunk/cmake/standalone.cmake

    r1968 r1970  
    22# CMakeLists.txt for standalone build
    33###
    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} )
    1254
    1265
     
    1309# always use libcasacore.so
    13110set( 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} )
     11set( CASACORE_PATHS "/usr/local;/usr" )
    24712
    24813
     
    25015# wcslib
    25116#
    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} )
     17set( WCSLIB_PATHS "/usr/local;/usr" )
    27718
    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} )
    34119
    34220#
  • 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.