Skip to content

Commit

Permalink
Copy shaders to consumer executable path
Browse files Browse the repository at this point in the history
  • Loading branch information
sguionni committed Nov 7, 2023
1 parent 00ce02e commit 4782615
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 57 deletions.
4 changes: 1 addition & 3 deletions lib/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ file(GLOB_RECURSE SOURCES src/*)
add_library(vtx_core STATIC ${HEADERS} ${SOURCES})
target_include_directories(vtx_core PUBLIC include)

target_link_libraries(vtx_core PRIVATE vtx_util::vtx_util)

install(TARGETS vtx_core)
target_link_libraries(vtx_core PRIVATE vtx_util::vtx_util)
4 changes: 1 addition & 3 deletions lib/io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ target_include_directories(vtx_io PUBLIC include)

target_link_libraries(vtx_io PRIVATE vtx_util::vtx_util)
target_link_libraries(vtx_io PRIVATE vtx_core::vtx_core)
target_link_libraries(vtx_io PRIVATE chemfiles::chemfiles)

install(TARGETS vtx_io)
target_link_libraries(vtx_io PRIVATE chemfiles::chemfiles)
15 changes: 1 addition & 14 deletions lib/renderer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,4 @@ target_include_directories(vtx_renderer PUBLIC include)
# TODO: PRIVATE
target_include_directories(vtx_renderer PUBLIC vendor)

target_link_libraries(vtx_renderer PRIVATE vtx_util::vtx_util)

# Copy shaders.
#file(GLOB_RECURSE SHADERS src/renderer/context/gl/shaders/*)
#set(SHADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/renderer/context/gl/shaders PARENT_SCOPE)
#add_custom_target(vtx_shaders SOURCES ${SHADERS})

set_target_properties(vtx_renderer PROPERTIES SHADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/renderer/context/gl/shaders)

#add_custom_target(vtx_renderer_copy_shader ALL COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src/renderer/context/gl/shaders $<TARGET_FILE_DIR:vtx_renderer>/shaders)
#add_dependencies(vtx_renderer vtx_renderer_copy_shader)

install(TARGETS vtx_renderer)
#install(FILES ${SHADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/shaders)
target_link_libraries(vtx_renderer PRIVATE vtx_util::vtx_util)
26 changes: 8 additions & 18 deletions lib/renderer/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ find_package(vtx_renderer CONFIG REQUIRED)
find_package(vtx_core CONFIG REQUIRED)
find_package(vtx_io CONFIG REQUIRED)
find_package(SDL2 REQUIRED)
#find_package(stb REQUIRED)
find_package(imgui REQUIRED)

file(GLOB_RECURSE SOURCES src/*)
Expand All @@ -22,24 +21,15 @@ target_link_libraries(vtx_renderer_bench PRIVATE vtx_core::vtx_core)
target_link_libraries(vtx_renderer_bench PRIVATE vtx_io::vtx_io)
target_link_libraries(vtx_renderer_bench PRIVATE SDL2::SDL2-static)
target_link_libraries(vtx_renderer_bench PRIVATE SDL2::SDL2main)
#target_link_libraries(vtx_renderer_bench PRIVATE stb::stb)
target_link_libraries(vtx_renderer_bench PRIVATE imgui::imgui)

get_target_property(SHADERS vtx_renderer::vtx_renderer SHADERS_DIR)
message(STATUS "Chemin du répertoire des shaders : ${SHADERS}")
message(STATUS "++++++++++++++++++++++++++Shaders dir : ${dir_shaders}")

# Copy shaders.
#add_custom_target(vtx_renderer_bench_copy_shaders ALL COMMAND ${CMAKE_COMMAND} -E copy_directory $<TARGET_PROPERTY:vtx_renderer::vtx_renderer,shadersDir> $<TARGET_FILE_DIR:vtx_renderer_bench>/shaders)
#add_dependencies(vtx_renderer_bench vtx_renderer_bench_copy_shaders)
#add_dependencies(vtx_renderer_bench vtx_renderer::vtx_renderer_shaders)

# Copy assets.
#add_custom_target(VTX_RENDERER_COPY_ASSETS ALL COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets $<TARGET_FILE_DIR:vtx_renderer_bench>/assets)
#add_dependencies(vtx_renderer_bench VTX_RENDERER_COPY_ASSETS)

# Install.
# TODO: set target name as parameter?
#set(INSTALL_DIR DESTINATION VTXRendererBench)
#install(DIRECTORY DESTINATION ${INSTALL_DIR})
#install(TARGETS vtx_renderer_bench RUNTIME DESTINATION ${INSTALL_DIR})
#install(DIRECTORY $<TARGET_FILE_DIR:vtx_renderer_bench>/shaders DESTINATION ${INSTALL_DIR})
add_custom_target(
vtx_renderer_bench_copy_shader
ALL COMMAND
${CMAKE_COMMAND} -E copy_directory
${dir_shaders}
$<TARGET_FILE_DIR:vtx_renderer_bench>/shaders)
add_dependencies(vtx_renderer_bench vtx_renderer_bench_copy_shader)
16 changes: 9 additions & 7 deletions lib/renderer/bench/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
import os
from conan import ConanFile
from conan.tools.cmake import cmake_layout, CMake
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
from conan.tools.files import copy

class VTXRendererBenchRecipe(ConanFile):
settings = "os", "compiler", "build_type", "arch"
package_type = "application"

generators = "CMakeToolchain", "CMakeDeps"
generators = "CMakeDeps"

def requirements(self):
self.requires("vtx_util/1.0")
self.requires("vtx_renderer/1.0")
self.requires("vtx_core/1.0")
self.requires("vtx_io/1.0")
self.requires("sdl/2.28.3")
#self.requires("stb/cci.20230920")
self.requires("sdl/2.28.3")
self.requires("imgui/1.89.9")

def generate(self):
tc = CMakeToolchain(self)
dir_shaders = self.dependencies["vtx_renderer"].conf_info.get("user.myconf:dir_shaders")
tc.cache_variables["dir_shaders"] = dir_shaders
tc.generate()

copy(self, "*sdl2*", os.path.join(self.dependencies["imgui"].package_folder,
"res", "bindings"), os.path.join(self.source_folder, "vendor/imgui"))
copy(self, "*opengl3*", os.path.join(self.dependencies["imgui"].package_folder,
"res", "bindings"), os.path.join(self.source_folder, "vendor/imgui"))
"res", "bindings"), os.path.join(self.source_folder, "vendor/imgui"))

def layout(self):
cmake_layout(self)
# Add vendor folder to the include path.
self.cpp.source.includedirs = ["include", "vendor"]
#self.cpp.package.includedirs = ["include", "vendor"]

def build(self):
cmake = CMake(self)
Expand Down
11 changes: 3 additions & 8 deletions lib/renderer/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout

Expand All @@ -22,12 +23,8 @@ def config_options(self):
del self.options.fPIC

def layout(self):
cmake_layout(self)
# Add vendor folder to the include path.
# self.cpp.source and cpp.build are only for editable!
cmake_layout(self)
self.cpp.source.includedirs = ["include", "vendor"]
#self.cpp.package.includedirs = ["include", "vendor"]
self.cpp.package.set_property("SHADERS_DIR", "/path/to/shaders")

def build(self):
cmake = CMake(self)
Expand All @@ -40,7 +37,5 @@ def package(self):

def package_info(self):
self.cpp_info.libs = ["vtx_renderer"]
# Same as self.cpp.package.includedirs in layout()
#self.cpp_info.includedirs = ["include", "vendor"]
self.cpp_info.set_property("SHADERS_DIR", self.package_folder + "/path/to/shaders")
self.conf_info.define("user.myconf:dir_shaders", os.path.join(self.package_folder + "/src/renderer/context/gl/shaders"))

2 changes: 0 additions & 2 deletions lib/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ target_link_libraries(vtx_util PRIVATE spdlog::spdlog)
target_link_libraries(vtx_util PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(vtx_util PRIVATE magic_enum::magic_enum)
target_link_libraries(vtx_util PRIVATE asio::asio)

install(TARGETS vtx_util)
6 changes: 4 additions & 2 deletions lib/util/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ class VTXUtilRecipe(ConanFile):

def requirements(self):
self.requires("glm/0.9.9.8", transitive_headers=True)
#TODO: hide impl to remove transitive_headers.
#TODO: hide impl to remove transitive_headers?
self.requires("spdlog/1.12.0", transitive_headers=True)
self.requires("nlohmann_json/3.11.2")
self.requires("magic_enum/0.9.3", transitive_headers=True)
self.requires("asio/1.28.1")

#TODO: get CMake?
#def build_requirements(self):

def config_options(self):
Expand All @@ -31,6 +30,7 @@ def config_options(self):

def layout(self):
cmake_layout(self)
# self.cpp.source and cpp.build are only for editable.

def build(self):
cmake = CMake(self)
Expand All @@ -43,4 +43,6 @@ def package(self):

def package_info(self):
self.cpp_info.libs = ["vtx_util"]
# Same as self.cpp.package.includedirs in layout()
#self.cpp_info.includedirs = []

0 comments on commit 4782615

Please sign in to comment.