поддержка vcpkg
This commit is contained in:
parent
fe5cab0db0
commit
9651dd13a5
4
.gitignore
vendored
4
.gitignore
vendored
@ -31,6 +31,10 @@ Debug/voxel_engine
|
||||
AppDir
|
||||
appimage-build/
|
||||
|
||||
# for vcpkg
|
||||
/vcpkg/
|
||||
.gitmodules
|
||||
|
||||
# macOS folder attributes
|
||||
*.DS_Store
|
||||
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
option(VOXELENGINE_BUILD_WINDOWS_VCPKG OFF)
|
||||
if(VOXELENGINE_BUILD_WINDOWS_VCPKG AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
|
||||
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(VoxelEngine)
|
||||
|
||||
@ -28,8 +33,10 @@ if(VOXELENGINE_BUILD_APPDIR)
|
||||
install(TARGETS VoxelEngine DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin)
|
||||
endif()
|
||||
|
||||
|
||||
if(MSVC)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||
endif()
|
||||
if((CMAKE_BUILD_TYPE EQUAL "Release") OR (CMAKE_BUILD_TYPE EQUAL "RelWithDebInfo"))
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Release>:Release>")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /MT /O2)
|
||||
@ -45,17 +52,52 @@ else()
|
||||
-Wwrite-strings -Wno-unused-parameter)
|
||||
endif()
|
||||
|
||||
if(VOXELENGINE_BUILD_WINDOWS_VCPKG AND WIN32)
|
||||
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/.git")
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND)
|
||||
message(STATUS "Adding vcpkg as a git submodule...")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule add https://github.com/microsoft/vcpkg.git vcpkg WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
else()
|
||||
message(FATAL_ERROR "Git not found, cannot add vcpkg submodule.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/.git")
|
||||
message(STATUS "Initializing and updating vcpkg submodule...")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E chdir vcpkg ./bootstrap-vcpkg.bat WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER ${CONFIG_TYPE} CONFIG_TYPE_UPPER)
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_SOURCE_DIR}/res ${CMAKE_BINARY_DIR}/${CONFIG_TYPE_UPPER}/res)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLEW REQUIRED)
|
||||
find_package(OpenAL REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
# luajit has no CMakeLists.txt to use it as subdirectory, so install it
|
||||
find_package(Lua REQUIRED)
|
||||
|
||||
if (WIN32)
|
||||
set(PNGLIB spng)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libs/glfw)
|
||||
if(VOXELENGINE_BUILD_WINDOWS_VCPKG)
|
||||
set(LUA_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/luajit_x64-windows/lib/lua51.lib")
|
||||
set(LUA_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/luajit_x64-windows/include/luajit")
|
||||
find_package(glfw3 REQUIRED)
|
||||
find_package(spng REQUIRED)
|
||||
find_package(glm REQUIRED)
|
||||
set(PNGLIB spng::spng)
|
||||
else()
|
||||
find_package(Lua REQUIRED)
|
||||
set(PNGLIB spng)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libs/glfw)
|
||||
endif()
|
||||
else()
|
||||
# luajit has no CMakeLists.txt to use it as subdirectory, so install it manually
|
||||
find_package(Lua REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
set(PNGLIB PNG::PNG)
|
||||
endif()
|
||||
|
||||
14
vcpkg.json
Normal file
14
vcpkg.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "voxelengine",
|
||||
"version-string": "1.0.0",
|
||||
"dependencies": [
|
||||
"opengl",
|
||||
"openal-soft",
|
||||
"glfw3",
|
||||
"glew",
|
||||
"glm",
|
||||
"libspng",
|
||||
"zlib",
|
||||
"luajit"
|
||||
]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user