I have re-organized a CMake Qt5 project in multiple subdirectory, the final folder structure looks like this:
├── CMakeLists.txt
├── headers
│ ├── a.h
│ ├── b.h
├── LICENSE
├── README.md
├── resources
│ ├── images
│ │ ├── img.png
│ └── res.qrc
├── sources
│ ├── main.cpp
│ ├── a.cpp
│ ├── b.cpp
└── ui
├── a.ui
└── b.ui
The problems comes when i try to compile the whole project: in fact the compiler say that it cannot find headers ui files(e.g. ui_main.h
and ui_sub.h
), this is the error:
In file included from /home/vbm/test/headers/a.h:13,
from /home/vbm/test/headers/b.h:14,
from /home/vbm/test/sources/main.cpp:6:
/home/vbm/test/headers/a.h:12:10: fatal error: ui_a.h: No such file or directory
#include "ui_a.h"
^~~~~~~~
This is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.9)
project(test VERSION 0.1)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
# Declaring files
set( SOURCES
sources/main.cpp
source/a.cpp
source/b.cpp
)
set( HEADERS
headers/a.h
headers/b.h
)
set( UIS
ui/a.ui
ui/b.ui
)
set( RES
resources/res.qrc
)
add_executable(test ${SOURCES} ${HEADERS} ${UIS} ${RES})
target_link_libraries(test Qt5::Widgets Qt5::Core)
How can i specify the output directory of those header UI files?
--EDIT--
I have already added the CMAKE_AUTOUIC_SEARCH_PATHS
property without any success, the compiler still gave me the same error.
This is what i've added to the CMakeLists.txt:
set(CMAKE_AUTOUIC_SEARCH_PATHS "${PROJECT_SOURCE_DIR}/ui")