Modify Qt5 CMake and include Qt Charts Option (#1837)
Update CMake search for Qt5 componets to be consistent with recommended practice from Kitware. (see https://blog.kitware.com/cmake-finding-qt5-the-right-way/) Incorporate ability to build cppcheck-gui with Qt Charts via CMake switch. Option "WITH_QCHARTS" will enable search for Qt Charts to Qt5 component search and add build flag "HAVE_QCHART".
This commit is contained in:
parent
e80181d35a
commit
dc5a38e61c
|
@ -1,9 +1,9 @@
|
|||
if (BUILD_GUI)
|
||||
find_package(Qt5Core)
|
||||
find_package(Qt5Gui)
|
||||
find_package(Qt5Widgets)
|
||||
find_package(Qt5PrintSupport)
|
||||
find_package(Qt5LinguistTools)
|
||||
if (NOT WITH_QCHART)
|
||||
find_package(Qt5 COMPONENTS Core Gui Widgets PrintSupport LinguistTools REQUIRED)
|
||||
else()
|
||||
find_package(Qt5 COMPONENTS Core Gui Widgets PrintSupport LinguistTools Charts REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (HAVE_RULES)
|
||||
|
|
|
@ -37,6 +37,7 @@ endif()
|
|||
|
||||
option(BUILD_TESTS "Build tests" OFF)
|
||||
option(BUILD_GUI "Build the qt application" OFF)
|
||||
option(WITH_QCHART "When building GUI(need BUILD_GUI=ON), use Qt5 Charts" OFF)
|
||||
|
||||
option(HAVE_RULES "Usage of rules (needs PCRE library and headers)" OFF)
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ message( STATUS )
|
|||
message( STATUS "BUILD_SHARED_LIBS = ${BUILD_SHARED_LIBS}" )
|
||||
message( STATUS "BUILD_TESTS = ${BUILD_TESTS}" )
|
||||
message( STATUS "BUILD_GUI = ${BUILD_GUI}" )
|
||||
message( STATUS "WITH_QCHART = ${WITH_QCHART}" )
|
||||
message( STATUS )
|
||||
message( STATUS "HAVE_RULES = ${HAVE_RULES}" )
|
||||
message( STATUS )
|
||||
|
|
|
@ -25,6 +25,10 @@ if (BUILD_GUI)
|
|||
target_link_libraries(cppcheck-gui pcre)
|
||||
endif()
|
||||
target_link_libraries(cppcheck-gui Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport)
|
||||
if(WITH_QCHART)
|
||||
target_compile_definitions (cppcheck-gui PRIVATE HAVE_QCHART )
|
||||
target_link_libraries(cppcheck-gui Qt5::Charts)
|
||||
endif()
|
||||
|
||||
install(TARGETS cppcheck-gui RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)
|
||||
install(FILES ${qms} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)
|
||||
|
|
Loading…
Reference in New Issue