elements
elements copied to clipboard
Should the current working dir be added automatically to search paths?
Hello Thanks for working on elements. This is more of a question than an issue.
I use CMake's fetch content to add elements as a dependency, cmake also fetches other git submodules automatically:
cmake_minimum_required(VERSION 3.15)
project(app)
set(ELEMENTS_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
include(FetchContent)
FetchContent_Declare(elements GIT_REPOSITORY https://github.com/cycfi/elements)
FetchContent_MakeAvailable(elements)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE cycfi::elements)
The problem is adding resources via ELEMENTS_APP_RESOURCES won't work in that setup, and add_search_path("."); feels like it should be implied.
Sorry, I can't see a question there. Can you make the question more explicit?
Sorry, I can't see a question there. Can you make the question more explicit?
Ah... the question is in the title. Well, if you think you have a way to improve the cmake build, I'll welcome a PR.
Sure. I’ll have a go at it.
So I found a solution to using fetchContent without having to modify element's cmake files. It also allows the use of elements' bundled fonts and other resources, and allows specifying a resource dir for my test project. The minimal CMakeLists.txt looks like:
cmake_minimum_required(VERSION 3.15)
project(elements_example)
set(ELEMENTS_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
include(FetchContent)
FetchContent_Declare(elements GIT_REPOSITORY https://github.com/cycfi/elements)
FetchContent_MakeAvailable(elements)
set(ELEMENTS_ROOT ${elements_SOURCE_DIR})
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${ELEMENTS_ROOT}/cmake")
set(ELEMENTS_APP_PROJECT "app")
set(ELEMENTS_APP_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/resources/ex.png)
include(ElementsConfigApp)
Looks good. Perhaps the examples could make use of that as well. I'd welcome a PR.
Using fetchContent in the examples dir seems out of place. I could add it to the setup docs, assuming it's under the qplug_api_changes branch.