source: trunk/CMakeLists.txt @ 3004

Last change on this file since 3004 was 3004, checked in by Kana Sugimoto, 10 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): build of asap by cmake

Description: minor modifications of removing white lines mainly to test merge.


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