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

[QUESTION] using xtd in a pre-written CMake project #251

Open
ethindp opened this issue Feb 17, 2024 · 4 comments
Open

[QUESTION] using xtd in a pre-written CMake project #251

ethindp opened this issue Feb 17, 2024 · 4 comments
Assignees

Comments

@ethindp
Copy link

ethindp commented Feb 17, 2024

Your question

I'm trying to incorporate xtd into a project via the cpm.cmake package manager. However, this doesn't work because I have to first execute find_package and then when I try to do target_xxx CMake either: (1) claims that target_link_libraries(...) has already been used, or (2) the library tries to generate assembly information, but it does it in a weird way (it does something like ${CMAKE_SOURCE_DIR}/{generated_code_here}). Obviously, this doesn't work. What am I doing wrong?

@gammasoft71 gammasoft71 self-assigned this Feb 17, 2024
@gammasoft71
Copy link
Owner

Hi,

First of all, thank you for your interest in xtd.

xtd does not yet have package management, see #221. This may explain your problem.
I don't know cpm.cmake. Maybe adding find_package can be a solution. But I think the best way to do this is to start with a minimal project and for example not to use the xtd.cmake specific commands but the standard cmake commands.

Creates a project too simple like this and try it with cpm.cmake.

  • my_app.cpp
#include <xtd/xtd>

auto main()->int {
  xtd::forms::application::run(xtd::forms::form::create("My app"));
}
  • CMakeLists.txt :
cmake_minimum_required(VERSION 3.20)

project(my_app)
find_package(xtd REQUIRED)
add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE my_app.cpp)
target_link_libraries(${PROJECT_NAME} xtd)

After that, if it works, add specific commands to xtd.cmake like add_sources, add_resources, target_type...
and see what happens.

I hope this helps.

@ethindp
Copy link
Author

ethindp commented Feb 17, 2024

@gammasoft71 cpm.cmake is pretty neat. I'll give your suggestion a try though - thanks!

@ethindp
Copy link
Author

ethindp commented Feb 21, 2024

@gammasoft71 Update: I tried it and it didn't work. It still complained about CMake trying to override my project (saying that, e.g., target_xxx_xxx() (like target_link_libraries) was already called on my CMake project). Essentially what I'm trying to do is download and build xtd alongside my project instead of forcing people to install it separately.

@gammasoft71
Copy link
Owner

gammasoft71 commented Feb 24, 2024

Sorry this is not working. I don't have enough information to help you.
I think the problem may be that xtd doesn't have package management #221 yet.

Apart from that, I really don't see how xtd's cmake management could be blocking.
The cmake commands added by xtd only set variables to prepare the work of the target_type command.
And it's only when target_type is called that it has specific processing for xtd (such as managing resources, languages and settings).
And if you use standard cmake commands, xtd does nothing...

Stupid question: have you ever tried the same operation with a library as complex as xtd, such as fltk, wxwidgets, or other ?

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