license and cmake
This commit is contained in:
parent
4242a4d6b2
commit
51b3b89e1c
6 changed files with 316 additions and 0 deletions
1
engine/.gitignore
vendored
Normal file
1
engine/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/cmake/CPM.cmake
|
||||
|
|
@ -1,6 +1,21 @@
|
|||
cmake_minimum_required(VERSION 3.11)
|
||||
project(fishbone)
|
||||
|
||||
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake")
|
||||
message(STATUS "Downloading CPM.cmake...")
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
file(DOWNLOAD "https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/CPM.cmake"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake"
|
||||
STATUS status
|
||||
LOG log_content
|
||||
)
|
||||
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake")
|
||||
message(FATAL_ERROR "Failed to download CPM.cmake: ${status}\n${log_content}")
|
||||
endif()
|
||||
endif()
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake")
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/util.cmake")
|
||||
|
||||
file(GLOB_RECURSE SRCS src/**.cc src/**.c)
|
||||
|
||||
add_library(fishbone SHARED ${SRCS})
|
||||
|
|
@ -16,3 +31,5 @@ macro(pkg_add)
|
|||
endmacro()
|
||||
|
||||
pkg_add(sdl2 REQUIRED)
|
||||
|
||||
fb_add_dep(fishbone ode)
|
||||
|
|
|
|||
65
engine/cmake/deps/ode.cmake
Normal file
65
engine/cmake/deps/ode.cmake
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
cmake_minimum_required(VERSION 3.11)
|
||||
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake")
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "ode"
|
||||
GITHUB_REPOSITORY "odedevs/ode"
|
||||
GIT_TAG "0.16.6"
|
||||
DOWNLOAD_ONLY ON
|
||||
)
|
||||
|
||||
set(ODE_BASE "${ode_SOURCE_DIR}")
|
||||
|
||||
file(GLOB ODE_SRC
|
||||
${ODE_BASE}/ode/src/*.c
|
||||
${ODE_BASE}/ode/src/*.cpp
|
||||
${ODE_BASE}/ode/src/joints/*.cpp
|
||||
${ODE_BASE}/ou/src/ou/*.cpp
|
||||
${ODE_BASE}/GIMPACT/src/*.cpp
|
||||
${ODE_BASE}/libccd/src/*.c
|
||||
)
|
||||
add_library(ode STATIC ${ODE_SRC})
|
||||
target_include_directories(ode PUBLIC
|
||||
${ODE_BASE}/include
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
target_include_directories(ode PRIVATE
|
||||
${ODE_BASE}/ode/src
|
||||
${ODE_BASE}/ode/src/joints
|
||||
${ODE_BASE}/OPCODE
|
||||
${ODE_BASE}/ou/include
|
||||
${ODE_BASE}/GIMPACT/include
|
||||
${ODE_BASE}/libccd/src/custom
|
||||
${ODE_BASE}/libccd/src
|
||||
)
|
||||
|
||||
list(REMOVE_ITEM ODE_SRC ${ODE_BASE}/ode/src/collision_trimesh_trimesh_old.cpp)
|
||||
list(REMOVE_ITEM ODE_SRC ${ODE_BASE}/ode/src/collision_trimesh_opcode.cpp)
|
||||
list(REMOVE_ITEM ODE_SRC ${ODE_BASE}/ode/src/collision_trimesh_disabled.cpp)
|
||||
|
||||
target_compile_definitions(ode PRIVATE
|
||||
_OU_NAMESPACE=odeou
|
||||
_OU_FEATURE_SET=_OU_FEATURE_SET_TLS
|
||||
dLIBCCD_ENABLED
|
||||
dLIBCCD_INTERNAL
|
||||
dLIBCCD_BOX_CYL
|
||||
dLIBCCD_CYL_CYL
|
||||
dLIBCCD_CAP_CYL
|
||||
dLIBCCD_CONVEX_BOX
|
||||
dLIBCCD_CONVEX_CAP
|
||||
dLIBCCD_CONVEX_CYL
|
||||
dLIBCCD_CONVEX_SPHERE
|
||||
dLIBCCD_CONVEX_CONVEX
|
||||
)
|
||||
|
||||
target_link_libraries(ode PUBLIC stdc++)
|
||||
|
||||
set(ODE_PRECISION "dDOUBLE")
|
||||
set(CCD_PRECISION "CCD_DOUBLE")
|
||||
set(ODE_VERSION "Custom-ODE")
|
||||
|
||||
configure_file(${ODE_BASE}/include/ode/version.h.in ode/version.h)
|
||||
configure_file(${ODE_BASE}/include/ode/precision.h.in ode/precision.h)
|
||||
configure_file(${ODE_BASE}/libccd/src/ccd/precision.h.in ccd/precision.h)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ode/config.h.in config.h)
|
||||
20
engine/cmake/util.cmake
Normal file
20
engine/cmake/util.cmake
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
function(fb_add_dep TARGET_NAME DEP_NAME)
|
||||
get_target_property(TARGET_TYPE ${TARGET_NAME} TYPE)
|
||||
if(TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
|
||||
set(LINK_SCOPE "INTERFACE")
|
||||
else()
|
||||
set(LINK_SCOPE "PRIVATE")
|
||||
endif()
|
||||
|
||||
if(TARGET deps::${DEP_NAME})
|
||||
target_link_libraries(${TARGET_NAME} ${LINK_SCOPE} deps::${DEP_NAME})
|
||||
|
||||
return()
|
||||
endif()
|
||||
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/deps/${DEP_NAME}.cmake")
|
||||
|
||||
add_library(deps::${DEP_NAME} ALIAS ${DEP_NAME})
|
||||
|
||||
target_link_libraries(${TARGET_NAME} ${LINK_SCOPE} deps::${DEP_NAME})
|
||||
endfunction()
|
||||
11
engine/ode/config.h.in
Normal file
11
engine/ode/config.h.in
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef _ODE_CONFIG_H_
|
||||
#define _ODE_CONFIG_H_
|
||||
#define dTRIMESH_ENABLED 1
|
||||
#define dTRIMESH_GIMPACT 1
|
||||
#define dOU_ENABLED 1
|
||||
#define dATOMICS_ENABLED 0
|
||||
#define dTLS_ENABLED 0
|
||||
#define dBUILTIN_THREADING_IMPL_ENABLED 0
|
||||
#define dTHREADING_INTF_DISABLED 1
|
||||
#include "typedefs.h"
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue