|
| 1 | +macro(download_file_if_it_doesnt_exist filename url) |
| 2 | + if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${filename}) |
| 3 | + message(STATUS "Downloading ${filename}") |
| 4 | + file(DOWNLOAD ${url} ${CMAKE_CURRENT_SOURCE_DIR}/${filename} STATUS stat) |
| 5 | + list(GET stat 0 success) |
| 6 | + list(GET stat 1 error) |
| 7 | + if (NOT ${success}) |
| 8 | + message(STATUS "Downloaded ${filename} succesfully") |
| 9 | + else() |
| 10 | + file(REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/${filename}) |
| 11 | + message(FATAL_ERROR "Failed to download ${filename} (${error})") |
| 12 | + endif() |
| 13 | + endif() |
| 14 | +endmacro(download_file_if_it_doesnt_exist) |
| 15 | + |
| 16 | +download_file_if_it_doesnt_exist(ini.c https://raw.githubusercontent.com/benhoyt/inih/master/ini.c) |
| 17 | +download_file_if_it_doesnt_exist(ini.h https://raw.githubusercontent.com/benhoyt/inih/master/ini.h) |
| 18 | +download_file_if_it_doesnt_exist(lodepng/lodepng.c https://raw.githubusercontent.com/lvandeve/lodepng/master/lodepng.cpp) |
| 19 | +download_file_if_it_doesnt_exist(lodepng/lodepng.h https://raw.githubusercontent.com/lvandeve/lodepng/master/lodepng.h) |
| 20 | +download_file_if_it_doesnt_exist(dr_wav.c https://raw.githubusercontent.com/mackron/dr_libs/master/dr_wav.h) |
| 21 | +download_file_if_it_doesnt_exist(stb_truetype.h https://raw.githubusercontent.com/nothings/stb/master/stb_truetype.h) |
| 22 | +download_file_if_it_doesnt_exist(parson.c https://raw.githubusercontent.com/kgabis/parson/master/parson.c) |
| 23 | +download_file_if_it_doesnt_exist(parson.h https://raw.githubusercontent.com/kgabis/parson/master/parson.h) |
| 24 | +download_file_if_it_doesnt_exist(http.h https://raw.githubusercontent.com/mattiasgustavsson/libs/master/http.h) |
| 25 | + |
| 26 | +list(APPEND CLIENT_SOURCES aabb.c) |
| 27 | +list(APPEND CLIENT_SOURCES camera.c) |
| 28 | +list(APPEND CLIENT_SOURCES cameracontroller.c) |
| 29 | +list(APPEND CLIENT_SOURCES chunk.c) |
| 30 | +list(APPEND CLIENT_SOURCES config.c) |
| 31 | +list(APPEND CLIENT_SOURCES dr_wav.c) |
| 32 | +list(APPEND CLIENT_SOURCES file.c) |
| 33 | +list(APPEND CLIENT_SOURCES font.c) |
| 34 | +list(APPEND CLIENT_SOURCES glx.c) |
| 35 | +list(APPEND CLIENT_SOURCES grenade.c) |
| 36 | +list(APPEND CLIENT_SOURCES http.c) |
| 37 | +list(APPEND CLIENT_SOURCES hud.c) |
| 38 | +list(APPEND CLIENT_SOURCES ini.c) |
| 39 | +list(APPEND CLIENT_SOURCES list.c) |
| 40 | +list(APPEND CLIENT_SOURCES main.c) |
| 41 | +list(APPEND CLIENT_SOURCES map.c) |
| 42 | +list(APPEND CLIENT_SOURCES matrix.c) |
| 43 | +list(APPEND CLIENT_SOURCES model.c) |
| 44 | +list(APPEND CLIENT_SOURCES network.c) |
| 45 | +list(APPEND CLIENT_SOURCES parson.c) |
| 46 | +list(APPEND CLIENT_SOURCES particle.c) |
| 47 | +list(APPEND CLIENT_SOURCES player.c) |
| 48 | +list(APPEND CLIENT_SOURCES sound.c) |
| 49 | +list(APPEND CLIENT_SOURCES stb_truetype.c) |
| 50 | +list(APPEND CLIENT_SOURCES texture.c) |
| 51 | +list(APPEND CLIENT_SOURCES tracer.c) |
| 52 | +list(APPEND CLIENT_SOURCES weapon.c) |
| 53 | +list(APPEND CLIENT_SOURCES window.c) |
| 54 | +list(APPEND CLIENT_SOURCES ${BetterSpades_SOURCE_DIR}/resources/icon.rc) |
| 55 | + |
| 56 | +add_executable(client ${CLIENT_SOURCES}) |
| 57 | +target_compile_definitions(client PRIVATE DR_WAV_IMPLEMENTATION) |
| 58 | +set_target_properties( |
| 59 | + client PROPERTIES |
| 60 | + RUNTIME_OUTPUT_DIRECTORY ${BetterSpades_SOURCE_DIR}/build/BetterSpades |
| 61 | + C_STANDARD 99 |
| 62 | +) |
| 63 | + |
| 64 | +set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${BetterSpades_SOURCE_DIR}/deps) |
| 65 | +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${BetterSpades_SOURCE_DIR}/cmake/Modules) |
| 66 | +find_package(glfw3 REQUIRED) |
| 67 | +find_package(OpenGL REQUIRED) |
| 68 | +find_package(OpenAL CONFIG REQUIRED) |
| 69 | +find_package(enet REQUIRED) |
| 70 | +find_package(deflate REQUIRED) |
| 71 | + |
| 72 | +target_link_libraries(client glfw OpenGL::GL OpenAL::OpenAL enet::enet deflate::deflate) |
| 73 | + |
| 74 | +add_custom_command( |
| 75 | + TARGET client |
| 76 | + POST_BUILD |
| 77 | + COMMAND ${CMAKE_COMMAND} -E echo "Copying resources.." |
| 78 | + COMMAND ${CMAKE_COMMAND} -E copy_directory ${BetterSpades_SOURCE_DIR}/resources ${BetterSpades_SOURCE_DIR}/build/BetterSpades |
| 79 | +) |
0 commit comments