Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should the current working dir be added automatically to search paths? #261

Open
MoAlyousef opened this issue Apr 6, 2021 · 6 comments
Open

Comments

@MoAlyousef
Copy link

MoAlyousef commented Apr 6, 2021

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.

@djowel
Copy link
Collaborator

djowel commented Apr 7, 2021

Sorry, I can't see a question there. Can you make the question more explicit?

@djowel
Copy link
Collaborator

djowel commented Apr 7, 2021

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.

@MoAlyousef
Copy link
Author

Sure. I’ll have a go at it.

@MoAlyousef
Copy link
Author

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)

@djowel
Copy link
Collaborator

djowel commented Apr 10, 2021

Looks good. Perhaps the examples could make use of that as well. I'd welcome a PR.

@MoAlyousef
Copy link
Author

MoAlyousef commented Apr 11, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants