Skip to content

Commit dd4a482

Browse files
committed
Build JKQPLotter statically (8MB)
1 parent bd6af44 commit dd4a482

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

CMakeLists.txt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,19 +659,29 @@ if(UNIX)
659659
list(APPEND QT_INCLUDES ${Qt6XcbQpa_INCLUDE_DIRS})
660660
endif()
661661

662+
####################### JKQTPlotter ######################
662663
# Make JKQTPlotter available after finding Qt
663664
include(FetchContent)
664665

666+
# Build it statically
667+
set(OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
668+
set(BUILD_SHARED_LIBS OFF)
669+
665670
set(JKQtPlotter_BUILD_EXAMPLES OFF)
671+
set(JKQtPlotter_BUILD_LIB_JKQTFASTPLOTTER OFF)
672+
673+
# Force finding the same Qt
674+
find_package(QT NAMES Qt6 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGl REQUIRED PATHS ${QT_INSTALL_DIR} NO_DEFAULT_PATH)
666675

667-
FetchContent_Declare(JKQTPlotter
668-
GIT_REPOSITORY https://github.com/jkriege2/JKQtPlotter.git
669-
GIT_TAG v4.0.3)
676+
FetchContent_Declare(JKQTPlotter${QT_VERSION_MAJOR}
677+
GIT_REPOSITORY https://github.com/jkriege2/JKQtPlotter.git
678+
# GIT_TAG v5.0.0 # This is unreleased, but FetchContent support was added after v4.0.3
679+
)
670680

671-
FetchContent_MakeAvailable(JKQTPlotter)
681+
FetchContent_MakeAvailable(JKQTPlotter${QT_VERSION_MAJOR})
682+
set(BUILD_SHARED_LIBS ${OLD_BUILD_SHARED_LIBS})
672683

673-
list(APPEND JKQT_LIBS JKQTCommonSharedLib)
674-
list(APPEND JKQT_LIBS JKQTPlotterSharedLib)
684+
##########################################################
675685

676686
set(CMAKE_AUTOMOC OFF)
677687

src/openstudio_app/CMakeLists.txt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ if( APPLE )
188188

189189
elseif( UNIX )
190190

191-
foreach(LIB ${QT_LIBS} ${QT_WEB_LIBS} ${JKQT_LIBS})
191+
foreach(LIB ${QT_LIBS} ${QT_WEB_LIBS})
192192
get_property(LIB_LOCATION TARGET ${LIB} PROPERTY LOCATION)
193193
list(APPEND QT_LIB_LOCATIONS "${LIB_LOCATION}")
194194
endforeach()
@@ -275,14 +275,6 @@ elseif( WIN32 )
275275
#COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_v8_context_snapshot} $<TARGET_FILE_DIR:${target_name}>/resources/
276276
)
277277

278-
add_custom_command(TARGET ${target_name}
279-
POST_BUILD
280-
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:JKQTCommonSharedLib> $<TARGET_FILE_DIR:${target_name}>/
281-
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:JKQTFastPlotterSharedLib> $<TARGET_FILE_DIR:${target_name}>/
282-
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:JKQTMathTextSharedLib> $<TARGET_FILE_DIR:${target_name}>/
283-
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:JKQTPlotterSharedLib> $<TARGET_FILE_DIR:${target_name}>/
284-
)
285-
286278
# On Windows, we must copy the DLLs inside the build folder or it won't find them
287279
# TODO: IMPORTED_SONAME_RELEASE now contains @rpath so it fails
288280
# get_target_property(LIBOSLIB openstudio::openstudiolib IMPORTED_LOCATION_RELEASE)
@@ -395,7 +387,7 @@ if( NOT APPLE )
395387
install(PROGRAMS $<TARGET_FILE_DIR:${target_name}>/D3Dcompiler_47.dll DESTINATION bin/ COMPONENT OpenStudioApp)
396388
install(PROGRAMS $<TARGET_FILE_DIR:${target_name}>/opengl32sw.dll DESTINATION bin/ COMPONENT OpenStudioApp)
397389

398-
foreach(LIB ${QT_LIBS} ${QT_WEB_LIBS} ${JKQT_LIBS})
390+
foreach(LIB ${QT_LIBS} ${QT_WEB_LIBS})
399391
install(PROGRAMS $<TARGET_FILE_DIR:${target_name}>/$<TARGET_FILE_NAME:${LIB}> DESTINATION bin/ COMPONENT OpenStudioApp)
400392
endforeach()
401393

@@ -416,7 +408,7 @@ if( NOT APPLE )
416408
install(DIRECTORY $<TARGET_FILE_DIR:${target_name}>/xcbglintegrations/ DESTINATION bin/xcbglintegrations/ COMPONENT OpenStudioApp)
417409
# install(PROGRAMS $<TARGET_FILE_DIR:${target_name}>/xcbglintegrations/$<TARGET_FILE_NAME:Qt6::QXcbGlxIntegrationPlugin> DESTINATION bin/xcbglintegrations/ COMPONENT OpenStudioApp)
418410

419-
foreach(LIB ${QT_LIBS} ${QT_WEB_LIBS} ${JKQT_LIBS})
411+
foreach(LIB ${QT_LIBS} ${QT_WEB_LIBS})
420412
install(PROGRAMS $<TARGET_FILE_DIR:${target_name}>/$<TARGET_FILE_NAME:${LIB}> DESTINATION bin/ COMPONENT OpenStudioApp)
421413
endforeach()
422414

src/openstudio_lib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ set(${target_name}_depends
774774
openstudio::openstudiolib
775775
${QT_LIBS}
776776
${QT_WEB_LIBS}
777-
${JKQT_LIBS}
777+
JKQTPlotter${QT_VERSION_MAJOR}::JKQTPlotter${QT_VERSION_MAJOR}
778778
)
779779

780780
if(WIN32)

0 commit comments

Comments
 (0)