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