source: trunk/CMakeLists.txt@ 3141

Last change on this file since 3141 was 3113, checked in by Kana Sugimoto, 8 years ago

New Development: No

JIRA Issue: Yes (CAS-9626)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs: build asap

Put in Release Notes: No

Module(s): asap

Description: Applied a patch received from Darrell to set appropriate build flags for intel Mac.


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