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

Fix CMake to be included via CPM #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

diegoiast
Copy link

@diegoiast diegoiast commented Nov 11, 2024

Main problem was that the header was not found by the containing proect. Took also the liberty to cleanup the CMakeLists.txt. I also fixed compilation under MSVC (only build system problems, code compiles perfectly).

Now including the project is as simple as:

CPMAddPackage("gh:/dridk/QJsonModel#master")

target_link_libraries(my_epic_app Qt6::Core Qt6::Widgets Qt6::PrintSupport Qt6::Svg Qt6::Xml QJsonModelStatic)

Then in your C++ file:

auto model = new QJsonModel();
model->loadJson(str.toUtf8());
treeView->setModel(model);

I might need to review the commit message, as its kinda.. not ideal :) and also squash the commits - if the fixes are good for you.

Main problem was that the header was not found by the containing
proect. Took also the liberty to cleanup the CMakeLists.txt

Now including the project is as simple as:
```CMake

CPMAddPackage("gh:/dridk/QJsonModel#master")

target_link_libraries(my_epic_app Qt6::Core Qt6::Widgets Qt6::PrintSupport Qt6::Svg Qt6::Xml QJsonModelStatic)
```

Then in your C++ file:

```C++

auto model = new QJsonModel();
model->loadJson(str.toUtf8());
treeView->setModel(model);
```
It seems most of the code was not needed, and reduced the build script
even more. The trigger? It worked on my Fedora system, but not on my
Debian.

Removed most of the C related stuff, removed redundant declarations.
Include path fixed.
@diegoiast diegoiast changed the title Fix CMake to be included Fix CMake to be included via CPM Nov 12, 2024
On MSVC CMake cannot make foo.dll, and foo.lib. If you try to do this, you get:

```
[cmake]    ninja: error: build.ninja:2527: multiple rules generate _deps/qjsonmodel-build/QJsonModel.lib
```

To overcome this, the static target will have its own output name.
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.

1 participant