source: trunk/CMakeLists.txt @ 2971

Last change on this file since 2971 was 2971, checked in by KohjiNakamura, 10 years ago

native optimization

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