]> git.openstreetmap.org Git - nominatim.git/blob - CMakeLists.txt
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / CMakeLists.txt
1 #-----------------------------------------------------------------------------
2 #
3 #  CMake Config
4 #
5 #  Nominatim
6 #
7 #-----------------------------------------------------------------------------
8
9 cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
10 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
11
12
13 #-----------------------------------------------------------------------------
14 #
15 #  Project version
16 #
17 #-----------------------------------------------------------------------------
18
19 project(nominatim)
20
21 set(NOMINATIM_VERSION_MAJOR 3)
22 set(NOMINATIM_VERSION_MINOR 4)
23 set(NOMINATIM_VERSION_PATCH 0)
24
25 set(NOMINATIM_VERSION "${NOMINATIM_VERSION_MAJOR}.${NOMINATIM_VERSION_MINOR}.${NOMINATIM_VERSION_PATCH}")
26
27 add_definitions(-DNOMINATIM_VERSION="${NOMINATIM_VERSION}")
28
29
30 #-----------------------------------------------------------------------------
31 #
32 #  Find external dependencies
33 #
34 #-----------------------------------------------------------------------------
35
36 set(BUILD_TESTS off CACHE BOOL "Build test suite" FORCE)
37 set(WITH_LUA off CACHE BOOL "Build with lua support" FORCE)
38 set(ONLY_DOCS off CACHE BOOL "Build documentation only")
39
40 if (NOT ONLY_DOCS)
41     if (NOT EXISTS "${CMAKE_SOURCE_DIR}/osm2pgsql/CMakeLists.txt")
42         message(FATAL_ERROR "The osm2pgsql directory is empty.\
43         Did you forget to check out Nominatim recursively?\
44         \nTry updating submodules with: git submodule update --init")
45     endif()
46     add_subdirectory(osm2pgsql)
47
48     find_package(Threads REQUIRED)
49
50     unset(PostgreSQL_TYPE_INCLUDE_DIR CACHE)
51     set(PostgreSQL_TYPE_INCLUDE_DIR "/usr/include/")
52     find_package(PostgreSQL REQUIRED)
53     include_directories(${PostgreSQL_INCLUDE_DIRS})
54     link_directories(${PostgreSQL_LIBRARY_DIRS})
55
56     find_program(PYOSMIUM pyosmium-get-changes)
57     if (NOT EXISTS "${PYOSMIUM}")
58         set(PYOSMIUM_PATH "")
59             message(WARNING "pyosmium-get-changes not found (required for updates)")
60     else()
61         set(PYOSMIUM_PATH "${PYOSMIUM}")
62         message(STATUS "Using pyosmium-get-changes at ${PYOSMIUM_PATH}")
63     endif()
64
65
66     find_program(PG_CONFIG pg_config)
67     execute_process(COMMAND ${PG_CONFIG} --pgxs
68                     OUTPUT_VARIABLE PGXS
69                     OUTPUT_STRIP_TRAILING_WHITESPACE)
70
71     if (NOT EXISTS "${PGXS}")
72         message(FATAL_ERROR "Postgresql server package not found.")
73     endif()
74
75     find_package(ZLIB REQUIRED)
76
77     find_package(BZip2 REQUIRED)
78
79     find_package(LibXml2 REQUIRED)
80     include_directories(${LIBXML2_INCLUDE_DIR})
81
82     # Setting PHP binary variable as to command line (prevailing) or auto detect
83     if (NOT PHP_BIN)
84          find_program (PHP_BIN php)
85     endif()
86     # sanity check if PHP binary exists
87     if (NOT EXISTS ${PHP_BIN})
88         message(FATAL_ERROR "PHP binary not found. Install php or provide location with -DPHP_BIN=/path/php ")
89     endif()
90     message (STATUS "Using PHP binary " ${PHP_BIN})
91 endif()
92
93 #-----------------------------------------------------------------------------
94 #
95 # Setup settings and paths
96 #
97 #-----------------------------------------------------------------------------
98
99 set(WEBSITESCRIPTS
100     website/deletable.php
101     website/details.php
102     website/hierarchy.php
103     website/lookup.php
104     website/polygons.php
105     website/reverse.php
106     website/search.php
107     website/status.php
108 )
109
110 set(WEBSITEFILES
111     403.html
112     509.html
113     crossdomain.xml
114     favicon.ico
115     nominatim.xml
116     robots.txt
117     taginfo.json
118 )
119
120 set(CUSTOMSCRIPTS
121     utils/country_languages.php
122     utils/importWikipedia.php
123     utils/export.php
124     utils/query.php
125     utils/setup.php
126     utils/specialphrases.php
127     utils/update.php
128     utils/warm.php
129    )
130
131 foreach (script_source ${CUSTOMSCRIPTS})
132     configure_file(${PROJECT_SOURCE_DIR}/cmake/script.tmpl
133                    ${PROJECT_BINARY_DIR}/${script_source})
134 endforeach()
135
136 foreach (script_source ${WEBSITESCRIPTS})
137     configure_file(${PROJECT_SOURCE_DIR}/cmake/website.tmpl
138                    ${PROJECT_BINARY_DIR}/${script_source})
139 endforeach()
140
141 foreach (webfile ${WEBSITEFILES})
142     configure_file(${PROJECT_SOURCE_DIR}/website/${webfile}
143                    ${PROJECT_BINARY_DIR}/website/${webfile})
144 endforeach()
145
146 configure_file(${PROJECT_SOURCE_DIR}/settings/defaults.php
147                ${PROJECT_BINARY_DIR}/settings/settings.php)
148
149 set(WEBPATHS css images js)
150
151 foreach (wp ${WEBPATHS})
152     execute_process(
153         COMMAND ln -sf ${PROJECT_SOURCE_DIR}/website/${wp} ${PROJECT_BINARY_DIR}/website/
154     )
155 endforeach()
156
157
158 #-----------------------------------------------------------------------------
159 #
160 # Tests
161 #
162 #-----------------------------------------------------------------------------
163
164 if (NOT ONLY_DOCS)
165     include(CTest)
166
167     set(TEST_BDD db osm2pgsql api)
168
169     foreach (test ${TEST_BDD})
170         add_test(NAME bdd_${test}
171                  COMMAND lettuce features/${test}
172                  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests)
173         set_tests_properties(bdd_${test}
174             PROPERTIES ENVIRONMENT "NOMINATIM_DIR=${PROJECT_BINARY_DIR}")
175     endforeach()
176
177     add_test(NAME php
178              COMMAND phpunit ./
179              WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests-php)
180 endif()
181
182 #-----------------------------------------------------------------------------
183
184 if (NOT ONLY_DOCS)
185     add_subdirectory(module)
186     add_subdirectory(nominatim)
187 endif()
188 add_subdirectory(docs)
189
190 #-----------------------------------------------------------------------------