Fix usage vcpkg for windows and fix readme, remove vcpkg usage flag from cmake
This commit is contained in:
parent
ea23ed2e00
commit
dccda99364
4
.gitignore
vendored
4
.gitignore
vendored
@ -36,10 +36,6 @@ Debug/voxel_engine
|
||||
AppDir
|
||||
appimage-build/
|
||||
|
||||
# for vcpkg
|
||||
/vcpkg/
|
||||
.gitmodules
|
||||
|
||||
# macOS folder attributes
|
||||
*.DS_Store
|
||||
|
||||
|
||||
@ -1,13 +1,8 @@
|
||||
option(VOXELENGINE_BUILD_WINDOWS_VCPKG ON)
|
||||
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)
|
||||
|
||||
option(VOXELENGINE_BUILD_APPDIR OFF)
|
||||
option(VOXELENGINE_BUILD_TESTS OFF)
|
||||
option(VOXELENGINE_BUILD_APPDIR "" OFF)
|
||||
option(VOXELENGINE_BUILD_TESTS "" OFF)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
@ -44,30 +39,14 @@ else()
|
||||
endif()
|
||||
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()
|
||||
# if(VOXELENGINE_BUILD_WINDOWS_VCPKG AND WIN32)
|
||||
# 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()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie -lstdc++fs")
|
||||
|
||||
25
README.md
25
README.md
@ -108,17 +108,28 @@ cmake --build .
|
||||
>[!NOTE]
|
||||
> Requirement:
|
||||
>
|
||||
> vcpkg, CMake
|
||||
> vcpkg, CMake, Git
|
||||
If you want use vcpkg, install vcpkg from git to you system:
|
||||
```PowerShell
|
||||
cd C:/
|
||||
git clone https://github.com/microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
.\bootstrap-vcpkg.bat
|
||||
```
|
||||
After installing vcpkg, setup env variable VCPKG_ROOT and add it to PATH:
|
||||
```PowerShell
|
||||
$env:VCPKG_ROOT = "C:\path\to\vcpkg"
|
||||
$env:PATH = "$env:VCPKG_ROOT;$env:PATH"
|
||||
```
|
||||
For troubleshooting you can read full [documentation](https://learn.microsoft.com/ru-ru/vcpkg/get_started/get-started?pivots=shell-powershell) for vcpkg
|
||||
|
||||
```sh
|
||||
After installing vcpkg you can build project:
|
||||
```PowerShell
|
||||
git clone --recursive https://github.com/MihailRis/VoxelEngine-Cpp.git
|
||||
cd VoxelEngine-Cpp
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_WINDOWS_VCPKG=ON ..
|
||||
del CMakeCache.txt
|
||||
rmdir /s /q CMakeFiles
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_WINDOWS_VCPKG=ON ..
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
cmake --build . --config Release
|
||||
```
|
||||
|
||||
@ -128,7 +139,7 @@ cmake --build . --config Release
|
||||
> [!WARNING]
|
||||
> If you have issues during the vcpkg integration, try navigate to ```vcpkg\downloads```
|
||||
> and extract PowerShell-[version]-win-x86 to ```vcpkg\downloads\tools``` as powershell-core-[version]-windows.
|
||||
> Then rerun ```cmake -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_WINDOWS_VCPKG=ON ..```
|
||||
> Then rerun ```cmake -DCMAKE_BUILD_TYPE=Release ..```
|
||||
|
||||
## Build using Docker
|
||||
|
||||
|
||||
@ -8,8 +8,6 @@ list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
|
||||
|
||||
add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS})
|
||||
|
||||
option(VOXELENGINE_BUILD_WINDOWS_VCPKG ON)
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLEW REQUIRED)
|
||||
find_package(OpenAL REQUIRED)
|
||||
@ -22,26 +20,21 @@ endif()
|
||||
|
||||
set(LIBS "")
|
||||
|
||||
if (WIN32)
|
||||
if(VOXELENGINE_BUILD_WINDOWS_VCPKG)
|
||||
if (MSVC)
|
||||
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")
|
||||
else()
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(OpenAL REQUIRED IMPORTED_TARGET openal)
|
||||
set(LIBS ${LIBS} luajit-5.1 wsock32 ws2_32 pthread PkgConfig::OpenAL -static-libstdc++)
|
||||
message(${OPENAL_LIBRARY})
|
||||
endif()
|
||||
find_package(glfw3 REQUIRED)
|
||||
find_package(glm REQUIRED)
|
||||
find_package(vorbis REQUIRED)
|
||||
set(VORBISLIB Vorbis::vorbis Vorbis::vorbisfile)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
if (MSVC)
|
||||
set(LUA_LIBRARIES "${CMAKE_SOURCE_DIR}/vcpkg/packages/luajit_x64-windows/lib/lua51.lib")
|
||||
set(LUA_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/vcpkg/packages/luajit_x64-windows/include/luajit")
|
||||
else()
|
||||
find_package(Lua REQUIRED)
|
||||
set(VORBISLIB vorbis vorbisfile) # not tested
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libs/glfw)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(OpenAL REQUIRED IMPORTED_TARGET openal)
|
||||
set(LIBS ${LIBS} luajit-5.1 wsock32 ws2_32 pthread PkgConfig::OpenAL -static-libstdc++)
|
||||
message(STATUS ${OPENAL_LIBRARY})
|
||||
endif()
|
||||
find_package(glfw3 REQUIRED)
|
||||
find_package(glm REQUIRED)
|
||||
find_package(vorbis REQUIRED)
|
||||
set(VORBISLIB Vorbis::vorbis Vorbis::vorbisfile)
|
||||
|
||||
elseif(APPLE)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(LUAJIT REQUIRED luajit)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user