-
Notifications
You must be signed in to change notification settings - Fork 32
/
CMakeLists.txt
98 lines (84 loc) · 2.64 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
cmake_minimum_required (VERSION 2.8.4)
project (iceball)
set(CMAKE_SOURCE_DIR src)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-fno-strict-aliasing -Wall -Wextra -g) # keep debugging symbols even in Release builds
endif ()
include_directories(include)
if (WIN32)
if (MSVC)
set_source_files_properties(filename.c PROPERTIES LANGUAGE CXX )
endif (MSVC)
endif (WIN32)
if (MINGW)
set(CMAKE_PREFIX_PATH "dist/mingw/enet;dist/mingw/sdl2;dist/mingw/lua51;dist/mingw/sackit;dist/mingw/zlib" CACHE PATH "" FORCE)
elseif (MSVC)
set(CMAKE_PREFIX_PATH "dist/msvc/enet;dist/msvc/sdl2;dist/msvc/lua51;dist/msvc/sackit;dist/msvc/zlib" CACHE PATH "" FORCE)
endif ()
find_package(ENet REQUIRED)
find_package(SDL2 REQUIRED)
find_package(ZLIB REQUIRED)
find_package(LuaJIT)
if (LUAJIT_FOUND)
add_definitions(-DUSE_LUAJIT)
set(LUA_LIBRARIES ${LUA_LIBRARY} m)
else ()
find_package(Lua REQUIRED)
endif ()
find_package(sackit REQUIRED)
find_package(OpenGL REQUIRED)
include_directories(
${ENet_INCLUDE_DIRS}
${sackit_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${SDL2_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
)
file(GLOB LUA_FILES src/lua* src/external/bit.c)
set(MAIN_FILES
src/dsp.c
src/img.c
src/json.c
src/logtxt.c
src/main.c
src/map.c
src/model.c
src/network.c
src/path.c
src/png.c
src/random.c
src/vecmath.c
src/wav.c
)
set(GL_FILES
src/gl/glad.c
src/gl/render.c
src/gl/render_img.c
)
source_group(gl FILES ${GL_FILES})
source_group(lua FILES ${LUA_FILES})
# iceball target
add_executable(iceball ${MAIN_FILES} ${LUA_FILES} ${GL_FILES})
target_link_libraries(iceball ${CMAKE_DL_LIBS} ${ENet_LIBRARIES} ${ZLIB_LIBRARIES} ${sackit_LIBRARY} ${LUA_LIBRARIES} ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES})
set_target_properties(iceball PROPERTIES C_STANDARD 99)
# iceball-dedi target
add_executable(iceball-dedi EXCLUDE_FROM_ALL ${MAIN_FILES} ${LUA_FILES})
target_link_libraries(iceball-dedi ${CMAKE_DL_LIBS} ${ENet_LIBRARIES} ${ZLIB_LIBRARIES} ${LUA_LIBRARIES} ${SDL_LIBRARY})
set_target_properties(iceball-dedi PROPERTIES C_STANDARD 99)
set_target_properties(iceball-dedi PROPERTIES COMPILE_DEFINITIONS "DEDI")
function(copy_run_dep arg1)
add_custom_command(TARGET iceball POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/${arg1}"
$<TARGET_FILE_DIR:iceball>)
endfunction()
if (MINGW)
copy_run_dep(dist/mingw/sdl2/bin/libSDL2.dll)
copy_run_dep(dist/mingw/lua51/bin/liblua.dll)
copy_run_dep(dist/mingw/zlib/bin/libzlib.dll)
elseif (MSVC)
copy_run_dep(dist/msvc/sdl2/bin/SDL2.dll)
copy_run_dep(dist/msvc/lua51/bin/lua.dll)
copy_run_dep(dist/msvc/zlib/bin/zlib.dll)
endif ()