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