source: trunk/CMakeLists.txt@ 3020

Last change on this file since 3020 was 3014, checked in by TakTsutsumi, 10 years ago

New Development: No

JIRA Issue: Yes, maybe CAS-6739?

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: ASAP CMakeLists mod from Dave for the components module

relocation


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