Technically Working with CPM, but doesn't handle Re3DLibrary dependencies automagically

This commit is contained in:
2024-06-24 12:08:26 -04:00
parent bf03df8f52
commit 8c89401ae8
2 changed files with 64 additions and 13 deletions

View File

@@ -1,9 +1,22 @@
#TODO this is a massive hack. I'm surprised it even works at-all. But Re3D's dependencies weren't passing through in a nice way when using CPM.
cmake_minimum_required(VERSION 3.18)
project(Re3DExampleProject)
project(
Re3DExampleProject
VERSION 1.0
LANGUAGES CXX C
)
if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")
# Enable Package Managers
include(cmake/CPM.cmake)
file(GLOB_RECURSE HEADERS "include/*.h")
file(GLOB_RECURSE SOURCES "src/*.cpp")
@@ -13,24 +26,61 @@ file(COPY "cfg" DESTINATION "${PROJECT_BINARY_DIR}")
include_directories("include" "include/Re3D" "include/Re3D/Re3D")
if(UNIX AND NOT APPLE)
#if(UNIX AND NOT APPLE)
#build Re3D and copy the lib directory to the build dir.
execute_process(
COMMAND bash -c "git clone https://git.redacted.cc/Redacted/Re3D.git && cd Re3D && mkdir build && cd build && cmake .. && make -j$(nproc) && mv lib/ ../../"
)
# execute_process(
# COMMAND bash -c "git clone https://git.redacted.cc/Redacted/Re3D.git && cd Re3D && mkdir build && cd build && cmake .. && make -j$(nproc) && mv lib/ ../../"
# )
#Copy the headers to include/Re3D
execute_process(
COMMAND bash -c "cd Re3D/include && mkdir Re3D && mv engine types Re3D && mv Re3D ${CMAKE_SOURCE_DIR}/include/Re3D && cd ../build/_deps && mv archive-src/include/archive.h event-src/include/Event.h event-src/include/EventConnection.h ${CMAKE_SOURCE_DIR}/include/Re3D && mv collage-src/include/Collage glad-src/include/glad glad-src/include/KHR j3ml-src/include/J3ML jgl-src/include/JGL rehardwareid-src/include/reHardwareID retexture-src/include/ReTexture rewindow-src/include/rewindow uuid-src/include/uuid ${CMAKE_SOURCE_DIR}/include/Re3D"
)
# execute_process(
# COMMAND bash -c "cd Re3D/include && mkdir Re3D && mv engine types Re3D && mv Re3D ${CMAKE_SOURCE_DIR}/include/Re3D && cd ../build/_deps && mv archive-src/include/archive.h event-src/include/Event.h event-src/include/EventConnection.h ${CMAKE_SOURCE_DIR}/include/Re3D && mv collage-src/include/Collage glad-src/include/glad glad-src/include/KHR j3ml-src/include/J3ML jgl-src/include/JGL rehardwareid-src/include/reHardwareID retexture-src/include/ReTexture rewindow-src/include/rewindow uuid-src/include/uuid ${CMAKE_SOURCE_DIR}/include/Re3D"
# )
#Delete the Re3D directory in the build directory.
execute_process(COMMAND bash -c "rm -rf Re3D/")
endif()
# execute_process(COMMAND bash -c "rm -rf Re3D/")
#endif()
CPMAddPackage(
NAME archive
URL https://git.redacted.cc/Redacted/archive/archive/v1.0.zip
)
CPMAddPackage(
NAME glad
URL https://git.redacted.cc/Redacted/glad/archive/v2.1ext_mt.zip
)
CPMAddPackage(
NAME J3ML
URL https://git.redacted.cc/josh/j3ml/archive/Release-2.1.zip
)
CPMAddPackage(
NAME ReWindow
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-2.zip
)
CPMAddPackage(
NAME Re3D
URL https://git.redacted.cc/Redacted/Re3D/archive/Prerelease-1.zip
)
CPMAddPackage(
NAME jlog
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-8.zip
)
include_directories(${Re3D_SOURCE_DIR}/include)
include_directories(${ReWindow_SOURCE_DIR}/include)
include_directories(${J3ML_SOURCE_DIR}/include)
include_directories(${glad_SOURCE_DIR}/include)
include_directories(${archive_SOURCE_DIR}/include)
include_directories(${jlog_SOURCE_DIR}/include)
add_executable(Re3DExampleProject ${SOURCES} ${HEADERS} main.cpp)
set_target_properties(Re3DExampleProject PROPERTIES LINKER_LANGUAGE CXX)
#Link based on relative path.
set_target_properties(Re3DExampleProject PROPERTIES BUILD_RPATH "\$ORIGIN/lib")
target_link_libraries(Re3DExampleProject PUBLIC ${CMAKE_BINARY_DIR}/lib/libRe3D.so ${CMAKE_BINARY_DIR}/lib/libJ3ML.so ${CMAKE_BINARY_DIR}/lib/libReWindowLibrary.so ${CMAKE_BINARY_DIR}/lib/libReHardwareID.so ${CMAKE_BINARY_DIR}/lib/libReTexture.so ${CMAKE_BINARY_DIR}/lib/libglad.so ${CMAKE_BINARY_DIR}/lib/libCollage.so ${CMAKE_BINARY_DIR}/lib/libJGL.so ${CMAKE_BINARY_DIR}/lib/libarchive.so ${CMAKE_BINARY_DIR}/lib/libEvent.so)
#set_target_properties(Re3DExampleProject PROPERTIES BUILD_RPATH "\$ORIGIN/lib")
target_link_libraries(Re3DExampleProject PUBLIC GL glad J3ML ReWindowLibrary Re3D archive jlog)

View File

@@ -1,4 +1,5 @@
#include <Re3D/engine/engine.h>
#include <Redacted3D/engine/engine.h>
int main() {
engine->window = new ReWindow::RWindow("Re3D Test Application", 1152, 864, RenderingAPI::OPENGL);