source: trunk/CMakeLists.txt@ 3093

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

New Development: Yes

JIRA Issue: Yes (CAS-8172)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs: build asap

Put in Release Notes: No

Module(s): asap

Description: Added a search path for python to support build on OpenSUSE.


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 ${NUMPY_ROOT_DIR}
403 ${python_prefix}/lib/python${PYTHONV}/site-packages/numpy/core
404 ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}
405 ${python_prefix}/Library/Frameworks/Python.framework/Versions/${PYTHONV}/lib/python${PYTHONV}/site-packages/numpy/core
406 LIBS ${python_library}
407 CPP_VERSION PY_VERSION )
408
409 # Store PYTHON_LIBNAME in the cache
410 set( PYTHON_LIBNAME ${PYTHON_LIBNAME} CACHE STRING "Python major and minor version to use" FORCE )
411
412 # Define pyroot to two directory levels above Python.h.
413 string( REGEX REPLACE "/[^/]+/[^/]+/?$" "" pyroot ${PYTHON_Python.h} )
414
415 set( PYTHON_DEFINITIONS ${PYTHON_DEFINITIONS}
416 -DAIPSROOT=\"${CMAKE_SOURCE_DIR}\"
417 -DAIPSARCH=\"${arch}\"
418 -DAIPSSITE=\"garching\"
419 -DPYTHONROOT=\"${pyroot}\"
420 -DPYTHONVER=\"${PYTHONV}\"
421 -DPYVERSION=${PV} )
422endif()
423message( STATUS "PYTHON_INCLUDE_DIRS = " ${PYTHON_INCLUDE_DIRS} )
424message( STATUS "PYTHON_LINRARIES = " ${PYTHON_LIBRARIES} )
425message( STATUS "PYTHONV = " ${PYTHONV} )
426
427
428#
429# DL
430#
431set( DL_LIBRARIES ${CMAKE_DL_LIBS} CACHE STRING "dl libraries" FORCE )
432if( DL_LIBRARIES STREQUAL "dl" )
433 set( DL_LIBRARIES "-ldl" CACHE STRING "dl libraries" FORCE )
434endif()
435message( STATUS "DL_LIBRARIES = " ${DL_LIBRARIES} )
436
437
438#
439# BLAS
440#
441find_library( BLAS_LIBRARIES libblas.${SO} )
442if ( BLAS_LIBRARIES MATCHES "NOTFOUND$" )
443 message( FATAL_ERROR "blas could not be found. Please check!" )
444endif()
445message( STATUS "BLAS_LIBRARIES = " ${BLAS_LIBRARIES} )
446
447
448#
449# LAPACK
450#
451find_library( LAPACK_LIBRARIES liblapack.${SO} )
452if ( LAPACK_LIBRARIES MATCHES "NOTFOUND$" )
453 message( FATAL_ERROR "lapack could not be found. Please check!" )
454endif()
455message( STATUS "LAPACK_LIBRARIES = " ${LAPACK_LIBRARIES} )
456
457
458#
459# Boost
460#
461set( boost_components python )
462if( NOT STANDALONE )
463 set( boost_components ${boost_components} system )
464endif()
465find_package( Boost REQUIRED ${boost_components} )
466if( NOT Boost_FOUND )
467 message( FATAL_ERROR "Boost could not be found. Please check!" )
468endif()
469
470if(CMAKE_SYSTEM_NAME STREQUAL Linux AND Boost_LIBRARIES)
471 if(EXISTS "/usr/lib64/libicuuc.so")
472 set( Boost_LIBRARIES "${Boost_LIBRARIES};/usr/lib64/libicuuc.so" )
473 endif( )
474 if(EXISTS "/usr/lib64/libicudata.so")
475 set( Boost_LIBRARIES "${Boost_LIBRARIES};/usr/lib64/libicudata.so" )
476 endif( )
477 if(EXISTS "/usr/lib64/libicui18n.so")
478 set( Boost_LIBRARIES "${Boost_LIBRARIES};/usr/lib64/libicui18n.so" )
479 endif( )
480 message(STATUS "Boost_LIBRARIES=${Boost_LIBRARIES}")
481endif( )
482
483
484message( STATUS "BOOST_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
485message( STATUS "BOOST_LIBRARIES = " ${Boost_LIBRARIES} )
486
487
488#
489# cfitsio
490#
491if( STANDALONE )
492 find_path( CFITSIO_INCLUDE_DIRS fitsio.h
493 PATH_SUFFIXES cfitsio )
494 if( CFITSIO_INCLUDE_DIRS MATCHES "NOTFOUND$" )
495 message( FATAL_ERROR "fitsio.h could not be found. Please check!" )
496 endif()
497 string( REGEX REPLACE "/[^/]+/?$" "" CFITSIO_ROOT ${CFITSIO_INCLUDE_DIRS} )
498 message( STATUS "CFITSIO_ROOT=" ${CFITSIO_ROOT} )
499 find_library( CFITSIO_LIBRARIES libcfitsio.${SO}
500 PATHS ${CFITSIO_ROOT}
501 PATH_SUFFIXES lib64 lib
502 NO_DEFAULT_PATH )
503 if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" )
504 find_library( CFITSIO_LIBRARIES libcfitsio.a
505 PATHS ${CFITSIO_ROOT}
506 PATH_SUFFIXES lib64 lib
507 NO_DEFAULT_PATH )
508 endif()
509 find_library( CFITSIO_LIBRARIES libcfitsio.${SO}
510 PATHS /usr/local /usr
511 PATH_SUFFIXES lib64 lib )
512 if( CFITSIO_LIBRARIES MATCHES "NOTFOUND$" )
513 message( FATAL_ERROR "libcfitsio.so could not be found. Please check!" )
514 endif()
515else()
516 casa_find( CFITSIO
517 VERSION 3.006
518 INCLUDES fitsio.h fitsio2.h
519 INCLUDES_SUFFIXES cfitsio
520 LIBS cfitsio
521 CPP_VERSION CFITSIO_VERSION
522 RUN_VERSION "(ffvers(&v), v)" )
523endif()
524message( STATUS "CFITSIO_INCLUDE_DIRS = " ${CFITSIO_INCLUDE_DIRS} )
525message( STATUS "CFITSIO_LIBRARIES = " ${CFITSIO_LIBRARIES} )
526
527
528#
529# Fortran
530#
531if( NOT FORTRAN_LIBRARIES )
532
533 message( STATUS "Looking for Fortran runtime libraries" )
534 set( _try ${CMAKE_BINARY_DIR}/try_fortran.cc )
535 file( WRITE ${_try}
536 "int main() { return 0; }\n"
537 )
538
539 execute_process( COMMAND ${CMAKE_Fortran_COMPILER} -print-search-dirs
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; last; }} last if $found; } last if $found;}"
541# 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;}"
542 OUTPUT_VARIABLE _gfortran_lib_path
543 OUTPUT_STRIP_TRAILING_WHITESPACE )
544
545 if( _gfortran_lib_path )
546 try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
547 CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=${_gfortran_lib_path}"
548 )
549 else()
550 try_compile( _have_gfortran ${CMAKE_BINARY_DIR} ${_try}
551 CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lgfortran"
552 )
553 endif()
554 try_compile( _have_g2c ${CMAKE_BINARY_DIR} ${_try}
555 CMAKE_FLAGS -Wdev "-DCMAKE_EXE_LINKER_FLAGS=-lg2c"
556 )
557
558 if( _have_gfortran )
559 if( _gfortran_lib_path )
560 set( FORTRAN_LIBRARIES ${_gfortran_lib_path}
561 CACHE STRING "Fortran library linker option" FORCE )
562 else()
563 set( FORTRAN_LIBRARIES -lgfortran
564 CACHE STRING "Fortran library linker option" FORCE )
565 endif()
566 message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
567 elseif( _have_g2c )
568 set( FORTRAN_LIBRARIES -lg2c
569 CACHE STRING "Fortran library linker option" FORCE )
570 message( STATUS "Looking for Fortran runtime libraries -- ${FORTRAN_LIBRARIES}" )
571 else()
572 set( FORTRAN_LIBRARIES ""
573 CACHE STRING "Fortran library linker option" FORCE )
574 message( STATUS "Looking for Fortran runtime libraries -- <none>" )
575 # Not a fatal error because it might work, if all Fortran dependencies were
576 # already linked statically to the Fortran runtime...
577 endif()
578endif()
579
580# X11.
581if( NOT APPLE )
582 find_package( X11 REQUIRED )
583 # Rename
584 set( X11_INCLUDE_DIRS ${X11_INCLUDE_DIR} )
585endif()
586
587# PGPLOT (FORTRAN plotting package).
588# depends on X11
589# not require in standalone mode
590if( NOT STANDALONE )
591 if( APPLE )
592 set( _deps FORTRAN )
593 else()
594 set( _deps X11 FORTRAN )
595 endif()
596 if (CMAKE_SYSTEM MATCHES ^Darwin-11 AND NOT LLVMCOMPILER )
597 set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit -lgfortran" )
598 else()
599 if (APPLE)
600 set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error -framework AppKit" )
601 else()
602 set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined -Wl,error" )
603 endif()
604 endif()
605 casa_find( PGPLOT
606 VERSION 5.3.1
607 PREFIX_HINTS ${PGPLOT_ROOT_DIR}
608 INCLUDES cpgplot.h
609 LIBS pgplot${pgplot_ext} cpgplot${pgplot_ext}
610 DEPENDS ${_deps} )
611
612 add_definitions( -DENABLE_PLOTTER2 )
613endif()
614
615#
616# RPFITS
617#
618if ( STANDALONE )
619 find_path( RPFITS_INCLUDE_DIRS RPFITS.h
620 PATHS /usr/local /usr
621 PATH_SUFFIXES include )
622 if( RPFITS_INCLUDE_DIRS MATCHES "NOTFOUND$" )
623 message( FATAL_ERROR "RPFITS.h could not be found. Please check!" )
624 endif()
625 find_library( RPFITS_LIBRARIES librpfits.so
626 PATHS /usr/local /usr
627 PATH_SUFFIXES lib64 lib )
628 if( RPFITS_LIBRARIES MATCHES "NOTFOUND$" )
629 message( FATAL_ERROR "librpfits.so could not be found. Please check!" )
630 endif()
631 list( APPEND RPFITS_LIBRARIES ${FORTRAN_LIBRARIES} )
632else()
633 casa_find( RPFITS
634 VERSION 2.11
635 INCLUDES RPFITS.h
636 LIBS rpfits
637 RUN_VERSION names_.rpfitsversion
638 DEPENDS FORTRAN )
639endif()
640message( STATUS "RPFITS_INCLUDE_DIRS = " ${RPFITS_INCLUDE_DIRS} )
641message( STATUS "RPFITS_LIBRARIES = " ${RPFITS_LIBRARIES} )
642
643
644#
645# wcslib
646#
647set( _wcslib libwcs.${SO} )
648set( _wcs_version 4.3 )
649find_library( WCSLIB ${_wcslib}
650 PATHS ${WCSLIB_PATHS}
651 PATH_SUFFIXES lib64 lib )
652if( WCSLIB MATCHES "NOTFOUND$" )
653 message( STATUS "${_wcslib} could not be found." )
654 unset( _wcslib CACHE )
655 unset( WCSLIB CACHE )
656 set( _wcslib libwcs.${_wcs_version}.${SO} )
657 message( STATUS "Try to find ${_wcslib}..." )
658 find_library( WCSLIB ${_wcslib}
659 PATHS ${WCSLIB_PATHS}
660 PATH_SUFFIXES lib64 lib )
661 if( WCSLIB MATCHES "NOTFOUND$" )
662 message( FATAL_ERROR "${_wcslib} could not be found. Please check!" )
663 endif()
664endif()
665message( STATUS "WCSLIB = " ${WCSLIB} )
666find_path( WCSLIB_INCLUDE_DIR wcslib/wcs.h
667 PATHS ${WCSLIB_PATHS}
668 PATH_SUFFIXES include )
669if( WCSLIB_INCLUDE_DIR MATCHES "NOTFOUND$" )
670 message( FATAL_ERROR "wcs.h could not be found. Please check!" )
671endif()
672message( STATUS "WCSLIB_INCLUDE_DIR = " ${WCSLIB_INCLUDE_DIR} )
673
674
675#
676# common include path
677#
678include_directories( ${CASACORE_INCLUDE_DIR}/..
679 ${CASACORE_INCLUDE_DIR}
680 ${Boost_INCLUDE_DIR}
681 ${X11_INCLUDE_DIRS}
682 ${PGPLOT_INCLUDE_DIRS}
683 ${PYTHON_INCLUDE_DIRS}
684 ${WCSLIB_INCLUDE_DIR}
685 ${CFITSIO_INCLUDE_DIRS}
686 ${RPFITS_INCLUDE_DIRS} )
687
688
689#
690# install directory
691#
692set( EXEC_INSTALL_DIR bin )
693set( LIB_INSTALL_DIR lib )
694set( PYTHON_INSTALL_DIR python/${PYTHONV}/asap )
695set( SHARED_INSTALL_DIR share/asap )
696
697#
698# execute getsvnrev.sh to create/update svninfo.txt
699# run chmod to make sure the script has executable
700#
701execute_process( COMMAND svn info
702 RESULT_VARIABLE SVNINFOSTATUS
703 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
704)
705message("SVNINFOSTATUS: ${SVNINFOSTATUS}")
706
707if(${SVNINFOSTATUS} STREQUAL "0")
708 message("Running svn scripts.")
709 exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/getsvnrev.sh )
710 exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/cmake/exec_getsvnrev.sh )
711 exec_program( ${ASAP_SOURCE_DIR}/cmake/exec_getsvnrev.sh ARGS ${ASAP_SOURCE_DIR})
712else ()
713 message("Couldn't get svn info. Running git scripts.")
714 exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/getgitrev.sh )
715 exec_program( chmod ARGS a+x ${ASAP_SOURCE_DIR}/cmake/exec_getgitrev.sh )
716 exec_program( ${ASAP_SOURCE_DIR}/cmake/exec_getgitrev.sh ARGS ${ASAP_SOURCE_DIR})
717endif ()
718
719# Add the modules to be built.
720#
721# Choose to have correct RPATHs both in the build tree and
722# in the install tree (at the cost of having to change the
723# rpath when installing)
724#
725set( CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib )
726set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
727set( CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib )
728
729#
730# PKSMS
731#
732if ( NOT PKSMS )
733 add_definitions( -DNOPKSMS )
734endif()
735
736#
737# libraries and executables
738#
739set( ASAPPYLIB _asap )
740set( ASAPLIB asap )
741#set( PYRAPLIB pyrap )
742#set( ATNFLIB atnf )
743set( ATNFLIB atnf_asap )
744set( ASAP2TO3 asap2to3 )
745#if ( NOT STANDALONE )
746# set( ASDM2ASAP_OLD oldasdm2ASAP )
747# set( ASDM2ASAP asdm2ASAP )
748#endif()
749
750#
751# always install by default
752#
753add_custom_target( inst ALL ${CMAKE_BUILD_TOOL} install/fast )
754
755#
756# subdirectories
757#
758asap_add_subdirectory()
Note: See TracBrowser for help on using the repository browser.