Skip to content

Commit

Permalink
make using cmake_script for copying libqcustomplot.dll
Browse files Browse the repository at this point in the history
  • Loading branch information
UmbrellaLeaf5 committed May 9, 2024
1 parent 469868c commit 943bbde
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,15 @@ include(${CMAKESCRIPTS_DIR}/scripts_for_qcustomplot.cmake)
replace_include_qcustomplot_in_autogen(${CMAKE_BINARY_DIR})
add_subdirectory(${QCUSTOMPLOT_DIR}) # here adding qcustomplot subfolder

# copy one dll file: the command QCUSTOMPLOT_USE_LIBRARY does not work for an unknown reason
load_qcustomplot_dll(${CMAKE_CURRENT_SOURCE_DIR})

# --------------------------------- Our code subdirs ---------------------------------
add_subdirectory(lib)
add_subdirectory(tests)
add_subdirectory(main)

# ------------------------------------------------------------------------------------------

# the programmer in VS Code is tired of constantly copying one dll file,
# and the command QCUSTOMPLOT_USE_LIBRARY does not work for an unknown reason
include(${CMAKESCRIPTS_DIR}/scripts_for_vscode.cmake)
load_qcustomplot_dll(${CMAKE_CURRENT_SOURCE_DIR})

# add images to build directory
file(COPY ${IMAGES_DIR} DESTINATION ${CMAKE_BINARY_DIR})
32 changes: 31 additions & 1 deletion cmake_scripts/scripts_for_qcustomplot.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function(replace_include_qcustomplot_in_autogen BUILD_DIR)
if(EXISTS "${BUILD_DIR}/main/main_autogen/include/ui_mainwindow.h")
message(STATUS "Found ${BUILD_DIR}/main/main_autogen/include/ui_mainwindow.h, replacing qcustomplot include")
message(STATUS "Found ${BUILD_DIR}/main/main_autogen/include/ui_mainwindow.h , replacing qcustomplot include")

# open the file where you need to replace the line in FILE_CONTENT
file(READ "${BUILD_DIR}/main/main_autogen/include/ui_mainwindow.h" FILE_CONTENT)
Expand All @@ -17,3 +17,33 @@ function(replace_include_qcustomplot_in_autogen BUILD_DIR)
message(STATUS "warning: ${BUILD_DIR}/main/main_autogen/include does not exist, please build and reconfigure the project")
endif()
endfunction()

function(load_qcustomplot_dll START_DIR)
if(EXISTS "${START_DIR}/qcustomplot")
# add needed files to QCUSTOMPLOTDLLFILES
file(GLOB_RECURSE QCUSTOMPLOTDLLFILES "${CMAKE_BINARY_DIR}/libqcustomplot.dll")

if(QCUSTOMPLOTDLLFILES)
message(STATUS "Found libqcustomplot.dll, copying to build")
else()
file(GLOB_RECURSE QCUSTOMPLOTDLLFILES "${START_DIR}/libqcustomplot.dll")

if(QCUSTOMPLOTDLLFILES)
message(STATUS "Found ${QCUSTOMPLOTDLLFILES} , copying libqcustomplot.dll to build")
else()
message(STATUS "warning: libqcustomplot.dll not found in build folder, please build and reconfigure the project")
endif()
endif()

# copy from QCUSTOMPLOTDLLFILES to dir in binary
foreach(file ${QCUSTOMPLOTDLLFILES})
if(QCUSTOMPLOTDLLFILES)
# copy to main, where qcustomplot is used
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/main)
endif()
endforeach()
return()
else()
message(STATUS "warning: ${START_DIR}/qcustomplot does not exist, please install submodule 'https://github.com/legerch/QCustomPlot-library'")
endif()
endfunction()
24 changes: 0 additions & 24 deletions cmake_scripts/scripts_for_vscode.cmake

This file was deleted.

2 changes: 0 additions & 2 deletions tests/lib/segment_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <QApplication>
#include <random>

#include "gui/segment.h"

#if !defined(WIN32)
#define BOOST_TEST_DYN_LINK
#endif
Expand Down

0 comments on commit 943bbde

Please sign in to comment.