-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
98 lines (87 loc) · 2.98 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#
# abstract_astar_search_c cmake
#
cmake_minimum_required(VERSION 2.8.7)
project(abstract_astar_search_c C)
#
# abstract_astar_search_c version
#
set(VERSION_MAJOR 0)
set(VERSION_MINOR 1)
set(VERSION_PATCH 1)
#
# Version file :)
#
configure_file(
"${PROJECT_SOURCE_DIR}/include/version.h.in"
"${PROJECT_SOURCE_DIR}/include/version.h"
)
#
# Avoid source tree pollution
#
if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR})
message(WARNING "In-source builds are not recommended. "
"Consider building in a separate directory, "
"to avoid polluting the source tree.")
endif()
#
# Per compiler flags
#
set(GCC_COMPILER_FLAGS_DEBUG "-Wall -g")
set(GCC_COMPILER_FLAGS_RELEASE "-Wall -DNO_LINENOS -DNDEBUG")
set(CLANG_COMPILER_FLAGS_DEBUG "-Wall -g")
set(CLANG_COMPILER_FLAGS_RELEASE"-Wall -DNO_LINENOS -DNDEBUG")
set(MSVC_COMPILER_FLAGS_DEBUG "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /wd4820 /nologo")
set(MSVC_COMPILER_FLAGS_RELEASE "/DNO_LINENOS /DNDEBUG /W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /wd4820 /nologo")
#
# Set more "sane" output folders
#
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
#
# Compiler specific flags
#
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
message(STATUS "Setting clang flags.")
set(CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} ${CLANG_COMPILER_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE
"${CMAKE_C_FLAGS_RELEASE} ${CLANG_COMPILER_FLAGS_RELEASE}")
add_definitions("-std=gnu99")
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
message(STATUS "Setting gcc flags.")
set(CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} ${GCC_COMPILER_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE
"${CMAKE_C_FLAGS_RELEASE} ${GCC_COMPILER_FLAGS_RELEASE}")
add_definitions("-std=gnu99")
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
message(STATUS "Setting MSVC flags.")
set(CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} ${MSVC_COMPILER_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE
"${CMAKE_C_FLAGS_RELEASE} ${MSVC_COMPILER_FLAGS_RELEASE}")
endif()
message(STATUS "Set debug flags to ${CMAKE_C_FLAGS_DEBUG}")
message(STATUS "Set release flags to ${CMAKE_C_FLAGS_RELEASE}")
#
# Cmake Modules that define how to find any external libs will be placed here
#
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake-modules)
#
# Add external libs that are required for abstract_astar_search_c to build here as sub
# directories such that we can build and link against them as static libraries
#
add_subdirectory(${PROJECT_SOURCE_DIR}/deps/bstring)
#
# Header files required by abstract_astar_search_c
#
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/deps/bstring/include)
#
# Add the abstract_astar_search_c src and tests to the build
#
add_subdirectory(src)
add_subdirectory(test)
#add_subdirectory(docs)