forked from voodooattack/ADWIF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
183 lines (151 loc) · 7.2 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
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
183
cmake_minimum_required(VERSION 2.8.8)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules" ${CMAKE_MODULE_PATH})
# include(cotire)
include(GetGitRevisionDescription)
get_git_head_revision(ADWIF_GIT_BRANCH ADWIF_GIT_REVISION)
project(adwif)
enable_language(C CXX)
set(ADWIF_SOURCES
noisemodules.cpp noiseutils.cpp imageutils.cpp mapgenerator.cpp mapgenstate.cpp item.cpp
fileutils.cpp jsonutils.cpp renderer.cpp animationutils.cpp util.cpp scripting.cpp game.cpp
player.cpp newgamestate.cpp introanimation.cpp animation.cpp mainmenustate.cpp introstate.cpp
mapcell.cpp engine.cpp main.cpp
)
set(DEP_DIR ${PROJECT_SOURCE_DIR}/deps)
set(V8_ROOT ${DEP_DIR}/v8)
set(PHYSFS_CPP_ROOT ${DEP_DIR}/physfs-cpp)
find_package(Subversion)
find_package(Git)
MESSAGE ("Looking for 7-Zip")
find_program(ZIP_UNZIP_COMMAND 7z PATHS "$ENV{ProgramFiles}/7-Zip")
if(ZIP_UNZIP_COMMAND)
set(ZIP_UNZIP_OPTION x CACHE INTERNAL "option for unzipping")
set(ZIP_ZIP_OPTION u -tzip -bd CACHE INTERNAL "option for zipping")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(7Zip DEFAULT_MSG ZIP_UNZIP_COMMAND)
mark_as_advanced(ZIP_UNZIP_COMMAND)
if(NOT DEFINED V8_CHECKOUT)
#execute_process(COMMAND ${SUBVERSION_SVN_EXECUTABLE} co --force http://v8.googlecode.com/svn/trunk/ ${V8_ROOT})
#execute_process(COMMAND make -C ${V8_ROOT} -f ${V8_ROOT}/Makefile i18nsupport=off werror=no dependencies native)
set(V8_CHECKOUT TRUE CACHE INTERNAL "whether or not Google V8 was checked out")
endif()
if(NOT DEFINED PHYSFS_CPP_CHECKOUT)
execute_process(COMMAND ${GIT_EXECUTABLE} clone https://github.com/kahowell/physfs-cpp/ ${PHYSFS_CPP_ROOT})
set(PHYSFS_CPP_CHECKOUT TRUE CACHE INTERNAL "whether or not physfs-cpp was checked out")
endif()
add_subdirectory(${DEP_DIR})
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-std=gnu++11")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libstdc++")
elseif(MSVC)
# On by default
endif()
#execute_process(COMMAND make -C ${V8_ROOT} -f ${V8_ROOT}/Makefile i18nsupport=off werror=no native)
set(ADWIF_MAP_ENGINE "Custom" CACHE STRING
"Select a mapping backend, valid values are 'OpenVDB', 'Field3D', or 'Custom'")
set_property(CACHE ADWIF_MAP_ENGINE PROPERTY STRINGS
"OpenVDB" "Field3D" "Custom")
if(ADWIF_MAP_ENGINE STREQUAL "OpenVDB")
find_package(OpenVDB REQUIRED)
find_package(Half)
find_package(TBB)
set(ADWIF_SOURCES ${ADWIF_SOURCES} map_openvdb.cpp mapbank.cpp)
set(ADWIF_MAP_INCLUDES ${OPENVDB_INCLUDE_DIRS} ${TBB_INCLUDE_DIRS})
set(ADWIF_MAP_LIBRARIES ${OPENVDB_LIBRARIES} ${TBB_LIBRARIES} ${HALF_LIBRARIES})
elseif(ADWIF_MAP_ENGINE STREQUAL "Field3D")
find_package(Field3D REQUIRED)
find_package(ILMBase REQUIRED)
find_package(HDF5 REQUIRED)
set(ADWIF_SOURCES ${ADWIF_SOURCES} map_field3d.cpp mapbank.cpp)
set(ADWIF_MAP_INCLUDES ${FIELD3D_INCLUDE_DIRS} ${ILMBASE_INCLUDE_DIRS} ${HDF5_INCLUDE_DIRS})
set(ADWIF_MAP_LIBRARIES ${FIELD3D_LIBRARIES} ${HDF5_LIBRARIES})
elseif(ADWIF_MAP_ENGINE STREQUAL "Custom")
find_package(TBB)
set(ADWIF_SOURCES ${ADWIF_SOURCES} map_custom.cpp mapbank.cpp)
endif()
set(ADWIF_RENDERER "curses" CACHE STRING
"Select a rendering backend, valid values are 'curses' and 'tcod'")
set_property(CACHE ADWIF_RENDERER PROPERTY STRINGS
"curses" "tcod")
set(Boost_USE_MULTITHREADED ON)
if(ADWIF_RENDERER STREQUAL "curses")
set(CURSES_NEED_WIDE on)
find_package(curses REQUIRED)
set(ADWIF_RENDERER_USE_CURSES True)
set(ADWIF_RENDERER_SOURCES "curses.cpp")
set(ADWIF_RENDERER_INCLUDES ${CURSES_INCLUDE_DIR})
set(ADWIF_RENDERER_LIBRARIES ${CURSES_LIBRARIES})
elseif(ADWIF_RENDERER STREQUAL "tcod")
find_package(TCOD REQUIRED)
set(ADWIF_RENDERER_USE_TCOD True)
set(ADWIF_RENDERER_SOURCES "tcod.cpp")
set(ADWIF_RENDERER_INCLUDES ${LIBTCOD_INCLUDE_DIRS})
set(ADWIF_RENDERER_LIBRARIES ${LIBTCOD_LIBRARIES})
endif()
option(ADWIF_LOGGING "whether or not to enable logging" ON)
option(ADWIF_UNICODE "whether or not to use unicode output" ON)
if(ADWIF_UNICODE)
find_package(UTF8CPP REQUIRED)
endif()
find_package(V8 REQUIRED)
find_package(PhysFS REQUIRED)
find_package(JsonCpp REQUIRED)
find_package(FreeImage REQUIRED)
find_package(Noise REQUIRED)
#find_package(Eigen3 REQUIRED)
find_package(Boost 1.55.0 COMPONENTS serialization coroutine context filesystem system iostreams regex program_options thread chrono REQUIRED)
find_package(Threads REQUIRED)
option(ADWIF_BUILD_EDITOR "whether or not to build the game editor" OFF)
if (ADWIF_BUILD_EDITOR)
set(EDITOR_DIR "editor")
include_directories(${EDITOR_DIR})
set(CMAKE_AUTOMOC ON)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(OpenGL REQUIRED)
set(EDITOR_UI editor/editor.ui editor/heightmapeditor.ui)
set(EDITOR_SOURCES
editor/editor.cpp editor/heightmapeditor.cpp editor/noisegraphbuilder.cpp
editor/extendedvariantmanager.cpp editor/extendedvarianteditorfactory.cpp
editor/propertybrowserbox.cpp editor/curveeditor.cpp editor/scrollablegraphicsview.cpp
)
set(EDITOR_HEADERS
editor/editor.hpp editor/heightmapeditor.hpp editor/noisegraphbuilder.hpp
editor/extendedvariantmanager.hpp editor/extendedvarianteditorfactory.hpp
editor/propertybrowserbox.hpp editor/curveeditor.hpp editor/scrollablegraphicsview.hpp
)
set(EDITOR_RESOURCES editor/resources.qrc)
qt5_wrap_ui(EDITOR_UI_SRC ${EDITOR_UI})
qt5_add_resources(EDITOR_RC ${EDITOR_RESOURCES})
set(ADWIF_SOURCES ${EDITOR_UI_SRC} ${ADWIF_SOURCES} ${EDITOR_SOURCES} ${EDITOR_RC} editorstate.cpp)
include_directories(${DEP_DIR}/QtPropertyBrowser)
endif()
# get_cmake_property(_variableNames VARIABLES)
# foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
# endforeach()
configure_file ("${PROJECT_SOURCE_DIR}/config.hpp.in" "${PROJECT_BINARY_DIR}/config.hpp")
include_directories(${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${EDITOR_INCLUDES} ${ADWIF_MAP_INCLUDES}
${ADWIF_RENDERER_INCLUDES} ${PHYSFS_INCLUDE_DIR} ${V8_INCLUDE_DIR}
${Boost_INCLUDE_DIRS} ${HALF_INCLUDE_DIRS} ${PHYSFS_CPP_ROOT}/include ${JSONCPP_INCLUDE_DIR}
${UTF8CPP_INCLUDE_DIR} ${FREEIMAGE_INCLUDE_PATH} ${NOISE_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR})
add_executable(adwif ${ADWIF_RENDERER_SOURCES} ${ADWIF_SOURCES})
add_dependencies(adwif physfs++)
if (ADWIF_BUILD_EDITOR)
add_dependencies(adwif QtPropertyBrowser)
target_link_libraries(adwif QtPropertyBrowser)
qt5_use_modules(adwif Core Widgets OpenGL)
endif()
target_link_libraries(adwif ${EDITOR_LIBRARIES} ${ADWIF_RENDERER_LIBRARIES} ${ADWIF_MAP_LIBRARIES} ${PHYSFS_LIBRARY}
${V8_LIBRARIES} ${Boost_LIBRARIES} ${TBB_LIBRARIES} ${FREEIMAGE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
${JSONCPP_LIBRARIES} ${NOISE_LIBRARY} physfs++)
#add_custom_command(TARGET adwif POST_BUILD COMMENT
# COMMAND ${CMAKE_COMMAND} -E copy_directory
# ${CMAKE_SOURCE_DIR}/data $<TARGET_FILE_DIR:adwif>/data)
add_custom_command(TARGET adwif PRE_BUILD
COMMAND ${ZIP_UNZIP_COMMAND} ${ZIP_ZIP_OPTION}
$<TARGET_FILE_DIR:adwif>/data.dat ${CMAKE_SOURCE_DIR}/data/*)
#cotire(adwif)
install(TARGETS adwif RUNTIME DESTINATION bin)