1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.3) |
---|
2 | PROJECT(PGROUTING) |
---|
3 | |
---|
4 | #----------------------------------------------------------------------------- |
---|
5 | # PGROUTING version number. |
---|
6 | SET(PGROUTING_VERSION_MAJOR "1") |
---|
7 | SET(PGROUTING_VERSION_MINOR "0") |
---|
8 | SET(PGROUTING_VERSION_PATCH "1") |
---|
9 | |
---|
10 | SET(PGROUTING_VERSION_STRING "${PGROUTING_VERSION_MAJOR}.${PGROUTING_VERSION_MINOR}.${PGROUTING_VERSION_PATCH}") |
---|
11 | |
---|
12 | add_subdirectory(cmake) |
---|
13 | SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") |
---|
14 | |
---|
15 | include (MacroLibrary) |
---|
16 | |
---|
17 | macro_optional_find_package(PostgreSQL) |
---|
18 | IF(NOT POSTGRESQL_FOUND) |
---|
19 | MESSAGE(FATAL ERROR " Please check your Boost installation.") |
---|
20 | ENDIF(NOT POSTGRESQL_FOUND) |
---|
21 | |
---|
22 | FIND_PACKAGE(Boost) |
---|
23 | IF(Boost_INCLUDE_DIRS) |
---|
24 | MESSAGE("Boost headers were found here: ${Boost_INCLUDE_DIR}") |
---|
25 | ELSE(Boost_INCLUDE_DIRS) |
---|
26 | MESSAGE(FATAL ERROR " Please check your Boost installation ") |
---|
27 | ENDIF(Boost_INCLUDE_DIRS) |
---|
28 | |
---|
29 | EXEC_PROGRAM(pg_config |
---|
30 | ARGS --pkglibdir |
---|
31 | OUTPUT_VARIABLE LIB_DIR) |
---|
32 | |
---|
33 | IF(LIB_DIR) |
---|
34 | MESSAGE("Output directory for libraries is set to ${LIB_DIR}") |
---|
35 | ELSE(LIB_DIR) |
---|
36 | SET(LIB_DIR ${PGROUTING_BINARY_DIR}/lib) |
---|
37 | MESSAGE("pg_config not found, output directory for libraries is set to ${PGROUTING_BINARY_DIR}/lib") |
---|
38 | ENDIF(LIB_DIR) |
---|
39 | |
---|
40 | if(PGROUTING_CORE_INCLUDE_DIR) |
---|
41 | set(PGROUTING_CORE_FOUND TRUE) |
---|
42 | |
---|
43 | else(PGROUTING_CORE_INCLUDE_DIR) |
---|
44 | FIND_PATH(PGROUTING_CORE_INCLUDE_DIR dijkstra.h |
---|
45 | PATHS |
---|
46 | ${CMAKE_CURRENT_SOURCE_DIR}/core/src |
---|
47 | ) |
---|
48 | |
---|
49 | if(PGROUTING_CORE_INCLUDE_DIR) |
---|
50 | set(PGROUTING_CORE_FOUND TRUE) |
---|
51 | message(STATUS "Found PGROUTING_CORE core: ${PGROUTING_CORE_INCLUDE_DIR}") |
---|
52 | INCLUDE_DIRECTORIES(${PGROUTING_CORE_INCLUDE_DIR}) |
---|
53 | else(PGROUTING_CORE_INCLUDE_DIR) |
---|
54 | set(PGROUTING_CORE_FOUND FALSE) |
---|
55 | message(STATUS "PGROUTING_CORE core not found.") |
---|
56 | endif(PGROUTING_CORE_INCLUDE_DIR) |
---|
57 | |
---|
58 | mark_as_advanced(PGROUTING_CORE_INCLUDE_DIR) |
---|
59 | |
---|
60 | endif(PGROUTING_CORE_INCLUDE_DIR) |
---|
61 | |
---|
62 | OPTION(WITH_TSP "Build TSP library" OFF) |
---|
63 | OPTION(WITH_DD "Build Driving distance library" OFF) |
---|
64 | |
---|
65 | IF(UNIX) |
---|
66 | SET(LIBRARY_INSTALL_PATH ${LIB_DIR}) |
---|
67 | SET(SQL_INSTALL_PATH /usr/share/postlbs) |
---|
68 | MESSAGE("Installation directory for libraries is set to ${LIBRARY_INSTALL_PATH} and for SQL files is set to ${SQL_INSTALL_PATH}") |
---|
69 | ELSE(UNIX) |
---|
70 | SET(LIBRARY_INSTALL_PATH ${PGROUTING_BINARY_DIR}/lib) |
---|
71 | SET(SQL_INSTALL_PATH ${PGROUTING_BINARY_DIR}/lib) |
---|
72 | ENDIF(UNIX) |
---|
73 | |
---|
74 | SET(PGROUTING_INCLUDE_DIRECTORIES ${PGROUTING_SOURCE_DIR}/core ${PGROUTING_SOURCE_DIR}/core/src ${PGROUTING_SOURCE_DIR}/extra ${PGROUTING_SOURCE_DIR}/extra/tsp ${PGROUTING_SOURCE_DIR}/extra/tsp/src ${PGROUTING_SOURCE_DIR}/extra/driving_distance ${PGROUTING_SOURCE_DIR}/extra/driving_distance/src |
---|
75 | ) |
---|
76 | |
---|
77 | INCLUDE_DIRECTORIES(. ${PGROUTING_INCLUDE_DIRECTORIES} ${POSTGRESQL_INCLUDE_DIR} ${Boost_INCLUDE_DIRS}) |
---|
78 | IF(WIN32) |
---|
79 | INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${POSTGRESQL_INCLUDE_DIR}/port/win32) |
---|
80 | ENDIF(WIN32) |
---|
81 | |
---|
82 | # we need link libpostgres.a on win32 env |
---|
83 | IF(WIN32) |
---|
84 | LINK_DIRECTORIES(${LIB_DIR}) |
---|
85 | LINK_LIBRARIES(postgres) |
---|
86 | ENDIF(WIN32) |
---|
87 | |
---|
88 | SET(CMAKE_C_FLAGS "-O2 -g") |
---|
89 | SET(CMAKE_CXX_FLAGS "-O2 -g") |
---|
90 | |
---|
91 | # Recurse into the subdirectories. This does not actually |
---|
92 | # cause another cmake executable to run. The same process will walk through |
---|
93 | # the project's entire directory structure. |
---|
94 | SUBDIRS(core) |
---|
95 | |
---|
96 | IF(WITH_TSP) |
---|
97 | macro_optional_find_package(GAUL) |
---|
98 | IF(NOT GAUL_FOUND) |
---|
99 | message(FATAL ERROR " Please check your gaul installation, or set correct path to GAUL_INCLUDE_DIR and GAUL_LIBRARIES.") |
---|
100 | ENDIF(NOT GAUL_FOUND) |
---|
101 | INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${GAUL_INCLUDE_DIR}) |
---|
102 | ADD_SUBDIRECTORY(extra/tsp) |
---|
103 | ENDIF(WITH_TSP) |
---|
104 | |
---|
105 | IF(WITH_DD) |
---|
106 | macro_optional_find_package(CGAL) |
---|
107 | IF(NOT CGAL_FOUND) |
---|
108 | message(FATAL ERROR " Please check your CGAL installation, or set correct path to CGAL_INCLUDE_DIR and CGAL_LIBRARIES.") |
---|
109 | ENDIF(NOT CGAL_FOUND) |
---|
110 | INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${CGAL_INCLUDE_DIR}) |
---|
111 | ADD_SUBDIRECTORY(extra/driving_distance) |
---|
112 | ENDIF(WITH_DD) |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | |
---|