~widelands-dev/widelands/trunk

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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/build_info.cc.cmake ${CMAKE_CURRENT_BINARY_DIR}/build_info.cc)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/../cmake/datadirversion.cmake ${CMAKE_CURRENT_SOURCE_DIR}/../data/datadirversion)

# Catchall target to codecheck all files.
add_custom_target(codecheck)
add_custom_target(run_build_deps
  COMMAND
    ${Python3_EXECUTABLE}
    ${CMAKE_SOURCE_DIR}/utils/build_deps.py
  COMMENT "Checking CMakeLists.txt files."
)
add_dependencies(codecheck run_build_deps)

# A target that depends on all unit tests as 'make test' will not rebuild
# tests:
# https://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests
add_custom_target(wl_tests)

#include the cmake version dependend macro _include_directories
if (CMAKE_VERSION VERSION_LESS 2.8.11)
  include (${CMAKE_SOURCE_DIR}/cmake/IncludeDirectoriesOld.cmake)
else (CMAKE_VERSION VERSION_LESS 2.8.11)
  include (${CMAKE_SOURCE_DIR}/cmake/IncludeDirectories.cmake)
endif (CMAKE_VERSION VERSION_LESS 2.8.11)

wl_library(build_info
  SRCS
    build_info.cc
    build_info.h
)

if (WIN32)
	configure_file (${CMAKE_CURRENT_SOURCE_DIR}/../utils/windows/widelands.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/widelands.rc)
	message (STATUS "Configured windows resource file")
	set(WIN32_ICON_O ${CMAKE_CURRENT_BINARY_DIR}/wl_icon.o)
	if(MSVC)
		ADD_CUSTOM_COMMAND(OUTPUT ${WIN32_ICON_O}
			COMMAND rc
				/fo ${WIN32_ICON_O}
				${CMAKE_CURRENT_BINARY_DIR}/widelands.rc
		)
	else()
		ADD_CUSTOM_COMMAND(OUTPUT ${WIN32_ICON_O}
			COMMAND ${MINGW_PREFIX}windres
				-o${WIN32_ICON_O}
				-i${CMAKE_CURRENT_BINARY_DIR}/widelands.rc
		)
	endif()

  wl_binary(widelands
    WIN32
    SRCS
      main.cc
      ${WIN32_ICON_O}
    DEPENDS
      base_exceptions
      widelands_ball_of_mud
      build_info
  )
else()
  wl_binary(widelands
    SRCS
      main.cc
    DEPENDS
      base
      base_exceptions
      base_time_string
      logic_filesystem_constants
      widelands_ball_of_mud
      build_info
  )
endif()

if(OPTION_FORCE_EMBEDDED_MINIZIP)
    # unset these two if they are cached
    unset(MINIZIP_FOUND)
    set(MINIZIP_STATIC_LIBRARIES "")
else()
   # If pkg-config is ever needed to find other libraries, move the include outside the if() block
  include(FindPkgConfig)
  if(PKG_CONFIG_FOUND)
    pkg_check_modules(MINIZIP minizip)
  endif()
endif()

add_subdirectory(third_party)
add_subdirectory(ai)
add_subdirectory(base)
add_subdirectory(chat)
add_subdirectory(commands)
add_subdirectory(economy)
add_subdirectory(editor)
add_subdirectory(game_io)
add_subdirectory(graphic)
add_subdirectory(io)
add_subdirectory(logic)
add_subdirectory(map_io)
add_subdirectory(network)
add_subdirectory(notifications)
add_subdirectory(scripting)
add_subdirectory(sound)
add_subdirectory(ui_basic)
add_subdirectory(ui_fsmenu)
if (OPTION_BUILD_WEBSITE_TOOLS)
  add_subdirectory(website)
endif (OPTION_BUILD_WEBSITE_TOOLS)
add_subdirectory(wui)

# TODO(unknown): Ideally widelands_ball_of_mud shouldn't exist, everything should be in a
# library.
wl_library(widelands_ball_of_mud
  SRCS
    wlapplication.cc
    wlapplication.h
    wlapplication_messages.cc
    wlapplication_messages.h
  USES_ATOMIC
  USES_SDL2
  USES_SDL2_TTF
  DEPENDS
    base
    base_exceptions
    base_geometry
    base_macros
    base_random
    base_time_string
    build_info
    editor
    graphic
    graphic_fonthandler
    graphic_functions
    graphic_mouse_cursor
    graphic_text
    io_filesystem
    logic
    logic_addons
    logic_exceptions
    logic_filesystem_constants
    logic_game_controller
    logic_game_settings
    logic_map
    logic_single_player_game_settings
    map_io_map_loader
    network
    sound
    ui_basic
    ui_fsmenu
    widelands_options
    wui
    wui_chat_ui
    wui_common_mapdetails
)

wl_library(widelands_options
  SRCS
    wlapplication_options.cc
    wlapplication_options.h
    wlapplication_mousewheel_options.cc
    wlapplication_mousewheel_options.h
  DEPENDS
    base
    base_geometry
    graphic_text_layout
    io_filesystem
    io_profile
    logic_filesystem_constants
  USES_SDL2
)

if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR
    CMAKE_SYSTEM_NAME MATCHES "NetBSD" OR
    CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
  target_link_libraries(widelands_ball_of_mud ${EXECINFO_LIBRARY})
endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR
       CMAKE_SYSTEM_NAME MATCHES "NetBSD" OR
       CMAKE_SYSTEM_NAME MATCHES "OpenBSD")

if (WIN32)
  target_link_libraries(widelands_ball_of_mud wsock32)
#  set_target_properties(widelands PROPERTIES LINK_FLAGS_RELEASE -s)
endif (WIN32)