source: trunk/CMakeLists.txt@ 3025

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

New Development: Yes

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): asap (built by CMake)

Description: Introduced a build flag that defines complex mul/div rule in fortran style.


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