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