source: trunk/CMakeLists.txt@ 3102

Last change on this file since 3102 was 3102, checked in by Kana Sugimoto, 8 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): build of asap

Description: added a search path of aipsdef.h based on the request by Darrell.


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