From e16cd4b41c83a7e788285a1a1304c2465ee098a2 Mon Sep 17 00:00:00 2001 From: Charbel Jacquin Date: Mon, 19 Jul 2021 22:48:17 +0200 Subject: [PATCH 1/3] build libhydrogen-gui --- src/gui/CMakeLists.txt | 46 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index fc8b31c7f..e8fe1429a 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1,9 +1,14 @@ -FILE(GLOB_RECURSE hydrogen_SRCS src/*.cpp src/*.h) +FILE(GLOB_RECURSE hydrogen_SRCS src/main.cpp) +get_filename_component(main_cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp ABSOLUTE) +FILE(GLOB_RECURSE libhydrogen_gui_INCLUDES *.h) +FILE(GLOB_RECURSE libhydrogen_gui_SOURCES *.cpp *.cc *.c *.ui) +list(REMOVE_ITEM libhydrogen_gui_SOURCES "${main_cpp}") +#LIST(APPEND libhydrogen_gui_INCLUDES ${CMAKE_CURRENT_BINARY_DIR}/config.h) # add undiscovered dependencies to generated config.h INCLUDE(AddFileDependencies) -FOREACH( _file ${hydrogen_H} ${hydrogen_SRCS}) +FOREACH( _file ${libhydrogen_gui_INCLUDES} ${libhydrogen_gui_SRCS} ${hydrogen_SRCS}) FILE(READ "${_file}" _FILE_CONTENT) IF( "${_FILE_CONTENT}" MATCHES "H2CORE_HAVE_" ) ADD_FILE_DEPENDENCIES( ${_file} ${CMAKE_BINARY_DIR}/src/core/config.h) @@ -12,6 +17,7 @@ ENDFOREACH() INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} # ui_ headers + ${CMAKE_CURRENT_BINARY_DIR}/hydrogen-gui-${VERSION}_autogen/include ${CMAKE_CURRENT_SOURCE_DIR}/src # gui headers ${CMAKE_BINARY_DIR}/src # generated config.h ${CMAKE_SOURCE_DIR}/src # top level headers @@ -45,7 +51,14 @@ IF(APPLE) ENDIF() -ADD_EXECUTABLE(hydrogen WIN32 MACOSX_BUNDLE ${hydrogen_SRCS} ${hydrogen_MOC} ${hydrogen_UIS_H} ${CMAKE_SOURCE_DIR}/windows/icon.rc) +ADD_LIBRARY( hydrogen-gui-${VERSION} ${H2CORE_LIBRARY_TYPE} ${libhydrogen_gui_SOURCES} ${libhydrogen_gui_MOC} ${libhydrogen_gui_UIS_H} ${CMAKE_SOURCE_DIR}/windows/icon.rc) + +TARGET_LINK_LIBRARIES(hydrogen-gui-${VERSION} + hydrogen-core-${VERSION} + Qt5::Widgets +) + +ADD_EXECUTABLE(hydrogen WIN32 MACOSX_BUNDLE ${hydrogen_SRCS}) SET_PROPERTY(TARGET hydrogen PROPERTY CXX_STANDARD 17) if(APPLE) add_custom_command( @@ -74,11 +87,16 @@ if(APPLE) endif() -TARGET_LINK_LIBRARIES(hydrogen +TARGET_LINK_LIBRARIES(hydrogen-gui-${VERSION} hydrogen-core-${VERSION} Qt5::Widgets ) +TARGET_LINK_LIBRARIES(hydrogen + hydrogen-gui-${VERSION} + Qt5::Widgets +) + # Precompiled headers for Qt and std::vector. These dramatically reduce GUI build times if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16) target_precompile_headers(hydrogen @@ -89,6 +107,24 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16) endif() -ADD_DEPENDENCIES(hydrogen hydrogen-core-${VERSION}) +ADD_DEPENDENCIES(hydrogen hydrogen-gui-${VERSION}) INSTALL(TARGETS hydrogen RUNTIME DESTINATION ${H2_BIN_PATH} BUNDLE DESTINATION ${H2_BIN_PATH}) + +IF(WIN32) + # On Windows we do not want to install import library (.dll.a) + INSTALL(TARGETS hydrogen-gui-${VERSION} + LIBRARY DESTINATION "${H2_LIB_PATH}" + RUNTIME DESTINATION "${H2_LIB_PATH}" + ) +ELSE() + INSTALL(TARGETS hydrogen-gui-${VERSION} + LIBRARY DESTINATION "${H2_LIB_PATH}" + RUNTIME DESTINATION "${H2_LIB_PATH}" + ARCHIVE DESTINATION "${H2_LIB_PATH}" + ) +ENDIF() +IF(NOT APPLE AND NOT WIN32) + INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/core DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hydrogen" FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE) + INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/config.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hydrogen" ) +ENDIF() From be6ce4448a2f06c1741f4d5695d247eea623d2ae Mon Sep 17 00:00:00 2001 From: Charbel Jacquin Date: Thu, 22 Jul 2021 20:39:39 +0200 Subject: [PATCH 2/3] force vtable for DragScroller --- src/gui/src/Selection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/src/Selection.h b/src/gui/src/Selection.h index e433854b8..3518e881d 100644 --- a/src/gui/src/Selection.h +++ b/src/gui/src/Selection.h @@ -132,7 +132,7 @@ class DragScroller : public QObject { m_pScrollArea = pScrollArea; } - ~DragScroller() { + virtual ~DragScroller() { if ( m_pTimer != nullptr) { delete m_pTimer; } From cfa62685111e7a55d0aff50345108a95152a6d22 Mon Sep 17 00:00:00 2001 From: Charbel Jacquin Date: Thu, 22 Jul 2021 21:20:55 +0200 Subject: [PATCH 3/3] force DragScroller vtable --- src/gui/src/Selection.cpp | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/gui/src/Selection.cpp diff --git a/src/gui/src/Selection.cpp b/src/gui/src/Selection.cpp new file mode 100644 index 000000000..0b15c002d --- /dev/null +++ b/src/gui/src/Selection.cpp @@ -0,0 +1 @@ +#include "Selection.h" \ No newline at end of file