source: branches/casa-release-4_3-test02/CMakeLists.txt@ 3130

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

dummy commit: modified a code

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