diff --git a/config/ext/ProjectFix.cmake b/config/ext/ProjectFix.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d3f26b4a5323f473868d87cc94d39b52eafd4313 --- /dev/null +++ b/config/ext/ProjectFix.cmake @@ -0,0 +1,13 @@ + +# the first argument should be the project's target +macro(fix_project) + # 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}) + set_target_properties(${ARGV1} 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(${ARGV1} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + endif() +endmacro() diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 8010718447b8e72aed8eab42c8eac3e9591986ee..191db33180f170a1e939ea60a385a09790d7837c 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -1,4 +1,6 @@ +include(${vkcv_config_ext}/ProjectFix.cmake) + # Add new projects/examples here: add_subdirectory(first_triangle) add_subdirectory(first_mesh) diff --git a/projects/first_mesh/CMakeLists.txt b/projects/first_mesh/CMakeLists.txt index 6455e75d88eee276fb89b9f7a1b3462fcbc54da2..0302b628ee7411e0991763dbb07feac58eae90a0 100644 --- a/projects/first_mesh/CMakeLists.txt +++ b/projects/first_mesh/CMakeLists.txt @@ -10,16 +10,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # adding source files to the project add_executable(first_mesh src/main.cpp) - -# this should fix the execution path to load local files from the project (for MSVC) -if(MSVC) - set_target_properties(first_mesh PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - set_target_properties(first_mesh 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(first_mesh PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -endif() +fix_project(first_mesh) # 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}) diff --git a/projects/first_scene/CMakeLists.txt b/projects/first_scene/CMakeLists.txt index ba2f7b1a7ae4845a12b9701269361a0a3f8affb7..8b2b5e51f3b7514ac5d9e29e946a3fee5894e23b 100644 --- a/projects/first_scene/CMakeLists.txt +++ b/projects/first_scene/CMakeLists.txt @@ -10,16 +10,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # adding source files to the project add_executable(first_scene src/main.cpp) - -# this should fix the execution path to load local files from the project (for MSVC) -if(MSVC) - set_target_properties(first_scene PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - set_target_properties(first_scene 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(first_scene PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -endif() +fix_project(first_scene) # 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}) diff --git a/projects/first_triangle/CMakeLists.txt b/projects/first_triangle/CMakeLists.txt index ba8c83c06fc804082e6a0a14c3c0414899ef3057..c3eab5382cee52cf9ce61b3bc6e448cb53536d8f 100644 --- a/projects/first_triangle/CMakeLists.txt +++ b/projects/first_triangle/CMakeLists.txt @@ -10,16 +10,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # adding source files to the project add_executable(first_triangle src/main.cpp) - -# this should fix the execution path to load local files from the project (for MSVC) -if(MSVC) - set_target_properties(first_triangle PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - set_target_properties(first_triangle 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(first_triangle PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -endif() +fix_project(first_triangle) # 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}) diff --git a/projects/indirect_dispatch/CMakeLists.txt b/projects/indirect_dispatch/CMakeLists.txt index 7bc86cbc8470352f13bbfcc62f793b0a99d92884..e46473bb20378c2a89681a5010b23e45428bf5ef 100644 --- a/projects/indirect_dispatch/CMakeLists.txt +++ b/projects/indirect_dispatch/CMakeLists.txt @@ -26,16 +26,8 @@ target_sources(indirect_dispatch PRIVATE src/MotionBlurSetup.hpp src/MotionBlurSetup.cpp) - -# this should fix the execution path to load local files from the project (for MSVC) -if(MSVC) - set_target_properties(indirect_dispatch PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - set_target_properties(indirect_dispatch 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_dispatch PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -endif() + +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}) diff --git a/projects/mesh_shader/CMakeLists.txt b/projects/mesh_shader/CMakeLists.txt index 1aa5d5ff3977a47dce75a38329216d550b1b9311..4f5792aa85b914e8bf487e25afe9a39c3cccc447 100644 --- a/projects/mesh_shader/CMakeLists.txt +++ b/projects/mesh_shader/CMakeLists.txt @@ -10,18 +10,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # adding source files to the project add_executable(mesh_shader src/main.cpp) - -target_sources(mesh_shader PRIVATE) - -# this should fix the execution path to load local files from the project (for MSVC) -if(MSVC) - set_target_properties(mesh_shader PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - set_target_properties(mesh_shader 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(mesh_shader PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -endif() +fix_project(mesh_shader) # 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}) diff --git a/projects/particle_simulation/CMakeLists.txt b/projects/particle_simulation/CMakeLists.txt index 2a665202c521ac10ae94905cb7580205e897eef9..239595ad34185d61394b50c584fe2c0478c7e6a5 100644 --- a/projects/particle_simulation/CMakeLists.txt +++ b/projects/particle_simulation/CMakeLists.txt @@ -18,15 +18,7 @@ add_executable(particle_simulation src/BloomAndFlares.hpp src/BloomAndFlares.cpp) -# this should fix the execution path to load local files from the project (for MSVC) -if(MSVC) - set_target_properties(particle_simulation PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - set_target_properties(particle_simulation 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(particle_simulation PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -endif() +fix_project(particle_simulation) # including headers of dependencies and the VkCV framework target_include_directories(particle_simulation SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_testing_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include}) diff --git a/projects/voxelization/CMakeLists.txt b/projects/voxelization/CMakeLists.txt index d2f533b0f9c7313ddcc6046fb29378c3a507d1fe..2c543d6c3db27d9debdf3be84f0c31aff984a1e3 100644 --- a/projects/voxelization/CMakeLists.txt +++ b/projects/voxelization/CMakeLists.txt @@ -19,15 +19,7 @@ target_sources(voxelization PRIVATE src/BloomAndFlares.hpp src/BloomAndFlares.cpp) -# this should fix the execution path to load local files from the project (for MSVC) -if(MSVC) - set_target_properties(voxelization PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - set_target_properties(voxelization 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(voxelization PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -endif() +fix_project(voxelization) # including headers of dependencies and the VkCV framework target_include_directories(voxelization SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include} ${vkcv_gui_include} ${vkcv_upscaling_include})