Skip to content
Snippets Groups Projects
Verified Commit 5c3daf60 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

Reduced CMake configuration in projects and improved build instructions

parent 43a09d9c
No related branches found
No related tags found
No related merge requests found
Showing
with 54 additions and 141 deletions
# the first argument should be the project's target
macro(fix_project)
macro(add_project)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# this will create an executable for the project
add_executable(${ARGN})
# this should fix the execution path to load local files from the project (for MSVC)
if(MSVC)
set_target_properties(${ARGV1} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
......
# How to build on Linux
## How to build with GCC on Archlinux by the way
## How to build on Ubuntu
1. Install the required and useful packages to develop:
```
sudo apt install cmake make gcc g++ libvulkan-dev vulkan-validationlayers-dev vulkan-tools
```
2. Install the Vulkan drivers for your system:
```
# For most GPUs (except Nvidia):
sudo apt install mesa-vulkan-drivers
```
3. Clone the repository and run the following commands:
```
mkdir debug
cd debug
cmake -DCMAKE_C_COMPILER="/usr/bin/gcc" -DCMAKE_CXX_COMPILER="/usr/bin/g++" -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .
```
## How to build on Archlinux by the way
1. Install required and useful tools to develop:
```
sudo pacman -S cmake gcc vulkan-icd-loader vulkan-headers vulkan-validation-layers vulkan-tools
sudo pacman -S cmake make gcc vulkan-icd-loader vulkan-headers vulkan-validation-layers vulkan-tools
```
2. Install the matching Vulkan drivers for your system:
```
# For discrete Nvidia GPUs:
sudo pacman -S nvidia
# For integrated or discrete Radeon GPUs:
# For integrated or discrete (AMD) Radeon GPUs:
sudo pacman -S vulkan-radeon
# For integrated or discrete Intel GPUs:
......@@ -25,6 +44,8 @@ cmake -DCMAKE_C_COMPILER="/usr/bin/gcc" -DCMAKE_CXX_COMPILER="/usr/bin/g++" -DCM
cmake --build .
```
## How to build with Clang on Archlinux by the way
## How to build with Clang on Linux
Just follow the steps of "How to build with GCC on Archlinux by the way" but replace `gcc` with `clang` and `g++` with `clang++`.
Just follow the steps of "How to build on YOUR DISTRO" but replace `gcc` with `clang` and `g++` with `clang++`.
This should work actually but maybe the names of the packages are a little different. So look at your official
repository for the packages and their names if it doesn't work.
......@@ -3,19 +3,20 @@
## How to build with MSVC on Windows
1. Download and install [VulkanSDK](https://vulkan.lunarg.com/sdk/home#windows)
2. Download and install [VisualStudio](https://visualstudio.microsoft.com/vs/features/cplusplus/) for MSVC
3. (optional) Download and install [CLion](https://www.jetbrains.com/clion/) as IDE to develop
2. Download and install [CMake](https://cmake.org/install/)
3. Download and install [VisualStudio](https://visualstudio.microsoft.com/vs/features/cplusplus/) for MSVC
4. Create and configure a project with the framework and build it
## How to build with GCC on Windows
1. Install [MSYS2](https://www.msys2.org/)
2. Run "MSYS2 MSYS" from Start menu
3. Enter the following commands into MSYS2 console:
3. Enter the following commands into MSYS2 console: (this will update and install required packages)
```
pacman -Syu
pacman -Su
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
pacman -S mingw-w64-x86_64-vulkan-devel
pacman -S cmake
```
4. Add to Path:
......
include(${vkcv_config_ext}/ProjectFix.cmake)
include(${vkcv_config_ext}/Project.cmake)
# Add new projects/examples here:
add_subdirectory(first_triangle)
......
......@@ -5,21 +5,8 @@ project(bindless_textures)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(bindless_textures src/main.cpp)
# this should fix the execution path to load local files from the project (for MSVC)
if(MSVC)
set_target_properties(bindless_textures PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set_target_properties(bindless_textures PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# in addition to setting the output directory, the working directory has to be set
# by default visual studio sets the working directory to the build directory, when using the debugger
set_target_properties(bindless_textures PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
add_project(bindless_textures src/main.cpp)
# including headers of dependencies and the VkCV framework
target_include_directories(bindless_textures SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include})
......
......@@ -5,12 +5,8 @@ project(first_mesh)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(first_mesh src/main.cpp)
fix_project(first_mesh)
add_project(first_mesh src/main.cpp)
# including headers of dependencies and the VkCV framework
target_include_directories(first_mesh SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include})
......
......@@ -5,12 +5,8 @@ project(first_scene)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(first_scene src/main.cpp)
fix_project(first_scene)
add_project(first_scene src/main.cpp)
# including headers of dependencies and the VkCV framework
target_include_directories(first_scene SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_scene_include} ${vkcv_shader_compiler_include} ${vkcv_gui_include})
......
......@@ -5,12 +5,8 @@ project(first_triangle)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(first_triangle src/main.cpp)
fix_project(first_triangle)
add_project(first_triangle src/main.cpp)
# including headers of dependencies and the VkCV framework
target_include_directories(first_triangle SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_testing_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include} ${vkcv_gui_include})
......
......@@ -5,12 +5,8 @@ project(head_demo)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(head_demo src/main.cpp)
fix_project(head_demo)
add_project(head_demo src/main.cpp)
# including headers of dependencies and the VkCV framework
target_include_directories(head_demo SYSTEM BEFORE PRIVATE
......
......@@ -5,11 +5,8 @@ project(indirect_dispatch)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(indirect_dispatch src/main.cpp)
add_project(indirect_dispatch src/main.cpp)
target_sources(indirect_dispatch PRIVATE
src/App.hpp
......@@ -27,8 +24,6 @@ target_sources(indirect_dispatch PRIVATE
src/MotionBlurSetup.hpp
src/MotionBlurSetup.cpp)
fix_project(indirect_dispatch)
# including headers of dependencies and the VkCV framework
target_include_directories(indirect_dispatch SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_testing_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include} ${vkcv_gui_include})
......
......@@ -5,21 +5,8 @@ project(indirect_draw)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(indirect_draw src/main.cpp)
# this should fix the execution path to load local files from the project (for MSVC)
if(MSVC)
set_target_properties(indirect_draw PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set_target_properties(indirect_draw PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# in addition to setting the output directory, the working directory has to be set
# by default visual studio sets the working directory to the build directory, when using the debugger
set_target_properties(indirect_draw PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
add_project(indirect_draw src/main.cpp)
# including headers of dependencies and the VkCV framework
target_include_directories(indirect_draw SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include} ${vkcv_gui_include})
......
......@@ -5,12 +5,8 @@ project(mesh_shader)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(mesh_shader src/main.cpp)
fix_project(mesh_shader)
add_project(mesh_shader src/main.cpp)
# including headers of dependencies and the VkCV framework
target_include_directories(mesh_shader SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_testing_include} ${vkcv_camera_include} ${vkcv_meshlet_include} ${vkcv_shader_compiler_include} ${vkcv_gui_include})
......
......@@ -5,19 +5,14 @@ project(particle_simulation)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(particle_simulation
add_project(particle_simulation
src/main.cpp
src/ParticleSystem.hpp
src/ParticleSystem.cpp
src/Particle.hpp
src/Particle.cpp)
fix_project(particle_simulation)
# including headers of dependencies and the VkCV framework
target_include_directories(particle_simulation SYSTEM BEFORE PRIVATE
${vkcv_include}
......
......@@ -5,22 +5,8 @@ project(path_tracer)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(path_tracer
src/main.cpp)
# this should fix the execution path to load local files from the project (for MSVC)
if(MSVC)
set_target_properties(path_tracer PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set_target_properties(path_tracer PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# in addition to setting the output directory, the working directory has to be set
# by default visual studio sets the working directory to the build directory, when using the debugger
set_target_properties(path_tracer PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
add_project(path_tracer src/main.cpp)
# including headers of dependencies and the VkCV framework
target_include_directories(path_tracer SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_testing_include} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include} ${vkcv_gui_include})
......
......@@ -5,9 +5,6 @@ project(rtx_ambient_occlusion)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(rtx_source ${PROJECT_SOURCE_DIR}/src/RTX)
set(rtx_sources
......@@ -19,20 +16,10 @@ set(rtx_sources
${rtx_source}/RTXExtensions.hpp
${rtx_source}/RTXExtensions.cpp
)
)
# adding source files to the project
add_executable(rtx_ambient_occlusion src/main.cpp src/teapot.hpp ${rtx_sources})
# this should fix the execution path to load local files from the project (for MSVC)
if(MSVC)
set_target_properties(rtx_ambient_occlusion PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set_target_properties(rtx_ambient_occlusion PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# in addition to setting the output directory, the working directory has to be set
# by default visual studio sets the working directory to the build directory, when using the debugger
set_target_properties(rtx_ambient_occlusion PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
add_project(rtx_ambient_occlusion src/main.cpp src/teapot.hpp ${rtx_sources})
# including headers of dependencies and the VkCV framework
target_include_directories(rtx_ambient_occlusion SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_scene_include} ${vkcv_shader_compiler_include})
......
......@@ -5,24 +5,8 @@ project(saf_r)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(saf_r
src/main.cpp
"src/safrScene.hpp"
)
# this should fix the execution path to load local files from the project (for MSVC)
if(MSVC)
set_target_properties(saf_r PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set_target_properties(saf_r PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# in addition to setting the output directory, the working directory has to be set
# by default visual studio sets the working directory to the build directory, when using the debugger
set_target_properties(saf_r PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
add_project(saf_r src/main.cpp "src/safrScene.hpp")
# including headers of dependencies and the VkCV framework
target_include_directories(saf_r SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_testing_include} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include})
......
......@@ -5,19 +5,14 @@ project(sph)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(sph
add_project(sph
src/main.cpp
src/Particle.hpp
src/Particle.cpp
src/PipelineInit.hpp
src/PipelineInit.cpp)
fix_project(sph)
# including headers of dependencies and the VkCV framework
target_include_directories(sph SYSTEM BEFORE PRIVATE
${vkcv_include}
......
......@@ -5,11 +5,8 @@ project(voxelization)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(voxelization src/main.cpp)
add_project(voxelization src/main.cpp)
target_sources(voxelization PRIVATE
src/Voxelization.hpp
......@@ -17,8 +14,6 @@ target_sources(voxelization PRIVATE
src/ShadowMapping.hpp
src/ShadowMapping.cpp)
fix_project(voxelization)
# including headers of dependencies and the VkCV framework
target_include_directories(voxelization SYSTEM BEFORE PRIVATE
${vkcv_include}
......
......@@ -5,14 +5,8 @@ project(wobble_bobble)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(wobble_bobble
src/main.cpp)
fix_project(wobble_bobble)
add_project(wobble_bobble src/main.cpp)
# including headers of dependencies and the VkCV framework
target_include_directories(wobble_bobble SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_camera_include} ${vkcv_gui_include} ${vkcv_shader_compiler_include})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment