This repository has been archived by the owner on Jun 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
81 lines (69 loc) · 2.81 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
SET(CMAKE_CXX_COMPILER "autopch-g++")
PROJECT(sofadb)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
ENABLE_TESTING()
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
#SET(CMAKE_BUILD_TYPE MinSizeRel)
#SET(CMAKE_BUILD_TYPE RelWithDebInfo)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-inline -O0")
ENDIF(NOT CMAKE_BUILD_TYPE)
# Define DEBUG on debug builds
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_DEBUG DEBUG=1)
# Define 'NDEBUG' on release builds
foreach (configuration MINSIZEREL RELWITHDEBINFO RELEASE)
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_${configuration} "NDEBUG=1")
endforeach ()
#set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_RELEASE -DNDEBUG)
IF(WIN32)
ADD_DEFINITIONS(-DUNICODE -D_UNICODE -D_DEBUG)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:NOREF")
IF(CMAKE_GENERATOR MATCHES "Visual Studio")
# replace /MDd with /MTd
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG_INIT
${CMAKE_CXX_FLAGS_DEBUG_INIT})
STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG_INIT
${CMAKE_C_FLAGS_DEBUG_INIT})
STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE
${CMAKE_C_FLAGS_RELEASE})
STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO
${CMAKE_C_FLAGS_RELWITHDEBINFO})
STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL
${CMAKE_C_FLAGS_MINSIZEREL})
STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG
${CMAKE_C_FLAGS_DEBUG})
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE
${CMAKE_CXX_FLAGS_RELEASE})
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO
${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL
${CMAKE_CXX_FLAGS_MINSIZEREL})
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG
${CMAKE_CXX_FLAGS_DEBUG})
ENDIF()
ELSEIF(UNIX)
ADD_DEFINITIONS(-fPIC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fvisibility=hidden -fvisibility-inlines-hidden -fno-builtin-memcmp")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=core2 -msse4.2")
SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -mtune=core2 -msse4.2")
ELSE()
MESSAGE(FATAL_ERROR "Unsupported target OS!")
ENDIF()
FIND_PACKAGE(LevelDb REQUIRED)
#FIND_PACKAGE(Boost 1.42 COMPONENTS thread regex date_time unit_test_framework)
FIND_PACKAGE(Boost 1.42 COMPONENTS thread regex date_time)
CONFIGURE_FILE(
"cmake/config.h.in"
"${PROJECT_BINARY_DIR}/include/sofadb_generated_config.h"
)
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/include)
ADD_SUBDIRECTORY(libsofadb)
ADD_SUBDIRECTORY(server)
ADD_SUBDIRECTORY(example)
#ADD_SUBDIRECTORY(test)
ADD_SUBDIRECTORY(tools)