source: trunk/CMakeLists.txt @ 3051

Last change on this file since 3051 was 3051, checked in by Kana Sugimoto, 9 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): cmake build of asap

Description: changes to top level CMakeLists.txt from Ville to supress "unknown warning option '-Wno-non-template-friend'" warnings at build.


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