]> git.openstreetmap.org Git - nominatim.git/blob - CMakeLists.txt
Add optional compilation of osm2pgsl
[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 set(BUILD_DOCS on CACHE BOOL "Build documentation")
39 set(BUILD_SERVER on CACHE BOOL "Build API server")
40 set(BUILD_MODULE on CACHE BOOL "Build PostgreSQL module")
41 set(BUILD_NOMINATIM on CACHE BOOL "Build Nominatim executable")
42 set(BUILD_OSM2PGSQL on CACHE BOOL "Build osm2pgsql")
43
44 if (BUILD_SERVER)
45     if (BUILD_OSM2PGSQL)
46        if (NOT EXISTS "${CMAKE_SOURCE_DIR}/osm2pgsql/CMakeLists.txt")
47            message(FATAL_ERROR "The osm2pgsql directory is empty.\
48            Did you forget to check out Nominatim recursively?\
49            \nTry updating submodules with: git submodule update --init")
50        endif()
51        add_subdirectory(osm2pgsql)
52     endif()
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     # Setting PHP binary variable as to command line (prevailing) or auto detect
65     if (NOT PHP_BIN)
66          find_program (PHP_BIN php)
67     endif()
68     # sanity check if PHP binary exists
69     if (NOT EXISTS ${PHP_BIN})
70         message(FATAL_ERROR "PHP binary not found. Install php or provide location with -DPHP_BIN=/path/php ")
71     endif()
72     message (STATUS "Using PHP binary " ${PHP_BIN})
73 endif()
74
75 #-----------------------------------------------------------------------------
76 #
77 # Setup settings and paths
78 #
79 #-----------------------------------------------------------------------------
80
81 if (BUILD_SERVER)
82    set(WEBSITESCRIPTS
83        website/deletable.php
84        website/details.php
85        website/hierarchy.php
86        website/lookup.php
87        website/polygons.php
88        website/reverse.php
89        website/search.php
90        website/status.php
91    )
92
93    set(CUSTOMSCRIPTS
94        utils/country_languages.php
95        utils/importWikipedia.php
96        utils/export.php
97        utils/query.php
98        utils/setup.php
99        utils/specialphrases.php
100        utils/update.php
101        utils/warm.php
102       )
103
104    foreach (script_source ${CUSTOMSCRIPTS})
105        configure_file(${PROJECT_SOURCE_DIR}/cmake/script.tmpl
106                       ${PROJECT_BINARY_DIR}/${script_source})
107    endforeach()
108
109    foreach (script_source ${WEBSITESCRIPTS})
110        configure_file(${PROJECT_SOURCE_DIR}/cmake/website.tmpl
111                       ${PROJECT_BINARY_DIR}/${script_source})
112    endforeach()
113
114    configure_file(${PROJECT_SOURCE_DIR}/settings/defaults.php
115                   ${PROJECT_BINARY_DIR}/settings/settings.php)
116
117    set(WEBPATHS css images js)
118
119    foreach (wp ${WEBPATHS})
120        execute_process(
121            COMMAND ln -sf ${PROJECT_SOURCE_DIR}/website/${wp} ${PROJECT_BINARY_DIR}/website/
122        )
123    endforeach()
124 endif()
125
126 #-----------------------------------------------------------------------------
127 #
128 # Tests
129 #
130 #-----------------------------------------------------------------------------
131
132 if (BUILD_TESTS)
133     include(CTest)
134
135     set(TEST_BDD db osm2pgsql api)
136
137     foreach (test ${TEST_BDD})
138         add_test(NAME bdd_${test}
139                  COMMAND lettuce features/${test}
140                  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests)
141         set_tests_properties(bdd_${test}
142             PROPERTIES ENVIRONMENT "NOMINATIM_DIR=${PROJECT_BINARY_DIR}")
143     endforeach()
144
145     add_test(NAME php
146              COMMAND phpunit ./
147              WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests-php)
148 endif()
149
150 #-----------------------------------------------------------------------------
151
152 if (BUILD_MODULE)
153     add_subdirectory(module)
154 endif()
155 if (BUILD_NOMINATIM)
156     add_subdirectory(nominatim)
157 endif()
158 if (BUILD_DOCS)
159    add_subdirectory(docs)
160 endif()
161
162 #-----------------------------------------------------------------------------