CMakeLists.txt 10.1 KB
Newer Older
1
# Documentation: Some useful options:
Mohcine Chraibi's avatar
Mohcine Chraibi committed
2 3 4
# -DCMAKE_CXX_COMPILER:STRING=clang++   -DCMAKE_C_COMPILER:STRING=clang .
# -DCMAKE_BUILD_TYPE:STRING=Debug (default Release)
# -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON (default OFF)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
5
# -DBUILD_TESTING=ON (default OFF)
6
#--------------------------------------------------------------------------
7 8

cmake_minimum_required(VERSION 2.8  FATAL_ERROR)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
9

10
project(JPScore)
11

Mohcine Chraibi's avatar
Mohcine Chraibi committed
12
set(CMAKE_COLOR_MAKEFILE ON)
13 14 15 16 17
set(JPSCORE_MAJOR_VERSION 0)
set(JPSCORE_MINOR_VERSION 1)
set(JPSCORE_PATCH_VERSION 0)
set(JPSCORE_VERSION
  ${JPSCORE_MAJOR_VERSION}.${JPSCORE_MINOR_VERSION}.${JPSCORE_PATCH_VERSION})
18 19
message( STATUS "JPSCORE_VERSION: " ${JPSCORE_VERSION} )

Mohcine Chraibi's avatar
Mohcine Chraibi committed
20 21 22
if(NOT BUILD_TESTING)
  set(BUILD_TESTING OFF)
endif(NOT BUILD_TESTING)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
23

Mohcine Chraibi's avatar
Mohcine Chraibi committed
24
message( STATUS "BUILD_TESTING: " ${BUILD_TESTING} )
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
if(NOT DEFINED PROCESSOR_COUNT)
  # Unknown:
  set(PROCESSOR_COUNT 0)

  # Linux:
  set(cpuinfo_file "/proc/cpuinfo")
  if(EXISTS "${cpuinfo_file}")
    file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$")
    list(LENGTH procs PROCESSOR_COUNT)
  endif(EXISTS "${cpuinfo_file}")


  # Windows:
  if(WIN32)
    set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}")
  endif(WIN32)
endif(NOT DEFINED PROCESSOR_COUNT)

if(PROCESSOR_COUNT)
44
  message( STATUS "PROCESSOR_COUNT: " ${PROCESSOR_COUNT})
45 46
  set(CTEST_BUILD_FLAGS "-j${PROCESSOR_COUNT}")
endif(PROCESSOR_COUNT)
47

48
if(NOT CMAKE_BUILD_TYPE)
David H's avatar
David H committed
49
  set (CMAKE_BUILD_TYPE Release)
50 51 52 53
endif(NOT CMAKE_BUILD_TYPE)
message( STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} )

#------------------ set important directories --------------------
54 55
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
Mohcine Chraibi's avatar
Mohcine Chraibi committed
56
set(LIBRARY_OUTPUT_PATH  ${CMAKE_SOURCE_DIR}/lib/${CMAKE_BUILD_TYPE})
57
set(CMAKE_TEST_DIR ${CMAKE_SOURCE_DIR}/Utest)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
58 59 60 61 62
#include_directories( ${LIBRARY_OUTPUT_PATH} )
#add_subdirectory(${LIBRARY_OUTPUT_PATH} )
message( STATUS "CMAKE_BINARY_DIR: " ${CMAKE_BINARY_DIR} )
message( STATUS "CMAKE_SOURCE_DIR: " ${CMAKE_SOURCE_DIR} )
message( STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR} )
63
message( STATUS "CMAKE_RUNTIME_OUTPUT_DIRECTORY: " ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} )
64 65
message( STATUS "EXECUTABLE_OUTPUT_PATH: " ${EXECUTABLE_OUTPUT_PATH} )
message( STATUS "CMAKE_VERBOSE_MAKEFILE: " ${CMAKE_VERBOSE_MAKEFILE} )
Mohcine Chraibi's avatar
Mohcine Chraibi committed
66 67
#add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose)

Mohcine Chraibi's avatar
Mohcine Chraibi committed
68 69 70 71

# add a target to generate API documentation with Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
72 73 74 75 76 77
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  add_custom_target(doc
    ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMENT "Generating API documentation with Doxygen" VERBATIM
    )
Mohcine Chraibi's avatar
Mohcine Chraibi committed
78 79
endif(DOXYGEN_FOUND)

Mohcine Chraibi's avatar
Mohcine Chraibi committed
80 81 82
#find the correct OpenMP flag
FIND_PACKAGE(OpenMP)
if(OPENMP_FOUND)
83 84 85
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
Mohcine Chraibi's avatar
Mohcine Chraibi committed
86 87 88 89 90 91 92 93
else(OPENMP_FOUND)
  message( STATUS "Disabling OpenMP support" )
endif(OPENMP_FOUND)

#find and add the CGAL library
#fixme: complete this section
FIND_PACKAGE(CGAL QUIET)
if(CGAL_FOUND)
94 95
  include (${CGAL_USE_FILE})
  INCLUDE_DIRECTORIES(${CGAL_CORE_INCLUDE_DIR})
Mohcine Chraibi's avatar
Mohcine Chraibi committed
96
  add_definitions(-D_CGAL=1)  
97 98 99 100
  message (SEND_ERROR "${CGAL_FOUND}")
  message (FATAL_ERROR "${CGAL_CORE_INCLUDE_DIR}")
  message (SEND_ERROR " Erreur: ${CGAL_FOUND}")
  message (SEND_ERROR " Erreur: ${CGAL_USE_FILE}")
Mohcine Chraibi's avatar
Mohcine Chraibi committed
101 102 103
else(CGAL_FOUND)
  message( STATUS "CGAL not found. But don't panik .." )
endif(CGAL_FOUND)
104 105

# test files: all cpp-files in Utest
Mohcine Chraibi's avatar
Mohcine Chraibi committed
106 107 108 109
if(BUILD_TESTING)
  file(GLOB test_files "${CMAKE_TEST_DIR}/*.cpp")
endif(BUILD_TESTING)

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
set (   source_files
  main.cpp
  Simulation.cpp
  general/ArgumentParser.cpp

  tinyxml/tinystr.cpp
  tinyxml/tinyxml.cpp
  tinyxml/tinyxmlerror.cpp
  tinyxml/tinyxmlparser.cpp

  geometry/Building.cpp
  geometry/Line.cpp
  geometry/Point.cpp
  geometry/Transition.cpp
  geometry/Hline.cpp
  geometry/Obstacle.cpp
  geometry/SubRoom.cpp
  geometry/Crossing.cpp
  geometry/NavLine.cpp
  geometry/Room.cpp
  geometry/Wall.cpp
  geometry/Goal.cpp

  IO/IODispatcher.cpp
  IO/OutputHandler.cpp
  IO/TraVisToClient.cpp

  math/Distribution.cpp
  math/ForceModel.cpp
  math/Mathematics.cpp
  math/ODESolver.cpp

  mpi/LCGrid.cpp

  pedestrian/Ellipse.cpp
  pedestrian/PedDistributor.cpp
  pedestrian/Pedestrian.cpp

  routing/AccessPoint.cpp
  routing/DirectionStrategy.cpp
  routing/DummyRouter.cpp
  routing/GlobalRouter.cpp
  routing/GraphRouter.cpp
  routing/QuickestPathRouter.cpp
  routing/SafestPathRouter.cpp
  routing/Router.cpp
  routing/RoutingEngine.cpp
  routing/NavMesh.cpp
  routing/DTriangulation.cpp
  routing/MeshRouter.cpp
  routing/mesh/Mesh.cpp

  routing/graph/NavLineState.cpp
  routing/graph/RoutingGraph.cpp
  routing/graph/RoutingGraphStorage.cpp

  routing/CognitiveMapRouter.cpp
  routing/cognitive_map/CognitiveMap.cpp
  routing/cognitive_map/NavigationGraph.cpp
  routing/cognitive_map/CognitiveMapStorage.cpp
  routing/cognitive_map/AbstractCognitiveMapCreator.cpp
  routing/cognitive_map/CompleteCognitiveMapCreator.cpp
  routing/cognitive_map/EmptyCognitiveMapCreator.cpp
  routing/cognitive_map/navigation_graph/GraphEdge.cpp
  routing/cognitive_map/navigation_graph/GraphVertex.cpp
  routing/cognitive_map/sensor/RoomToFloorSensor.cpp
  routing/cognitive_map/sensor/SensorManager.cpp
  routing/cognitive_map/sensor/AbstractSensor.cpp
  poly2tri/common/shapes.cpp
  poly2tri/sweep/sweep_context.cpp
  poly2tri/sweep/advancing_front.cpp
  poly2tri/sweep/sweep.cpp
  poly2tri/sweep/cdt.cpp
183
  events/EventManager.cpp
184
  )
185
set (   header_files
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
  routing/NavMesh.h
  routing/DirectionStrategy.h
  routing/DummyRouter.h
  routing/GlobalRouter.h
  routing/GraphRouter.h
  routing/QuickestPathRouter.h
  routing/SafestPathRouter.h
  routing/Router.h
  routing/RoutingEngine.h
  routing/AccessPoint.h
  routing/DTriangulation.h
  routing/MeshRouter.h
  routing/mesh/Mesh.h
  routing/graph/RoutingGraphStorage.h
  routing/graph/RoutingGraph.h
  routing/graph/NavLineState.h

  routing/CognitiveMapRouter.h
  routing/cognitive_map/CognitiveMap.h
  routing/cognitive_map/NavigationGraph.h
  routing/cognitive_map/CognitiveMapStorage.h
  routing/cognitive_map/AbstractCognitiveMapCreator.h
  routing/cognitive_map/CompleteCognitiveMapCreator.h
  routing/cognitive_map/EmptyCognitiveMapCreator.h
  routing/cognitive_map/navigation_graph/GraphEdge.h
  routing/cognitive_map/navigation_graph/GraphVertex.h
  routing/cognitive_map/sensor/AbstractSensor.h
  routing/cognitive_map/sensor/RoomToFloorSensor.h
  routing/cognitive_map/sensor/SensorManager.h


  pedestrian/Pedestrian.h
  pedestrian/PedDistributor.h
  pedestrian/Ellipse.h

  mpi/LCGrid.h

  tinyxml/tinyxml.h
  tinyxml/tinystr.h

  general/ArgumentParser.h
  general/Macros.h

  geometry/Crossing.h
  geometry/NavLine.h
  geometry/Room.h
  geometry/Building.h
  geometry/Wall.h
  geometry/Line.h
  geometry/Point.h
  geometry/Transition.h
  geometry/Hline.h
  geometry/Obstacle.h
  geometry/SubRoom.h
  geometry/Goal.h

  IO/IODispatcher.h
  IO/OutputHandler.h
  IO/TraVisToClient.h

  math/ForceModel.h
  math/Distribution.h
  math/Mathematics.h
  math/ODESolver.h

  poly2tri/poly2tri.h
  poly2tri/common/shapes.h
  poly2tri/sweep/cdt.h
  poly2tri/common/utils.h
  poly2tri/sweep/sweep_context.h
  poly2tri/sweep/advancing_front.h
  poly2tri/sweep/sweep.h
258
  events/EventManager.h
259 260 261 262
  )


add_library ( core SHARED ${source_files} )
Mohcine Chraibi's avatar
Mohcine Chraibi committed
263

264 265
#Target
add_executable(
266 267
  jpscore main.cpp
  )
268 269
target_link_libraries(jpscore  core)

270
if(WIN32)
271
  target_link_libraries (jpscore core wsock32)
272
endif(WIN32)
273

274 275 276
if(CGAL_FOUND)
   target_link_libraries (jpscore ${CGAL_CORE_LIBRARY})
endif(CGAL_FOUND)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
277
#---------------------------- compiler -------------------------------
278
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
Mohcine Chraibi's avatar
Mohcine Chraibi committed
279
  message(STATUS "Using CLANG++" )
280
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
281
if(CMAKE_COMPILER_IS_GNUCXX)
282
  message( STATUS "Set compiler flags (g++)" )
283
  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall  -std=c++11")
284
endif(CMAKE_COMPILER_IS_GNUCXX)
285

Mohcine Chraibi's avatar
Mohcine Chraibi committed
286
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE MATCHES Debug)
287
  message(STATUS "In Debug Build")
288
  set(WITH_COVERAGE TRUE)
David H's avatar
David H committed
289
  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wno-deprecated -Woverloaded-virtual -Wwrite-strings -fprofile-arcs -ftest-coverage -std=c++11")
290
  set(CMAKE_CXX_LDFLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
Mohcine Chraibi's avatar
Mohcine Chraibi committed
291
  message(STATUS "Debug flags for coverage: " ${CMAKE_CXX_FLAGS_DEBUG} )
292 293
else(CMAKE_COMPILER_IS_GNUCXX  AND CMAKE_BUILD_TYPE MATCHES Debug)
  message(STATUS "Release flags: " ${CMAKE_CXX_FLAGS_RELEASE} )
Mohcine Chraibi's avatar
Mohcine Chraibi committed
294
endif(CMAKE_COMPILER_IS_GNUCXX  AND CMAKE_BUILD_TYPE MATCHES Debug)
295

296
# ----------------------------- cTest ------------------------------------------
Mohcine Chraibi's avatar
Mohcine Chraibi committed
297 298 299 300 301 302 303 304 305 306 307 308 309 310
if(BUILD_TESTING)
  enable_testing() #adds another build target, which is test for Makefile generators
  include(CTest) #adding Dart support

  #test if code compiles and runs default setting. Takes about 30 seconds
  add_test (jpscore_compile ${CMAKE_CTEST_COMMAND}
    --build-and-test "${CMAKE_SOURCE_DIR}" "${EXECUTABLE_OUTPUT_PATH}" #"${CMAKE_BINARY_DIR}"
    --build-generator ${CMAKE_GENERATOR}
    --build-makeprogram ${CMAKE_MAKE_PROGRAM} -j${PROCESSOR_COUNT}
    --build-two-config
    --build-exe-dir ${EXECUTABLE_OUTPUT_PATH}  # todo wo soll der exe hin?: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
    --build-project JPScore
    --test-command jpscore --ini=${CMAKE_SOURCE_DIR}/inputfiles/Default/ini.xml
    )
Mohcine Chraibi's avatar
Mohcine Chraibi committed
311

Mohcine Chraibi's avatar
Mohcine Chraibi committed
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
  foreach (test_src ${test_files})
    GET_FILENAME_COMPONENT(test ${test_src} NAME_WE)
    add_executable( ${test} ${test_src})
    target_link_libraries (${test} core)
    add_test(NAME ${test} COMMAND ${test})
  endforeach(test_src ${test_files})

  find_package(PythonInterp)
  if(PYTHONINTERP_FOUND)
    message(STATUS "Found Python: " ${PYTHON_EXECUTABLE})
    message(STATUS "run: " ${CMAKE_SOURCE_DIR}/Utest/testflow.py)
    set (test_parameters "${CMAKE_SOURCE_DIR}")
    add_test(NAME flow  COMMAND "${CMAKE_TEST_DIR}/testflow.py" "${test_parameters}")
  endif(PYTHONINTERP_FOUND)
endif(BUILD_TESTING)