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