Control the location of (ui_*.h) files with CMake
-
Is there a way to specify/define the location where "ui_*.h" files (such as ui_mainwindow.h) will be generated by the CMakeLists.txt file?
############################### EDIT #########################################
Since my question is causing a lot of confusion and problems, I decided to give some more explanation :)
It all started with me making a decision to make my self more familiar with the structure of a Qt project. I made a simple project and named it "QtProject". I attempted to understand the folder structure of the project in depth. The biggest issue that I had was the following code:
#include "mainwindow.h" #include "./ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; }The above is the standard code that comes with nearly every project in a QWidget application for the mainwindow.cpp file. My issue in particular is the following include line:
#include "./ui_mainwindow.h"The above include line really confused me since I could not figure out where it was placed in relation to the mainwindow.cpp file. As far as I am aware, the path of "./" is referring to the current directory. But, I never found the header file near my mainwindow.cpp file. I eventually found it under the path of "QtProject_autogen\include". This path was confusing to me, so I wanted to ask kindly if there is a way to specify where it will place this file.
-
Is there a way to specify/define the location where "ui_*.h" files (such as ui_mainwindow.h) will be generated by the CMakeLists.txt file?
############################### EDIT #########################################
Since my question is causing a lot of confusion and problems, I decided to give some more explanation :)
It all started with me making a decision to make my self more familiar with the structure of a Qt project. I made a simple project and named it "QtProject". I attempted to understand the folder structure of the project in depth. The biggest issue that I had was the following code:
#include "mainwindow.h" #include "./ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; }The above is the standard code that comes with nearly every project in a QWidget application for the mainwindow.cpp file. My issue in particular is the following include line:
#include "./ui_mainwindow.h"The above include line really confused me since I could not figure out where it was placed in relation to the mainwindow.cpp file. As far as I am aware, the path of "./" is referring to the current directory. But, I never found the header file near my mainwindow.cpp file. I eventually found it under the path of "QtProject_autogen\include". This path was confusing to me, so I wanted to ask kindly if there is a way to specify where it will place this file.
-
@Saviz Is there a reason why you want to control that? These files are autogenerated and thus put in build folder.
-
@jsulm I know this may not be a very convincing answer to your question, but I am just simply curious. I may want to specify a custom location for them just for the sake of keeping my project organized the way I want it to :)
@Saviz said in Control the location of (ui_*.h) files with CMake:
just for the sake of keeping my project organized the way I want it to :)
No, it's not possible and why would someone organize the temporary build folder?
/edit: you can modify them a little bit with AUTOGEN_BUILD_DIR
-
@Saviz said in Control the location of (ui_*.h) files with CMake:
just for the sake of keeping my project organized the way I want it to :)
No, it's not possible and why would someone organize the temporary build folder?
/edit: you can modify them a little bit with AUTOGEN_BUILD_DIR
@Christian-Ehrlicher ui files have layout info and sometimes people do need to take a look at them. qmake has UI_DIR for this. The build dir made by cmake is sort of messy and not intuitive. That is why I have both qmake and cmake in my apps. In my qmake file I use OBJECTS_DIR, MOC_DIR and UI_DIR to organize build output.
-
@Christian-Ehrlicher ui files have layout info and sometimes people do need to take a look at them. qmake has UI_DIR for this. The build dir made by cmake is sort of messy and not intuitive. That is why I have both qmake and cmake in my apps. In my qmake file I use OBJECTS_DIR, MOC_DIR and UI_DIR to organize build output.
@JoeCFD said in Control the location of (ui_*.h) files with CMake:
ui files have layout info and sometimes people do need to take a look at them
QtCreator: Go to the source where the header is included and move the cursor to the include, press F2
Put your cursor to a ui element, press F2You really want to tell me that searching the file in a directory is faster than this?
-
@JoeCFD said in Control the location of (ui_*.h) files with CMake:
ui files have layout info and sometimes people do need to take a look at them
QtCreator: Go to the source where the header is included and move the cursor to the include, press F2
Put your cursor to a ui element, press F2You really want to tell me that searching the file in a directory is faster than this?
@Christian-Ehrlicher I mainly work from command line on Linux. I simply want to make my build dir look a bit cleaner. Speed is another issue.
-
@Christian-Ehrlicher I mainly work from command line on Linux. I simply want to make my build dir look a bit cleaner. Speed is another issue.
@JoeCFD said in Control the location of (ui_*.h) files with CMake:
I mainly work from command line on Linux.
Speed is another issue.
So you want to tell me you're faster programming on the command line than in a good IDE? No need to discuss further...
-
@JoeCFD said in Control the location of (ui_*.h) files with CMake:
I mainly work from command line on Linux.
Speed is another issue.
So you want to tell me you're faster programming on the command line than in a good IDE? No need to discuss further...
@Christian-Ehrlicher Where did you get this? Why does it matter who is faster or not. I am not working with you. I said I want to keep my build dir cleaner since I work more from command line. If you work with qtcreator all the time, you may not care about how the build dir looks like.
-
@Christian-Ehrlicher ui files have layout info and sometimes people do need to take a look at them. qmake has UI_DIR for this. The build dir made by cmake is sort of messy and not intuitive. That is why I have both qmake and cmake in my apps. In my qmake file I use OBJECTS_DIR, MOC_DIR and UI_DIR to organize build output.