1 | ###
|
---|
2 | # CMakeLists.txt for ASAP module
|
---|
3 | ###
|
---|
4 |
|
---|
5 | # minimum requirement for cmake version
|
---|
6 | cmake_minimum_required( VERSION 2.8 )
|
---|
7 |
|
---|
8 | # project name is ASAP
|
---|
9 | project( 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
|
---|
18 | string( REGEX REPLACE /[^/]+/?$ "" casaroot ${CMAKE_SOURCE_DIR} )
|
---|
19 | message( STATUS "casaroot = " ${casaroot} )
|
---|
20 |
|
---|
21 | # flags
|
---|
22 | set( DEFAULT_CXX_FLAGS
|
---|
23 | "-pipe -Wall -Wextra -Wno-non-template-friend -Wcast-align -Wno-comment" )
|
---|
24 | find_package( OpenMP )
|
---|
25 | if( OPENMP_FOUND )
|
---|
26 | set( DEFAULT_CXX_FLAGS "${DEFAULT_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
|
---|
27 | endif()
|
---|
28 |
|
---|
29 | # environment dependent settings
|
---|
30 | if( 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()
|
---|
62 | elseif( 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()
|
---|
79 | endif()
|
---|
80 | message( STATUS "arch = " ${arch} )
|
---|
81 |
|
---|
82 | # set root directory for installation
|
---|
83 | set( CMAKE_INSTALL_PREFIX ${casaroot}/${arch} )
|
---|
84 | message( STATUS "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX} )
|
---|
85 |
|
---|
86 | # set flags for cpp compiler
|
---|
87 | set( CMAKE_CXX_FLAGS ${DEFAULT_CXX_FLAGS} )
|
---|
88 |
|
---|
89 | #
|
---|
90 | # casacore
|
---|
91 | #
|
---|
92 | set( CASACORE_INCLUDE_DIR ${casaroot}/${arch}/include/casacore )
|
---|
93 |
|
---|
94 | set( CASACORE_LIBS casa
|
---|
95 | components
|
---|
96 | coordinates
|
---|
97 | fits
|
---|
98 | images
|
---|
99 | lattices
|
---|
100 | measures
|
---|
101 | mirlib
|
---|
102 | ms
|
---|
103 | msfits
|
---|
104 | scimath
|
---|
105 | scimath_f
|
---|
106 | tables )
|
---|
107 | set( _casacore_libs "" )
|
---|
108 | foreach( _a ${CASACORE_LIBS} )
|
---|
109 | set( _libname libcasa_${_a}.${SO} )
|
---|
110 | unset( _casacore_lib CACHE )
|
---|
111 | find_library( _casacore_lib ${_libname}
|
---|
112 | PATHS ${CMAKE_INSTALL_PREFIX} PATH_SUFFIXES lib )
|
---|
113 | if( NOT _casacore_lib-NOTFOUND )
|
---|
114 | list( APPEND _casacore_libs casa_${_a} )
|
---|
115 | endif()
|
---|
116 | endforeach()
|
---|
117 | set( CASACORE_LIBRARIES ${_casacore_libs} )
|
---|
118 | message( STATUS "CASACORE_LIBRARIES = " ${CASACORE_LIBRARIES} )
|
---|
119 |
|
---|
120 | #
|
---|
121 | # Python
|
---|
122 | #
|
---|
123 | # tentative
|
---|
124 | set( PYVERSION 2.6 )
|
---|
125 | if (NOT PYTHON_ROOT )
|
---|
126 | set( PYTHON_ROOT ${casa_packages} )
|
---|
127 | endif()
|
---|
128 | find_package( PythonLibs REQUIRED python${PYVERSION} )
|
---|
129 |
|
---|
130 | if( NOT PYTHONLIBS_FOUND )
|
---|
131 | message( FATAL_ERROR "Python could not be found. Please check!" )
|
---|
132 | endif()
|
---|
133 | message( STATUS "PYTHON_INCLUDE_PATH = " ${PYTHON_INCLUDE_PATH} )
|
---|
134 | message( STATUS "PYTHON_LIBRARIES = " ${PYTHON_LIBRARIES} )
|
---|
135 |
|
---|
136 | set( PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_PATH} )
|
---|
137 | find_path( NUMPY_INC_DIR numpy/npy_interrupt.h
|
---|
138 | PATHS ${casa_packages}/lib/python${PYVERSION}/site-packages/numpy/core/include )
|
---|
139 | message( STATUS "NUMPY_INC_DIR = " ${NUMPY_INC_DIR} )
|
---|
140 | if( NOT NUMPY_INC_DIR STREQUAL NUMPY_INC_DIR-NOTFOUND )
|
---|
141 | list( APPEND PYTHON_INCLUDE_DIR ${NUMPY_INC_DIR} )
|
---|
142 | endif()
|
---|
143 | message( STATUS "PYTHON_INCLUDE_DIR = " ${PYTHON_INCLUDE_DIR} )
|
---|
144 |
|
---|
145 | #
|
---|
146 | # Boost
|
---|
147 | #
|
---|
148 | if( NOT BOOST_ROOT )
|
---|
149 | set( BOOST_ROOT ${casa_packages} )
|
---|
150 | endif()
|
---|
151 |
|
---|
152 | set( boost_components regex program_options filesystem )
|
---|
153 | find_package( Boost REQUIRED ${boost_components} )
|
---|
154 |
|
---|
155 | if( NOT Boost_FOUND )
|
---|
156 | message( FATAL_ERROR "Boost could not be found. Please check!" )
|
---|
157 | endif()
|
---|
158 |
|
---|
159 | # For boost >= 1.35, we need to link also to boost-system
|
---|
160 | if( Boost_VERSION GREATER 103499 )
|
---|
161 |
|
---|
162 | # Force redetection by resetting these variables
|
---|
163 | if( NOT Boost_SYSTEM_FOUND )
|
---|
164 | message( STATUS "Boost version (${Boost_VERSION}) is 1.35.0 or newer" )
|
---|
165 | unset( Boost_FOUND )
|
---|
166 | unset( Boost_INCLUDE_DIR CACHE )
|
---|
167 | endif()
|
---|
168 | set( boost_components regex program_options filesystem system )
|
---|
169 | find_package( Boost REQUIRED ${boost_components} )
|
---|
170 |
|
---|
171 | if( NOT Boost_FOUND )
|
---|
172 | message( FATAL_ERROR "Boost-system could not be found. Please check!" )
|
---|
173 | endif()
|
---|
174 | endif()
|
---|
175 |
|
---|
176 | if( NOT Boost_VERSION GREATER 103199 AND NOT CASA_IGNORE_VERSION )
|
---|
177 | message( FATAL_ERROR "Boost version (${Boost_VERSION}) is too old! Must be 103200 (1.32.0) or newer. Please check!" )
|
---|
178 | endif()
|
---|
179 |
|
---|
180 |
|
---|
181 |
|
---|
182 | # include path
|
---|
183 | message( STATUS "Boost_INCLUDE_DIR = " ${Boost_INCLUDE_DIR} )
|
---|
184 | include_directories( ${CASACORE_INCLUDE_DIR}
|
---|
185 | ${Boost_INCLUDE_DIR}
|
---|
186 | ${PYTHON_INCLUDE_DIR} )
|
---|
187 |
|
---|
188 | # link path
|
---|
189 | set( CASACORE_LIBRARY_DIR ${casaroot}/${arch}/lib )
|
---|
190 | link_directories( ${CASACORE_LIBRARY_DIR} )
|
---|
191 |
|
---|
192 |
|
---|
193 | # install directory
|
---|
194 | set( EXEC_INSTALL_DIR bin )
|
---|
195 | set( LIB_INSTALL_DIR lib )
|
---|
196 | set( PYTHON_INSTALL_DIR python/${PYVERSION}/asap )
|
---|
197 | set( SHARED_INSTALL_DIR share/asap )
|
---|
198 |
|
---|
199 | # subdirectories
|
---|
200 | # asap2to3 apps
|
---|
201 | # libpyrap.so external/libpyrap
|
---|
202 | # libatnf.so external-alma/atnf
|
---|
203 | # _asap.so src
|
---|
204 | # python modules python
|
---|
205 | add_subdirectory( apps )
|
---|
206 | add_subdirectory( external/libpyrap )
|
---|
207 | add_subdirectory( external-alma/atnf )
|
---|
208 | add_subdirectory( src )
|
---|
209 | add_subdirectory( python )
|
---|
210 | add_subdirectory( share )
|
---|
211 |
|
---|
212 |
|
---|