From 77084729d80718be3e4f35fcbce47f56caab44e1 Mon Sep 17 00:00:00 2001 From: Jimmy Tremblay-Bernier Date: Thu, 21 Nov 2024 10:00:21 -0500 Subject: [PATCH] CONGE-1 - Setup that works with conan and cmake --- .gitignore | 1 + CMakeLists.txt | 30 ++++++++++++++----- ConjureEngine/CMakeLists.txt | 23 ++++---------- .../src/ConjureEngine/ConjureEngine.h | 4 +++ Demo1/CMakeLists.txt | 13 +------- Demo1/conanfile.txt | 8 ----- ConjureEngine/conanfile.txt => conanfile.txt | 0 debug.sh | 8 +++++ release.sh | 8 +++++ 9 files changed, 51 insertions(+), 44 deletions(-) delete mode 100644 Demo1/conanfile.txt rename ConjureEngine/conanfile.txt => conanfile.txt (100%) create mode 100755 debug.sh create mode 100755 release.sh diff --git a/.gitignore b/.gitignore index 8d7f31d..d5e139a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ CMakeCache.txt build.ninja cmake_install.cmake CMakeCache.txt +CMakeUserPresets.json .ninja* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index eec78fb..7c209cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,35 @@ cmake_minimum_required(VERSION 3.29) project(ConjureEngineProject) +set(CMAKE_CXX_STANDARD 20) + # Set the default build type to Debug if not specified by the user if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type (default Debug)" FORCE) endif() -set(CONAN_DEPENDENCIES_DIR ${CMAKE_BINARY_DIR}/Conan) +# Set architecture +if(NOT DEFINED ARCH) + set(ARCH x64) # Default to x64 architecture +endif() -execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR}/ConjureEngine --output-folder=${CONAN_DEPENDENCIES_DIR} --build=missing) -execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR}/Demo1 --output-folder=${CONAN_DEPENDENCIES_DIR} --build=missing) +set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build) -set(CMAKE_TOOLCHAIN_FILE "${CONAN_DEPENDENCIES_DIR}/build/Release/generators/conan_toolchain.cmake" CACHE FILEPATH "Conan toolchain file") -set(CMAKE_PREFIX_PATH "${CONAN_DEPENDENCIES_DIR}/build/Release/generators" ${CMAKE_PREFIX_PATH}) -set(CMAKE_MODULE_PATH "${CONAN_DEPENDENCIES_DIR}/build/Release/generators" ${CMAKE_MODULE_PATH}) +# Include the Conan-generated files +list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/generators") +include("${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/generators/conan_toolchain.cmake") + + +# Set common output directories +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/intermediates/${CMAKE_BUILD_TYPE}/${ARCH}/${PROJECT_NAME}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}/${ARCH}/${PROJECT_NAME}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}/${ARCH}/${PROJECT_NAME}) + +# Locate packages using find_package +find_package(glm REQUIRED) +find_package(SDL2 REQUIRED) + +# Add subdirectories for engine and demo add_subdirectory(./ConjureEngine) -add_subdirectory(./Demo1) \ No newline at end of file +add_subdirectory(./Demo1) diff --git a/ConjureEngine/CMakeLists.txt b/ConjureEngine/CMakeLists.txt index 909c6f8..b5b42f6 100644 --- a/ConjureEngine/CMakeLists.txt +++ b/ConjureEngine/CMakeLists.txt @@ -1,27 +1,16 @@ cmake_minimum_required(VERSION 3.29) project(ConjureEngine) -set(CMAKE_CXX_STANDARD 17) - -# Set the architecture (assuming you're passing the architecture as a CMake variable) -# Replace 'x64' with your system's architecture, or set this dynamically based on the system -if(NOT DEFINED ARCH) - set(ARCH x64) # You can change this to x86 or any other architecture you are targeting -endif() - - - -# Set common output directories -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/intermediates/${ARCH}/${PROJECT_NAME}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${ARCH}/${PROJECT_NAME}) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${ARCH}/${PROJECT_NAME}) +set(CMAKE_CXX_STANDARD 20) find_package(glm REQUIRED) +find_package(SDL2 REQUIRED) find_package(Vulkan REQUIRED) add_library(${PROJECT_NAME} STATIC src/ConjureEngine/ConjureEngine.h src/ConjureEngine/ConjureEngine.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) - # Specify include directories -target_include_directories(ConjureEngine PUBLIC include) \ No newline at end of file +target_include_directories(${PROJECT_NAME} PUBLIC include) +target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_BINARY_DIR}/include) + +target_link_libraries(${PROJECT_NAME} SDL2::SDL2 glm::glm) \ No newline at end of file diff --git a/ConjureEngine/src/ConjureEngine/ConjureEngine.h b/ConjureEngine/src/ConjureEngine/ConjureEngine.h index b2a96c2..a076112 100644 --- a/ConjureEngine/src/ConjureEngine/ConjureEngine.h +++ b/ConjureEngine/src/ConjureEngine/ConjureEngine.h @@ -1,4 +1,8 @@ #pragma once + +#include "glm/glm.hpp" + namespace ConjureEngine { void SayHello(); + glm::vec3& Forward(); } diff --git a/Demo1/CMakeLists.txt b/Demo1/CMakeLists.txt index 0eec459..a2c2abc 100644 --- a/Demo1/CMakeLists.txt +++ b/Demo1/CMakeLists.txt @@ -1,18 +1,7 @@ cmake_minimum_required(VERSION 3.29) project(Demo1) -set(CMAKE_CXX_STANDARD 17) - -# Set the architecture (assuming you're passing the architecture as a CMake variable) -# Replace 'x64' with your system's architecture, or set this dynamically based on the system -if(NOT DEFINED ARCH) - set(ARCH x64) # You can change this to x86 or any other architecture you are targeting -endif() - -# Set common output directories -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/intermediates/${ARCH}/${PROJECT_NAME}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${ARCH}/${PROJECT_NAME}) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/${ARCH}/${PROJECT_NAME}) +set(CMAKE_CXX_STANDARD 20) add_executable(${PROJECT_NAME} src/main.cpp) diff --git a/Demo1/conanfile.txt b/Demo1/conanfile.txt deleted file mode 100644 index bc6f23d..0000000 --- a/Demo1/conanfile.txt +++ /dev/null @@ -1,8 +0,0 @@ -[requires] - -[generators] -CMakeDeps -CMakeToolchain - -[layout] -cmake_layout \ No newline at end of file diff --git a/ConjureEngine/conanfile.txt b/conanfile.txt similarity index 100% rename from ConjureEngine/conanfile.txt rename to conanfile.txt diff --git a/debug.sh b/debug.sh new file mode 100755 index 0000000..4fb253f --- /dev/null +++ b/debug.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Run Conan to install dependencies +conan install . -s build_type=Debug --build=missing + +# Run CMake with the updated CMAKE_PREFIX_PATH +#cmake -DCMAKE_BUILD_TYPE=Debug -S . -B build +#cmake --build build diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..dbada7d --- /dev/null +++ b/release.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Run Conan to install dependencies +conan install . -s build_type=Release --build=missing + +# Run CMake with the updated CMAKE_PREFIX_PATH +#cmake -DCMAKE_BUILD_TYPE=Release -S . -B build +#cmake --build build