Explorar o código

V0.4.12
1、标准库使用spdlog中的fmt库,并可以编译通过

Apple hai 4 meses
pai
achega
4bfdfd1ab6
Modificáronse 6 ficheiros con 25 adicións e 168 borrados
  1. 4 2
      CMakeLists.txt
  2. 13 10
      demo/time/CMakeLists.txt
  3. 8 8
      demo/time/main.cpp
  4. 0 54
      demo/time/widget.cpp
  5. 0 32
      demo/time/widget.h
  6. 0 62
      demo/time/widget.ui

+ 4 - 2
CMakeLists.txt

@@ -96,6 +96,8 @@ endif()
 add_compile_definitions(SPDLOG_COMPILED_LIB)
 #给spdlog添加宏定义,使其支持%#等源文件相关的标志
 add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
+#使用spdlog的静态库
+option(ENABLE_SPDLOG_STATIC_LIB "Enable spdlog static library" ON)
 
 
 #=========================================================
@@ -146,7 +148,7 @@ file(GLOB GLOBAL_SRC
 # add_subdirectory(${CMAKE_SOURCE_DIR}/demo/ftp)
 # add_subdirectory(${CMAKE_SOURCE_DIR}/demo/OneThread)
 # add_subdirectory(${CMAKE_SOURCE_DIR}/demo/timer)
-# add_subdirectory(${CMAKE_SOURCE_DIR}/demo/time)
+add_subdirectory(${CMAKE_SOURCE_DIR}/demo/time)
 # add_subdirectory(${CMAKE_SOURCE_DIR}/demo/VideoPlayer)
-add_subdirectory(${CMAKE_SOURCE_DIR}/demo/xlsx)
+# add_subdirectory(${CMAKE_SOURCE_DIR}/demo/xlsx)
 

+ 13 - 10
demo/time/CMakeLists.txt

@@ -10,9 +10,9 @@ file(GLOB LOCAL_SRC
     ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/*.ui
 
-    ${CMAKE_SOURCE_DIR}/External/common/LightLog/*.cpp
-    ${CMAKE_SOURCE_DIR}/External/common/Logs/*.cpp
-    ${CMAKE_SOURCE_DIR}/External/common/ThreadPool/*.cpp
+    # ${CMAKE_SOURCE_DIR}/External/common/LightLog/*.cpp
+    # ${CMAKE_SOURCE_DIR}/External/common/Logs/*.cpp
+    # ${CMAKE_SOURCE_DIR}/External/common/ThreadPool/*.cpp
     
 )
 
@@ -30,12 +30,12 @@ add_executable(${this_exe}
 target_include_directories(${this_exe} PRIVATE
 
     ${CMAKE_CURRENT_SOURCE_DIR}
-    ${CMAKE_SOURCE_DIR}/External/common/LightLog
     ${CMAKE_SOURCE_DIR}/External/common
-    ${CMAKE_SOURCE_DIR}/External/common/FmtLog
-    ${CMAKE_SOURCE_DIR}/External/common/Timer
-    ${CMAKE_SOURCE_DIR}/External/common/ThreadPool
-    ${CMAKE_SOURCE_DIR}/External/common/RingQueue
+    # ${CMAKE_SOURCE_DIR}/External/common/FmtLog
+    # ${CMAKE_SOURCE_DIR}/External/common/ThreadPool
+
+    # ${fmt_INCLUDE_DIR}
+    ${spdlog_INCLUDE_DIR}
 )
 
 target_link_libraries(${this_exe} PRIVATE
@@ -48,9 +48,12 @@ target_link_libraries(${this_exe} PRIVATE
 )
 
 target_link_libraries(${this_exe} PRIVATE 
-    fmt::fmt
-    spdlog::spdlog
+    # fmt::fmt
+    # spdlog::spdlog
     ${CURL_LIBRARY}
+    # ${fmt_LIBRARY}
+    # ${spdlog_LIBRARY}
+    ${spdlog_STATIC_LIBRARY}
 )
 
 if(CMAKE_CXX_COMPILER_VERSION LESS 9.0)

+ 8 - 8
demo/time/main.cpp

@@ -1,10 +1,9 @@
-#include "widget.h"
 
 #include <QCoreApplication>
-#include "Logs/loginit.h"
+#include <thread>
+// #include "Logs/loginit.h"
 #include "spdlog/spdlog.h"
-#include "Timer/TWTimer.hpp"
-
+#include "FmtLog/fmtlog.h"
 
 
 
@@ -15,7 +14,7 @@ void printCPPTime()
     while(true)
     {
         std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
-        SPDLOG_INFO("C++风格的时间 间隔: {} us", std::chrono::duration_cast<std::chrono::microseconds>(now - lastTime).count());
+        // SPDLOG_INFO("C++风格的时间 间隔: {} us", std::chrono::duration_cast<std::chrono::microseconds>(now - lastTime).count());
         lastTime = now;
         count++;
         std::this_thread::sleep_for(std::chrono::milliseconds(1000));
@@ -29,7 +28,7 @@ void printCTime()
     while(true)
     {
         std::time_t now = std::time(nullptr);
-        SPDLOG_INFO("***** C风格的时间 间隔: {} us", std::difftime(now, lastTime));
+        // SPDLOG_INFO("***** C风格的时间 间隔: {} us", std::difftime(now, lastTime));
         lastTime = now;
         count++;
         std::this_thread::sleep_for(std::chrono::milliseconds(1000));
@@ -39,14 +38,15 @@ void printCTime()
 int main(int argc, char *argv[])
 {
     QCoreApplication a(argc, argv);
-    init_log();
+    FMTLOG_INFO("********** Time **********");
+    // init_log();
 
     SPDLOG_INFO("********** Time **********");
 
     // CPPTP.add_task(printCPPTime);
     // CPPTP.add_task(printCTime);
     auto now = std::time(nullptr);
-    SPDLOG_INFO("{}", std::ctime(&now));
+    // SPDLOG_INFO("{}", std::ctime(&now));
 
 
     return a.exec();

+ 0 - 54
demo/time/widget.cpp

@@ -1,54 +0,0 @@
-#include "widget.h"
-#include "./ui_widget.h"
-
-#include <QTimer>
-
-#include "spdlog/spdlog.h"
-#include "fmtlog.h"
-#include "LightLog.h"
-
-
-Widget::Widget(QWidget *parent)
-    : QWidget(parent)
-    , ui(new Ui::Widget)
-{
-    ui->setupUi(this);
-
-
-    SPDLOG_INFO("***** Qt Library *****");
-}
-
-Widget::~Widget()
-{
-
-    delete ui;
-}
-
-
-void Widget::on_pBtn_connect_clicked()
-{
-    SPDLOG_INFO("点击了“连接按钮”");
-    std::vector<std::string> list;
-}
-
-
-
-void Widget::on_pBtn_downloadFile_clicked()
-{
-    SPDLOG_INFO("点击了“下载文件”");
-
-}
-
-void Widget::on_pBtn_downloadVideo_clicked()
-{
-    SPDLOG_INFO("点击了“下载视频”");
-
-   
-}
-
-void Widget::on_pBtn_logSpeed_clicked()
-{
-    SPDLOG_INFO("点击了“日志速度”");
-    
-}
-

+ 0 - 32
demo/time/widget.h

@@ -1,32 +0,0 @@
-#ifndef WIDGET_H
-#define WIDGET_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-namespace Ui { class Widget; }
-QT_END_NAMESPACE
-
-class Widget : public QWidget
-{
-    Q_OBJECT
-
-public:
-    Widget(QWidget *parent = nullptr);
-    ~Widget();
-
-private slots:
-
-    void on_pBtn_connect_clicked();
-
-    void on_pBtn_downloadFile_clicked();
-
-    void on_pBtn_downloadVideo_clicked();
-
-    void on_pBtn_logSpeed_clicked();
-
-private:
-    Ui::Widget *ui;
-
-};
-#endif // WIDGET_H

+ 0 - 62
demo/time/widget.ui

@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Widget</class>
- <widget class="QWidget" name="Widget">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>800</width>
-    <height>600</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Widget</string>
-  </property>
-  <widget class="QWidget" name="widget_pBtn" native="true">
-   <property name="geometry">
-    <rect>
-     <x>30</x>
-     <y>30</y>
-     <width>681</width>
-     <height>311</height>
-    </rect>
-   </property>
-   <layout class="QGridLayout" name="gridLayout">
-    <item row="0" column="1">
-     <widget class="QPushButton" name="pBtn_downloadFile">
-      <property name="text">
-       <string>下载文件</string>
-      </property>
-     </widget>
-    </item>
-    <item row="0" column="0">
-     <widget class="QPushButton" name="pBtn_connect">
-      <property name="text">
-       <string>连接</string>
-      </property>
-     </widget>
-    </item>
-    <item row="2" column="0" colspan="2">
-     <widget class="QLineEdit" name="lineEdit"/>
-    </item>
-    <item row="1" column="0">
-     <widget class="QPushButton" name="pBtn_downloadVideo">
-      <property name="text">
-       <string>下载视频</string>
-      </property>
-     </widget>
-    </item>
-    <item row="1" column="1">
-     <widget class="QPushButton" name="pBtn_logSpeed">
-      <property name="text">
-       <string>日志速度对比</string>
-      </property>
-     </widget>
-    </item>
-   </layout>
-  </widget>
- </widget>
- <resources/>
- <connections/>
-</ui>