refactor(cmake): (Thanks @FloofyPlasma!) replaced vcpkg with CPM
This commit is contained in:
parent
8b8776cbd7
commit
330f128dd3
9 changed files with 81 additions and 57 deletions
|
@ -1,8 +1,5 @@
|
|||
find_package(SDL2 REQUIRED)
|
||||
include_directories(${SDL2_INCLUDE_DIRS})
|
||||
|
||||
find_package(glfw3 REQUIRED)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/deps.cmake)
|
||||
|
||||
add_executable(client "src/main.cpp")
|
||||
target_link_libraries(client PRIVATE ${SDL2_LIBRARIES} openblocks glfw)
|
||||
target_link_libraries(client PRIVATE openblocks glfw)
|
||||
add_dependencies(client openblocks)
|
12
client/deps.cmake
Normal file
12
client/deps.cmake
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Declare/fetch packages
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
glfw3
|
||||
GIT_REPOSITORY https://github.com/glfw/glfw
|
||||
GIT_TAG 3.4
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(glfw3)
|
||||
|
||||
# Find/include packages
|
23
cmake/CPM.cmake
Normal file
23
cmake/CPM.cmake
Normal file
|
@ -0,0 +1,23 @@
|
|||
set(CPM_DOWNLOAD_VERSION 0.42.0)
|
||||
# Patch support is broken in CPM upstream atm, so we have to use a fork
|
||||
set(CPM_HASH_SUM "f7d92592a257d184fd8de6fb496a711ce393676ed68999b96043aab2e5e6f9e6")
|
||||
# set(CPM_HASH_SUM "2020b4fc42dba44817983e06342e682ecfc3d2f484a581f11cc5731fbe4dce8a")
|
||||
|
||||
if(CPM_SOURCE_CACHE)
|
||||
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
|
||||
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
else()
|
||||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
endif()
|
||||
|
||||
# Expand relative path. This is important if the provided path contains a tilde (~)
|
||||
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
||||
|
||||
file(DOWNLOAD
|
||||
https://raw.githubusercontent.com/BohdanBuinich/CPM.cmake/refs/heads/feat/fix_patch_command/cmake/CPM.cmake
|
||||
# https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
|
||||
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
|
||||
)
|
||||
|
||||
include(${CPM_DOWNLOAD_LOCATION})
|
|
@ -1,30 +0,0 @@
|
|||
# Distributed under the OSI-approved BSD 3-Clause License.
|
||||
# Copyright Stefano Sinigardi
|
||||
|
||||
#.rst:
|
||||
# FindStb
|
||||
# ------------
|
||||
#
|
||||
# Find the Stb include headers.
|
||||
#
|
||||
# Result Variables
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module defines the following variables:
|
||||
#
|
||||
# ``Stb_FOUND``
|
||||
# True if Stb library found
|
||||
#
|
||||
# ``Stb_INCLUDE_DIR``
|
||||
# Location of Stb headers
|
||||
#
|
||||
|
||||
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
|
||||
include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake)
|
||||
|
||||
if(NOT Stb_INCLUDE_DIR)
|
||||
find_path(Stb_INCLUDE_DIR NAMES stb_image.h PATHS ${Stb_DIR} PATH_SUFFIXES include stb include/stb)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(Stb DEFAULT_MSG Stb_INCLUDE_DIR)
|
||||
mark_as_advanced(Stb_INCLUDE_DIR)
|
|
@ -1,21 +1,4 @@
|
|||
find_package(OpenGL REQUIRED COMPONENTS OpenGL)
|
||||
|
||||
find_package(GLEW REQUIRED)
|
||||
include_directories(${GLEW_INCLUDE_DIRS})
|
||||
|
||||
find_package(OpenGL)
|
||||
find_package(glm CONFIG REQUIRED)
|
||||
find_package(ReactPhysics3D REQUIRED)
|
||||
find_package(pugixml 1.15 REQUIRED)
|
||||
find_package(Freetype)
|
||||
|
||||
find_package(Stb REQUIRED)
|
||||
include_directories(${Stb_INCLUDE_DIR})
|
||||
|
||||
# PkgConfig packages
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(LUAJIT REQUIRED luajit)
|
||||
link_directories(${LUAJIT_LIBRARY_DIRS})
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/deps.cmake)
|
||||
|
||||
### Autogen
|
||||
file(GLOB_RECURSE AUTOGEN_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src" "src/objects/*.h" "src/datatypes/*.h" "src/enum/*.h")
|
||||
|
@ -51,8 +34,8 @@ list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/src/version.cpp)
|
|||
add_library(openblocks STATIC ${SOURCES})
|
||||
set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks")
|
||||
target_link_directories(openblocks PUBLIC ${LUAJIT_LIBRARY_DIRS})
|
||||
target_link_libraries(openblocks ${GLEW_LIBRARIES} ${LUAJIT_LIBRARIES} OpenGL::GL ReactPhysics3D::ReactPhysics3D pugixml::pugixml Freetype::Freetype)
|
||||
target_include_directories(openblocks PUBLIC "src" "../include" ${LUAJIT_INCLUDE_DIRS})
|
||||
target_link_libraries(openblocks libglew_static reactphysics3d pugixml::pugixml Freetype::Freetype glm::glm libluajit ${LuaJIT_LIBRARIES})
|
||||
target_include_directories(openblocks PUBLIC "src" "../include" ${ReactPhysics3D_SOURCE_DIR}/include ${LUAJIT_INCLUDE_DIRS} ${stb_SOURCE_DIR} ${glew_SOURCE_DIR}/include)
|
||||
add_dependencies(openblocks autogen_build autogen)
|
||||
|
||||
# Windows-specific dependencies
|
||||
|
|
24
core/deps.cmake
Normal file
24
core/deps.cmake
Normal file
|
@ -0,0 +1,24 @@
|
|||
|
||||
include(CPM)
|
||||
|
||||
CPMAddPackage("gh:Perlmint/glew-cmake#glew-cmake-2.2.0")
|
||||
CPMAddPackage("gh:g-truc/glm#1.0.1")
|
||||
CPMAddPackage(NAME reactphysics3d GITHUB_REPOSITORY "DanielChappuis/reactphysics3d" VERSION 0.10.2 PATCHES ${CMAKE_SOURCE_DIR}/patches/std_chrono.patch)
|
||||
# https://github.com/StereoKit/StereoKit/blob/0be056efebcee5e58ad1438f4cf6dfdb942f6cf9/CMakeLists.txt#L205
|
||||
set_property(TARGET reactphysics3d PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
CPMAddPackage("gh:zeux/pugixml@1.15")
|
||||
|
||||
CPMAddPackage(
|
||||
NAME freetype
|
||||
GIT_REPOSITORY https://github.com/aseprite/freetype2.git
|
||||
GIT_TAG VER-2-10-0
|
||||
VERSION 2.10.0
|
||||
)
|
||||
|
||||
if (freetype_ADDED)
|
||||
add_library(Freetype::Freetype ALIAS freetype)
|
||||
endif()
|
||||
|
||||
CPMAddPackage("gh:nothings/stb#8cfb1605c02aee9fb6eb5d8ea559017745bd9a16") # 2.14
|
||||
CPMAddPackage("gh:WohlSoft/LuaJIT#a5da8f4a31972b74254f00969111b8b7a07cf584") # v2.1
|
||||
set(LUAJIT_INCLUDE_DIRS ${LuaJIT_SOURCE_DIR}/src)
|
|
@ -6,6 +6,8 @@ extern "C" {
|
|||
#include <lua.h>
|
||||
}
|
||||
|
||||
LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
|
||||
|
||||
inline const char* x_luaL_udatatname (lua_State *L, int ud) {
|
||||
void *p = lua_touserdata(L, ud);
|
||||
if (p != NULL) {
|
||||
|
@ -16,4 +18,6 @@ inline const char* x_luaL_udatatname (lua_State *L, int ud) {
|
|||
return str;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#define LUA_OK 0
|
1
deps.txt
1
deps.txt
|
@ -2,7 +2,6 @@ opengl (Linux: glvnd, Windows: [built-in/none])
|
|||
glfw
|
||||
glew
|
||||
glm
|
||||
sdl2
|
||||
stb
|
||||
qt6
|
||||
reactphysics3d
|
||||
|
|
12
patches/std_chrono.patch
Normal file
12
patches/std_chrono.patch
Normal file
|
@ -0,0 +1,12 @@
|
|||
diff --git a/include/reactphysics3d/utils/DefaultLogger.h b/include/reactphysics3d/utils/DefaultLogger.h
|
||||
index 1088d1e..8360f07 100644
|
||||
--- a/include/reactphysics3d/utils/DefaultLogger.h
|
||||
+++ b/include/reactphysics3d/utils/DefaultLogger.h
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <iomanip>
|
||||
#include <mutex>
|
||||
#include <ctime>
|
||||
+#include <chrono>
|
||||
|
||||
/// ReactPhysics3D namespace
|
||||
namespace reactphysics3d {
|
Loading…
Add table
Reference in a new issue