CMakeLists.txt 21 KB
Newer Older
1 2 3 4
#
# Format convention
# - command (lower case)
# - VARIABLE (upper case)
5
# (http://www.cmake.org/cmake/help/v2.8.12/cmake.html)
6 7
#

8
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
9

10 11 12 13 14 15 16 17 18 19
if(POLICY CMP0046)
    cmake_policy(SET CMP0046 OLD)
endif()

if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
        message(FATAL_ERROR "In-source builds not allowed.
        Please make a new directory (called a build directory) and run CMake from there.
        You may need to remove CMakeCache.txt." )
endif()

20 21 22 23
#---------------------------------------------
# Setting kind of build
#---------------------------------------------
#
24 25
# for developing
# cmake -DMAKE_BUILD_TYPE=Develop
26 27 28
#----------------------

message(STATUS "CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
29 30 31 32 33 34
if (CMAKE_BUILD_TYPE MATCHES Develop)
    set(CMAKE_BUILD_TYPE Debug CACHE STRING
        "Choose the type of build, options are: None Debug Release RelWithDebInfo
        MinSizeRel."
        FORCE)
    set(WITH_INTERNAL_TESTS)
35 36 37 38 39 40 41 42
endif()
message(STATUS "CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")


#---------------------------------------------
#---------------------------------------------
#---------------------------------------------

43 44
project(PGROUTING)

45 46 47 48
#---------------------------------------------
#---------------------------------------------
#---------------------------------------------

49 50
if(POLICY CMP0054)
   cmake_policy(SET CMP0054 OLD)
51 52 53 54 55 56 57 58 59
endif()

if(MSVC)
    cmake_policy(SET CMP0046 OLD)
endif()

#=============================================
# Set the working directories
#=============================================
60

61 62 63 64 65 66 67 68
#---------------------------------------------
#  PgRouting_SOURCE_NAMES
#---------------------------------------------
#
# Name of the directories that have C/C++ code
#  - <directory>/src/CMakelists.txt must exist
#  - <directory>/sql/CMakeLists.txt  must exist
#----------------------
69 70 71 72
configure_file("configuration.conf" "configuration.conf")
file(STRINGS configuration.conf PgRouting_CONFIGURATION_FILE)

set(PgRouting_SOURCE_NAMES "")
73 74
set(PgRouting_SQL_DIRECTORIES "")
set(PgRouting_DOC_DIRECTORIES "")
75
foreach(line ${PgRouting_CONFIGURATION_FILE})
76
    string(REGEX REPLACE "^(#).*" "\\1" comment ${line})
77 78 79 80 81 82 83
    if("${comment}" MATCHES "#")
        continue()
    endif()
    string(REGEX REPLACE "^(.*)\\|(.*)\\|(.*)\\|(.*)" "\\1" directory ${line})
    string(REGEX REPLACE "^(.*)\\|(.*)\\|(.*)\\|(.*)" "\\2" has_code ${line})
    string(REGEX REPLACE "^(.*)\\|(.*)\\|(.*)\\|(.*)" "\\3" has_sql ${line})
    string(REGEX REPLACE "^(.*)\\|(.*)\\|(.*)\\|(.*)" "\\4" has_doc ${line})
84

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
    string(STRIP ${directory} directory)
    string(STRIP ${has_code} has_code)
    string(STRIP ${has_sql} has_sql)
    string(STRIP ${has_doc} has_doc)


    if( ${has_code} MATCHES "Y")
        list(APPEND PgRouting_SOURCE_NAMES "${directory}")
    endif()
    if( ${has_sql} MATCHES "Y")
        list(APPEND PgRouting_SQL_DIRECTORIES "${directory}")
    endif()
    if( ${has_doc} MATCHES "Y")
        list(APPEND PgRouting_DOC_DIRECTORIES "${directory}")
    endif()
endforeach()

if (PGROUTING_DEBUG)
    message(STATUS "${PgRouting_SOURCE_NAMES}")
    message(STATUS "${PgRouting_SQL_DIRECTORIES}")
    message(STATUS "${PgRouting_DOC_DIRECTORIES}")
endif()
107 108


109

110 111 112
#---------------------------------------------
# minimum versions
#---------------------------------------------
113
set(DOXYGEN_MINIMUM_VERSION "1.7")
114
set(SPHINX_MINIMUM_VERSION "1.1")
115
set(POSTGRESQL_MINIMUM_VERSION "9.2.0")
116
set(BOOST_MINIMUM_VERSION "1.53")
117 118 119 120
set(CGAL_CXX_MINIMUM_VERSION "4.4")
set(POSTGIS_MINIMUM_VERSION "2.0.0")
set(GNU_CXX_MINIMUM_VERSION "4.6")
set(MSVC_CXX_MINIMUM_VERSION "18.0")
121 122 123

message(STATUS "DOXYGEN_MINIMUM_VERSION=${DOXYGEN_MINIMUM_VERSION}")
message(STATUS "SPHINX_MINIMUM_VERSION=${SPHINX_MINIMUM_VERSION}")
124 125 126 127 128
message(STATUS "POSTGRESQL_MINIMUM_VERSION=${POSTGRESQL_MINIMUM_VERSION}")
message(STATUS "POSTGIS_MINIMUM_VERSION=${POSTGIS_MINIMUM_VERSION}")
message(STATUS "GNU_CXX_MINIMUM_VERSION=${GNU_CXX_MINIMUM_VERSION}")
message(STATUS "CLANG_CXX_MINIMUM_VERSION=${CLANG_CXX_MINIMUM_VERSION}")
message(STATUS "MSVC_CXX_MINIMUM_VERSION=${MSVC_CXX_MINIMUM_VERSION}")
129 130 131


#---------------------------------------------
132
# adding cmake modules
133 134
#---------------------------------------------

135 136 137 138 139 140 141 142 143 144 145
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
foreach(dir ${CMAKE_MODULE_PATH})
    message(STATUS "dir='${dir}'")
endforeach()

include(MacroLibrary)
include(TargetDistclean)

#---------------------------------------------
# C++ Compiler requirements
#---------------------------------------------
146 147 148

include(CheckCXXCompilerFlag)

149 150 151 152
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS GNU_CXX_MINIMUM_VERSION)
153 154
        message(FATAL_ERROR "GCC version must be at least ${GNU_CXX_MINIMUM_VERSION}!
        Found version ${CMAKE_CXX_COMPILER_VERSION}")
155 156 157 158
    endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS MSVC_CXX_MINIMUM_VERSION)
        message(FATAL_ERROR "MSVC version must be at least ${MSVC_CXX_MINIMUM_VERSION}!")
159
    endif()
160 161
else()
    message(STATUS "Unknown compiler minimum version for ${CMAKE_CXX_COMPILER_ID}")
162
endif()
163

164 165
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
166
    message(STATUS "Using  -std=c++11.")
167 168
elseif(COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
169
    message(STATUS "Using  -std=c++0x.")
170 171 172
else()
    message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++0x or C++11 flags support.")
endif()
173

174

175 176 177 178 179 180 181
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# PGROUTING version variables
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
182

183
set(PGROUTING_VERSION_MAJOR "2")
184
set(PGROUTING_VERSION_MINOR "6")
185
set(PGROUTING_VERSION_PATCH "1")
186
set(PGROUTING_VERSION_DEV "")
187

188 189 190
set(PGROUTING_SHORT_VERSION "${PGROUTING_VERSION_MAJOR}.${PGROUTING_VERSION_MINOR}")
set(PGROUTING_VERSION "${PGROUTING_VERSION_MAJOR}.${PGROUTING_VERSION_MINOR}.${PGROUTING_VERSION_PATCH}")
set(PGROUTING_FULL_VERSION "v${PGROUTING_VERSION}${PGROUTING_VERSION_DEV}")
191 192


193 194 195 196
#---------------------------------------------
# Variables used in pgr_version()
#---------------------------------------------
file(STRINGS "${PGROUTING_SOURCE_DIR}/VERSION" PGROUTING_BUILD_STRING)
197

198
set(PGROUTING_GIT_HASH "")
199 200 201
string(REGEX REPLACE "^([0-9]+)-([0-9a-f]+) (.*)$" "\\2" PGROUTING_GIT_HASH ${PGROUTING_BUILD_STRING})
string(REGEX REPLACE "^([0-9]+)-([0-9a-f]+) (.*)$" "\\3" PGROUTING_GIT_BRANCH ${PGROUTING_BUILD_STRING})

202 203 204 205
#if (NOT "${PGROUTING_GIT_BRANCH}" STREQUAL "master")
#    set (PGROUTING_GIT_HASH  "")
#    set (PGROUTING_GIT_BRANCH  "")
#endif()
206

207 208 209 210 211 212 213 214 215 216 217 218

if (PGROUTING_DEBUG)
    message(STATUS "PGROUTING_VERSION: ${PGROUTING_FULL_VERSION}")
    message(STATUS "PGROUTING_SHORT_VERSION: ${PGROUTING_FULL_VERSION}")
    message(STATUS "PGROUTING_FULL_VERSION: ${PGROUTING_FULL_VERSION}")
    message(STATUS "VERSION file contents: ${PGROUTING_BUILD_STRING}")
    message(STATUS "PGROUTING_GIT_HASH: ${PGROUTING_GIT_HASH}")
    message(STATUS "PGROUTING_GIT_BRANCH: ${PGROUTING_GIT_BRANCH}")
    message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
    message(STATUS "PGROUTING_SOURCE_DIR: ${PGROUTING_SOURCE_DIR}")
    message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
endif()
219

220 221 222 223 224 225
#----------------------
# PGROUTING library name used in the pgr_functions
#  '$libdir/${PGROUTING_LIBRARY_NAME}'
#----------------------
set(PGROUTING_LIBRARY_NAME "libpgrouting-${PGROUTING_SHORT_VERSION}")

226

227
#-----------------------------------------------------------------------------
228 229 230 231
#-----------------------------------------------------------------------------
# Windows compiler flags
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
232 233


234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
if(WIN32 AND NOT MSVC)
    set(OS_BUILD  $ENV{OS_BUILD})
    if(NOT OS_BUILD)
        set(OS_BUILD "64")
    endif(NOT OS_BUILD)
    set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}:/c/ming${OS_BUILD}/projects/pgx${OS_BUILD}/pg92)
    if (NOT BOOST_ROOT)
        set(BOOST_ROOT c:/ming${OS_BUILD}/msys/local)
    endif(NOT BOOST_ROOT)

    if (NOT CGAL_ROOT)
        set(CGAL_ROOT c:/ming${OS_BUILD}/msys/local)
    endif(NOT CGAL_ROOT)

    if (NOT GMP_ROOT)
        set(GMP_ROOT c:/ming${OS_BUILD}/mingw${OS_BUILD})
    endif(NOT GMP_ROOT)
251 252 253 254 255 256 257
    if (PGROUTING_DEBUG)
        message(STATUS "OS_BUILD=${OS_BUILD}")
        message(STATUS "CGAL_ROOT=${CGAL_ROOT}")
        message(STATUS "GMP_ROOT=${GMP_ROOT}")
        message(STATUS "BOOST_ROOT=${BOOST_ROOT}")
        message(STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
    endif()
258
endif(WIN32 AND NOT MSVC)
259

260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
if(WIN32 AND MSVC)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_DEPRECATE")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_SCL_SECURE_NO_DEPRECATE")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_SCL_SECURE_NO_WARNINGS")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_NONSTDC_NO_DEPRECATE")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -EHsc")
endif()

#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Finding prerequisites
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
276

277 278 279 280 281
#---------------------------------------------
#---------------------------------------------
# Perl
#---------------------------------------------
#---------------------------------------------
282 283
include(FindPerl)
if(NOT PERL_EXECUTABLE)
284
    message(FATAL_ERROR " Please check your Perl installation.")
285 286
endif(NOT PERL_EXECUTABLE)

287 288 289 290 291
#---------------------------------------------
#---------------------------------------------
# PostgreSQL
#---------------------------------------------
#---------------------------------------------
292 293
find_package(PostgreSQL)
if(NOT POSTGRESQL_FOUND)
294
    message(FATAL_ERROR " Please check your PostgreSQL installation.")
295 296
endif(NOT POSTGRESQL_FOUND)

297 298
if(NOT POSTGRESQL_VERSION_STRING)
    message(FATAL_ERROR "pg_config was not found. Please check your PostgreSQL installation!")
299
endif()
300

301
string(SUBSTRING "${POSTGRESQL_VERSION_STRING}" 11 -1 POSTGRESQL_VERSION)
302 303

# for XbetaY XalphaY XrcY -> X.Y
304
string(REGEX REPLACE "^([0-9]+)[beta|alpha|rc|devel].*" "\\1.0" POSTGRESQL_VERSION ${POSTGRESQL_VERSION})
305

306
#for X.Y.Z -> XY  Y<10
307 308
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*" "\\1\\2" PGSQL_VERSION ${POSTGRESQL_VERSION})

309

310 311 312 313 314 315 316 317 318 319 320 321 322 323
if("${POSTGRESQL_VERSION}" VERSION_LESS "${POSTGRESQL_MINIMUM_VERSION}")
    message(FATAL_ERROR " PostgreSQL ${POSTGRESQL_MINIMUM_VERSION} or greater is required.")
endif("${POSTGRESQL_VERSION}" VERSION_LESS "${POSTGRESQL_MINIMUM_VERSION}")

#-------
include_directories(${POSTGRESQL_INCLUDE_DIR})
if(WIN32)
    include_directories(${POSTGRESQL_INCLUDE_DIR}/port/win32)
    if(MSVC)
        include_directories(${POSTGRESQL_INCLUDE_DIR}/port/win32_msvc/)
    endif(MSVC)
endif(WIN32)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPGSQL_VERSION=${PGSQL_VERSION}")
324
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DPGSQL_VERSION=${PGSQL_VERSION}")
325
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DPGSQL_VERSION=${PGSQL_VERSION}")
326
message(STATUS "PGSQL_VERSION=${PGSQL_VERSION}")
327 328 329 330 331 332 333 334


#---------------------------------------------
#---------------------------------------------
# Boost
#---------------------------------------------
#---------------------------------------------
find_package(Boost ${BOOST_MINIMUM_VERSION})
335
if(Boost_INCLUDE_DIRS)
336
    message(STATUS "Boost headers were found here: ${Boost_INCLUDE_DIRS}")
337
else(Boost_INCLUDE_DIRS)
338
    message(FATAL_ERROR " Please check your Boost installation ")
339 340
endif(Boost_INCLUDE_DIRS)

341 342 343 344 345 346 347 348 349
include_directories(${Boost_INCLUDE_DIRS})


#---------------------------------------------
#---------------------------------------------
# CGAL
#---------------------------------------------
#---------------------------------------------
find_package(CGAL ${CGAL_MINIMUM_VERSION})
350
if(NOT CGAL_FOUND)
351
    message(FATAL_ERROR " Please check your CGAL installation, or set correct path to CGAL_INCLUDE_DIR and CGAL_LIBRARIES.")
352 353
endif(NOT CGAL_FOUND)

354 355
#-------
include_directories(${CGAL_INCLUDE_DIR})
356

357 358 359 360 361
#---------------------------------------------
#---------------------------------------------
# PgRouting includes
#---------------------------------------------
#---------------------------------------------
362

363
set(PGROUTING_INCLUDE_DIRECTORIES
364
    ${PGROUTING_SOURCE_DIR}/include
365
    )
366

367 368 369 370 371 372 373 374 375 376 377 378 379 380
#-------
include_directories(${PGROUTING_INCLUDE_DIRECTORIES})


#---------------------------------------------
if (PGROUTING_DEBUG)
    message(STATUS "PERL_VERSION_STRING = ${PERL_VERSION_STRING}")
    message(STATUS "POSTGRESQL_VERSION is ${PGSQL_VERSION}")
    message(STATUS "PGSQL_VERSION is ${PGSQL_VERSION}")
    message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
    message(STATUS "CGAL_INCLUDE_DIR: ${CGAL_INCLUDE_DIR}")
    message(STATUS "PGROUTING_INCLUDE_DIRECTORIES = ${PGROUTING_INCLUDE_DIRECTORIES}")
    message(STATUS "POSTGRESQL_INCLUDE_DIR = ${POSTGRESQL_INCLUDE_DIR}")
    message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
381 382
endif()

383 384 385 386 387 388 389

#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Posgres installation directories
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------

390 391


392 393 394
#---------------------------------------------
# library directory
#---------------------------------------------
395
execute_process(
396 397 398
    COMMAND ${POSTGRESQL_PG_CONFIG} --pkglibdir
    OUTPUT_STRIP_TRAILING_WHITESPACE
    OUTPUT_VARIABLE LIB_DIR)
399

400
if(NOT LIB_DIR)
401
    message(FATAL_ERROR "pg_config --pkglibdir failed to return a value. Please check your PostgreSQL installation!")
402
endif()
403

404
#-------
405 406
set(LIBRARY_INSTALL_PATH ${LIB_DIR})

407 408 409 410
#---------------------------------------------
# extension directory
#---------------------------------------------

411
execute_process(
412 413 414
    COMMAND ${POSTGRESQL_PG_CONFIG} --sharedir
    OUTPUT_STRIP_TRAILING_WHITESPACE
    OUTPUT_VARIABLE SHARE_DIR)
415

416
#-------
417
if(SHARE_DIR)
418
    set(SHARE_DIR "${SHARE_DIR}/extension")
419
else(SHARE_DIR)
420
    message(FATAL_ERROR "pg_config --sharedir failed to return a value. Please check your PostgreSQL installation!")
421 422
endif(SHARE_DIR)

423 424 425 426 427
#---------------------------------------------
if (PGROUTING_DEBUG)
    message(STATUS "Install directory for libraries is set to ${LIB_DIR}")
    message(STATUS "Extension directory for SQL files is set to ${SHARE_DIR}")
endif()
428

429 430


431 432 433
#---------------------------------------------
# Special cases for windows
#---------------------------------------------
434 435

if(WIN32)
436 437 438
    message(STATUS "LINK_DIRECTORIES = ${POSTGRESQL_LIBRARIES}")
    link_directories(${POSTGRESQL_LIBRARIES} ${LIB_DIR})
    link_libraries(postgres)
439 440 441 442 443 444 445 446 447 448
endif()

#-----------------------------------------------------------------------------

if (PGROUTING_DEBUG)
    get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
    foreach(dir ${dirs})
        message(STATUS "dir='${dir}'")
    endforeach()
endif()
449

450

451
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
452
#compiler directives
453 454
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

455
# for UNIX & JENKINS
456
if(UNIX OR (WIN32 AND NOT MSVC))
457
    set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}  -std=gnu99")
458 459
endif()

460
if(NOT WIN32)
461 462 463 464 465 466 467 468
    CHECK_C_COMPILER_FLAG("-fPIC" C_COMPILER_SUPPORTS_FPIC)
    CHECK_CXX_COMPILER_FLAG("-fPIC" CXX_COMPILER_SUPPORTS_FPIC)
    if(C_COMPILER_SUPPORTS_FPIC)
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC ")
    endif()
    if(CXX_COMPILER_SUPPORTS_FPIC)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC ")
    endif()
469
endif()
470

471 472 473 474
if(WIN32 AND MSVC)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
endif()

475 476
CHECK_C_COMPILER_FLAG("-frounding-math" C_COMPILER_SUPPORTS_ROUNDING_MATH)
CHECK_CXX_COMPILER_FLAG("-frounding-math" CXX_COMPILER_SUPPORTS_ROUNDING_MATH)
477 478 479 480 481 482
if(C_COMPILER_SUPPORTS_ROUNDING_MATH)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -frounding-math ")
endif()
if(CXX_COMPILER_SUPPORTS_ROUNDING_MATH)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frounding-math ")
endif()
483

484 485 486 487 488
# TODO use -Werror when TRSP gets rewritten
set(CMAKE_C_FLAGS_DEBUG   "${CMAKE_C_FLAGS_DEBUG}   -Wall -Wconversion -pedantic -Wmissing-prototypes -W -Wunused -Wuninitialized -Wextra -Wdouble-promotion")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fno-implicit-inline-templates -Wconversion -pedantic -W -Wunused -Wuninitialized -Wextra -Wdouble-promotion")


489

490
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
491

492 493 494 495
if (PGROUTING_DEBUG)
    message(STATUS "CMAKE_CXX_FLAGS_DEBUG= ${CMAKE_CXX_FLAGS_DEBUG}")
    message(STATUS "CMAKE_CXX_FLAGS_RELEASE= ${CMAKE_CXX_FLAGS_RELEASE}")
    message(STATUS "CMAKE_CXX_FLAGS= ${CMAKE_CXX_FLAGS}")
496

497 498 499
    message(STATUS "CMAKE_C_FLAGS_DEBUG= ${CMAKE_C_FLAGS_DEBUG}")
    message(STATUS "CMAKE_C_FLAGS_RELEASE= ${CMAKE_C_FLAGS_RELEASE}")
    message(STATUS "CMAKE_C_FLAGS= ${CMAKE_C_FLAGS}")
500

501 502 503 504
    message(STATUS "UNIX=${UNIX}")
    message(STATUS "WIN32=${WIN32}")
    message(STATUS "MSVC=${MSVC}")
endif()
505 506

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
507

508 509 510 511 512

#====================================================================
# Include the working directories
#====================================================================

513
if(WITH_INTERNAL_TESTS)
514 515 516
    message("Including InternalQueryTests")
    set(PgRouting_SOURCE_NAMES ${PgRouting_SOURCE_NAMES} "internalQueryTests")
endif()
517 518

#-------------------
519
# add the subdirectories that have the C/C++ code
520 521 522
#-------------------

foreach (subdir ${PgRouting_SOURCE_NAMES})
523
    add_subdirectory("${PGROUTING_SOURCE_DIR}/src/${subdir}")
524 525 526
endforeach()


527
#====================================================================
528 529


530 531 532 533 534 535 536 537 538 539 540 541

# assemble the object files from the src functions into
# a single library librouting.so
set(LIBRARY_OUTPUT_PATH lib)

if(APPLE)
    set(LIBRARY_MODE_TARGET "MODULE")
else(APPLE)
    set(LIBRARY_MODE_TARGET "SHARED")
endif(APPLE)


542
LINK_LIBRARIES(${CGAL_LIBRARIES} ${GMP_LIBRARIES} ${BOOST_THREAD_LIBRARIES})
543

544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559
#-------------------
# pgRouting objects to be linked
#-------------------
foreach (subdir ${PgRouting_SOURCE_NAMES} )
    set(PGROUTING_OBJECTS ${PGROUTING_OBJECTS} "$<TARGET_OBJECTS:${subdir}>")
endforeach()


#-----------------------------------------------------------------------------
# PGROUTING Library names
#-----------------------------------------------------------------------------


#----------------------
# PGROUTING installation files names have the following name
#----------------------
560
set(PGROUTING_LIB_NAME "pgrouting-${PGROUTING_SHORT_VERSION}")
561 562 563


add_library(${PGROUTING_LIB_NAME}
564
    ${LIBRARY_MODE_TARGET}
565
    ${PGROUTING_OBJECTS})
566

567

568 569

if(APPLE)
570
    set_target_properties(${PGROUTING_LIB_NAME}
571 572 573
        PROPERTIES
        LINK_FLAGS "-bundle_loader ${POSTGRESQL_EXECUTABLE} -bundle")
endif(APPLE)
574 575 576
if(WIN32 AND MSVC)
    set_target_properties(${PGROUTING_LIB_NAME} PROPERTIES PREFIX "lib")
endif(WIN32 AND MSVC)
577 578


579 580 581 582 583 584 585
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# sql subdirectory creates the files:
#  pgrouting--(version).sql
#  pgrouting--(oldVersion)--(version).sql
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
586

587
add_subdirectory(sql)
588

589 590 591 592 593
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# INSTALLATION
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
594 595


596 597 598 599
install(TARGETS ${PGROUTING_LIB_NAME} DESTINATION ${LIBRARY_INSTALL_PATH})
install(FILES
    ${PgRouting_SQL_FILES_TO_INSTALL}
    DESTINATION "${SHARE_DIR}"
600 601
    )

602 603 604 605 606 607 608 609
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# DOCUMENTATION
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
add_subdirectory(doxygen)
add_subdirectory(doc)

610

611 612 613 614
if (PGROUTING_DEBUG)
    foreach (f ${PgRouting_SQL_FILES})
        message(STATUS ${f})
    endforeach()
615
endif()