CMakeLists.txt 2.88 KB
Newer Older
1 2 3 4 5 6 7
# UMANS: Unified Microscopic Agent Navigation Simulator
# Copyright (C) 2018-2020  Inria Rennes Bretagne Atlantique - Rainbow - Julien Pettré
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
8
#
9 10
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 13
# GNU General Public License for more details.
#
14 15
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
16 17
#
# Contact: crowd_group@inria.fr
18 19
# Website: https://project.inria.fr/crowdscience/
# See the file AUTHORS.md for a list of all contributors.
20

21
cmake_minimum_required( VERSION 2.8 )
22
project( UMANS )
Fabien Grzeskowiak's avatar
Fabien Grzeskowiak committed
23
set (CMAKE_CXX_STANDARD 17)
24

Javad AMIRIAN's avatar
Javad AMIRIAN committed
25
#set(EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE})
26

VAN TOLL Wouter's avatar
VAN TOLL Wouter committed
27
# === Include 3rd-party code
28

29
include_directories( ./include )
30
include_directories(./3rd-party/tinyxml/ ./3rd-party/nanoflann/ ./3rd-party/ORCA/)
31

VAN TOLL Wouter's avatar
VAN TOLL Wouter committed
32
#link_directories( ./lib/${CMAKE_BUILD_TYPE} )
33

Javad AMIRIAN's avatar
Javad AMIRIAN committed
34
file( GLOB_RECURSE source_files src/* include/*)
35
file( GLOB_RECURSE 3rd_party 3rd-party/*)
36

VAN TOLL Wouter's avatar
VAN TOLL Wouter committed
37
# === Use multithreading?
38

39 40
option(UMANS_USE_MULTITHREADING "Allow the program to use multiple parallel threads" ON)
if (UMANS_USE_MULTITHREADING)
41
	if (MSVC)
Fabien Grzeskowiak's avatar
Fabien Grzeskowiak committed
42 43 44
	  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /openmp")
	else()
	  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
45 46
    endif ()
endif (UMANS_USE_MULTITHREADING)
47

VAN TOLL Wouter's avatar
VAN TOLL Wouter committed
48 49 50
# === Linux compatibility compiler option

if (NOT MSVC)
Fabien Grzeskowiak's avatar
Fabien Grzeskowiak committed
51
	add_definitions(-O3 -lstdc++fs -fPIC -shared)
52
endif() 
53

54 55
# === Engine project: a static library that performs the simulation

56
add_library(Engine STATIC ${source_files} ${3rd_party})
57

58 59
# === Console application

VAN TOLL Wouter's avatar
VAN TOLL Wouter committed
60
if (WIN32)
61 62
	add_executable(UMANS_ConsoleApplication_Windows main.cpp)
	target_link_libraries(UMANS_ConsoleApplication_Windows Engine)
VAN TOLL Wouter's avatar
VAN TOLL Wouter committed
63
else()
64 65
	add_executable(UMANS_ConsoleApplication_Linux main.cpp)
	target_link_libraries(UMANS_ConsoleApplication_Linux Engine)
VAN TOLL Wouter's avatar
VAN TOLL Wouter committed
66
endif()
67

68
# === Dynamic library (e.g. a DLL on Windows) to include into other programs
Javad AMIRIAN's avatar
Javad AMIRIAN committed
69

70 71
add_library(UMANS_Library SHARED "APIFunctions.h" "APIFunctions.cpp")
target_link_libraries(UMANS_Library Engine)
72

73
# === Clean up the project's directory structure
74 75 76 77 78 79 80 81 82

foreach(_source IN ITEMS ${source_files})
    get_filename_component(_source_path "${_source}" PATH)
    file(RELATIVE_PATH _source_path_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source_path}")
	string(REPLACE "include/" "" _source_path_rel ${_source_path_rel})
	string(REPLACE "src/" "" _source_path_rel ${_source_path_rel})
    string(REPLACE "/" "\\" _group_path "${_source_path_rel}")
    source_group("${_group_path}" FILES "${_source}")
endforeach()
83
source_group("3rd-party" FILES ${3rd_party})