-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
82 lines (65 loc) · 2.42 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Option to build shared libraries
option(BUILD_SHARED_LIBS "Build shared libraries." OFF)
# Option for building all of OBD's tests
option(obd_build_tests "Build all of OBD's tests." ON)
# Option for building the bicycle GUI
option(obd_build_gui "Build Qt4 gui tool." ON)
# Option for building documentation using Doxygen
option(obd_build_docs "Build Doxygen documentation." OFF)
# We need to call enable_testing() before any subdirectories are added
if (obd_build_tests)
enable_testing()
endif()
# Add custom FindXXX.cmake files cmake/Modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
project(OBD CXX C)
cmake_minimum_required(VERSION 2.8)
# Set g++ compiler flags if GNU C++ compiler is being used
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
endif()
set(OBD_VERSION_MAJOR 0)
set(OBD_VERSION_MINOR 3)
# If we find git installed, set OBD_VERSION_COMMIT to most recent SHA1
find_package(Git)
if(GIT_FOUND)
# TODO: check that ${PROJECT_SOURCE_DIR} has a .git folder to ensure it is
# a git repo rather than just a source tar-ball.
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --pretty=oneline
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE OBD_VERSION_COMMIT)
# Keep everything up to the first space, add quotes
string(REGEX REPLACE "([^ ]+).*"
"\"\\1\"" OBD_VERSION_COMMIT
${OBD_VERSION_COMMIT})
else()
set(OBD_VERSION_COMMIT "\"\"")
endif()
configure_file("${PROJECT_SOURCE_DIR}/include/OBDConfig.h.in"
"${PROJECT_BINARY_DIR}/include/OBDConfig.h")
include_directories("${PROJECT_BINARY_DIR}/include")
# Find GSL
find_package(GSL REQUIRED)
# Directories for each bicycle model
add_subdirectory(whipple)
if (obd_build_docs)
find_package(Doxygen)
if (DOXYGEN_FOUND STREQUAL "NO")
message(FATAL_ERROR "Doxygen not found. Please get a copy http://www.doxygen.org")
endif()
# prepare doxygen configuration file
configure_file(${PROJECT_SOURCE_DIR}/Doxyfile.in
${PROJECT_BINARY_DIR}/Doxyfile)
add_custom_target(doc
${DOXYGEN_EXECUTABLE}
${PROJECT_BINARY_DIR}/Doxyfile)
endif()
if (obd_build_gui)
find_package(Qt4 REQUIRED)
add_subdirectory(bikegui)
endif()
if (obd_build_tests)
add_subdirectory(gtest)
endif()