-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
48 lines (35 loc) · 1.26 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(OSSCPP)
# Default build type
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug CACHE STRING
"Choose the type of build, options are: Debug Release"
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
# CMAKE_BUILD_TYPE can only be one of Debug or Release
SET(BUILD_TYPE_OK FALSE)
FOREACH(build_type "Debug" "Release")
IF (${CMAKE_BUILD_TYPE} STREQUAL ${build_type})
SET(BUILD_TYPE_OK TRUE)
ENDIF (${CMAKE_BUILD_TYPE} STREQUAL ${build_type})
ENDFOREACH(build_type)
IF (NOT BUILD_TYPE_OK)
MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE can only be one of \"Debug\" or \"Release\"")
ENDIF (NOT BUILD_TYPE_OK)
IF (${OSSCPP_BINARY_DIR} STREQUAL ${OSSCPP_SOURCE_DIR})
MESSAGE(FATAL_ERROR "In-tree-compile is not prefered.")
ENDIF (${OSSCPP_BINARY_DIR} STREQUAL ${OSSCPP_SOURCE_DIR})
# Build types
SET(CMAKE_C_FLAGS "-std=c99 -Wall"
CACHE
STRING "Flags used by the compiler during all build types." FORCE)
SET(CMAKE_C_FLAGS_DEBUG "-g -O0" CACHE
STRING "Flags used by the compiler during debug builds." FORCE)
SET(CMAKE_C_FLAGS_RELEASE "-O2" CACHE
STRING "Flags used by the compiler during release builds." FORCE)
IF(UNIX)
ADD_DEFINITIONS("-D_GNU_SOURCE")
ENDIF(UNIX)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(example)
# vim:tabstop=4:shiftwidth=4