Giter VIP home page Giter VIP logo

Comments (7)

Youw avatar Youw commented on August 20, 2024 1

In that case you'd need to have a separate custom command for each .ui file, and a single custom target to aggregate all of those, something like:

SET(SOURCES file1.ui file2.ui file3.ui)
set(UI_GENERATION_COMMANDS)
foreach(SOURCE SOURCES)
    set(OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SOURCE}.py")
    add_custom_command(
        OUTPUT "${OUTPUT_FILE}"
        COMMAND "uic -g python -o ${OUTPUT_FILE} ${SOURCE}"
        COMMENT "Generating ${SOURCE} -> ${OUTPUT_FILE}"
    )
    list(APPEND UI_GENERATION_COMMANDS "${OUTPUT_FILE}")
endforeach()
add_custom_target(GenerateUIToPy ALL DEPENDS ${UI_GENERATION_COMMANDS})

from avrdude.

dl8dtl avatar dl8dtl commented on August 20, 2024 1

OK, thanks a lot for the explanation.
Alas, I just noticed that there appears to be a lot of confusion about the uic command for PySide. In the past, the command was called pyside2-uic. Older versions of uic only supported Java and C++ as generator targets, yet the silently accepted -g python – and generated C++ code. :-o Then, the Qt5 in Ubuntu22.04 has dropped pyside2-uic entirely (probably because it was based on Python 2.7 still), but did not upgrade their Qt to a recent enough version that would support Python code generation.
So bottom line, this would probably prevent many people from experimenting with it, and I decided to rather load the .ui files at run-time instead.
But it's nevertheless good to know the solution! The issue tracker will record it for eternity. ;-)

from avrdude.

mcuee avatar mcuee commented on August 20, 2024

@Youw

Just wondering if you can provide a quick tip here. Thanks.

from avrdude.

Youw avatar Youw commented on August 20, 2024

Either set CMAKE_AUTOUIC to TRUE before creating a target (a library or executable) or set the AUTOUIC property of the target to TRUE.
Then add your .ui files to your target as if it is a regular cpp source.

Sample:

set(CMAKE_AUTOUIC ON)
add_library(testLib
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
)

or

add_library(testLib
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
)
set_target_properties(testLib
    PROPERTIES AUTOUIC ON
)

from avrdude.

Youw avatar Youw commented on August 20, 2024

there're other ways to achieve the same, but the one above is the most convenient

and the one you've tried to use (manyally invoking the uic) is probably the least convenient/recommended

from avrdude.

dl8dtl avatar dl8dtl commented on August 20, 2024

I tried CMAKE_AUTOUIC, to no avail.
Problem here: it's not C++, it's Python. I do not need to compile anything but only the .ui files. As far as I could see, CMAKE_AUTOUIC only seems to parse C++ implementation files – which I don't have.
I don't even know how I would setup a CMake target for something that isn't going to be a classic compilation result. (A couple of steps later, it might become one: when trying to create a portable bundle out of all the Python files.)
It's not that I'd object to using C++, but the purpose of all this is to demonstrate a Python wrapper around our backend library.

from avrdude.

dl8dtl avatar dl8dtl commented on August 20, 2024

Besides, your example is also valuable in case we'd have a need for running any similar custom command in future.

from avrdude.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.