diff --git a/CMakeLists.txt b/CMakeLists.txt index ea494921488..e2022327ae5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,8 +123,10 @@ omc_add_subdirectory(OMParser EXCLUDE_FROM_ALL) omc_add_subdirectory(OMPlot EXCLUDE_FROM_ALL) omc_add_subdirectory(OMShell EXCLUDE_FROM_ALL) omc_add_subdirectory(OMNotebook EXCLUDE_FROM_ALL) -# omc_add_subdirectory(libraries) + include(omsimulator.cmake) +omc_add_subdirectory(OMEdit EXCLUDE_FROM_ALL) +# omc_add_subdirectory(libraries) ## Report some status info. diff --git a/OMCompiler/Compiler/CMakeLists.txt b/OMCompiler/Compiler/CMakeLists.txt index 4d305e24ff1..c323f9672ce 100644 --- a/OMCompiler/Compiler/CMakeLists.txt +++ b/OMCompiler/Compiler/CMakeLists.txt @@ -190,6 +190,16 @@ add_library(OpenModelicaCompiler SHARED ${OMC_C_SOURCE_FILES} .cmake/omc_entry_p target_compile_definitions(OpenModelicaCompiler PRIVATE ADD_METARECORD_DEFINITIONS=) +# There is a lonely omc_file.h in Util/. It belongs in runtime/. Remove this when it is moved. +target_include_directories(OpenModelicaCompiler PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Util) + +# This should not be needed ideally. However linking libs sometimes need to include the generated headers. +# Right now this only happens for OMEdit. OMEdit includes Script/OpenModelicaScriptingAPIQt.h +# which in turn wants to include OpenModelicaScriptingAPI.h. This header is generated from +# translation of OpenModelicaScriptingAPI.mo. So this interface include dir is needed. +# We can maybe copy these headers to some specific location after generation and avoid this. +target_include_directories(OpenModelicaCompiler INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/c_files) + # OMC will overflow the stack (at least on Windows old OMDev) on very deep recursive calls. # E.g., try translating the CodegenCpp* tpl files to mo files with # an omc not compiled without large stack size. The tpl parser is quite recursive and will @@ -202,10 +212,6 @@ target_compile_definitions(OpenModelicaCompiler PRIVATE ADD_METARECORD_DEFINITIO add_dependencies(OpenModelicaCompiler DEPENDENCY_UPDATE) -# There is a lonely omc_file.h in Util/. It belongs in runtime/. Remove this when it is moved. -target_include_directories(OpenModelicaCompiler PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Util) - - target_link_libraries(OpenModelicaCompiler PUBLIC omc::parser) target_link_libraries(OpenModelicaCompiler PUBLIC omc::compiler::backendruntime) target_link_libraries(OpenModelicaCompiler PUBLIC omc::compiler::runtime) diff --git a/OMEdit/CMakeLists.txt b/OMEdit/CMakeLists.txt new file mode 100644 index 00000000000..fcecaf8479d --- /dev/null +++ b/OMEdit/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required (VERSION 3.14) + +project(OMEdit) + +## Set the C++ standard to use. +set(CMAKE_CXX_STANDARD 14) +set(CXX_STANDARD_REQUIRED ON) +## Make sure we do not start relying on extensions down the road. +set(CMAKE_CXX_EXTENSIONS OFF) + + +find_package(Qt5 COMPONENTS Widgets PrintSupport WebKitWidgets Xml XmlPatterns OpenGL Network REQUIRED) +find_package(OpenSceneGraph COMPONENTS osgViewer osgDB osgGA REQUIRED) + +# Configure omedit_config.h. This will be generated in the build directory +configure_file(omedit_config.h.in omedit_config.h) +## Add a config library for OMEdit. They will provide access to common config headres such as +## config.h. So by linking to this library you get the include directories. +add_library(omedit_config INTERFACE) +add_library(omedit::config ALIAS omedit_config) +target_include_directories(omedit_config INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) + +omc_add_subdirectory(OMEditLIB) +omc_add_subdirectory(OMEditGUI) + diff --git a/OMEdit/OMEditGUI/CMakeLists.txt b/OMEdit/OMEditGUI/CMakeLists.txt new file mode 100644 index 00000000000..cca2047aacb --- /dev/null +++ b/OMEdit/OMEditGUI/CMakeLists.txt @@ -0,0 +1,7 @@ + + +add_executable(OMEdit main.cpp rc_omedit.rc) + +target_link_libraries(OMEdit PRIVATE OMEditLib) + +install(TARGETS OMEdit) diff --git a/OMEdit/OMEditLIB/CMakeLists.txt b/OMEdit/OMEditLIB/CMakeLists.txt new file mode 100644 index 00000000000..c29f4c33043 --- /dev/null +++ b/OMEdit/OMEditLIB/CMakeLists.txt @@ -0,0 +1,291 @@ +# file(GLOB_RECURSE OMEDITLIB_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h) + +# file(GLOB_RECURSE OMEDITLIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +# set(OMEDITLIB_SOURCES resource_omedit.qrc ${OMEDITLIB_SOURCES}) + +omc_add_subdirectory(Debugger/Parser) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(OMEDITLIB_SOURCES Util/Helper.cpp + Util/Utilities.cpp + Util/StringHandler.cpp + Util/OutputPlainTextEdit.cpp + MainWindow.cpp + OMC/OMCProxy.cpp + Modeling/MessagesWidget.cpp + Modeling/ItemDelegate.cpp + Modeling/LibraryTreeWidget.cpp + Modeling/Commands.cpp + Modeling/CoOrdinateSystem.cpp + Modeling/ModelWidgetContainer.cpp + Modeling/ModelicaClassDialog.cpp + Modeling/FunctionArgumentDialog.cpp + Modeling/InstallLibraryDialog.cpp + Search/SearchWidget.cpp + Options/OptionsDialog.cpp + Editors/BaseEditor.cpp + Editors/ModelicaEditor.cpp + Editors/TransformationsEditor.cpp + Editors/TextEditor.cpp + Editors/CEditor.cpp + Editors/CompositeModelEditor.cpp + Editors/OMSimulatorEditor.cpp + Editors/MetaModelicaEditor.cpp + Editors/HTMLEditor.cpp + Plotting/PlotWindowContainer.cpp + Element/Element.cpp + Annotations/ShapeAnnotation.cpp + Element/CornerItem.cpp + Annotations/LineAnnotation.cpp + Annotations/PolygonAnnotation.cpp + Annotations/RectangleAnnotation.cpp + Annotations/EllipseAnnotation.cpp + Annotations/TextAnnotation.cpp + Annotations/BitmapAnnotation.cpp + Annotations/DynamicAnnotation.cpp + Annotations/BooleanAnnotation.cpp + Annotations/ColorAnnotation.cpp + Annotations/ExtentAnnotation.cpp + Annotations/PointAnnotation.cpp + Annotations/RealAnnotation.cpp + Annotations/StringAnnotation.cpp + Element/ElementProperties.cpp + Element/Transformation.cpp + Modeling/DocumentationWidget.cpp + Simulation/TranslationFlagsWidget.cpp + Simulation/SimulationDialog.cpp + Simulation/SimulationOutputWidget.cpp + Simulation/SimulationOutputHandler.cpp + Simulation/OpcUaClient.cpp + Simulation/ArchivedSimulationsWidget.cpp + TLM/FetchInterfaceDataDialog.cpp + TLM/FetchInterfaceDataThread.cpp + TLM/TLMCoSimulationDialog.cpp + TLM/TLMCoSimulationOutputWidget.cpp + TLM/TLMCoSimulationThread.cpp + FMI/ImportFMUDialog.cpp + FMI/ImportFMUModelDescriptionDialog.cpp + Plotting/VariablesWidget.cpp + Plotting/DiagramWindow.cpp + Options/NotificationsDialog.cpp + Annotations/ShapePropertiesDialog.cpp + TransformationalDebugger/OMDumpXML.cpp + TransformationalDebugger/diff_match_patch.cpp + TransformationalDebugger/TransformationsWidget.cpp + Debugger/GDB/CommandFactory.cpp + Debugger/GDB/GDBAdapter.cpp + Debugger/StackFrames/StackFramesWidget.cpp + Debugger/Locals/LocalsWidget.cpp + Debugger/Locals/ModelicaValue.cpp + Debugger/Breakpoints/BreakpointMarker.cpp + Debugger/Breakpoints/BreakpointsWidget.cpp + Debugger/Breakpoints/BreakpointDialog.cpp + Debugger/DebuggerConfigurationsDialog.cpp + Debugger/Attach/AttachToProcessDialog.cpp + Debugger/Attach/ProcessListModel.cpp + CrashReport/backtrace.c + CrashReport/GDBBacktrace.cpp + CrashReport/CrashReportDialog.cpp + Git/GitCommands.cpp + Git/CommitChangesDialog.cpp + Git/RevertCommitsDialog.cpp + Git/CleanDialog.cpp + OMEditApplication.cpp + Traceability/TraceabilityGraphViewWidget.cpp + Traceability/TraceabilityInformationURI.cpp + OMS/OMSProxy.cpp + OMS/ModelDialog.cpp + OMS/BusDialog.cpp + OMS/ElementPropertiesDialog.cpp + OMS/SystemSimulationInformationDialog.cpp + OMS/OMSSimulationDialog.cpp + OMS/OMSSimulationOutputWidget.cpp + Animation/TimeManager.cpp + Util/ResourceCache.cpp + Util/NetworkAccessManager.cpp + FlatModelica/Expression.cpp + FlatModelica/ExpressionFuncs.cpp + Animation/OpenGLWidget.cpp + Animation/AbstractAnimationWindow.cpp + Animation/ViewerWidget.cpp + Animation/AnimationWindow.cpp + Animation/ThreeDViewer.cpp + Animation/ExtraShapes.cpp + Animation/Visualizer.cpp + Animation/VisualizerMAT.cpp + Animation/VisualizerCSV.cpp + Animation/VisualizerFMU.cpp + Animation/FMUSettingsDialog.cpp + Animation/FMUWrapper.cpp + Animation/Shapes.cpp + resource_omedit.qrc) + + +set(OMEDITLIB_HEADERS Util/Helper.h + Util/Utilities.h + Util/StringHandler.h + Util/OutputPlainTextEdit.h + MainWindow.h + OMC/OMCProxy.h + Modeling/MessagesWidget.h + Modeling/ItemDelegate.h + Modeling/LibraryTreeWidget.h + Modeling/Commands.h + Modeling/CoOrdinateSystem.h + Modeling/ModelWidgetContainer.h + Modeling/ModelicaClassDialog.h + Modeling/FunctionArgumentDialog.h + Modeling/InstallLibraryDialog.h + Search/SearchWidget.h + Options/OptionsDialog.h + Editors/BaseEditor.h + Editors/ModelicaEditor.h + Editors/TransformationsEditor.h + Editors/TextEditor.h + Editors/CEditor.h + Editors/CompositeModelEditor.h + Editors/OMSimulatorEditor.h + Editors/MetaModelicaEditor.h + Editors/HTMLEditor.h + Plotting/PlotWindowContainer.h + Element/Element.h + Annotations/ShapeAnnotation.h + Element/CornerItem.h + Annotations/LineAnnotation.h + Annotations/PolygonAnnotation.h + Annotations/RectangleAnnotation.h + Annotations/EllipseAnnotation.h + Annotations/TextAnnotation.h + Annotations/BitmapAnnotation.h + Annotations/DynamicAnnotation.h + Annotations/BooleanAnnotation.h + Annotations/ColorAnnotation.h + Annotations/ExtentAnnotation.h + Annotations/PointAnnotation.h + Annotations/RealAnnotation.h + Annotations/StringAnnotation.h + Element/ElementProperties.h + Element/Transformation.h + Modeling/DocumentationWidget.h + Simulation/SimulationOptions.h + Simulation/TranslationFlagsWidget.h + Simulation/SimulationDialog.h + Simulation/SimulationOutputWidget.h + Simulation/SimulationOutputHandler.h + Simulation/OpcUaClient.h + Simulation/ArchivedSimulationsWidget.h + TLM/FetchInterfaceDataDialog.h + TLM/FetchInterfaceDataThread.h + TLM/TLMCoSimulationOptions.h + TLM/TLMCoSimulationDialog.h + TLM/TLMCoSimulationOutputWidget.h + TLM/TLMCoSimulationThread.h + FMI/ImportFMUDialog.h + FMI/ImportFMUModelDescriptionDialog.h + Plotting/VariablesWidget.h + Plotting/DiagramWindow.h + Options/NotificationsDialog.h + Annotations/ShapePropertiesDialog.h + TransformationalDebugger/OMDumpXML.cpp + TransformationalDebugger/diff_match_patch.h + TransformationalDebugger/TransformationsWidget.h + Debugger/GDB/CommandFactory.h + Debugger/GDB/GDBAdapter.h + Debugger/StackFrames/StackFramesWidget.h + Debugger/Locals/LocalsWidget.h + Debugger/Locals/ModelicaValue.h + Debugger/Breakpoints/BreakpointMarker.h + Debugger/Breakpoints/BreakpointsWidget.h + Debugger/Breakpoints/BreakpointDialog.h + Debugger/DebuggerConfigurationsDialog.h + Debugger/Attach/AttachToProcessDialog.h + Debugger/Attach/ProcessListModel.h + CrashReport/backtrace.h + CrashReport/GDBBacktrace.h + CrashReport/CrashReportDialog.h + Git/GitCommands.h + Git/CommitChangesDialog.h + Git/RevertCommitsDialog.h + Git/CleanDialog.h + OMEditApplication.h + Traceability/TraceabilityGraphViewWidget.h + Traceability/TraceabilityInformationURI.h + OMS/OMSProxy.h + OMS/ModelDialog.h + OMS/BusDialog.h + OMS/ElementPropertiesDialog.h + OMS/SystemSimulationInformationDialog.h + OMS/OMSSimulationDialog.h + OMS/OMSSimulationOutputWidget.h + Animation/TimeManager.h + Interfaces/InformationInterface.h + Interfaces/ModelInterface.h + Util/ResourceCache.h + Util/NetworkAccessManager.h + FlatModelica/Expression.h + FlatModelica/ExpressionFuncs.h + Animation/OpenGLWidget.h + Animation/AbstractAnimationWindow.h + Animation/ViewerWidget.h + Animation/AnimationWindow.h + Animation/ThreeDViewer.h + Animation/AnimationUtil.h + Animation/ExtraShapes.h + Animation/Visualizer.h + Animation/VisualizerMAT.h + Animation/VisualizerCSV.h + Animation/VisualizerFMU.h + Animation/FMUSettingsDialog.h + Animation/FMUWrapper.h + Animation/Shapes.h + Animation/rapidxml.hpp) + + +# Add the OpenModelica generated files to sources +set(OMEDITLIB_HEADERS ${OMEDITLIB_HEADERS} ${OMCompiler_SOURCE_DIR}/Compiler/Script/OpenModelicaScriptingAPIQt.h) +set(OMEDITLIB_SOURCES ${OMEDITLIB_SOURCES} ${OMCompiler_SOURCE_DIR}/Compiler/Script/OpenModelicaScriptingAPIQt.cpp) +# Even though these are outputs of CMake custom commands, cmake fails to automatically recognize them as generated. +# My guess is that the directory difference is confusing it. So maunally mark them as generated. +set_source_files_properties(${OMCompiler_SOURCE_DIR}/Compiler/Script/OpenModelicaScriptingAPIQt.cpp GENERATED) +set_source_files_properties(${OMCompiler_SOURCE_DIR}/Compiler/Script/OpenModelicaScriptingAPIQt.h GENERATED) + +add_library(OMEditLib STATIC ${OMEDITLIB_SOURCES} ${OMEDITLIB_HEADERS}) + +target_include_directories(OMEditLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +target_link_libraries(OMEditLib PUBLIC omedit::config) +target_link_libraries(OMEditLib PUBLIC libOMSimulator) +target_link_libraries(OMEditLib PUBLIC omedit::debugger::parser) +target_link_libraries(OMEditLib PUBLIC Qt5::Xml) +target_link_libraries(OMEditLib PUBLIC Qt5::Widgets) +target_link_libraries(OMEditLib PUBLIC Qt5::PrintSupport) +target_link_libraries(OMEditLib PUBLIC Qt5::WebKitWidgets) +target_link_libraries(OMEditLib PUBLIC Qt5::OpenGL) +target_link_libraries(OMEditLib PUBLIC Qt5::Network) +target_link_libraries(OMEditLib PUBLIC Qt5::XmlPatterns) +target_link_libraries(OMEditLib PUBLIC omc::3rd::opcua) +target_link_libraries(OMEditLib PUBLIC OMPlotLib) +target_link_libraries(OMEditLib PUBLIC OpenModelicaCompiler) +target_link_libraries(OMEditLib PUBLIC ${OPENSCENEGRAPH_LIBRARIES}) + + +# OMEditLib needs OpenModelicaScriptingAPI.h which is generated in the build dir. +# So we have the build dir as include through linking libOpenModelicaCompiler +# There is also an OMSimulator.h generated in that dir from OMSimulator.mo +# We also have an OMSimulator.h from OMSimulatorLib which we actually want to use. +# Except we are using libOMSimulator as an imported lib now. +# Headers from imported libs are treated as system libs and are added at the end of the include command line. +# Which means the OMSimulator.h from OMSimulator.mo will be picked up first regardless of the order we specify for linking. +# So for now we disable SYSTEM marking of imported libs for OMEditLib here. +set_target_properties(OMEditLib PROPERTIES + NO_SYSTEM_FROM_IMPORTED ON) + +target_include_directories(OMEditLib PRIVATE ${OMCompiler_SOURCE_DIR}/Compiler/Script) + +target_link_options(OMEditLib PRIVATE -Wl,--no-undefined) + +install(TARGETS OMEditLib) + diff --git a/OMEdit/OMEditLIB/Debugger/Parser/CMakeLists.txt b/OMEdit/OMEditLIB/Debugger/Parser/CMakeLists.txt new file mode 100644 index 00000000000..1fee3011dee --- /dev/null +++ b/OMEdit/OMEditLIB/Debugger/Parser/CMakeLists.txt @@ -0,0 +1,35 @@ + +add_custom_command( + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/GDBMIOutput.g + SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/GDBMIOutput.g + COMMAND ${Java_JAVA_EXECUTABLE} + ARGS -cp ${OMAntlr3_ANTLRJAR} + org.antlr.Tool -Xconversiontimeout 10000 + -o ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/GDBMIOutput.g + + COMMENT "Generating ${output_file_path_no_ext}.c/h for ANTLR file ${CMAKE_CURRENT_SOURCE_DIR}/GDBMIOutput.g." + OUTPUT GDBMIOutputLexer.c + OUTPUT GDBMIOutputLexer.h + OUTPUT GDBMIOutputParser.c + OUTPUT GDBMIOutputParser.h + OUTPUT GDBMIOutput.tokens + ) + +## This generated C files include Parser/GDBMIParser.h. Which is a C++ header. Therefore we need to +## compile them as C++ files. +## antlr3 did not get a C++ support until 3.4. We are using antlr 3.2 +set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/GDBMIOutputLexer.c PROPERTIES LANGUAGE CXX) +set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/GDBMIOutputParser.c PROPERTIES LANGUAGE CXX) + + +add_library(libGDBMIParser STATIC GDBMIOutputLexer.c GDBMIOutputParser.c GDBMIParser.cpp) +add_library(omedit::debugger::parser ALIAS libGDBMIParser) + +# set_target_properties(libGDBMIParser PROPERTIES POSITION_INDEPENDENT_CODE ON) + +target_link_libraries(libGDBMIParser PUBLIC omc::3rd::omantlr3) + +target_include_directories(libGDBMIParser PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +## To pick up the generated header files. +target_include_directories(libGDBMIParser PUBLIC ${CMAKE_CURRENT_BINARY_DIR})