diff --git a/CMakeLists.txt b/CMakeLists.txt index 9df3fb08..7d0295b7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,14 +40,13 @@ configure_file ( ${PROJECT_BINARY_DIR}/DSView/config.h ) - #=============================================================================== #=pkg config #------------------------------------------------------------------------------- include(FindPkgConfig) include(GNUInstallDirs) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") find_package(PkgConfig) @@ -84,7 +83,7 @@ message("-- glib-2.0:") MESSAGE(STATUS " - includes:" ${GLIB_INCLUDE_DIRS}) MESSAGE(STATUS " - libraries:" ${GLIB_LIBRARIES}) include_directories(${GLIB_INCLUDE_DIRS}) -link_directories(${GLIB_LIBRARIES_DIRS}) +link_directories(${GLIB_LIBRARIES}) #=============================================================================== #= python3 @@ -137,12 +136,13 @@ include_directories(${PC_LIBZIP_INCLUDE_DIRS}) link_directories(${PC_LIBZIP_LIBRARIES}) #=============================================================================== -#= Qt5 +#= Qt5 or Qt6 #------------------------------------------------------------------------------- -find_package(Qt5Core REQUIRED) + +find_package(Qt5Core QUIET) if(Qt5Core_FOUND) - message("-- Qt5:") + message("-- use Qt5:") MESSAGE(STATUS " - includes:" ${Qt5Core_INCLUDE_DIRS}) find_package(Qt5Widgets REQUIRED) find_package(Qt5Gui REQUIRED) @@ -151,7 +151,22 @@ if(Qt5Core_FOUND) set(QT_LIBRARIES Qt5::Gui Qt5::Widgets) add_definitions(${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}) else() - message(FATAL_ERROR "-- Have not fond qt5 core, please install it!") + find_package(Qt6Core QUIET) +endif() + +if(Qt6Core_FOUND) + message("-- use Qt6:") + MESSAGE(STATUS " - includes:" ${Qt6Core_INCLUDE_DIRS}) + find_package(Qt6Widgets REQUIRED) + find_package(Qt6Gui REQUIRED) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt6Widgets_EXECUTABLE_COMPILE_FLAGS}") + set(QT_INCLUDE_DIRS ${Qt6Gui_INCLUDE_DIRS} ${Qt6Widgets_INCLUDE_DIRS}) + set(QT_LIBRARIES Qt6::Gui Qt6::Widgets) + add_definitions(${Qt6Gui_DEFINITIONS} ${Qt6Widgets_DEFINITIONS}) +endif() + +if(NOT Qt5Core_FOUND AND NOT Qt6Core_FOUND) + message(FATAL_ERROR "Please install Qt5 or Qt6!") endif() #=============================================================================== @@ -159,12 +174,6 @@ endif() #------------------------------------------------------------------------------- -list(APPEND PKGDEPS - -) - -###pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS}) - find_package(Threads) find_package(Boost 1.42 REQUIRED) @@ -469,7 +478,8 @@ if(WIN32) # Use the DSView icon for the DSView.exe executable. set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff -I${CMAKE_CURRENT_SOURCE_DIR} ") enable_language(RC) - list(APPEND DSView_SOURCES DSView/DSView.rc) + # app icon + list(APPEND DSView_SOURCES DSView/applogo.rc) endif() if(Qt5Core_FOUND) @@ -478,6 +488,12 @@ if(Qt5Core_FOUND) qt5_add_resources(DSView_RESOURCES_RCC ${DSView_RESOURCES}) endif() +if(Qt6Core_FOUND) + qt6_wrap_cpp(DSView_HEADERS_MOC ${DSView_HEADERS}) + qt6_wrap_ui(DSView_FORMS_HEADERS ${DSView_FORMS}) + qt6_add_resources(DSView_RESOURCES_RCC ${DSView_RESOURCES}) +endif() + #=============================================================================== #= Global Definitions #------------------------------------------------------------------------------- @@ -530,7 +546,10 @@ add_compile_options(-O3) link_directories(${Boost_LIBRARY_DIRS}) +link_directories("/usr/local/lib") + set(DSVIEW_LINK_LIBS + -lz ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${QT_LIBRARIES} @@ -538,7 +557,6 @@ set(DSVIEW_LINK_LIBS ${FFTW_LIBRARIES} ${PYTHON_LIBRARIES} ${GLIB_LIBRARIES} - ${ZLIB_LIBRARIES} ${PC_LIBZIP_LIBRARIES} ) @@ -587,8 +605,11 @@ install(DIRECTORY DSView/res DESTINATION share/DSView) install(FILES DSView/icons/logo.svg DESTINATION share/DSView RENAME logo.svg) install(FILES DSView/icons/logo.svg DESTINATION share/icons/hicolor/scalable/apps RENAME dsview.svg) install(FILES DSView/icons/logo.svg DESTINATION share/pixmaps RENAME dsview.svg) -install(FILES DSView/DreamSourceLab.rules DESTINATION /lib/udev/rules.d RENAME 60-dreamsourcelab.rules) -install(FILES DSView/DSView.desktop DESTINATION /usr/share/applications RENAME dsview.desktop) + +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + install(FILES DSView/DreamSourceLab.rules DESTINATION /lib/udev/rules.d RENAME 60-dreamsourcelab.rules) + install(FILES DSView/DSView.desktop DESTINATION /usr/share/applications RENAME dsview.desktop) +endif() install(FILES NEWS25 DESTINATION share/DSView RENAME NEWS25) install(FILES NEWS31 DESTINATION share/DSView RENAME NEWS31) diff --git a/DSView/pv/config/appconfig.cpp b/DSView/pv/config/appconfig.cpp index 08c69fa6..eeb697f3 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/pv/config/appconfig.cpp @@ -331,19 +331,29 @@ QString GetAppDataDir() if (dir1.exists()){ return dir1.absolutePath(); } - qDebug() << "dir is not exists:" <<"../share/DSView"; + qDebug() << "Data directory is not exists:" <<"../share/DSView"; assert(false); #else + // The bin location return QCoreApplication::applicationDirPath(); #endif } QString GetResourceDir(){ - QDir dir = GetAppDataDir() + "/res"; - if (dir.exists()){ - return dir.absolutePath(); + QDir dir1 = GetAppDataDir() + "/res"; + // ./res + if (dir1.exists()){ + return dir1.absolutePath(); } - qDebug() << "app data dir is not exists:" << dir.absolutePath(); + + QDir dir(QCoreApplication::applicationDirPath()); + // ../share/DSView/res + if (dir.cd("..") && dir.cd("share") && dir.cd("DSView") && dir.cd("res")) + { + return dir.absolutePath(); + } + + qDebug() << "Resource directory is not exists:" << dir1.absolutePath(); assert(false); } @@ -360,21 +370,17 @@ QString GetDecodeScriptDir() { QString path = GetAppDataDir() + "/decoders"; - #ifdef Q_OS_LINUX QDir dir1; - // ../share/DSView/decoders + // ./decoders if (dir1.exists(path)) { return path; - } + } QDir dir(QCoreApplication::applicationDirPath()); // ../share/libsigrokdecode4DSL/decoders if (dir.cd("..") && dir.cd("share") && dir.cd("libsigrokdecode4DSL") && dir.cd("decoders")) { return dir.absolutePath(); - } -#endif - - return path; + } } diff --git a/cmake_clear b/cmake_clear index 2a3d82ae..ae7c4009 100755 --- a/cmake_clear +++ b/cmake_clear @@ -1,16 +1,36 @@ -echo "rm cmake cache begin..." +echo "clean cmake cache begin..." -sudo rm -r ./build -rm -r ./CMakeFiles +echo "rm ./build" +rm -rf ./build -rm ./cmake_install.cmake -rm ./Makefile -rm ./CMakeCache.txt -rm ./*.cmake -rm ./DSView.qrc.depends +echo "rm ./CMakeFiles" +rm -rf ./CMakeFiles +echo "rm ./cmake_install.cmake" +rm -f ./cmake_install.cmake + +echo "rm ./Makefile" +rm -f ./Makefile + +echo "rm ./Makefile.tmp" +rm -f ./Makefile.tmp + +echo "rm ./CMakeCache.txt" +rm -f ./CMakeCache.txt + +echo "rm ./*.cmake" +rm -f ./*.cmake + +echo "rm ./DSView.qrc.depends" +rm -f ./DSView.qrc.depends + +echo "rm ./moc_*.cpp*" find . -name 'moc_*.cpp*' | xargs rm -rf + +echo "rm ./qrc_*.cpp" find . -name 'qrc_*.cpp' | xargs rm -rf -rm ./install_manifest.txt -echo "rm cmake cache end..." +echo "rm ./install_manifest.txt" +rm -f ./install_manifest.txt + +echo "clean cmake cache end."