mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
* build: add nlohmann/json library * build(deps): add harfbuzz dependency * feat(cmake): add guard to reject macOS builds * feat(font): add HarfBuzz shaping and replace font with unifont * feat(localization): add i18n support with en_US and zh_CN translations Implement Localization class to load JSON translation files. Replace hardcoded strings in UI with translation keys and update sliders/combo buttons to use dynamic text. * feat(localization): detect system locale for language default * feat(settings): add language selection option with restart notification * fix: use vckpg to add freetype on windows
163 lines
3.8 KiB
CMake
163 lines
3.8 KiB
CMake
cmake_minimum_required(VERSION 3.21)
|
|
|
|
if(APPLE)
|
|
message(FATAL_ERROR "This game does not support macOS")
|
|
endif()
|
|
|
|
project(Cubed LANGUAGES C CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
if(NOT CMAKE_CONFIGURATION_TYPES
|
|
AND NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED CUBED_VERSION)
|
|
set(CUBED_VERSION "dev")
|
|
endif()
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME})
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME})
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
|
|
)
|
|
|
|
include(Dependencies)
|
|
|
|
add_subdirectory(third_party/glad)
|
|
|
|
add_subdirectory(third_party/imgui)
|
|
|
|
add_subdirectory(third_party/dr_libs)
|
|
|
|
add_executable(${PROJECT_NAME})
|
|
|
|
add_subdirectory(src)
|
|
|
|
file(GLOB_RECURSE PROTO_FILES
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/proto/*.proto
|
|
)
|
|
|
|
protobuf_generate(
|
|
TARGET ${PROJECT_NAME}
|
|
LANGUAGE cpp
|
|
PROTOS ${PROTO_FILES}
|
|
IMPORT_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/proto
|
|
)
|
|
|
|
configure_file(
|
|
src/version.hpp.in
|
|
${CMAKE_BINARY_DIR}/generated/version.hpp
|
|
@ONLY
|
|
)
|
|
|
|
target_compile_options(${PROJECT_NAME}
|
|
PRIVATE
|
|
$<$<CONFIG:Debug>:-fno-omit-frame-pointer>
|
|
$<$<CONFIG:Debug>:-g>
|
|
#$<$<CONFIG:Debug>:-fsanitize=address>
|
|
#$<$<CONFIG:Debug>:-fsanitize=thread>
|
|
|
|
$<$<CXX_COMPILER_ID:GNU,Clang>:-Wall>
|
|
$<$<CXX_COMPILER_ID:GNU,Clang>:-Wextra>
|
|
$<$<CXX_COMPILER_ID:GNU,Clang>:-Wpedantic>
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
|
|
$<$<CXX_COMPILER_ID:MSVC>:/W4>
|
|
)
|
|
|
|
target_link_options(${PROJECT_NAME}
|
|
PRIVATE
|
|
#$<$<CONFIG:Debug>:-fsanitize=address>
|
|
#$<$<CONFIG:Debug>:-fsanitize=thread>
|
|
)
|
|
|
|
target_compile_definitions(${PROJECT_NAME}
|
|
PRIVATE
|
|
ASIO_STANDALONE
|
|
ASIO_NO_DEPRECATED
|
|
$<$<CONFIG:Debug>:DEBUG_MODE>
|
|
$<$<CXX_COMPILER_ID:MSVC>:
|
|
WIN32_LEAN_AND_MEAN
|
|
NOMINMAX
|
|
_CRT_SECURE_NO_WARNINGS
|
|
>
|
|
)
|
|
|
|
if(CMAKE_CONFIGURATION_TYPES)
|
|
# Visual Studio / Xcode multi-configuration generator
|
|
target_compile_definitions(${PROJECT_NAME}
|
|
PRIVATE
|
|
ASSETS_PATH="$<$<CONFIG:Debug>:${PROJECT_SOURCE_DIR}/assets/>$<$<NOT:$<CONFIG:Debug>>:./assets/>"
|
|
)
|
|
else()
|
|
# Ninja / Makefiles single-configuration generator
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
target_compile_definitions(${PROJECT_NAME}
|
|
PRIVATE
|
|
ASSETS_PATH="${PROJECT_SOURCE_DIR}/assets/"
|
|
)
|
|
else()
|
|
target_compile_definitions(${PROJECT_NAME}
|
|
PRIVATE
|
|
ASSETS_PATH="./assets/"
|
|
)
|
|
endif()
|
|
endif()
|
|
|
|
|
|
target_include_directories(${PROJECT_NAME}
|
|
PRIVATE
|
|
${PROJECT_SOURCE_DIR}/include
|
|
${PROJECT_SOURCE_DIR}/third_party/asio/include
|
|
${CMAKE_BINARY_DIR}/generated
|
|
${PROJECT_BINARY_DIR}
|
|
${PROJECT_BINARY_DIR}/src
|
|
|
|
)
|
|
|
|
|
|
target_link_libraries(${PROJECT_NAME}
|
|
PRIVATE
|
|
glfw
|
|
glad
|
|
glm::glm
|
|
OpenGL::GL
|
|
soil2
|
|
Freetype::Freetype
|
|
tomlplusplus::tomlplusplus
|
|
imgui
|
|
dr_libs
|
|
tbb
|
|
protobuf::libprotobuf
|
|
absl::log
|
|
absl::check
|
|
absl::base
|
|
absl::strings
|
|
absl::flat_hash_map
|
|
zstd::zstd
|
|
OpenAL::OpenAL
|
|
harfbuzz::harfbuzz
|
|
$<$<PLATFORM_ID:Windows>:ws2_32>
|
|
|
|
)
|
|
|
|
if(WIN32)
|
|
add_custom_command(
|
|
TARGET ${PROJECT_NAME}
|
|
POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}>
|
|
$<TARGET_FILE_DIR:${PROJECT_NAME}>
|
|
COMMAND_EXPAND_LISTS
|
|
)
|
|
endif() |