Autogen: Add test for CMAKE_GLOBAL_AUTOGEN/RCC_TARGET
This commit is contained in:
parent
3baa817c34
commit
8c8731b422
@ -7,6 +7,7 @@ ADD_AUTOGEN_TEST(UicOnly uicOnly)
|
||||
ADD_AUTOGEN_TEST(RccOnly rccOnly)
|
||||
ADD_AUTOGEN_TEST(RccEmpty rccEmpty)
|
||||
ADD_AUTOGEN_TEST(RccOffMocLibrary)
|
||||
ADD_AUTOGEN_TEST(GlobalAutogenTarget)
|
||||
if(QT_TEST_ALLOW_QT_MACROS)
|
||||
ADD_AUTOGEN_TEST(MocSkipSource)
|
||||
endif()
|
||||
|
123
Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt
Normal file
123
Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt
Normal file
@ -0,0 +1,123 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(GlobalAutogenTarget)
|
||||
include("../AutogenTest.cmake")
|
||||
|
||||
# This tests
|
||||
# CMAKE_GLOBAL_AUTOGEN_TARGET,
|
||||
# CMAKE_GLOBAL_AUTORCC_TARGET,
|
||||
# CMAKE_GLOBAL_AUTOGEN_TARGET_NAME and
|
||||
# CMAKE_GLOBAL_AUTORCC_TARGET_NAME
|
||||
# for the latter two with different values in different subdirectories.
|
||||
|
||||
# Directories
|
||||
set(GAT_SDIR "${CMAKE_CURRENT_SOURCE_DIR}/GAT")
|
||||
set(GAT_BDIR "${CMAKE_CURRENT_BINARY_DIR}/GAT")
|
||||
# Files
|
||||
set(MCA "sda/sda_autogen/mocs_compilation.cpp")
|
||||
set(MCB "sdb/sdb_autogen/mocs_compilation.cpp")
|
||||
set(MCC "sdc/sdc_autogen/mocs_compilation.cpp")
|
||||
set(MCG "gat_autogen/mocs_compilation.cpp")
|
||||
|
||||
set(DRA "sda/sda_autogen/*qrc_data.cpp")
|
||||
set(DRB "sdb/sdb_autogen/*qrc_data.cpp")
|
||||
set(DRC "sdc/sdc_autogen/*qrc_data.cpp")
|
||||
set(DRG "gat_autogen/*qrc_data.cpp")
|
||||
|
||||
# -- Utility macros
|
||||
macro(GAT_FIND_FILES VAR NAME)
|
||||
file(GLOB_RECURSE ${VAR} ${GAT_BDIR}/*${NAME})
|
||||
endmacro()
|
||||
|
||||
macro(GAT_FIND_FILE NAME)
|
||||
GAT_FIND_FILES(LST ${NAME})
|
||||
if(LST)
|
||||
message("Good find ${LST}")
|
||||
else()
|
||||
message(SEND_ERROR "Expected to find ${GAT_BDIR}/${NAME}")
|
||||
endif()
|
||||
unset(LST)
|
||||
endmacro()
|
||||
|
||||
macro(GAT_FIND_FILE_NOT NAME)
|
||||
GAT_FIND_FILES(LST ${NAME})
|
||||
if(LST)
|
||||
message(SEND_ERROR "Not expected to find ${GAT_BDIR}/${NAME}")
|
||||
else()
|
||||
message("Good not find ${GAT_BDIR}/${NAME}")
|
||||
endif()
|
||||
unset(LST)
|
||||
endmacro()
|
||||
|
||||
macro(GAT_BUILD_TARGET NAME)
|
||||
message("___ Building GAT ${NAME} target ___")
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" --build "${GAT_BDIR}" --target ${NAME}
|
||||
WORKING_DIRECTORY "${GAT_BDIR}"
|
||||
RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Building of GAT ${NAME} target failed")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
# -- Remove and recreate build directory
|
||||
file(REMOVE_RECURSE ${GAT_BDIR})
|
||||
file(MAKE_DIRECTORY ${GAT_BDIR})
|
||||
|
||||
|
||||
# -- Configure project
|
||||
message("___ Configuring GAT project ___")
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" "${GAT_SDIR}"
|
||||
"-DQT_TEST_VERSION=${QT_TEST_VERSION}"
|
||||
"-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
|
||||
"-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
|
||||
WORKING_DIRECTORY "${GAT_BDIR}"
|
||||
OUTPUT_VARIABLE output
|
||||
RESULT_VARIABLE result)
|
||||
if (result)
|
||||
message(SEND_ERROR "Configuring of GAT project failed")
|
||||
else()
|
||||
message("Configuring of GAT project succeeded")
|
||||
message("${output}")
|
||||
endif()
|
||||
|
||||
|
||||
# -- Build autogen subtargets
|
||||
GAT_BUILD_TARGET("autogen")
|
||||
GAT_FIND_FILE("${MCA}")
|
||||
GAT_FIND_FILE_NOT("${MCB}")
|
||||
GAT_FIND_FILE_NOT("${MCC}")
|
||||
GAT_FIND_FILE("${MCG}")
|
||||
|
||||
GAT_BUILD_TARGET("global_autogen_sdb")
|
||||
GAT_FIND_FILE("${MCA}")
|
||||
GAT_FIND_FILE("${MCB}")
|
||||
GAT_FIND_FILE_NOT("${MCC}")
|
||||
GAT_FIND_FILE("${MCG}")
|
||||
|
||||
GAT_BUILD_TARGET("all_autogen")
|
||||
GAT_FIND_FILE("${MCA}")
|
||||
GAT_FIND_FILE("${MCB}")
|
||||
GAT_FIND_FILE("${MCC}")
|
||||
GAT_FIND_FILE("${MCG}")
|
||||
|
||||
|
||||
# -- Build autorcc subtargets
|
||||
GAT_BUILD_TARGET("autorcc")
|
||||
GAT_FIND_FILE("${DRA}")
|
||||
GAT_FIND_FILE_NOT("${DRB}")
|
||||
GAT_FIND_FILE_NOT("${DRC}")
|
||||
GAT_FIND_FILE("${DRG}")
|
||||
|
||||
GAT_BUILD_TARGET("global_autorcc_sdb")
|
||||
GAT_FIND_FILE("${DRA}")
|
||||
GAT_FIND_FILE("${DRB}")
|
||||
GAT_FIND_FILE_NOT("${DRC}")
|
||||
GAT_FIND_FILE("${DRG}")
|
||||
|
||||
GAT_BUILD_TARGET("all_autorcc")
|
||||
GAT_FIND_FILE("${DRA}")
|
||||
GAT_FIND_FILE("${DRB}")
|
||||
GAT_FIND_FILE("${DRC}")
|
||||
GAT_FIND_FILE("${DRG}")
|
28
Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt
Normal file
28
Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(GAT)
|
||||
include("../../AutogenTest.cmake")
|
||||
|
||||
# Include directories
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# Enable AUTOMOC/UIC/RCC
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
# Disable ORIGN_DEPENDS and enable AUTOGEN global targets
|
||||
set(CMAKE_AUTOGEN_ORIGIN_DEPENDS OFF)
|
||||
set(CMAKE_GLOBAL_AUTOGEN_TARGET ON)
|
||||
set(CMAKE_GLOBAL_AUTORCC_TARGET ON)
|
||||
|
||||
add_subdirectory(sda)
|
||||
add_subdirectory(sdb)
|
||||
add_subdirectory(sdc)
|
||||
|
||||
# Add custom target that depends on all autogen/autorcc targets
|
||||
add_custom_target(all_autogen DEPENDS autogen global_autogen_sdb global_autogen_sdc)
|
||||
add_custom_target(all_autorcc DEPENDS autorcc global_autorcc_sdb global_autorcc_sdc)
|
||||
|
||||
# Main target
|
||||
add_executable(gat data.qrc item.cpp main.cpp)
|
||||
target_link_libraries(gat ${QT_LIBRARIES})
|
||||
target_link_libraries(gat sda sdb sdc)
|
5
Tests/QtAutogen/GlobalAutogenTarget/GAT/data.qrc
Normal file
5
Tests/QtAutogen/GlobalAutogenTarget/GAT/data.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>item.cpp</file>
|
||||
</qresource>
|
||||
</RCC>
|
20
Tests/QtAutogen/GlobalAutogenTarget/GAT/item.cpp
Normal file
20
Tests/QtAutogen/GlobalAutogenTarget/GAT/item.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "item.hpp"
|
||||
// Include ui_view.h in source and header
|
||||
#include <ui_view.h>
|
||||
|
||||
class MocLocal : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
MocLocal() = default;
|
||||
~MocLocal() = default;
|
||||
};
|
||||
|
||||
void Item::go()
|
||||
{
|
||||
Ui_View ui;
|
||||
MocLocal obj;
|
||||
}
|
||||
|
||||
#include "item.moc"
|
15
Tests/QtAutogen/GlobalAutogenTarget/GAT/item.hpp
Normal file
15
Tests/QtAutogen/GlobalAutogenTarget/GAT/item.hpp
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef ITEM_HPP
|
||||
#define ITEM_HPP
|
||||
|
||||
#include <QObject>
|
||||
// Include ui_view.h in source and header
|
||||
#include <ui_view.h>
|
||||
|
||||
class Item : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_SLOT
|
||||
void go();
|
||||
};
|
||||
|
||||
#endif
|
15
Tests/QtAutogen/GlobalAutogenTarget/GAT/main.cpp
Normal file
15
Tests/QtAutogen/GlobalAutogenTarget/GAT/main.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include "item.hpp"
|
||||
#include "sda/sda.hpp"
|
||||
#include "sdb/sdb.hpp"
|
||||
#include "sdc/sdc.hpp"
|
||||
|
||||
int main(int argv, char** args)
|
||||
{
|
||||
// Object instances
|
||||
Item item;
|
||||
// Library calls
|
||||
sda();
|
||||
sdb();
|
||||
sdc();
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
add_library(sda ../item.cpp ../data.qrc sda.cpp)
|
||||
target_link_libraries(sda ${QT_LIBRARIES})
|
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.cpp
Normal file
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include <item.hpp>
|
||||
|
||||
void sda()
|
||||
{
|
||||
Item item;
|
||||
}
|
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.hpp
Normal file
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef SDA_HPP
|
||||
#define SDA_HPP
|
||||
|
||||
void sda();
|
||||
|
||||
#endif
|
@ -0,0 +1,5 @@
|
||||
set(CMAKE_GLOBAL_AUTOGEN_TARGET_NAME "global_autogen_sdb")
|
||||
set(CMAKE_GLOBAL_AUTORCC_TARGET_NAME "global_autorcc_sdb")
|
||||
|
||||
add_library(sdb ../item.cpp ../data.qrc sdb.cpp)
|
||||
target_link_libraries(sdb ${QT_LIBRARIES})
|
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.cpp
Normal file
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include <item.hpp>
|
||||
|
||||
void sdb()
|
||||
{
|
||||
Item item;
|
||||
}
|
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.hpp
Normal file
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef SDB_HPP
|
||||
#define SDB_HPP
|
||||
|
||||
void sdb();
|
||||
|
||||
#endif
|
@ -0,0 +1,5 @@
|
||||
set(CMAKE_GLOBAL_AUTOGEN_TARGET_NAME "global_autogen_sdc")
|
||||
set(CMAKE_GLOBAL_AUTORCC_TARGET_NAME "global_autorcc_sdc")
|
||||
|
||||
add_library(sdc ../item.cpp ../data.qrc sdc.cpp)
|
||||
target_link_libraries(sdc ${QT_LIBRARIES})
|
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.cpp
Normal file
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include <item.hpp>
|
||||
|
||||
void sdc()
|
||||
{
|
||||
Item item;
|
||||
}
|
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.hpp
Normal file
6
Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef SDC_HPP
|
||||
#define SDC_HPP
|
||||
|
||||
void sdc();
|
||||
|
||||
#endif
|
24
Tests/QtAutogen/GlobalAutogenTarget/GAT/view.ui
Normal file
24
Tests/QtAutogen/GlobalAutogenTarget/GAT/view.ui
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>View</class>
|
||||
<widget class="QWidget" name="Base">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user