source: trunk/CMakeLists.txt @ 1956

Last change on this file since 1956 was 1956, checked in by Takeshi Nakazato, 13 years ago

New Development: No

JIRA Issue: Yes CAS-2668

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Introduced USE_LIBCASACORE switch to enable to choose casacore libraries
to be built with ASAP (libcasacore.so or libcasa_casa.so etc.).
Default is not use libcasacore.so library.


File size: 7.4 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# project name is ASAP
9project( ASAP )
10
11# install directory
12# set casaroot
13# the regular expression means '../'
14#  [^ ] Matches any character(s) not inside the brackets
15#  +    Matches preceding pattern one or more times
16#  ?    Matches preceding pattern zero or once only
17#  $    Mathces at end of a line
18string( REGEX REPLACE /[^/]+/?$ "" casaroot ${CMAKE_SOURCE_DIR} )
19message( STATUS "casaroot = " ${casaroot} )
20
21# flags
22set( DEFAULT_CXX_FLAGS
23     "-pipe -Wall -Wextra -Wno-non-template-friend -Wcast-align -Wno-comment" )
24find_package( OpenMP )
25if( OPENMP_FOUND )
26   set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
27endif()
28
29# environment dependent settings
30if( APPLE )
31   set( SO dylib )
32   if( NOT arch )
33      set( arch darwin )
34   endif()
35   if( CMAKE_SYSTEM MATHCES ^Darwin-10 )
36      if( NOT archflag )
37         if( EXISTS /opt/casa/darwin10-64b )
38            set( archflag x86_64 )
39         elseif( EXISTS /opt/casa/core2-apple-darwin10 )
40            set( archflag i386 )
41         else()
42            set( archflag x86_64 )
43         endif()
44      endif()
45      if( archflag STREQUAL x86_64 )
46         add_definitions( -DAIPS_64B )
47         set( casa_packages /opt/casa/darwin10-64b )
48      else()
49         set( casa_packages /opt/casa/core2-apple-darwin10 )
50      endif()
51      execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version
52                       COMMAND head -1
53                       COMMAND perl -pe "s|.*?(\\d+\\.\\d+)\\.\\d+$|$1|"
54                       OUTPUT_VARIABLE _cxx_version
55                       OUTPUT_STRIP_TRAILING_WHITESPACE )
56      if( NOT _cxx_version STREQUAL "4.4" )
57         set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -arch ${archflag}" )
58      endif()
59   elseif( CMAKE_SYSTEM MATCHES ^Darwin-9 )
60      set( casa_packages /opt/casa/core2-apple-darwin8/3rd-party )
61   endif()         
62elseif( CMAKE_SYSTEM_NAME STREQUAL Linux )
63   set( SO so )
64   add_definitions( -DAIPS_LINUX )
65   if( CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 )
66      set( casa_packages /usr/lib64/casapy )
67      if( NOT arch )
68         set( arch linux_64b )
69      endif()
70      add_definitions( -DAIPS_64B )
71      set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated" )
72   else()
73      set( casa_packages /usr/lib/casapy )
74      if( NOT arch )
75         set( arch linux_gnu )
76      endif()
77      set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wno-deprecated -Woverloaded-virtual" )
78   endif()
79endif()
80message( STATUS "arch = " ${arch} )
81
82# set root directory for installation
83set( CMAKE_INSTALL_PREFIX ${casaroot}/${arch} )
84message( STATUS "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX} )
85
86# set flags for cpp compiler
87set( CMAKE_CXX_FLAGS ${DEFAULT_CXX_FLAGS} )
88
89#
90# casacore
91#
92if( NOT USE_LIBCASACORE )
93   # use casacore libraries
94   set( _includename aipsdef.h )
95   find_path( CASACORE_INCPATH ${_includename}
96              HINTS ${casaroot}/${arch}/include/
97              PATH_SUFFIXES casacore/casa )
98   if( CASACORE_INCPATH STREQUAL CASACORE_INCPATH-NOTFOUND )
99     message( FATAL_ERROR "${_includename} could not be found. Please check!" )
100   else()
101      string( REGEX REPLACE /[^/]+/?$ "" CASACORE_INCLUDE_DIR ${CASACORE_INCPATH} ) 
102   endif()
103   set( CASACORE_LIBS casa
104                      components
105                      coordinates
106                      fits
107                      images
108                      lattices
109                      measures
110                      mirlib
111                      ms
112                      msfits
113                      scimath
114                      scimath_f
115                      tables )
116   set( _casacore_libs "" )
117   foreach( _a ${CASACORE_LIBS} )
118      set( _libname libcasa_${_a}.${SO} )
119      unset( _casacore_lib CACHE )
120      find_library( _casacore_lib ${_libname}
121                    PATHS ${CMAKE_INSTALL_PREFIX} PATH_SUFFIXES lib )
122      if( NOT _casacore_lib-NOTFOUND )
123         list( APPEND _casacore_libs casa_${_a} )
124      endif()
125   endforeach()
126   set( CASACORE_LIBRARIES ${_casacore_libs} )
127else()
128   # use libcasacore
129   set( _libname libcasacore.${SO} )
130   find_library( CASACORE_LIBRARIES ${_libname} )
131   if( CASACORE_LIBRARIES STREQUAL CASACORE_LIBRARIES-NOTFOUND )
132      message( FATAL_ERROR "${_libname} could not be found. Please check!" )
133   endif()
134   set( _includename aipsdef.h )
135   find_path( CASACORE_INCPATH ${_includename}
136              PATH_SUFFIXES casacore/casa )
137   if( CASACORE_INCPATH STREQUAL CASACORE_INCPATH-NOTFOUND )
138     message( FATAL_ERROR "${_includename} could not be found. Please check!" )
139   else()
140      string( REGEX REPLACE /[^/]+/?$ "" CASACORE_INCLUDE_DIR ${CASACORE_INCPATH} )
141   endif()
142endif()
143message( STATUS "CASACORE_LIBRARIES = " ${CASACORE_LIBRARIES} )
144message( STATUS "CASACORE_INCLUDE_DIR = " ${CASACORE_INCLUDE_DIR} )
145
146#
147# Python
148#
149# tentative
150set( PYVERSION 2.6 )
151if (NOT PYTHON_ROOT )
152   set( PYTHON_ROOT ${casa_packages} )
153endif()
154find_package( PythonLibs REQUIRED python${PYVERSION} )
155
156if( NOT PYTHONLIBS_FOUND )
157   message( FATAL_ERROR "Python could not be found. Please check!" )
158endif()
159message( STATUS "PYTHON_INCLUDE_PATH = " ${PYTHON_INCLUDE_PATH} )
160message( STATUS "PYTHON_LIBRARIES = " ${PYTHON_LIBRARIES} )
161
162set( PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_PATH} )
163find_path( NUMPY_INC_DIR numpy/npy_interrupt.h
164           PATHS ${casa_packages}/lib/python${PYVERSION}/site-packages/numpy/core/include )
165message( STATUS "NUMPY_INC_DIR = " ${NUMPY_INC_DIR} )
166if( NOT NUMPY_INC_DIR STREQUAL NUMPY_INC_DIR-NOTFOUND )
167   list( APPEND PYTHON_INCLUDE_DIR ${NUMPY_INC_DIR} )
168endif()
169message( STATUS "PYTHON_INCLUDE_DIR = " ${PYTHON_INCLUDE_DIR} )
170
171#
172# Boost
173#
174if( NOT BOOST_ROOT )
175   set( BOOST_ROOT ${casa_packages} )
176endif()
177
178set( boost_components regex program_options filesystem )
179find_package( Boost REQUIRED ${boost_components} )
180
181if( NOT Boost_FOUND )
182  message( FATAL_ERROR "Boost could not be found. Please check!" )
183endif()
184
185# For boost >= 1.35, we need to link also to boost-system
186if( Boost_VERSION GREATER 103499 )
187
188  # Force redetection by resetting these variables
189  if( NOT Boost_SYSTEM_FOUND )
190    message( STATUS "Boost version (${Boost_VERSION}) is 1.35.0 or newer" )
191    unset( Boost_FOUND )
192    unset( Boost_INCLUDE_DIR CACHE )
193  endif()
194  set( boost_components regex program_options filesystem system )
195  find_package( Boost REQUIRED ${boost_components} )
196
197  if( NOT Boost_FOUND )
198    message( FATAL_ERROR "Boost-system could not be found. Please check!" )
199  endif()
200endif()
201
202if( NOT Boost_VERSION GREATER 103199 AND NOT CASA_IGNORE_VERSION )
203  message( FATAL_ERROR "Boost version (${Boost_VERSION}) is too old! Must be 103200 (1.32.0) or newer. Please check!" )
204endif()
205
206
207
208# include path
209message( STATUS "Boost_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
210include_directories( ${CASACORE_INCLUDE_DIR}
211                     ${Boost_INCLUDE_DIR}
212                     ${PYTHON_INCLUDE_DIR} )
213
214# link path
215set( CASACORE_LIBRARY_DIR ${casaroot}/${arch}/lib )
216link_directories( ${CASACORE_LIBRARY_DIR} )
217
218
219# install directory
220set( EXEC_INSTALL_DIR bin )
221set( LIB_INSTALL_DIR lib )
222set( PYTHON_INSTALL_DIR python/${PYVERSION}/asap )
223set( SHARED_INSTALL_DIR share/asap )
224
225# subdirectories
226#  asap2to3       apps
227#  libpyrap.so    external/libpyrap
228#  libatnf.so     external-alma/atnf
229#  _asap.so       src
230#  python modules python
231add_subdirectory( apps )
232add_subdirectory( external/libpyrap )
233add_subdirectory( external-alma/atnf )
234add_subdirectory( src )
235add_subdirectory( python )
236add_subdirectory( share )
237
238
Note: See TracBrowser for help on using the repository browser.