summaryrefslogtreecommitdiff
path: root/src/common/CMakeLists.txt
blob: effd0b2ab359d8ecf70804eb26149f19e7e50a74 (plain) (blame)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#
# Create svnversion.h
#
message( STATUS "Creating svnversion.h" )
if( SVNVERSION )
	file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h
		"#ifndef SVNVERSION\n#define SVNVERSION ${SVNVERSION}\n#endif\n" )
else()
	file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h "" )
endif()
set( GLOBAL_INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "" )
set( SVNVERSION ${SVNVERSION}
	CACHE STRING "SVN version of the source code" )
if( INSTALL_COMPONENT_DEVELOPMENT )
	install( FILES ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h
		DESTINATION "src/common"
		COMPONENT Development_base )
endif( INSTALL_COMPONENT_DEVELOPMENT )
message( STATUS "Creating svnversion.h - done" )


#####################################################################
# setup
#
set( COMMON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
	CACHE PATH "common source directory" )
mark_as_advanced( COMMON_SOURCE_DIR )

set( COMMON_ALL_HEADERS
	"${CMAKE_CURRENT_BINARY_DIR}/svnversion.h"
	"${COMMON_SOURCE_DIR}/cbasetypes.h"
	"${COMMON_SOURCE_DIR}/mmo.h"
	"${COMMON_SOURCE_DIR}/plugin.h"
	)

set( COMMON_MINI_HEADERS
	${COMMON_ALL_HEADERS}
	"${COMMON_SOURCE_DIR}/core.h"
	"${COMMON_SOURCE_DIR}/malloc.h"
	"${COMMON_SOURCE_DIR}/showmsg.h"
	"${COMMON_SOURCE_DIR}/strlib.h"
	${LIBCONFIG_HEADERS} # needed by showmsg.h
	CACHE INTERNAL "" )
set( COMMON_MINI_SOURCES
	"${COMMON_SOURCE_DIR}/core.c"
	"${COMMON_SOURCE_DIR}/malloc.c"
	"${COMMON_SOURCE_DIR}/showmsg.c"
	"${COMMON_SOURCE_DIR}/strlib.c"
	${LIBCONFIG_SOURCES} # needed by showmsg.c
	CACHE INTERNAL "" )
set( COMMON_MINI_INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIRS} CACHE INTERNAL "" )
set( COMMON_MINI_DEFINITIONS "-DMINICORE ${LIBCONFIG_DEFINITIONS}" CACHE INTERNAL "" )


#
# common_base
#
if( WITH_ZLIB )
message( STATUS "Creating target common_base" )
set( COMMON_BASE_HEADERS
	${COMMON_ALL_HEADERS}
	"${COMMON_SOURCE_DIR}/conf.h"
	"${COMMON_SOURCE_DIR}/core.h"
	"${COMMON_SOURCE_DIR}/db.h"
	"${COMMON_SOURCE_DIR}/des.h"
	"${COMMON_SOURCE_DIR}/ers.h"
	"${COMMON_SOURCE_DIR}/grfio.h"
	"${COMMON_SOURCE_DIR}/lock.h"
	"${COMMON_SOURCE_DIR}/malloc.h"
	"${COMMON_SOURCE_DIR}/mapindex.h"
	"${COMMON_SOURCE_DIR}/md5calc.h"
	"${COMMON_SOURCE_DIR}/nullpo.h"
	"${COMMON_SOURCE_DIR}/plugins.h"
	"${COMMON_SOURCE_DIR}/random.h"
	"${COMMON_SOURCE_DIR}/showmsg.h"
	"${COMMON_SOURCE_DIR}/socket.h"
	"${COMMON_SOURCE_DIR}/strlib.h"
	"${COMMON_SOURCE_DIR}/timer.h"
	"${COMMON_SOURCE_DIR}/utils.h"
	${LIBCONFIG_HEADERS} # needed by conf.h/showmsg.h
	CACHE INTERNAL "common_base headers" )
set( COMMON_BASE_SOURCES
	"${COMMON_SOURCE_DIR}/conf.c"
	"${COMMON_SOURCE_DIR}/core.c"
	"${COMMON_SOURCE_DIR}/db.c"
	"${COMMON_SOURCE_DIR}/des.c"
	"${COMMON_SOURCE_DIR}/ers.c"
	"${COMMON_SOURCE_DIR}/grfio.c"
	"${COMMON_SOURCE_DIR}/lock.c"
	"${COMMON_SOURCE_DIR}/malloc.c"
	"${COMMON_SOURCE_DIR}/mapindex.c"
	"${COMMON_SOURCE_DIR}/md5calc.c"
	"${COMMON_SOURCE_DIR}/nullpo.c"
	"${COMMON_SOURCE_DIR}/plugins.c"
	"${COMMON_SOURCE_DIR}/random.c"
	"${COMMON_SOURCE_DIR}/showmsg.c"
	"${COMMON_SOURCE_DIR}/socket.c"
	"${COMMON_SOURCE_DIR}/strlib.c"
	"${COMMON_SOURCE_DIR}/timer.c"
	"${COMMON_SOURCE_DIR}/utils.c"
	${LIBCONFIG_SOURCES} # needed by conf.c/showmsg.c
	CACHE INTERNAL "common_base sources" )
set( COMMON_BASE_INCLUDE_DIRS
	${LIBCONFIG_INCLUDE_DIRS}
	CACHE INTERNAL "common_base include dirs" )
set( COMMON_BASE_DEFINITIONS
	${LIBCONFIG_DEFINITIONS}
	CACHE INTERNAL "common_base definitions" )
set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} )
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} )
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" )
set( SOURCE_FILES ${MT19937AR_HEADERS} ${MT19937AR_SOURCES} ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} )
source_group( mt19937ar FILES ${MT19937AR_HEADERS} ${MT19937AR_SOURCES} )
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} )
add_library( common_base ${SOURCE_FILES} )
target_link_libraries( common_base ${LIBRARIES} )
set_target_properties( common_base PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
include_directories( ${INCLUDE_DIRS} )
set( HAVE_common_base ON  CACHE INTERNAL "" )
set( TARGET_LIST ${TARGET_LIST} common_base  CACHE INTERNAL "" )
message( STATUS "Creating target common_base - done" )
else()
message( STATUS "Skipping target common_base (requires ZLIB)" )
unset( HAVE_common_base CACHE )
endif()


#
# common_sql
#
if( HAVE_common_base AND WITH_MYSQL )
message( STATUS "Creating target common_sql" )
set( COMMON_SQL_HEADERS
	${COMMON_ALL_HEADERS}
	"${CMAKE_CURRENT_SOURCE_DIR}/sql.h"
	CACHE INTERNAL "common_sql headers" )
set( COMMON_SQL_SOURCES
	"${CMAKE_CURRENT_SOURCE_DIR}/sql.c"
	CACHE INTERNAL "common_sql sources" )
set( DEPENDENCIES common_base )
set( LIBRARIES ${GLOBAL_LIBRARIES} ${MYSQL_LIBRARIES} )
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} )
set( DEFINITIONS "${GLOBAL_DEFINITIONS}" )
set( SOURCE_FILES ${COMMON_SQL_HEADERS} ${COMMON_SQL_SOURCES} )
source_group( common FILES ${COMMON_SQL_HEADERS} ${COMMON_SQL_SOURCES} )
add_library( common_sql ${SOURCE_FILES} )
add_dependencies( common_sql ${DEPENDENCIES} )
target_link_libraries( common_sql ${LIBRARIES} ${DEPENDENCIES} )
set_target_properties( common_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
include_directories( ${INCLUDE_DIRS} )
set( HAVE_common_sql ON  CACHE INTERNAL "" )
set( TARGET_LIST ${TARGET_LIST} common_sql  CACHE INTERNAL "" )
message( STATUS "Creating target common_sql - done" )
else()
message( STATUS "Skipping target common_sql (requires common_base and MYSQL)" )
unset( HAVE_common_sql CACHE )
endif()