mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
Tests: Add AUTOGEN policy CMP0100 test
Add a test for policy CMP0100 that configures whether or not AUTOMOC and AUTOUIC should process .hh header files.
This commit is contained in:
9
Tests/QtAutogen/MocCMP0100/CMakeLists.txt
Normal file
9
Tests/QtAutogen/MocCMP0100/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(MocCMP0100)
|
||||
include("../AutogenCoreTest.cmake")
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CSD ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_subdirectory(OLD)
|
||||
add_subdirectory(NEW)
|
10
Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt
Normal file
10
Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_policy(SET CMP0100 NEW)
|
||||
|
||||
add_executable(mocCMP0100New
|
||||
${CSD}/main.cpp
|
||||
${CSD}/Obj.hh # Manually include Obj.hh
|
||||
${CSD}/Obj.cpp
|
||||
${CSD}/Obj2.cpp # Let AUTOMOC detect Obj2.hh
|
||||
)
|
||||
target_link_libraries(mocCMP0100New ${QT_LIBRARIES})
|
31
Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt
Normal file
31
Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_policy(SET CMP0100 OLD)
|
||||
|
||||
# Generate moc files externally.
|
||||
# If AUTOMOC generates the header moc files as well
|
||||
# (it should not in OLD behavior), the test will fail with a
|
||||
# multiple definition error when linking the executable.
|
||||
qtx_wrap_cpp(mocCMP0100OldMoc ${CSD}/Obj.hh ${CSD}/Obj2.hh)
|
||||
qtx_generate_moc(${CBD}/Obj.cpp ${CMAKE_CURRENT_BINARY_DIR}/Obj.moc)
|
||||
qtx_generate_moc(${CBD}/Obj2.cpp ${CMAKE_CURRENT_BINARY_DIR}/Obj2.moc)
|
||||
|
||||
# Make sure AUTOGEN file skipping is disabled
|
||||
set_source_files_properties(
|
||||
${CSD}/Obj.hh
|
||||
${CBD}/Obj.cpp
|
||||
${CSD}/Obj2.hh
|
||||
${CBD}/Obj2.cpp
|
||||
PROPERTIES
|
||||
SKIP_AUTOGEN OFF
|
||||
SKIP_AUTOMOC OFF
|
||||
)
|
||||
|
||||
add_executable(mocCMP0100Old
|
||||
${CSD}/main.cpp
|
||||
${CSD}/Obj.hh # Manually include Obj.hh
|
||||
${CSD}/Obj.cpp
|
||||
${CSD}/Obj2.cpp # Let AUTOMOC detect Obj2.hh
|
||||
${mocCMP0100OldMoc}
|
||||
)
|
||||
target_link_libraries(mocCMP0100Old ${QT_LIBRARIES})
|
||||
target_include_directories(mocCMP0100Old PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
31
Tests/QtAutogen/MocCMP0100/Obj.cpp
Normal file
31
Tests/QtAutogen/MocCMP0100/Obj.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "Obj.hh"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class ObjPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ObjPrivate();
|
||||
~ObjPrivate();
|
||||
};
|
||||
|
||||
ObjPrivate::ObjPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
ObjPrivate::~ObjPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
Obj::Obj()
|
||||
: d(new ObjPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
Obj::~Obj()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
#include "Obj.moc"
|
20
Tests/QtAutogen/MocCMP0100/Obj.hh
Normal file
20
Tests/QtAutogen/MocCMP0100/Obj.hh
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef OBJ_HH
|
||||
#define OBJ_HH
|
||||
|
||||
#include <QObject>
|
||||
|
||||
// Qt enabled private class
|
||||
class ObjPrivate;
|
||||
// Qt enabled class
|
||||
class Obj : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Obj();
|
||||
~Obj();
|
||||
|
||||
private:
|
||||
ObjPrivate* const d;
|
||||
};
|
||||
|
||||
#endif
|
31
Tests/QtAutogen/MocCMP0100/Obj2.cpp
Normal file
31
Tests/QtAutogen/MocCMP0100/Obj2.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "Obj2.hh"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class Obj2Private : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Obj2Private();
|
||||
~Obj2Private();
|
||||
};
|
||||
|
||||
Obj2Private::Obj2Private()
|
||||
{
|
||||
}
|
||||
|
||||
Obj2Private::~Obj2Private()
|
||||
{
|
||||
}
|
||||
|
||||
Obj2::Obj2()
|
||||
: d(new Obj2Private)
|
||||
{
|
||||
}
|
||||
|
||||
Obj2::~Obj2()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
#include "Obj2.moc"
|
20
Tests/QtAutogen/MocCMP0100/Obj2.hh
Normal file
20
Tests/QtAutogen/MocCMP0100/Obj2.hh
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef OBJ2_HH
|
||||
#define OBJ2_HH
|
||||
|
||||
#include <QObject>
|
||||
|
||||
// Qt enabled private class
|
||||
class Obj2Private;
|
||||
// Qt enabled class
|
||||
class Obj2 : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Obj2();
|
||||
~Obj2();
|
||||
|
||||
private:
|
||||
Obj2Private* const d;
|
||||
};
|
||||
|
||||
#endif
|
9
Tests/QtAutogen/MocCMP0100/main.cpp
Normal file
9
Tests/QtAutogen/MocCMP0100/main.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "Obj.hh"
|
||||
#include "Obj2.hh"
|
||||
|
||||
int main(int argv, char** args)
|
||||
{
|
||||
Obj obj;
|
||||
Obj2 obj2;
|
||||
return 0;
|
||||
}
|
@@ -32,6 +32,7 @@ ADD_AUTOGEN_TEST(UicSkipSource)
|
||||
|
||||
if(QT_TEST_ALLOW_QT_MACROS)
|
||||
ADD_AUTOGEN_TEST(MocCMP0071)
|
||||
ADD_AUTOGEN_TEST(MocCMP0100)
|
||||
ADD_AUTOGEN_TEST(MocInclude)
|
||||
ADD_AUTOGEN_TEST(MocIncludeSymlink)
|
||||
ADD_AUTOGEN_TEST(MocSkipSource)
|
||||
|
Reference in New Issue
Block a user