# Usage:
#  Create build folder, like RC-build next to RobotControl and WifiScan folder
#  CD into build folder and execute 'cmake -DCMAKE_BUILD_TYPE=Debug ../RobotControl'
#  make

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

# select build type
SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" )

PROJECT(Walky)

IF(NOT CMAKE_BUILD_TYPE)
	MESSAGE(STATUS "No build type selected. Default to Debug")
	SET(CMAKE_BUILD_TYPE "Debug")
ENDIF()



INCLUDE_DIRECTORIES(
	../
	/apps/paper/diss/code
)


FILE(GLOB HEADERS
	./*.h
	./*/*.h
	./*/*/*.h
	./*/*/*/*.h
	./*/*/*/*/*.h
	./*/*/*/*/*/*.h
	./tests/data/*
	./tests/data/*/*
	./tests/data/*/*/*
)


FILE(GLOB SOURCES
	./*.cpp
	./*/*.cpp
	./*/*/*.cpp
	./*/*/*/*.cpp
	../Indoor/lib/tinyxml/tinyxml2.cpp
	../Indoor/lib/Recast/*.cpp
	/apps/paper/diss/code/Indoor/lib/tinyxml/tinyxml2.cpp
	/apps/paper/diss/code/Indoor/lib/Recast/*.cpp
)

FIND_PACKAGE( OpenMP REQUIRED)
if(OPENMP_FOUND)
	message("OPENMP FOUND")
	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}")
endif()

if(${CMAKE_GENERATOR} MATCHES "Visual Studio")

  SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_X86_ /D_USE_MATH_DEFINES")
  SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /Oi /GL /Ot /Ox /D_X86_ /D_USE_MATH_DEFINES")
  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
  SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG /INCREMENTAL:NO")

  set(CMAKE_CONFIGURATION_TYPES Release Debug)

else()

# system specific compiler flags
ADD_DEFINITIONS(

	-std=gnu++11

	-Wall
	-Werror=return-type
	-Wextra
	-Wpedantic

	-fstack-protector-all

	-g3
	-O0



	-march=native

	-DWITH_TESTS
	-DWITH_ASSERTIONS
	-DWITH_DEBUG_LOG

	-O2
	-DWITH_DEBUG_PLOT

)

endif()

# build a binary file
ADD_EXECUTABLE(
	${PROJECT_NAME}
	${HEADERS}
	${SOURCES}
)

# wifi scan?
#SET(EXTRA_LIBS ${EXTRA_LIBS} nl-genl-3 nl-3)
#INCLUDE_DIRECTORIES(/usr/include/libnl3/)
#SET(EXTRA_LIBS ${EXTRA_LIBS} iw)

# needed external libraries
TARGET_LINK_LIBRARIES(
	${PROJECT_NAME}
	#gtest
	pthread
	${EXTRA_LIBS}
	#-pg
)

SET(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER})

