Tests: Merge QtAutogen.MocIncludeStrict and MocIncludeRelaxed

This commit is contained in:
Sebastian Holtermann 2019-09-07 11:54:05 +02:00 committed by Brad King
parent d018d27c10
commit 706d9738a6
97 changed files with 1011 additions and 896 deletions

View File

@ -0,0 +1,112 @@
cmake_minimum_required(VERSION 3.15)
project(MocInclude)
get_filename_component(CS_REAL ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
include("${CS_REAL}/../AutogenCoreTest.cmake")
# Test moc include patterns
set(COM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Common")
macro(addCopyCommand from to)
add_custom_command(
OUTPUT ${to}
COMMAND ${CMAKE_COMMAND} -E copy ${from} ${to}
DEPENDS ${from})
endmacro()
# Create an executable
function(makeExecutable TARGET_NAME)
# Utility variables
set(CB_DIR "${CMAKE_CURRENT_BINARY_DIR}")
# Copy directory
file(REMOVE_RECURSE "${CB_DIR}/InIncludes")
file(COPY "${COM_DIR}/InIncludes.in" DESTINATION "${CB_DIR}")
file(RENAME "${CB_DIR}/InIncludes.in" "${CB_DIR}/InIncludes")
# Generate .moc file from the header externally and
# enabled SKIP_AUTOMOC on the source file
qtx_wrap_cpp(ExternDotMOC ${COM_DIR}/ExternDot.hpp OPTIONS "-p" "./")
addCopyCommand(${ExternDotMOC}
${CB_DIR}/ExternDot.moc)
set_property(
SOURCE ${COM_DIR}/ExternDot.cpp
PROPERTY SKIP_AUTOMOC ON)
# Generate .moc file from the GENERATED header externally
# and enabled SKIP_AUTOMOC on the source file
addCopyCommand(${COM_DIR}/ExternDotGenerated.hpp.in
${CB_DIR}/ExternDotGenerated.hpp)
addCopyCommand(${COM_DIR}/ExternDotGenerated.cpp.in
${CB_DIR}/ExternDotGenerated.cpp)
qtx_wrap_cpp(ExternDotGeneratedMOC
${CB_DIR}/ExternDotGenerated.hpp
OPTIONS "-p" "./")
addCopyCommand(${ExternDotGeneratedMOC}
${CB_DIR}/ExternDotGenerated.moc)
set_property(
SOURCE ${CB_DIR}/ExternDotGenerated.cpp
PROPERTY SKIP_AUTOMOC ON)
# Generate header moc file externally with a custom name
# and enabled SKIP_AUTOMOC on the header
qtx_wrap_cpp(MixedCustomMOC
${COM_DIR}/MixedCustom.hpp
OPTIONS "-p" "./")
addCopyCommand(${MixedCustomMOC}
${CB_DIR}/MixedCustom_extMoc.cpp)
set_property(
SOURCE ${COM_DIR}/MixedCustom.hpp
PROPERTY SKIP_AUTOMOC ON)
# Custom target to depend on
add_custom_target("${TARGET_NAME}_MixedCustom"
DEPENDS ${CB_DIR}/MixedCustom_extMoc.cpp
BYPRODUCTS ${CB_DIR}/moc_MixedCustom.cpp
COMMAND ${CMAKE_COMMAND} -E copy
${COM_DIR}/moc_MixedCustom.cpp.in
${CB_DIR}/moc_MixedCustom.cpp)
add_executable(${TARGET_NAME}
# Test own "*.moc" and "moc_*.cpp" includes
${COM_DIR}/None.cpp
${COM_DIR}/OwnDot.cpp
${COM_DIR}/OwnUnderscore.cpp
${COM_DIR}/OwnDotUnderscore.cpp
# Test "moc_*.cpp" includes of other files
${COM_DIR}/OtherUnderscore.cpp
${COM_DIR}/OtherUnderscoreExtra.cpp
${COM_DIR}/OtherUnderscoreSub.cpp
${COM_DIR}/OtherUnderscoreSubDir/SubExtra.cpp
# Test relative ../../ path for moc includes
${COM_DIR}/DualSub/Second/Second.cpp
${COM_DIR}/DualSubMocked.cpp
# Test externally generated moc files
${COM_DIR}/ExternDot.cpp
${CB_DIR}/ExternDot.moc
# Test externally generated moc files for GENERATED source
${CB_DIR}/ExternDotGenerated.cpp
${CB_DIR}/ExternDotGenerated.moc
# Test externally generated moc files and SKIP_AUTOMOC enabled header
${COM_DIR}/MixedSkipped.cpp
${COM_DIR}/MixedCustom.hpp
${COM_DIR}/MixedCustom.cpp
# Test sources in a subdirectory
${CB_DIR}/InIncludes/SubOwnDot.cpp
${COM_DIR}/InIncludesMoc.cpp
)
add_dependencies(${TARGET_NAME} "${TARGET_NAME}_MixedCustom")
target_include_directories(${TARGET_NAME} PRIVATE "${COM_DIR}")
target_include_directories(${TARGET_NAME} PRIVATE "${CB_DIR}")
target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
target_link_libraries(${TARGET_NAME} ${QT_LIBRARIES})
set_target_properties(${TARGET_NAME} PROPERTIES AUTOMOC ON)
endfunction()
add_subdirectory(Strict)
add_subdirectory(Relaxed)

View File

@ -0,0 +1,11 @@
#include "Second.hpp"
Second::Second()
{
}
Second::~Second()
{
}
#include "../../moc_DualSubMocked.cpp"

View File

@ -0,0 +1,14 @@
#ifndef Second_HPP
#define Second_HPP
#include <QObject>
class Second : public QObject
{
Q_OBJECT
public:
Second();
~Second();
};
#endif

View File

@ -0,0 +1,9 @@
#include "DualSubMocked.hpp"
DualSubMocked::DualSubMocked()
{
}
DualSubMocked::~DualSubMocked()
{
}

View File

@ -0,0 +1,15 @@
#ifndef DualSubMocked_HPP
#define DualSubMocked_HPP
#include <QObject>
// Header moc file is included by DualSub/Second/Second.cpp
class DualSubMocked : public QObject
{
Q_OBJECT
public:
DualSubMocked();
~DualSubMocked();
};
#endif

View File

@ -0,0 +1,11 @@
#include "ExternDot.hpp"
ExternDot::ExternDot()
{
}
ExternDot::~ExternDot()
{
}
#include "ExternDot.moc"

View File

@ -1,15 +1,15 @@
#ifndef SOBJA_HPP
#define SOBJA_HPP
#ifndef ExternDot_HPP
#define ExternDot_HPP
#include <QObject>
// Object source includes externally generated .moc file
class SObjA : public QObject
class ExternDot : public QObject
{
Q_OBJECT
public:
SObjA();
~SObjA();
ExternDot();
~ExternDot();
};
#endif

View File

@ -0,0 +1,11 @@
#include "ExternDotGenerated.hpp"
ExternDotGenerated::ExternDotGenerated()
{
}
ExternDotGenerated::~ExternDotGenerated()
{
}
#include "ExternDotGenerated.moc"

View File

@ -0,0 +1,15 @@
#ifndef ExternDotGenerated_HPP
#define ExternDotGenerated_HPP
#include <QObject>
// GENERATED Object source includes externally generated .moc file
class ExternDotGenerated : public QObject
{
Q_OBJECT
public:
ExternDotGenerated();
~ExternDotGenerated();
};
#endif

View File

@ -0,0 +1,43 @@
#include "SubOwnDot.hpp"
#include "SubOwnDot_p.hpp"
namespace InIncludes {
class SubOwnDotLocal : public QObject
{
Q_OBJECT
public:
SubOwnDotLocal();
~SubOwnDotLocal();
};
SubOwnDotLocal::SubOwnDotLocal()
{
}
SubOwnDotLocal::~SubOwnDotLocal()
{
}
SubOwnDotPrivate::SubOwnDotPrivate()
{
}
SubOwnDotPrivate::~SubOwnDotPrivate()
{
}
SubOwnDot::SubOwnDot()
{
SubOwnDotPrivate privateObj;
SubOwnDotLocal localObj;
}
SubOwnDot::~SubOwnDot()
{
}
} // End of namespace
// For the local QObject
#include "SubOwnDot.moc"

View File

@ -0,0 +1,17 @@
#ifndef InIncludes_SubOwnDot_HPP
#define InIncludes_SubOwnDot_HPP
#include <QObject>
namespace InIncludes {
class SubOwnDot : public QObject
{
Q_OBJECT
public:
SubOwnDot();
~SubOwnDot();
};
}
#endif

View File

@ -0,0 +1,18 @@
#ifndef InIncludes_SubOwnDot_P_HPP
#define InIncludes_SubOwnDot_P_HPP
#include <QObject>
namespace InIncludes {
class SubOwnDotPrivate : public QObject
{
Q_OBJECT
public:
SubOwnDotPrivate();
~SubOwnDotPrivate();
};
} // End of namespace
#endif

View File

@ -0,0 +1,4 @@
// Moc a header that is not in the sources but in a directory that
// is in the list of include directories.
#include "InIncludes/moc_SubOwnDot.cpp"

View File

@ -0,0 +1,32 @@
#include "MixedCustom.hpp"
class MixedCustomLocal : public QObject
{
Q_OBJECT
public:
MixedCustomLocal();
~MixedCustomLocal();
};
MixedCustomLocal::MixedCustomLocal()
{
}
MixedCustomLocal::~MixedCustomLocal()
{
}
MixedCustom::MixedCustom()
{
MixedCustomLocal local;
}
MixedCustom::~MixedCustom()
{
}
// AUTOMOC generated source moc
#include "MixedCustom.moc"
// Externally generated header moc
#include "MixedCustom_extMoc.cpp"

View File

@ -0,0 +1,20 @@
#ifndef MixedCustom_HPP
#define MixedCustom_HPP
#include <QObject>
// Object source includes
// - externally generated header moc file
// - AUTOMOC generated source .moc file
class MixedCustom : public QObject
{
Q_OBJECT
public:
MixedCustom();
~MixedCustom();
};
// Function forward declaration
void moc_MixedCustom(MixedCustom const& arg);
#endif

View File

@ -0,0 +1,39 @@
#include "MixedSkipped.hpp"
#include "MixedCustom.hpp"
class MixedSkippedLocal : public QObject
{
Q_OBJECT
public:
MixedSkippedLocal();
~MixedSkippedLocal();
};
MixedSkippedLocal::MixedSkippedLocal()
{
}
MixedSkippedLocal::~MixedSkippedLocal()
{
}
MixedSkipped::MixedSkipped()
{
MixedSkippedLocal local;
MixedCustom externCutom;
// Call moc named function
moc_MixedCustom(externCutom);
}
MixedSkipped::~MixedSkipped()
{
}
// Include AUTOMOC generated moc files
#include "MixedSkipped.moc"
#include "moc_MixedSkipped.cpp"
// Include externally generated moc_ named file that is not a moc file
// and for which the relevant header is SKIP_AUTOMOC enabled
#include "moc_MixedCustom.cpp"

View File

@ -0,0 +1,17 @@
#ifndef MixedSkipped_HPP
#define MixedSkipped_HPP
#include <QObject>
// Object source includes
// - Own moc_ and .moc files.
// - externally generated moc_ file from a SKIP_AUTOMOC enabled header
class MixedSkipped : public QObject
{
Q_OBJECT
public:
MixedSkipped();
~MixedSkipped();
};
#endif

View File

@ -0,0 +1,20 @@
#include "None.hpp"
#include "None_p.h"
NonePrivate::NonePrivate()
{
}
NonePrivate::~NonePrivate()
{
}
None::None()
: d(new NonePrivate)
{
}
None::~None()
{
delete d;
}

View File

@ -0,0 +1,19 @@
#ifndef None_HPP
#define None_HPP
#include <QObject>
// Object source comes without any _moc/.moc includes
class NonePrivate;
class None : public QObject
{
Q_OBJECT
public:
None();
~None();
private:
NonePrivate* const d;
};
#endif

View File

@ -0,0 +1,14 @@
#ifndef None_P_HPP
#define None_P_HPP
#include <QObject>
class NonePrivate : public QObject
{
Q_OBJECT
public:
NonePrivate();
~NonePrivate();
};
#endif

View File

@ -0,0 +1,44 @@
#include "OtherUnderscore.hpp"
#include "OtherUnderscoreExtra.hpp"
#include "OtherUnderscore_p.hpp"
class OtherUnderscoreLocal : public QObject
{
Q_OBJECT
public:
OtherUnderscoreLocal();
~OtherUnderscoreLocal();
};
OtherUnderscoreLocal::OtherUnderscoreLocal()
{
}
OtherUnderscoreLocal::~OtherUnderscoreLocal()
{
}
OtherUnderscorePrivate::OtherUnderscorePrivate()
{
OtherUnderscoreLocal localObj;
OtherUnderscoreExtra extraObj;
}
OtherUnderscorePrivate::~OtherUnderscorePrivate()
{
}
OtherUnderscore::OtherUnderscore()
: d(new OtherUnderscorePrivate)
{
}
OtherUnderscore::~OtherUnderscore()
{
delete d;
}
// For OtherUnderscoreLocal
#include "OtherUnderscore.moc"
// - Not the own header
#include "moc_OtherUnderscoreExtra.cpp"

View File

@ -0,0 +1,19 @@
#ifndef OtherUnderscore_HPP
#define OtherUnderscore_HPP
#include <QObject>
// Sources includes a moc_ includes of an extra object
class OtherUnderscorePrivate;
class OtherUnderscore : public QObject
{
Q_OBJECT
public:
OtherUnderscore();
~OtherUnderscore();
private:
OtherUnderscorePrivate* const d;
};
#endif

View File

@ -0,0 +1,20 @@
#include "OtherUnderscoreExtra.hpp"
#include "OtherUnderscoreExtra_p.hpp"
OtherUnderscoreExtraPrivate::OtherUnderscoreExtraPrivate()
{
}
OtherUnderscoreExtraPrivate::~OtherUnderscoreExtraPrivate()
{
}
OtherUnderscoreExtra::OtherUnderscoreExtra()
: d(new OtherUnderscoreExtraPrivate)
{
}
OtherUnderscoreExtra::~OtherUnderscoreExtra()
{
delete d;
}

View File

@ -0,0 +1,18 @@
#ifndef OtherUnderscoreEXTRA_HPP
#define OtherUnderscoreEXTRA_HPP
#include <QObject>
class OtherUnderscoreExtraPrivate;
class OtherUnderscoreExtra : public QObject
{
Q_OBJECT
public:
OtherUnderscoreExtra();
~OtherUnderscoreExtra();
private:
OtherUnderscoreExtraPrivate* const d;
};
#endif

View File

@ -0,0 +1,14 @@
#ifndef OtherUnderscoreEXTRA_P_HPP
#define OtherUnderscoreEXTRA_P_HPP
#include <QObject>
class OtherUnderscoreExtraPrivate : public QObject
{
Q_OBJECT
public:
OtherUnderscoreExtraPrivate();
~OtherUnderscoreExtraPrivate();
};
#endif

View File

@ -0,0 +1,45 @@
#include "OtherUnderscoreSub.hpp"
#include "OtherUnderscoreSubDir/SubExtra.hpp"
#include "OtherUnderscoreSub_p.hpp"
class OtherUnderscoreSubLocal : public QObject
{
Q_OBJECT
public:
OtherUnderscoreSubLocal();
~OtherUnderscoreSubLocal();
};
OtherUnderscoreSubLocal::OtherUnderscoreSubLocal()
{
}
OtherUnderscoreSubLocal::~OtherUnderscoreSubLocal()
{
}
OtherUnderscoreSubPrivate::OtherUnderscoreSubPrivate()
{
OtherUnderscoreSubLocal localObj;
SubExtra extraObj;
}
OtherUnderscoreSubPrivate::~OtherUnderscoreSubPrivate()
{
}
OtherUnderscoreSub::OtherUnderscoreSub()
: d(new OtherUnderscoreSubPrivate)
{
}
OtherUnderscoreSub::~OtherUnderscoreSub()
{
delete d;
}
// For OtherUnderscoreSubLocal
#include "OtherUnderscoreSub.moc"
// - Not the own header
// - in a subdirectory
#include "OtherUnderscoreSubDir/moc_SubExtra.cpp"

View File

@ -0,0 +1,19 @@
#ifndef OtherUnderscoreSub_HPP
#define OtherUnderscoreSub_HPP
#include <QObject>
// Sources includes a moc_ includes of an extra object in a subdirectory
class OtherUnderscoreSubPrivate;
class OtherUnderscoreSub : public QObject
{
Q_OBJECT
public:
OtherUnderscoreSub();
~OtherUnderscoreSub();
private:
OtherUnderscoreSubPrivate* const d;
};
#endif

View File

@ -0,0 +1,20 @@
#include "SubExtra.hpp"
#include "SubExtra_p.hpp"
SubExtraPrivate::SubExtraPrivate()
{
}
SubExtraPrivate::~SubExtraPrivate()
{
}
SubExtra::SubExtra()
: d(new SubExtraPrivate)
{
}
SubExtra::~SubExtra()
{
delete d;
}

View File

@ -0,0 +1,18 @@
#ifndef SubExtra_HPP
#define SubExtra_HPP
#include <QObject>
class SubExtraPrivate;
class SubExtra : public QObject
{
Q_OBJECT
public:
SubExtra();
~SubExtra();
private:
SubExtraPrivate* const d;
};
#endif

View File

@ -0,0 +1,14 @@
#ifndef SubExtra_P_HPP
#define SubExtra_P_HPP
#include <QObject>
class SubExtraPrivate : public QObject
{
Q_OBJECT
public:
SubExtraPrivate();
~SubExtraPrivate();
};
#endif

View File

@ -0,0 +1,14 @@
#ifndef OtherUnderscoreSub_P_HPP
#define OtherUnderscoreSub_P_HPP
#include <QObject>
class OtherUnderscoreSubPrivate : public QObject
{
Q_OBJECT
public:
OtherUnderscoreSubPrivate();
~OtherUnderscoreSubPrivate();
};
#endif

View File

@ -0,0 +1,14 @@
#ifndef OtherUnderscore_P_HPP
#define OtherUnderscore_P_HPP
#include <QObject>
class OtherUnderscorePrivate : public QObject
{
Q_OBJECT
public:
OtherUnderscorePrivate();
~OtherUnderscorePrivate();
};
#endif

View File

@ -0,0 +1,39 @@
#include "OwnDot.hpp"
#include "OwnDot_p.h"
class OwnDotLocal : public QObject
{
Q_OBJECT
public:
OwnDotLocal();
~OwnDotLocal();
};
OwnDotLocal::OwnDotLocal()
{
}
OwnDotLocal::~OwnDotLocal()
{
}
OwnDotPrivate::OwnDotPrivate()
{
OwnDotLocal localObj;
}
OwnDotPrivate::~OwnDotPrivate()
{
}
OwnDot::OwnDot()
: d(new OwnDotPrivate)
{
}
OwnDot::~OwnDot()
{
delete d;
}
#include "OwnDot.moc"

View File

@ -0,0 +1,19 @@
#ifndef OwnDot_HPP
#define OwnDot_HPP
#include <QObject>
// Object source comes with a .moc include
class OwnDotPrivate;
class OwnDot : public QObject
{
Q_OBJECT
public:
OwnDot();
~OwnDot();
private:
OwnDotPrivate* const d;
};
#endif

View File

@ -0,0 +1,40 @@
#include "OwnDotUnderscore.hpp"
#include "OwnDotUnderscore_p.h"
class OwnDotUnderscoreLocal : public QObject
{
Q_OBJECT
public:
OwnDotUnderscoreLocal();
~OwnDotUnderscoreLocal();
};
OwnDotUnderscoreLocal::OwnDotUnderscoreLocal()
{
}
OwnDotUnderscoreLocal::~OwnDotUnderscoreLocal()
{
}
OwnDotUnderscorePrivate::OwnDotUnderscorePrivate()
{
OwnDotUnderscoreLocal localObj;
}
OwnDotUnderscorePrivate::~OwnDotUnderscorePrivate()
{
}
OwnDotUnderscore::OwnDotUnderscore()
: d(new OwnDotUnderscorePrivate)
{
}
OwnDotUnderscore::~OwnDotUnderscore()
{
delete d;
}
#include "OwnDotUnderscore.moc"
#include "moc_OwnDotUnderscore.cpp"

View File

@ -0,0 +1,19 @@
#ifndef LOwnDotUnderscore_HPP
#define LOwnDotUnderscore_HPP
#include <QObject>
// Object source comes with a .moc and a _moc include
class OwnDotUnderscorePrivate;
class OwnDotUnderscore : public QObject
{
Q_OBJECT
public:
OwnDotUnderscore();
~OwnDotUnderscore();
private:
OwnDotUnderscorePrivate* const d;
};
#endif

View File

@ -0,0 +1,14 @@
#ifndef OwnDotUnderscore_P_HPP
#define OwnDotUnderscore_P_HPP
#include <QObject>
class OwnDotUnderscorePrivate : public QObject
{
Q_OBJECT
public:
OwnDotUnderscorePrivate();
~OwnDotUnderscorePrivate();
};
#endif

View File

@ -0,0 +1,14 @@
#ifndef OwnDot_P_HPP
#define OwnDot_P_HPP
#include <QObject>
class OwnDotPrivate : public QObject
{
Q_OBJECT
public:
OwnDotPrivate();
~OwnDotPrivate();
};
#endif

View File

@ -0,0 +1,22 @@
#include "OwnUnderscore.hpp"
#include "OwnUnderscore_p.h"
OwnUnderscorePrivate::OwnUnderscorePrivate()
{
}
OwnUnderscorePrivate::~OwnUnderscorePrivate()
{
}
OwnUnderscore::OwnUnderscore()
: d(new OwnUnderscorePrivate)
{
}
OwnUnderscore::~OwnUnderscore()
{
delete d;
}
#include "moc_OwnUnderscore.cpp"

View File

@ -0,0 +1,19 @@
#ifndef OwnUnderscore_HPP
#define OwnUnderscore_HPP
#include <QObject>
// Object source comes with a _moc include
class OwnUnderscorePrivate;
class OwnUnderscore : public QObject
{
Q_OBJECT
public:
OwnUnderscore();
~OwnUnderscore();
private:
OwnUnderscorePrivate* const d;
};
#endif

View File

@ -0,0 +1,14 @@
#ifndef OwnUnderscore_P_HPP
#define OwnUnderscore_P_HPP
#include <QObject>
class OwnUnderscorePrivate : public QObject
{
Q_OBJECT
public:
OwnUnderscorePrivate();
~OwnUnderscorePrivate();
};
#endif

View File

@ -0,0 +1,32 @@
#include "DualSub/Second/Second.hpp"
#include "DualSubMocked.hpp"
#include "ExternDot.hpp"
#include "ExternDotGenerated.hpp"
#include "None.hpp"
#include "OtherUnderscore.hpp"
#include "OtherUnderscoreSub.hpp"
#include "OwnDot.hpp"
#include "OwnDotUnderscore.hpp"
#include "OwnUnderscore.hpp"
#include "InIncludes/SubOwnDot.hpp"
bool @COMMON_FUNCTION_NAME@()
{
None objNone;
OwnUnderscore objOwnUnderscore;
OwnDot objOwnDot;
OwnDotUnderscore objOwnDotUnderscore;
OtherUnderscore objOtherUnderscore;
OtherUnderscoreSub objOtherUnderscoreSub;
Second second;
DualSubMocked dualSubMocked;
ExternDot objExternDot;
ExternDotGenerated objGeneratedExternDot;
InIncludes::SubOwnDot subOwnDot;
return true;
}

View File

@ -0,0 +1,5 @@
void moc_MixedCustom(MixedCustom const & arg)
{
(void)arg;
}

View File

@ -1,44 +0,0 @@
#include "EObjA.hpp"
#include "EObjAExtra.hpp"
#include "EObjA_p.hpp"
class EObjALocal : public QObject
{
Q_OBJECT
public:
EObjALocal();
~EObjALocal();
};
EObjALocal::EObjALocal()
{
}
EObjALocal::~EObjALocal()
{
}
EObjAPrivate::EObjAPrivate()
{
EObjALocal localObj;
EObjAExtra extraObj;
}
EObjAPrivate::~EObjAPrivate()
{
}
EObjA::EObjA()
: d(new EObjAPrivate)
{
}
EObjA::~EObjA()
{
delete d;
}
// For EObjALocal
#include "EObjA.moc"
// - Not the own header
#include "moc_EObjAExtra.cpp"

View File

@ -1,19 +0,0 @@
#ifndef EOBJA_HPP
#define EOBJA_HPP
#include <QObject>
// Sources includes a moc_ includes of an extra object
class EObjAPrivate;
class EObjA : public QObject
{
Q_OBJECT
public:
EObjA();
~EObjA();
private:
EObjAPrivate* const d;
};
#endif

View File

@ -1,20 +0,0 @@
#include "EObjAExtra.hpp"
#include "EObjAExtra_p.hpp"
EObjAExtraPrivate::EObjAExtraPrivate()
{
}
EObjAExtraPrivate::~EObjAExtraPrivate()
{
}
EObjAExtra::EObjAExtra()
: d(new EObjAExtraPrivate)
{
}
EObjAExtra::~EObjAExtra()
{
delete d;
}

View File

@ -1,18 +0,0 @@
#ifndef EOBJAEXTRA_HPP
#define EOBJAEXTRA_HPP
#include <QObject>
class EObjAExtraPrivate;
class EObjAExtra : public QObject
{
Q_OBJECT
public:
EObjAExtra();
~EObjAExtra();
private:
EObjAExtraPrivate* const d;
};
#endif

View File

@ -1,14 +0,0 @@
#ifndef EOBJAEXTRA_P_HPP
#define EOBJAEXTRA_P_HPP
#include <QObject>
class EObjAExtraPrivate : public QObject
{
Q_OBJECT
public:
EObjAExtraPrivate();
~EObjAExtraPrivate();
};
#endif

View File

@ -1,14 +0,0 @@
#ifndef EOBJA_P_HPP
#define EOBJA_P_HPP
#include <QObject>
class EObjAPrivate : public QObject
{
Q_OBJECT
public:
EObjAPrivate();
~EObjAPrivate();
};
#endif

View File

@ -1,45 +0,0 @@
#include "EObjB.hpp"
#include "EObjB_p.hpp"
#include "subExtra/EObjBExtra.hpp"
class EObjBLocal : public QObject
{
Q_OBJECT
public:
EObjBLocal();
~EObjBLocal();
};
EObjBLocal::EObjBLocal()
{
}
EObjBLocal::~EObjBLocal()
{
}
EObjBPrivate::EObjBPrivate()
{
EObjBLocal localObj;
EObjBExtra extraObj;
}
EObjBPrivate::~EObjBPrivate()
{
}
EObjB::EObjB()
: d(new EObjBPrivate)
{
}
EObjB::~EObjB()
{
delete d;
}
// For EObjBLocal
#include "EObjB.moc"
// - Not the own header
// - in a subdirectory
#include "subExtra/moc_EObjBExtra.cpp"

View File

@ -1,19 +0,0 @@
#ifndef EOBJB_HPP
#define EOBJB_HPP
#include <QObject>
// Sources includes a moc_ includes of an extra object in a subdirectory
class EObjBPrivate;
class EObjB : public QObject
{
Q_OBJECT
public:
EObjB();
~EObjB();
private:
EObjBPrivate* const d;
};
#endif

View File

@ -1,14 +0,0 @@
#ifndef EOBJB_P_HPP
#define EOBJB_P_HPP
#include <QObject>
class EObjBPrivate : public QObject
{
Q_OBJECT
public:
EObjBPrivate();
~EObjBPrivate();
};
#endif

View File

@ -1,39 +0,0 @@
#include "LObjA.hpp"
#include "LObjA_p.h"
class LObjALocal : public QObject
{
Q_OBJECT
public:
LObjALocal();
~LObjALocal();
};
LObjALocal::LObjALocal()
{
}
LObjALocal::~LObjALocal()
{
}
LObjAPrivate::LObjAPrivate()
{
LObjALocal localObj;
}
LObjAPrivate::~LObjAPrivate()
{
}
LObjA::LObjA()
: d(new LObjAPrivate)
{
}
LObjA::~LObjA()
{
delete d;
}
#include "LObjA.moc"

View File

@ -1,19 +0,0 @@
#ifndef LOBJA_HPP
#define LOBJA_HPP
#include <QObject>
// Object source comes with a .moc include
class LObjAPrivate;
class LObjA : public QObject
{
Q_OBJECT
public:
LObjA();
~LObjA();
private:
LObjAPrivate* const d;
};
#endif

View File

@ -1,14 +0,0 @@
#ifndef LOBJA_P_HPP
#define LOBJA_P_HPP
#include <QObject>
class LObjAPrivate : public QObject
{
Q_OBJECT
public:
LObjAPrivate();
~LObjAPrivate();
};
#endif

View File

@ -1,40 +0,0 @@
#include "LObjB.hpp"
#include "LObjB_p.h"
class LObjBLocal : public QObject
{
Q_OBJECT
public:
LObjBLocal();
~LObjBLocal();
};
LObjBLocal::LObjBLocal()
{
}
LObjBLocal::~LObjBLocal()
{
}
LObjBPrivate::LObjBPrivate()
{
LObjBLocal localObj;
}
LObjBPrivate::~LObjBPrivate()
{
}
LObjB::LObjB()
: d(new LObjBPrivate)
{
}
LObjB::~LObjB()
{
delete d;
}
#include "LObjB.moc"
#include "moc_LObjB.cpp"

View File

@ -1,19 +0,0 @@
#ifndef LLObjB_HPP
#define LLObjB_HPP
#include <QObject>
// Object source comes with a .moc and a _moc include
class LObjBPrivate;
class LObjB : public QObject
{
Q_OBJECT
public:
LObjB();
~LObjB();
private:
LObjBPrivate* const d;
};
#endif

View File

@ -1,14 +0,0 @@
#ifndef LOBJB_P_HPP
#define LOBJB_P_HPP
#include <QObject>
class LObjBPrivate : public QObject
{
Q_OBJECT
public:
LObjBPrivate();
~LObjBPrivate();
};
#endif

View File

@ -1,20 +0,0 @@
#include "ObjA.hpp"
#include "ObjA_p.h"
ObjAPrivate::ObjAPrivate()
{
}
ObjAPrivate::~ObjAPrivate()
{
}
ObjA::ObjA()
: d(new ObjAPrivate)
{
}
ObjA::~ObjA()
{
delete d;
}

View File

@ -1,19 +0,0 @@
#ifndef OBJA_HPP
#define OBJA_HPP
#include <QObject>
// Object source comes without any _moc/.moc includes
class ObjAPrivate;
class ObjA : public QObject
{
Q_OBJECT
public:
ObjA();
~ObjA();
private:
ObjAPrivate* const d;
};
#endif

View File

@ -1,14 +0,0 @@
#ifndef OBJA_P_HPP
#define OBJA_P_HPP
#include <QObject>
class ObjAPrivate : public QObject
{
Q_OBJECT
public:
ObjAPrivate();
~ObjAPrivate();
};
#endif

View File

@ -1,22 +0,0 @@
#include "ObjB.hpp"
#include "ObjB_p.h"
ObjBPrivate::ObjBPrivate()
{
}
ObjBPrivate::~ObjBPrivate()
{
}
ObjB::ObjB()
: d(new ObjBPrivate)
{
}
ObjB::~ObjB()
{
delete d;
}
#include "moc_ObjB.cpp"

View File

@ -1,19 +0,0 @@
#ifndef ObjB_HPP
#define ObjB_HPP
#include <QObject>
// Object source comes with a _moc include
class ObjBPrivate;
class ObjB : public QObject
{
Q_OBJECT
public:
ObjB();
~ObjB();
private:
ObjBPrivate* const d;
};
#endif

View File

@ -1,14 +0,0 @@
#ifndef OBJB_P_HPP
#define OBJB_P_HPP
#include <QObject>
class ObjBPrivate : public QObject
{
Q_OBJECT
public:
ObjBPrivate();
~ObjBPrivate();
};
#endif

View File

@ -0,0 +1,17 @@
# Enable relaxed mode
set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
# Common test
set(COMMON_FUNCTION_NAME commonRelaxed)
configure_file(
"${COM_DIR}/common.cpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/commonRelaxed.cpp")
makeExecutable(libRelaxed)
target_sources(libRelaxed PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}/commonRelaxed.cpp"
RObjA.cpp
RObjB.cpp
RObjC.cpp
relaxed.cpp
)

View File

@ -0,0 +1,21 @@
// AUTOMOC relaxed mode objects
#include "RObjA.hpp"
#include "RObjB.hpp"
#include "RObjC.hpp"
// Forward declaration
bool commonRelaxed();
int main(int argv, char** args)
{
// Common tests
if (!commonRelaxed()) {
return -1;
}
// Relaxed tests
RObjA rObjA;
RObjB rObjB;
RObjC rObjC;
return 0;
}

View File

@ -1,11 +0,0 @@
#include "SObjA.hpp"
SObjA::SObjA()
{
}
SObjA::~SObjA()
{
}
#include "SObjA.moc"

View File

@ -1,11 +0,0 @@
#include "SObjB.hpp"
SObjB::SObjB()
{
}
SObjB::~SObjB()
{
}
#include "SObjB.moc"

View File

@ -1,15 +0,0 @@
#ifndef SOBJB_HPP
#define SOBJB_HPP
#include <QObject>
// Object source includes externally generated .moc file
class SObjB : public QObject
{
Q_OBJECT
public:
SObjB();
~SObjB();
};
#endif

View File

@ -1,35 +0,0 @@
#include "SObjC.hpp"
void SObjCLocalFunction();
class SObjCLocal : public QObject
{
Q_OBJECT
public:
SObjCLocal();
~SObjCLocal();
};
SObjCLocal::SObjCLocal()
{
}
SObjCLocal::~SObjCLocal()
{
}
SObjC::SObjC()
{
SObjCLocal localObject;
SObjCLocalFunction();
}
SObjC::~SObjC()
{
}
#include "SObjC.moc"
#include "moc_SObjC.cpp"
// Include moc_ file for which the header is SKIP_AUTOMOC enabled
#include "moc_SObjCExtra.cpp"

View File

@ -1,15 +0,0 @@
#ifndef SOBJC_HPP
#define SOBJC_HPP
#include <QObject>
// Object source includes externally generated .moc file
class SObjC : public QObject
{
Q_OBJECT
public:
SObjC();
~SObjC();
};
#endif

View File

@ -1,31 +0,0 @@
#include "SObjCExtra.hpp"
class SObjCLocalExtra : public QObject
{
Q_OBJECT
public:
SObjCLocalExtra();
~SObjCLocalExtra();
};
SObjCLocalExtra::SObjCLocalExtra()
{
}
SObjCLocalExtra::~SObjCLocalExtra()
{
}
SObjCExtra::SObjCExtra()
{
}
SObjCExtra::~SObjCExtra()
{
}
// Externally generated header moc
#include "SObjCExtra_extMoc.cpp"
// AUTOMOC generated source moc
#include "SObjCExtra.moc"

View File

@ -1,15 +0,0 @@
#ifndef SOBJCEXTRA_HPP
#define SOBJCEXTRA_HPP
#include <QObject>
// Object source includes externally generated .moc file
class SObjCExtra : public QObject
{
Q_OBJECT
public:
SObjCExtra();
~SObjCExtra();
};
#endif

View File

@ -1,4 +0,0 @@
void SObjCLocalFunction()
{
}

View File

@ -0,0 +1,14 @@
# Disable relaxed mode
set(CMAKE_AUTOMOC_RELAXED_MODE FALSE)
# Common test
set(COMMON_FUNCTION_NAME commonStrict)
configure_file(
"${COM_DIR}/common.cpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/commonStrict.cpp")
makeExecutable(libStrict)
target_sources(libStrict PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}/commonStrict.cpp"
strict.cpp
)

View File

@ -0,0 +1,7 @@
// Forward declaration
bool commonStrict();
int main(int argv, char** args)
{
return commonStrict() ? 0 : -1;
}

View File

@ -0,0 +1,9 @@
// Forward declaration
bool libStrict();
bool libRelaxed();
int main(int argv, char** args)
{
return (libStrict() && libRelaxed()) ? 0 : -1;
}

View File

@ -1,71 +0,0 @@
# Test moc include patterns
include_directories("../MocInclude")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# Generate .moc file externally and enabled SKIP_AUTOMOC on the file
qtx_generate_moc(
${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjA.hpp
${CMAKE_CURRENT_BINARY_DIR}/SObjA.moc)
set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjA.cpp PROPERTY SKIP_AUTOMOC ON)
# Generate .moc file externally from generated source file
# and enabled SKIP_AUTOMOC on the source file
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjB.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjB.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp)
qtx_generate_moc(
${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp
${CMAKE_CURRENT_BINARY_DIR}/SObjB.moc)
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp PROPERTY SKIP_AUTOMOC ON)
# Generate moc file externally and enabled SKIP_AUTOMOC on the header
qtx_generate_moc(
${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.hpp
${CMAKE_CURRENT_BINARY_DIR}/SObjCExtra_extMoc.cpp)
set_property(
SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.hpp
PROPERTY SKIP_AUTOMOC ON)
# Custom target to depend on
set(SOBJC_MOC ${CMAKE_CURRENT_BINARY_DIR}/moc_SObjCExtra.cpp)
add_custom_target("${MOC_INCLUDE_NAME}_SOBJC"
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SObjCExtra_extMoc.cpp
BYPRODUCTS ${SOBJC_MOC}
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.moc.in
${SOBJC_MOC})
# MOC_INCLUDE_NAME must be defined by the includer
add_executable(${MOC_INCLUDE_NAME}
# Common sources
../MocInclude/ObjA.cpp
../MocInclude/ObjB.cpp
../MocInclude/LObjA.cpp
../MocInclude/LObjB.cpp
../MocInclude/EObjA.cpp
../MocInclude/EObjAExtra.cpp
../MocInclude/EObjB.cpp
../MocInclude/subExtra/EObjBExtra.cpp
../MocInclude/SObjA.cpp
${CMAKE_CURRENT_BINARY_DIR}/SObjA.moc
${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp
${CMAKE_CURRENT_BINARY_DIR}/SObjB.moc
../MocInclude/SObjC.cpp
../MocInclude/SObjCExtra.hpp
../MocInclude/SObjCExtra.cpp
../MocInclude/subGlobal/GObj.cpp
main.cpp
)
add_dependencies(${MOC_INCLUDE_NAME} "${MOC_INCLUDE_NAME}_SOBJC")
target_link_libraries(${MOC_INCLUDE_NAME} ${QT_LIBRARIES})
set_target_properties(${MOC_INCLUDE_NAME} PROPERTIES AUTOMOC ON)

View File

@ -1,20 +0,0 @@
#include "EObjBExtra.hpp"
#include "EObjBExtra_p.hpp"
EObjBExtraPrivate::EObjBExtraPrivate()
{
}
EObjBExtraPrivate::~EObjBExtraPrivate()
{
}
EObjBExtra::EObjBExtra()
: d(new EObjBExtraPrivate)
{
}
EObjBExtra::~EObjBExtra()
{
delete d;
}

View File

@ -1,18 +0,0 @@
#ifndef EOBJBEXTRA_HPP
#define EOBJBEXTRA_HPP
#include <QObject>
class EObjBExtraPrivate;
class EObjBExtra : public QObject
{
Q_OBJECT
public:
EObjBExtra();
~EObjBExtra();
private:
EObjBExtraPrivate* const d;
};
#endif

View File

@ -1,14 +0,0 @@
#ifndef EOBJBEXTRA_P_HPP
#define EOBJBEXTRA_P_HPP
#include <QObject>
class EObjBExtraPrivate : public QObject
{
Q_OBJECT
public:
EObjBExtraPrivate();
~EObjBExtraPrivate();
};
#endif

View File

@ -1,41 +0,0 @@
#include "GObj.hpp"
#include "GObj_p.hpp"
namespace subGlobal {
class GObjLocal : public QObject
{
Q_OBJECT
public:
GObjLocal();
~GObjLocal();
};
GObjLocal::GObjLocal()
{
}
GObjLocal::~GObjLocal()
{
}
GObjPrivate::GObjPrivate()
{
}
GObjPrivate::~GObjPrivate()
{
}
GObj::GObj()
{
GObjLocal localObj;
}
GObj::~GObj()
{
}
}
// For the local QObject
#include "GObj.moc"

View File

@ -1,17 +0,0 @@
#ifndef GOBJ_HPP
#define GOBJ_HPP
#include <QObject>
namespace subGlobal {
class GObj : public QObject
{
Q_OBJECT
public:
GObj();
~GObj();
};
}
#endif

View File

@ -1,17 +0,0 @@
#ifndef GOBJ_P_HPP
#define GOBJ_P_HPP
#include <QObject>
namespace subGlobal {
class GObjPrivate : public QObject
{
Q_OBJECT
public:
GObjPrivate();
~GObjPrivate();
};
}
#endif

View File

@ -1,20 +0,0 @@
cmake_minimum_required(VERSION 3.10)
project(MocIncludeRelaxed)
include("../AutogenCoreTest.cmake")
# Test moc include patterns
set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
# Shared executable
set(MOC_INCLUDE_NAME "mocIncludeRelaxed")
include(${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/shared.cmake)
# Relaxed only executable
add_executable(mocIncludeRelaxedOnly
RObjA.cpp
RObjB.cpp
RObjC.cpp
RMain.cpp
)
target_link_libraries(mocIncludeRelaxedOnly ${QT_LIBRARIES})
set_target_properties(mocIncludeRelaxedOnly PROPERTIES AUTOMOC ON)

View File

@ -1,12 +0,0 @@
// Relaxed AUTOMOC objects
#include "RObjA.hpp"
#include "RObjB.hpp"
#include "RObjC.hpp"
int main(int argv, char** args)
{
RObjA rObjA;
RObjB rObjB;
RObjC rObjC;
return 0;
}

View File

@ -1,26 +0,0 @@
#include "EObjA.hpp"
#include "EObjB.hpp"
#include "LObjA.hpp"
#include "LObjB.hpp"
#include "ObjA.hpp"
#include "ObjB.hpp"
#include "SObjA.hpp"
#include "SObjB.hpp"
#include "subGlobal/GObj.hpp"
int main(int argv, char** args)
{
subGlobal::GObj gObj;
ObjA objA;
ObjB objB;
LObjA lObjA;
LObjB lObjB;
EObjA eObjA;
EObjB eObjB;
SObjA sObjA;
SObjB sObjB;
return 0;
}
// Header in global subdirectory
#include "subGlobal/moc_GObj.cpp"

View File

@ -1,10 +0,0 @@
cmake_minimum_required(VERSION 3.10)
project(MocIncludeStrict)
include("../AutogenCoreTest.cmake")
# Test moc include patterns
set(CMAKE_AUTOMOC_RELAXED_MODE FALSE)
# Shared executable
set(MOC_INCLUDE_NAME "mocIncludeStrict")
include(${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/shared.cmake)

View File

@ -1,26 +0,0 @@
#include "EObjA.hpp"
#include "EObjB.hpp"
#include "LObjA.hpp"
#include "LObjB.hpp"
#include "ObjA.hpp"
#include "ObjB.hpp"
#include "SObjA.hpp"
#include "SObjB.hpp"
#include "subGlobal/GObj.hpp"
int main(int argv, char** args)
{
subGlobal::GObj gObj;
ObjA objA;
ObjB objB;
LObjA lObjA;
LObjB lObjB;
EObjA eObjA;
EObjB eObjB;
SObjA sObjA;
SObjB sObjB;
return 0;
}
// Header in global subdirectory
#include "subGlobal/moc_GObj.cpp"

View File

@ -32,8 +32,7 @@ ADD_AUTOGEN_TEST(UicSkipSource)
if(QT_TEST_ALLOW_QT_MACROS)
ADD_AUTOGEN_TEST(MocCMP0071)
ADD_AUTOGEN_TEST(MocIncludeRelaxed mocIncludeRelaxed)
ADD_AUTOGEN_TEST(MocIncludeStrict mocIncludeStrict)
ADD_AUTOGEN_TEST(MocInclude)
ADD_AUTOGEN_TEST(MocSkipSource)
endif()