Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,16 @@ A4_[Ss]olution/A4
/.vscode/

*.zip

# vcpkg
vcpkg_installed/

# Windows executables and other generated files by compiler (executables, dynamic link libraries, program database files, incremental linker files, etc. )
*.exe
*.dll
*.ilk
*.pdb


# Visual Studio
.vs/
37 changes: 37 additions & 0 deletions A0/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Gather all cpp files in this directory
file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
add_executable(A0 ${SOURCES})

# ---- Dependencies (resolved via the vcpkg toolchain) ----
find_package(glfw3 CONFIG REQUIRED) # glfw
find_package(imgui CONFIG REQUIRED) # imgui::imgui
find_package(OpenGL REQUIRED) # OpenGL::GL
# (No need to find gl3w here unless A0 itself includes <GL/gl3w.h>;
# cs488-framework already links gl3w.)

# ---- Includes ----
target_include_directories(A0 PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../shared"
"${CMAKE_CURRENT_SOURCE_DIR}/../shared/include"
)

# If any A0 source uses ImGui OpenGL3 backend directly, ensure the loader define:
target_compile_definitions(A0 PRIVATE IMGUI_IMPL_OPENGL_LOADER_GL3W)

# ---- Link (platform-agnostic; GLFW brings in what it needs) ----
target_link_libraries(A0 PRIVATE
cs488-framework
imgui::imgui
glfw
OpenGL::GL
)

# ---- Output location ----
set_target_properties(A0 PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)

# ---- Helpful note if the framework target is missing ----
if(NOT TARGET cs488-framework)
message(STATUS "Note: A0 requires cs488-framework to be built first.")
endif()
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.31)
project(cs488 CXX)

# Set C++ standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

add_compile_definitions(GLM_ENABLE_EXPERIMENTAL)

# Add shared subproject which builds framework
add_subdirectory(shared)

# Add the A0 subproject
add_subdirectory(A0)

message(STATUS "Top-level CMake setup complete.")
14 changes: 14 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": 4,
"configurePresets": [
{
"name": "vcpkg",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"CMAKE_CXX_STANDARD": "23"
}
}
]
}
12 changes: 12 additions & 0 deletions CMakeUserPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 4,
"configurePresets": [
{
"name": "default",
"inherits": "vcpkg",
"environment": {
"VCPKG_ROOT": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/vcpkg/"
}
}
]
}
50 changes: 22 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,41 @@
---

## Dependencies
* VCPKG
* If you're using Visual Studio: https://learn.microsoft.com/en-ca/vcpkg/get_started/get-started-vs?pivots=shell-powershell
* Otherwise: https://learn.microsoft.com/en-ca/vcpkg/get_started/overview#get-started-with-vcpkg
* OpenGL 3.2+
* GLFW
* http://www.glfw.org/
* Lua
* http://www.lua.org/
* Premake4
* https://github.com/premake/premake-4.x/wiki
* http://premake.github.io/download.html
* GLM
* http://glm.g-truc.net/0.9.7/index.html
* ImGui
* https://github.com/ocornut/imgui


---

## Building Projects
We use **premake4** as our cross-platform build system. First you will need to build all
the static libraries that the projects depend on. To build the libraries, open up a
terminal, and **cd** to the top level of the CS488 project directory and then run the
following:

$ premake4 gmake
$ make

This will build the following static libraries, and place them in the top level **lib**
folder of your cs488 project directory.
* libcs488-framework.a
* libglfw3.a
* libimgui.a

Next we can build a specific project. To do this, **cd** into one of the project folders,
say **A0** for example, and run the following terminal commands in order to compile the A0 executable using all .cpp files in the A0 directory:

$ cd A0/
$ premake4 gmake
$ make


----
We use CMake as our cross-platform build system. First you will need to fetch all
dependencies from `vcpkg` by doing `vcpkg install`. This will use the existing `vcpkg.json`
to install all dependencies.

If you're using Visual Studio, you can now click on the green arrow to build and run your
project. Otherwise, the equivalent CMake commands are ChatGPT-able, but they're roughly:
```
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake
$ cmake --build .
```
This will generate the build files in a `build` directory, and then build the project.
You can then run your project executable from the `build` directory.

```
$ ./build/A0.exe
```

---
## Windows
Sorry for all of the hardcore Microsoft fans out there. We have not had time to test the build system on Windows yet. Currently our build steps work for OSX and Linux, but all the steps should be the same on Windows, except you will need different libraries to link against when building your project executables. Some good news is that premake4 can output a Visual Studio .sln file by running:

Expand Down
40 changes: 40 additions & 0 deletions shared/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Finds (via vcpkg toolchain)
find_package(glfw3 CONFIG REQUIRED) # target: glfw
find_package(imgui CONFIG REQUIRED) # target: imgui::imgui
find_package(glm CONFIG REQUIRED) # target: glm
find_package(OpenGL REQUIRED) # target: OpenGL::GL
find_package(gl3w CONFIG REQUIRED) # target: gl3w
find_package(lua CONFIG REQUIRED) # target: lua

set(INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/shared"
"${CMAKE_SOURCE_DIR}/shared/include"
)

file(GLOB CS488_SOURCES "${CMAKE_SOURCE_DIR}/shared/cs488-framework/*.cpp")
add_library(cs488-framework STATIC ${CS488_SOURCES})

# Tell ImGui which GL loader you're using
target_compile_definitions(cs488-framework PRIVATE IMGUI_IMPL_OPENGL_LOADER_GL3W)

target_include_directories(cs488-framework PUBLIC ${INCLUDE_DIRS})

target_link_libraries(cs488-framework PUBLIC
imgui::imgui
glfw
glm::glm
OpenGL::GL
unofficial::gl3w::gl3w
lua
)

# If the port exports backend interface targets, link them (no-op if absent)
foreach(_t IN ITEMS imgui::glfw-binding imgui::opengl3-binding)
if(TARGET ${_t})
target_link_libraries(cs488-framework PRIVATE ${_t})
endif()
endforeach()

set_target_properties(cs488-framework PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
Loading