]> 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 3)
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
39 if (NOT EXISTS "${CMAKE_SOURCE_DIR}/osm2pgsql/CMakeLists.txt")
40     message(FATAL_ERROR "The osm2pgsql directory is empty.\
41     Did you forget to check out Nominatim recursively?\
42     \nTry updating submodules with: git submodule update --init")
43 endif()
44 add_subdirectory(osm2pgsql)
45
46 find_package(Threads REQUIRED)
47
48 unset(PostgreSQL_TYPE_INCLUDE_DIR CACHE)
49 set(PostgreSQL_TYPE_INCLUDE_DIR "/usr/include/")
50 find_package(PostgreSQL REQUIRED)
51 include_directories(${PostgreSQL_INCLUDE_DIRS})
52 link_directories(${PostgreSQL_LIBRARY_DIRS})
53
54 find_program(PYOSMIUM pyosmium-get-changes)
55 if (NOT EXISTS "${PYOSMIUM}")
56     set(PYOSMIUM_PATH "")
57         message(WARNING "pyosmium-get-changes not found (required for updates)")
58 else()
59     set(PYOSMIUM_PATH "${PYOSMIUM}")
60     message(STATUS "Using pyosmium-get-changes at ${PYOSMIUM_PATH}")
61 endif()
62
63
64 find_program(PG_CONFIG pg_config)
65 execute_process(COMMAND ${PG_CONFIG} --pgxs
66                 OUTPUT_VARIABLE PGXS
67                 OUTPUT_STRIP_TRAILING_WHITESPACE)
68
69 if (NOT EXISTS "${PGXS}")
70     message(FATAL_ERROR "Postgresql server package not found.")
71 endif()
72
73 find_package(ZLIB REQUIRED)
74
75 find_package(BZip2 REQUIRED)
76
77 find_package(LibXml2 REQUIRED)
78 include_directories(${LIBXML2_INCLUDE_DIR})
79
80 # Setting PHP binary variable as to command line (prevailing) or auto detect
81 if (NOT PHP_BIN)
82      find_program (PHP_BIN php)
83 endif()
84 # sanity check if PHP binary exists
85 if (NOT EXISTS ${PHP_BIN})
86     message(FATAL_ERROR "PHP binary not found. Install php or provide location with -DPHP_BIN=/path/php ")
87 endif()
88 message (STATUS "Using PHP binary " ${PHP_BIN})
89
90 #-----------------------------------------------------------------------------
91 #
92 # Setup settings and paths
93 #
94 #-----------------------------------------------------------------------------
95
96 set(WEBSITESCRIPTS
97     website/deletable.php
98     website/details.php
99     website/hierarchy.php
100     website/lookup.php
101     website/polygons.php
102     website/reverse.php
103     website/search.php
104     website/status.php
105 )
106
107 set(WEBSITEFILES
108     403.html
109     509.html
110     crossdomain.xml
111     favicon.ico
112     nominatim.xml
113     robots.txt
114     taginfo.json
115 )
116
117 set(CUSTOMSCRIPTS
118     utils/country_languages.php
119     utils/importWikipedia.php
120     utils/export.php
121     utils/query.php
122     utils/setup.php
123     utils/specialphrases.php
124     utils/update.php
125     utils/warm.php
126    )
127
128 foreach (script_source ${CUSTOMSCRIPTS})
129     configure_file(${PROJECT_SOURCE_DIR}/cmake/script.tmpl
130                    ${PROJECT_BINARY_DIR}/${script_source})
131 endforeach()
132
133 foreach (script_source ${WEBSITESCRIPTS})
134     configure_file(${PROJECT_SOURCE_DIR}/cmake/website.tmpl
135                    ${PROJECT_BINARY_DIR}/${script_source})
136 endforeach()
137
138 foreach (webfile ${WEBSITEFILES})
139     configure_file(${PROJECT_SOURCE_DIR}/website/${webfile}
140                    ${PROJECT_BINARY_DIR}/website/${webfile})
141 endforeach()
142
143 configure_file(${PROJECT_SOURCE_DIR}/settings/defaults.php
144                ${PROJECT_BINARY_DIR}/settings/settings.php)
145
146 set(WEBPATHS css images js)
147
148 foreach (wp ${WEBPATHS})
149     execute_process(
150         COMMAND ln -sf ${PROJECT_SOURCE_DIR}/website/${wp} ${PROJECT_BINARY_DIR}/website/
151     )
152 endforeach()
153
154
155 #-----------------------------------------------------------------------------
156 #
157 # Tests
158 #
159 #-----------------------------------------------------------------------------
160
161 include(CTest)
162
163 set(TEST_BDD db osm2pgsql api)
164
165 foreach (test ${TEST_BDD})
166     add_test(NAME bdd_${test}
167              COMMAND lettuce features/${test}
168              WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests)
169     set_tests_properties(bdd_${test}
170         PROPERTIES ENVIRONMENT "NOMINATIM_DIR=${PROJECT_BINARY_DIR}")
171 endforeach()
172
173 add_test(NAME php
174          COMMAND phpunit ./
175          WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests-php)
176
177 #-----------------------------------------------------------------------------
178
179 add_subdirectory(module)
180 add_subdirectory(nominatim)
181 add_subdirectory(docs)
182
183 #-----------------------------------------------------------------------------