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

add HELLO_IMGUI_LINK_LIBRARIES to hello_imgui_add_app.cmake #115

Closed
wants to merge 1 commit into from

Conversation

andersc
Copy link

@andersc andersc commented Jun 23, 2024

Unsure if this is an OK way to include libraries to be linked or if there is another preferred way. Did not update the documentation as I felt it was showing the minimal needed cmake config.

Did test like this ->

add_library(tstlib STATIC)
target_sources(tstlib PRIVATE librarytest.cpp)

add_library(tstlib2 STATIC)
target_sources(tstlib2 PRIVATE librarytest2.cpp)

SET(HELLO_IMGUI_LINK_LIBRARIES tstlib tstlib2)
hello_imgui_add_app(hello_world main.cpp)

Where main.cpp calls some public methods in tstlib and tstlib2

@pthom
Copy link
Owner

pthom commented Jun 23, 2024

Hello, thanks for this suggestion!

However, I'm not sure if this is really needed. Because what you are trying to do:

add_library(tstlib STATIC)
target_sources(tstlib PRIVATE librarytest.cpp)

add_library(tstlib2 STATIC)
target_sources(tstlib2 PRIVATE librarytest2.cpp)

SET(HELLO_IMGUI_LINK_LIBRARIES tstlib tstlib2)
hello_imgui_add_app(hello_world main.cpp)

Could be rewritten as:

add_library(tstlib STATIC)
target_sources(tstlib PRIVATE librarytest.cpp)

add_library(tstlib2 STATIC)
target_sources(tstlib2 PRIVATE librarytest2.cpp)

hello_imgui_add_app(hello_world main.cpp)

# Added this
target_link_libraries(hello_world PRIVATE tstlib tstlib2)

Would that be enough for you?

Or, if you have many many executable to generate and you are looking for a way to avoid having add the link manually for all of the executables? If so you could write a function with the same signature as hello_imgui_add_app, which would call hello_imgui_add_app and then add the link for the additional libraries.

Am I missing something? Is there another reason why this might be needed?

@andersc
Copy link
Author

andersc commented Jun 24, 2024

Hi.

Works for me and is more 'clean'.

/A

@andersc andersc closed this Jun 24, 2024
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

Successfully merging this pull request may close these issues.

2 participants