##// END OF EJS Templates
Made more consistent plugin install path with CMake, removed useless plugin lookup path...
jeandet -
r1398:728acc3a845d
parent child
Show More
@@ -1,93 +1,93
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the QLop Software
3 3 -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #include "MainWindow.h"
23 23 #include <QProcessEnvironment>
24 24 #include <QThread>
25 25 #include <SqpApplication.h>
26 26 #include <qglobal.h>
27 27
28 28 #include <PluginManager/PluginManager.h>
29 29 #include <QDir>
30 30 #include <QtPlugin>
31 31
32 32 #include <QLoggingCategory>
33 33
34 34 Q_LOGGING_CATEGORY(LOG_Main, "Main")
35 35
36 namespace {
36 namespace
37 {
37 38
38 39 const auto PLUGIN_DIRECTORY_NAME = QStringLiteral("plugins");
39 40
40 41
41 42 } // namespace
42 43
43 int main(int argc, char *argv[])
44 int main(int argc, char* argv[])
44 45 {
45 46 #ifdef QT_STATICPLUGIN
46 47 Q_IMPORT_PLUGIN(MockPlugin)
47 48 Q_IMPORT_PLUGIN(AmdaPlugin)
48 49 Q_INIT_RESOURCE(amdaresources);
49 50 #endif
50 51 Q_INIT_RESOURCE(sqpguiresources);
51 52
52 53 SqpApplication::setOrganizationName("LPP");
53 54 SqpApplication::setOrganizationDomain("lpp.fr");
54 55 SqpApplication::setApplicationName("SciQLop");
55 56
56 57 QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
57 58
58 SqpApplication a{argc, argv};
59 SqpApplication a { argc, argv };
59 60
60 61 MainWindow w;
61 62 w.show();
62 63
63 64 // Loads plugins
64 auto pluginDir = QDir{a.applicationDirPath()};
65 auto pluginDir = QDir { a.applicationDirPath() };
65 66 auto pluginLookupPath = {
66 a.applicationDirPath(),
67 a.applicationDirPath() + "/" + PLUGIN_DIRECTORY_NAME,
68 67 a.applicationDirPath() + "/../lib64/SciQlop",
69 68 a.applicationDirPath() + "/../lib64/sciqlop",
70 69 a.applicationDirPath() + "/../lib/SciQlop",
71 70 a.applicationDirPath() + "/../lib/sciqlop",
72 a.applicationDirPath() + "/../plugins",
73 71 };
74 72
75 73 #if _WIN32 || _WIN64
76 74 pluginDir.mkdir(PLUGIN_DIRECTORY_NAME);
77 75 pluginDir.cd(PLUGIN_DIRECTORY_NAME);
78 76 #endif
79 77
80 PluginManager pluginManager{};
78 PluginManager pluginManager {};
81 79
82 for (auto &&path : pluginLookupPath) {
83 QDir directory{path};
84 if (directory.exists()) {
80 for (auto&& path : pluginLookupPath)
81 {
82 QDir directory { path };
83 if (directory.exists())
84 {
85 85 qCDebug(LOG_Main())
86 86 << QObject::tr("Plugin directory: %1").arg(directory.absolutePath());
87 87 pluginManager.loadPlugins(directory);
88 88 }
89 89 }
90 90 pluginManager.loadStaticPlugins();
91 91
92 92 return a.exec();
93 93 }
@@ -1,93 +1,93
1 1 include_directories(include)
2 2 FILE (GLOB_RECURSE amdaplugin_SRCS
3 3 include/*.h
4 4 src/*.cpp
5 5 resources/*.qrc
6 6 )
7 7
8 8
9 9 set(AMDA_server_type hybrid CACHE STRING "AMDA server type selected at CMake configure time")
10 10
11 11 set(AMDA_SERVER_TYPE "hybrid;amdatest;localhost" CACHE STRING
12 12 "List of possible for AMDA server type")
13 13
14 14 set_property(CACHE AMDA_server_type PROPERTY STRINGS ${AMDA_SERVER_TYPE})
15 15 add_definitions(-DSCIQLOP_AMDA_SERVER="${AMDA_server_type}")
16 16 add_definitions(-DAMDAPLUGIN_LIB)
17 17 add_definitions(-DAMDA_LIB)
18 18
19 19 add_definitions(-DQT_PLUGIN)
20 20 add_definitions(-DSCIQLOP_PLUGIN_JSON_FILE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/amda.json")
21 21 if(NOT BUILD_SHARED_LIBS)
22 22 add_definitions(-DQT_STATICPLUGIN)
23 23 endif()
24 24
25 25 add_library(amdaplugin ${amdaplugin_SRCS})
26 26 SET_TARGET_PROPERTIES(amdaplugin PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
27 27
28 28 target_link_libraries(amdaplugin PUBLIC sciqlopgui)
29 29
30 30 install(TARGETS amdaplugin
31 31 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/SciQlop
32 32 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/SciQlop
33 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
33 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/SciQlop)
34 34
35 35 include(sciqlop_tests)
36 36
37 37 add_definitions(-DAMDA_TESTS_RESOURCES_DIR="${CMAKE_CURRENT_LIST_DIR}/tests-resources")
38 38
39 39 declare_test(TestAmdaParser TestAmdaParser tests/TestAmdaParser.cpp "amdaplugin;Qt5::Test")
40 40 declare_test(TestAmdaResultParser TestAmdaResultParser tests/TestAmdaResultParser.cpp "amdaplugin;Qt5::Test")
41 41 declare_test(TestAmdaAcquisition TestAmdaAcquisition tests/TestAmdaAcquisition.cpp "amdaplugin;Qt5::Test")
42 42 declare_test(TestAmdaFuzzing TestAmdaFuzzing "tests/TestAmdaFuzzing.cpp;tests/FuzzingValidators.cpp;tests/FuzzingUtils.cpp;tests/FuzzingOperations.cpp;tests/FuzzingDefs.cpp" "amdaplugin;Qt5::Test")
43 43
44 44
45 45 if(PyWrappers)
46 46 if(MINGW)
47 47 add_definitions(-D_hypot=hypot)
48 48 endif()
49 49 pybind11_add_module(pytestamda tests/PyTestAmdaWrapper.cpp)
50 50 target_link_libraries(pytestamda PUBLIC amdaplugin)
51 51 target_link_libraries(pytestamda PUBLIC pysciqlop)
52 52
53 53
54 54 #pybind11_add_module(pytestamdalib SHARED tests/PyTestAmdaWrapper.cpp)
55 55 add_library(pytestamdalib tests/PyTestAmdaWrapper.cpp)
56 56 target_link_libraries(pytestamdalib PUBLIC pybind11::module)
57 57 target_link_libraries(pytestamdalib PUBLIC pybind11::embed)
58 58 target_link_libraries(pytestamdalib PUBLIC amdaplugin)
59 59 target_link_libraries(pytestamdalib PUBLIC pysciqlop)
60 60
61 61 GET_PROPERTY(CORE_PYTHON_PATH GLOBAL PROPERTY CORE_PYTHON_PATH)
62 62
63 63 declare_test(TestAmdaFileParserEmbed TestAmdaFileParserEmbed "tests/PyTestAmdaWrapperExe.cpp" "pytestamdalib")
64 64 target_compile_definitions(TestAmdaFileParserEmbed PRIVATE -DPYTESTAMDA_SCRIPT="${CMAKE_CURRENT_LIST_DIR}/tests/TestAmdaFileParser.py")
65 65 set_tests_properties(TestAmdaFileParserEmbed PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CORE_PYTHON_PATH})
66 66
67 67
68 68 declare_test(TestAmdaDownloadEmbed TestAmdaDownloadEmbed "tests/PyTestAmdaWrapperExe.cpp" "pytestamdalib")
69 69 target_compile_definitions(TestAmdaDownloadEmbed PRIVATE -DPYTESTAMDA_SCRIPT="${CMAKE_CURRENT_LIST_DIR}/tests/TestAmdaDownload.py")
70 70 set_tests_properties(TestAmdaDownloadEmbed PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CORE_PYTHON_PATH})
71 71
72 72
73 73 declare_test(TestAmdaMiniFuzzEmbed TestAmdaMiniFuzzEmbed "tests/PyTestAmdaWrapperExe.cpp" "pytestamdalib")
74 74 target_compile_definitions(TestAmdaMiniFuzzEmbed PRIVATE -DPYTESTAMDA_SCRIPT="${CMAKE_CURRENT_LIST_DIR}/tests/TestAmdaMiniFuzz.py")
75 75 set_tests_properties(TestAmdaMiniFuzzEmbed PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CORE_PYTHON_PATH})
76 76
77 77
78 78 find_package(PythonInterp 3 REQUIRED)
79 79
80 80 add_test(NAME TestAmdaFileParser
81 81 COMMAND ${PYTHON_EXECUTABLE}
82 82 ${CMAKE_CURRENT_LIST_DIR}/tests/TestAmdaFileParser.py
83 83 TestAmdaFileParser)
84 84 set_tests_properties(TestAmdaFileParser PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CORE_PYTHON_PATH})
85 85
86 86
87 87 add_test(NAME TestAmdaDownload
88 88 COMMAND ${PYTHON_EXECUTABLE}
89 89 ${CMAKE_CURRENT_LIST_DIR}/tests/TestAmdaDownload.py
90 90 TestAmdaDownload)
91 91 set_tests_properties(TestAmdaDownload PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CORE_PYTHON_PATH})
92 92
93 93 endif(PyWrappers)
@@ -1,37 +1,37
1 1 include_directories(include)
2 2 FILE (GLOB_RECURSE mockplugin_SRCS
3 3 include/*.h
4 4 src/*.cpp
5 5 resources/*.qrc
6 6 )
7 7
8 8 add_definitions(-DQT_PLUGIN)
9 9 add_definitions(-DPLUGIN_JSON_FILE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/mockplugin.json")
10 10 if(NOT BUILD_SHARED_LIBS)
11 11 add_definitions(-DQT_STATICPLUGIN)
12 12 endif()
13 13
14 14 add_library(mockplugin ${mockplugin_SRCS})
15 15 SET_TARGET_PROPERTIES(mockplugin PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
16 16
17 17 target_link_libraries(mockplugin sciqlopgui)
18 18
19 19 install(TARGETS mockplugin
20 20 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/SciQlop
21 21 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/SciQlop
22 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
22 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/SciQlop)
23 23
24 24 include(sciqlop_tests)
25 25
26 26 add_definitions(-DMOCKPLUGIN_TESTS_RESOURCES_DIR="${CMAKE_CURRENT_LIST_DIR}/tests-resources")
27 27 add_definitions(-DMOCKPLUGIN_LIB)
28 28
29 29 #declare_test(TestCosinusAcquisition TestCosinusAcquisition tests/TestCosinusAcquisition.cpp "mockplugin;Qt5::Test")
30 30 if(PyWrappers)
31 31 if(MINGW)
32 32 add_definitions(-D_hypot=hypot)
33 33 endif()
34 34 pybind11_add_module(pytestmockplugin tests/PyTestMockPluginWrapper.cpp)
35 35 target_link_libraries(pytestmockplugin PUBLIC mockplugin)
36 36 target_link_libraries(pytestmockplugin PUBLIC pysciqlop)
37 37 endif()
General Comments 0
You need to be logged in to leave comments. Login now