source: trunk/CMakeLists.txt@ 3072

Last change on this file since 3072 was 3065, checked in by Kana Sugimoto, 9 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): none

Description: Committing the change to CMake script from Darrell. Updated the way to search boost libraries.


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