]> 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     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_package(PythonInterp 3)
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     # Setting PHP binary variable as to command line (prevailing) or auto detect
76     if (NOT PHP_BIN)
77          find_program (PHP_BIN php)
78     endif()
79     # sanity check if PHP binary exists
80     if (NOT EXISTS ${PHP_BIN})
81         message(FATAL_ERROR "PHP binary not found. Install php or provide location with -DPHP_BIN=/path/php ")
82     endif()
83     message (STATUS "Using PHP binary " ${PHP_BIN})
84 endif()
85
86 #-----------------------------------------------------------------------------
87 #
88 # Setup settings and paths
89 #
90 #-----------------------------------------------------------------------------
91
92 set(WEBSITESCRIPTS
93     website/deletable.php
94     website/details.php
95     website/hierarchy.php
96     website/lookup.php
97     website/polygons.php
98     website/reverse.php
99     website/search.php
100     website/status.php
101 )
102
103 set(WEBSITEFILES
104     403.html
105     509.html
106     crossdomain.xml
107     favicon.ico
108     nominatim.xml
109     robots.txt
110     taginfo.json
111 )
112
113 set(CUSTOMSCRIPTS
114     utils/check_import_finished.php
115     utils/country_languages.php
116     utils/export.php
117     utils/query.php
118     utils/setup.php
119     utils/specialphrases.php
120     utils/update.php
121     utils/warm.php
122    )
123
124 foreach (script_source ${CUSTOMSCRIPTS})
125     configure_file(${PROJECT_SOURCE_DIR}/cmake/script.tmpl
126                    ${PROJECT_BINARY_DIR}/${script_source})
127 endforeach()
128
129 foreach (script_source ${WEBSITESCRIPTS})
130     configure_file(${PROJECT_SOURCE_DIR}/cmake/website.tmpl
131                    ${PROJECT_BINARY_DIR}/${script_source})
132 endforeach()
133
134 foreach (webfile ${WEBSITEFILES})
135     configure_file(${PROJECT_SOURCE_DIR}/website/${webfile}
136                    ${PROJECT_BINARY_DIR}/website/${webfile})
137 endforeach()
138
139 configure_file(${PROJECT_SOURCE_DIR}/settings/defaults.php
140                ${PROJECT_BINARY_DIR}/settings/settings.php)
141
142 set(WEBPATHS css images js)
143
144 foreach (wp ${WEBPATHS})
145     execute_process(
146         COMMAND ln -sf ${PROJECT_SOURCE_DIR}/website/${wp} ${PROJECT_BINARY_DIR}/website/
147     )
148 endforeach()
149
150
151 #-----------------------------------------------------------------------------
152 #
153 # Tests
154 #
155 #-----------------------------------------------------------------------------
156
157 if (NOT ONLY_DOCS)
158     include(CTest)
159
160     set(TEST_BDD db osm2pgsql api)
161
162     foreach (test ${TEST_BDD})
163         add_test(NAME bdd_${test}
164                  COMMAND lettuce features/${test}
165                  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests)
166         set_tests_properties(bdd_${test}
167             PROPERTIES ENVIRONMENT "NOMINATIM_DIR=${PROJECT_BINARY_DIR}")
168     endforeach()
169
170     add_test(NAME php
171              COMMAND phpunit ./
172              WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests-php)
173 endif()
174
175 #-----------------------------------------------------------------------------
176
177 if (NOT ONLY_DOCS)
178     add_subdirectory(module)
179 endif()
180 add_subdirectory(docs)
181
182 #-----------------------------------------------------------------------------