Make it possible to link mtests with mscoreapp

This commit is contained in:
Dmitri Ovodok 2019-12-04 11:11:31 +02:00
parent e519e518f5
commit c06f096c5b
6 changed files with 118 additions and 67 deletions

View file

@ -16,6 +16,7 @@ enable_testing()
include_directories(
${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/thirdparty
)
if (USE_SYSTEM_FREETYPE)
@ -46,8 +47,8 @@ add_library (testResources STATIC
)
set (SOURCE_LIB
testutils.cpp
${PROJECT_SOURCE_DIR}/libmscore/mcursor.cpp
testutils.cpp
mtestglobals.cpp
${PROJECT_SOURCE_DIR}/mscore/bb.cpp
${PROJECT_SOURCE_DIR}/mscore/capella.cpp
${PROJECT_SOURCE_DIR}/mscore/capxml.cpp
@ -96,22 +97,6 @@ set (SOURCE_LIB
${PROJECT_SOURCE_DIR}/mscore/importxmlfirstpass.cpp
${PROJECT_SOURCE_DIR}/mscore/musicxmlfonthandler.cpp
${PROJECT_SOURCE_DIR}/mscore/musicxmlsupport.cpp
${PROJECT_SOURCE_DIR}/mscore/qml/msqmlengine.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/qmlplugin.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/qmlpluginengine.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/api/enums.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/api/qmlpluginapi.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/api/cursor.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/api/fraction.h
${PROJECT_SOURCE_DIR}/mscore/plugin/api/scoreelement.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/api/elements.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/api/score.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/api/part.h
${PROJECT_SOURCE_DIR}/mscore/plugin/api/excerpt.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/api/util.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/api/selection.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/api/tie.cpp
${PROJECT_SOURCE_DIR}/mscore/plugin/api/playevent.cpp
${PROJECT_SOURCE_DIR}/mscore/preferences.cpp
${PROJECT_SOURCE_DIR}/mscore/shortcut.cpp
${PROJECT_SOURCE_DIR}/mscore/stringutils.cpp
@ -142,6 +127,21 @@ else (MSVC)
)
endif (MSVC)
# testutils version that is linked to a full mscoreapp target
add_library(testutils_mscoreapp STATIC
testutils.cpp
mscoreappresources.cpp
)
if (MSVC)
target_sources(testutils_mscoreapp PRIVATE
${_all_h_file}
${PCH}
)
endif (MSVC)
target_link_libraries(testutils_mscoreapp mscoreapp)
add_executable(
mtest
mtest.cpp
@ -163,29 +163,18 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_
string(REPLACE ";" ";-I" INC "${QT_INCLUDES}")
if (APPLE AND (CMAKE_VERSION VERSION_LESS "3.5.0"))
set_target_properties (
testutils
PROPERTIES
COMPILE_FLAGS "-include all.h -D TESTROOT=\\\\\"${PROJECT_SOURCE_DIR}\\\\\" -g -Wall -Wextra"
)
set(TESTUTILS_COMPILE_FLAGS "-include all.h -D TESTROOT=\\\\\"${PROJECT_SOURCE_DIR}\\\\\" -g -Wall -Wextra")
else (APPLE AND (CMAKE_VERSION VERSION_LESS "3.5.0"))
if (MSVC)
set_target_properties (
testutils
PROPERTIES
COMPILE_FLAGS "${PCH_INCLUDE} /D TESTROOT=\\\"${PROJECT_SOURCE_DIR}\\\""
)
else (MSVC)
set_target_properties (
testutils
PROPERTIES
COMPILE_FLAGS "-include all.h -D TESTROOT=\\\"${PROJECT_SOURCE_DIR}\\\" -g -Wall -Wextra"
)
endif (MSVC)
if (MSVC)
set(TESTUTILS_COMPILE_FLAGS "${PCH_INCLUDE} /D TESTROOT=\\\"${PROJECT_SOURCE_DIR}\\\"")
else (MSVC)
set(TESTUTILS_COMPILE_FLAGS "-include all.h -D TESTROOT=\\\"${PROJECT_SOURCE_DIR}\\\" -g -Wall -Wextra")
endif (MSVC)
endif (APPLE AND (CMAKE_VERSION VERSION_LESS "3.5.0"))
set_target_properties(testutils PROPERTIES COMPILE_FLAGS "${TESTUTILS_COMPILE_FLAGS}")
set_target_properties(testutils_mscoreapp PROPERTIES COMPILE_FLAGS "${TESTUTILS_COMPILE_FLAGS}")
# COMPILE_FLAGS "-include all.h -I ${INC} -D TESTROOT=\\\"${PROJECT_SOURCE_DIR}\\\" -g -Wall -Wextra"
add_custom_target(report
COMMAND ant -f ${PROJECT_SOURCE_DIR}/mtest/build.xml -Droot.dir=${PROJECT_BINARY_DIR}/mtest report

View file

@ -17,10 +17,15 @@ add_executable(
${TARGET}.cpp
)
if (MTEST_LINK_MSCOREAPP)
target_link_libraries(${TARGET} testutils_mscoreapp mscoreapp)
else (MTEST_LINK_MSCOREAPP)
target_link_libraries(${TARGET} testutils)
endif (MTEST_LINK_MSCOREAPP)
target_link_libraries(
${TARGET}
${QT_QTTEST_LIBRARY}
testutils
testResources
libmscore
synthesizer

View file

@ -0,0 +1,41 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2019 MuseScore BVBA
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "testutils.h"
void initMuseScoreResources()
{
#ifdef Q_OS_MAC
Q_INIT_RESOURCE(musescore);
Q_INIT_RESOURCE(qml);
Q_INIT_RESOURCE(musescorefonts_Mac);
Q_INIT_RESOURCE(shortcut_Mac);
#else
Q_INIT_RESOURCE(musescore);
Q_INIT_RESOURCE(qml);
Q_INIT_RESOURCE(musescorefonts_MScore);
Q_INIT_RESOURCE(musescorefonts_Gootville);
Q_INIT_RESOURCE(musescorefonts_Bravura);
Q_INIT_RESOURCE(musescorefonts_MuseJazz);
Q_INIT_RESOURCE(musescorefonts_Campania);
Q_INIT_RESOURCE(musescorefonts_FreeSerif);
Q_INIT_RESOURCE(musescorefonts_Free);
Q_INIT_RESOURCE(shortcut);
#endif
}

40
mtest/mtestglobals.cpp Normal file
View file

@ -0,0 +1,40 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2019 MuseScore BVBA
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
/**
* \file
* Definitions of global variables used in mtests not linked to mscoreapp target
*/
#include "config.h"
#include "mscore/icons.h"
#include "mscore/musescore.h"
Q_LOGGING_CATEGORY(undoRedo, "undoRedo", QtCriticalMsg)
namespace Ms {
QString revision;
MasterSynthesizer* synti;
QString dataPath;
QIcon* icons[0];
QString mscoreGlobalShare;
}

View file

@ -19,16 +19,16 @@
#include "libmscore/instrtemplate.h"
#include "omr/omr.h"
#include "testutils.h"
#include "mscore/musescore.h"
#include "mscore/preferences.h"
#include "libmscore/page.h"
#include "synthesizer/msynthesizer.h"
#include "libmscore/musescoreCore.h"
#include "mscore/shortcut.h"
#include "mscore/importmidi/importmidi_operations.h"
#include "libmscore/xml.h"
#include "libmscore/excerpt.h"
inline void initMyResources() {
static void initMyResources() {
Q_INIT_RESOURCE(mtest);
Q_INIT_RESOURCE(musescorefonts_MScore);
Q_INIT_RESOURCE(musescorefonts_Gootville);
@ -36,36 +36,10 @@ inline void initMyResources() {
Q_INIT_RESOURCE(musescorefonts_MuseJazz);
Q_INIT_RESOURCE(musescorefonts_FreeSerif);
Q_INIT_RESOURCE(musescorefonts_Free);
}
extern Ms::Score::FileError importOve(Ms::MasterScore*, const QString& name);
Q_LOGGING_CATEGORY(undoRedo, "undoRedo", QtCriticalMsg)
// Q_LOGGING_CATEGORY(undoRedo, "undoRedo", QtDebugMsg)
}
namespace Ms {
#ifdef OMR
extern Score::FileError importPdf(MasterScore*, const QString&);
#endif
extern Score::FileError importBB(MasterScore*, const QString&);
extern Score::FileError importCapella(MasterScore*, const QString&);
extern Score::FileError importCapXml(MasterScore*, const QString&);
extern Score::FileError importCompressedMusicXml(MasterScore*, const QString&);
extern Score::FileError importMusicXml(MasterScore*, const QString&);
extern Score::FileError importGTP(MasterScore*, const QString&);
extern bool saveXml(Score*, const QString&);
bool debugMode = false;
QString revision;
bool enableTestMode;
MasterScore* score;
MasterSynthesizer* synti;
QString dataPath;
QIcon* icons[0];
QString mscoreGlobalShare;
//---------------------------------------------------------
// writeReadElement
// writes and element and reads it back

View file

@ -48,5 +48,7 @@ class MTest {
};
}
void initMuseScoreResources();
#endif