mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-06 04:03:27 +03:00
Autogen: Add test for OBJECT libraries
This commit is contained in:
1 parent
362f9bd755
commit
15ef27286a
8 files changed
+93
No files matched your search
@@ -192,6 +192,10 @@ endif()
|
||||
# Tests various .ui include directories
|
||||
add_subdirectory(uicInclude)
|
||||
|
||||
# -- Test
|
||||
# OBJECT libraries
|
||||
add_subdirectory(objectLibrary)
|
||||
|
||||
# -- Test
|
||||
# Complex test case
|
||||
add_subdirectory(complex)
|
||||
@@ -0,0 +1,14 @@
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
# Object library a defined in a subdirectory
|
||||
add_subdirectory(a)
|
||||
|
||||
# Object library b defined locally
|
||||
include_directories(b)
|
||||
add_library(b OBJECT b/classb.cpp)
|
||||
target_compile_features(b PRIVATE ${QT_COMPILE_FEATURES})
|
||||
|
||||
# Executable with OBJECT library generator expressions
|
||||
add_executable(someProgram main.cpp $<TARGET_OBJECTS:a> $<TARGET_OBJECTS:b>)
|
||||
target_link_libraries(someProgram ${QT_LIBRARIES})
|
||||
@@ -0,0 +1,2 @@
|
||||
add_library(a OBJECT classa.cpp)
|
||||
target_compile_features(a PRIVATE ${QT_COMPILE_FEATURES})
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "classa.h"
|
||||
#include <QDebug>
|
||||
|
||||
void ClassA::slotDoSomething()
|
||||
{
|
||||
qDebug() << m_member;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef CLASSA_H
|
||||
#define CLASSA_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class ClassA : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClassA()
|
||||
: m_member("Hello A")
|
||||
{
|
||||
}
|
||||
|
||||
public slots:
|
||||
void slotDoSomething();
|
||||
|
||||
private:
|
||||
QString m_member;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "classb.h"
|
||||
#include <QDebug>
|
||||
|
||||
void ClassB::slotDoSomething()
|
||||
{
|
||||
qDebug() << m_member;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef CLASSB_H
|
||||
#define CLASSB_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class ClassB : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClassB()
|
||||
: m_member("Hello B")
|
||||
{
|
||||
}
|
||||
|
||||
public slots:
|
||||
void slotDoSomething();
|
||||
|
||||
private:
|
||||
QString m_member;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "a/classa.h"
|
||||
#include "b/classb.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ClassA a;
|
||||
a.slotDoSomething();
|
||||
|
||||
ClassB b;
|
||||
b.slotDoSomething();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user