source: trunk/CMakeLists.txt@ 3106

Last change on this file since 3106 was 3106, checked in by Takeshi Nakazato, 9 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes/No

Interface Changes: Yes/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: Describe your changes here...


Check-in asap modifications from Jim regarding casacore namespace conversion.

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