-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
78 lines (68 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
cmake_minimum_required (VERSION 2.8)
project (m2o-reborn)
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Please select another Build Directory ! (and give it a clever name, like bin_Visual2012_64bits/)")
endif()
if (CMAKE_SOURCE_DIR MATCHES " ")
message("Your Source Directory contains spaces. If you experience problems when compiling, this can be the cause.")
endif()
if (CMAKE_BINARY_DIR MATCHES " ")
message("Your Build Directory contains spaces. If you experience problems when compiling, this can be the cause.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MT /Zi" CACHE STRING "Debug compiler flags" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT /Zi" CACHE STRING "Release compiler flags" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF /ignore:4099")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
macro(GroupSources curdir)
file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
foreach (child ${children})
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
GroupSources(${curdir}/${child})
else()
string(REPLACE "/" "\\" groupname ${curdir})
source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
endif()
endforeach()
endmacro()
macro(GroupSourcesNamed name curdir)
file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
foreach (child ${children})
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
GroupSourcesNamed(${name}/${child} ${curdir}/${child})
else()
string(REPLACE "/" "\\" groupname ${name})
source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
endif()
endforeach()
endmacro()
macro(GroupSourcesBase)
file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/*)
foreach (child ${children})
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${child})
GroupSources(${child})
else()
source_group("" FILES ${PROJECT_SOURCE_DIR}/${child})
endif()
endforeach()
endmacro()
endif()
if (M2O_SERVER)
message("-- M2O_SERVER enabled, generating server project ...")
add_subdirectory(projects/server)
endif()
if (M2O_CLIENT)
message("-- M2O_CLIENT enabled, generating client, launcher projects ...")
if (M2O_CEF)
set(M2O_CEF 1)
add_definitions(-DM2O_CEF=1)
add_subdirectory(projects/worker)
endif()
add_subdirectory(projects/launcher)
add_subdirectory(projects/client)
endif()
if(MSVC)
GroupSources(projects/)
GroupSources(vendor/)
endif()