debug test正常运行
This commit is contained in:
parent
5cce100311
commit
94c19cf117
2
DeviceManager/.gitignore
vendored
Normal file
2
DeviceManager/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/cmake-*
|
||||||
|
/output
|
@ -49,26 +49,41 @@ endif()
|
|||||||
|
|
||||||
target_link_libraries(DeviceManager PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
target_link_libraries(DeviceManager PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||||
|
|
||||||
|
set(WinDevice_INCLUDE_DIR "../WinDevice/output/include/")
|
||||||
|
set(WinDevice_THIRD_INCLUDE_DIR "../WinDevice/output/third_lib/")
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
# Debug 模式下,添加 WinDevice 项目作为子项目
|
set(WinDevice_LIB_DIR "../WinDevice/output/debug/")
|
||||||
add_subdirectory(../WinDevice WinDevice)
|
|
||||||
# 链接WinDevice项目
|
|
||||||
target_include_directories(DeviceManager PRIVATE
|
|
||||||
../WinDevice/src
|
|
||||||
include/third_lib
|
|
||||||
)
|
|
||||||
target_link_libraries(DeviceManager PRIVATE WinDevice)
|
|
||||||
else()
|
else()
|
||||||
# Release 模式下,链接 WinDevice 生成的库文件
|
set(WinDevice_LIB_DIR "../WinDevice/output/release/")
|
||||||
target_link_libraries(DeviceManager PRIVATE WinDevice)
|
|
||||||
# 在 Release 模式下,添加 WinDevice 的头文件路径
|
|
||||||
target_include_directories(DeviceManager PRIVATE
|
|
||||||
../WinDevice/lib
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
# 使用 find_library 查找动态库文件
|
||||||
|
find_library(WinDevice_LIB
|
||||||
|
NAMES WinDevice
|
||||||
|
HINTS ${WinDevice_LIB_DIR}
|
||||||
|
)
|
||||||
|
# 添加头文件目录
|
||||||
|
include_directories(${WinDevice_INCLUDE_DIR} ${WinDevice_THIRD_INCLUDE_DIR})
|
||||||
|
# 将找到的库链接到你的目标
|
||||||
|
target_link_libraries(DeviceManager PRIVATE ${WinDevice_LIB})
|
||||||
|
|
||||||
|
# if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
# # Debug 模式下,添加 WinDevice 项目作为子项目
|
||||||
|
# add_subdirectory(../WinDevice WinDevice)
|
||||||
|
# # 链接WinDevice项目
|
||||||
|
# target_include_directories(DeviceManager PRIVATE
|
||||||
|
# ../WinDevice/src
|
||||||
|
# include/third_lib
|
||||||
|
# )
|
||||||
|
# target_link_libraries(DeviceManager PRIVATE WinDevice)
|
||||||
|
# else()
|
||||||
|
# # Release 模式下,链接 WinDevice 生成的库文件
|
||||||
|
# target_link_libraries(DeviceManager PRIVATE WinDevice)
|
||||||
|
# # 在 Release 模式下,添加 WinDevice 的头文件路径
|
||||||
|
# target_include_directories(DeviceManager PRIVATE
|
||||||
|
# ../WinDevice/lib
|
||||||
|
# )
|
||||||
|
# endif()
|
||||||
|
|
||||||
## target_link_libraries(DeviceManager PRIVATE dxgi)
|
|
||||||
|
|
||||||
set_target_properties(DeviceManager PROPERTIES
|
set_target_properties(DeviceManager PROPERTIES
|
||||||
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
||||||
|
@ -27,13 +27,6 @@ if (ENABLE_UTF8_SOURCE)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# 使用通配符自动列举源文件
|
|
||||||
file(GLOB_RECURSE SOURCE_FILES "./src/*")
|
|
||||||
# 添加功能模块的源文件
|
|
||||||
add_library(WinDevice SHARED
|
|
||||||
${SOURCE_FILES}
|
|
||||||
)
|
|
||||||
|
|
||||||
# DirectX目录
|
# DirectX目录
|
||||||
set(Windows_Kits_DIR "C:\\Program Files (x86)\\Windows Kits\\10")
|
set(Windows_Kits_DIR "C:\\Program Files (x86)\\Windows Kits\\10")
|
||||||
set(Windows_Kits_Version "10.0.19041.0")
|
set(Windows_Kits_Version "10.0.19041.0")
|
||||||
@ -48,24 +41,33 @@ else()
|
|||||||
set(CMAKE_LIBRARY_ARCHITECTURE x86)
|
set(CMAKE_LIBRARY_ARCHITECTURE x86)
|
||||||
set(DirectX_SDK_LIB_DIR "${Windows_Kits_DIR}\\Lib\\${Windows_Kits_Version}\\um\\x86")
|
set(DirectX_SDK_LIB_DIR "${Windows_Kits_DIR}\\Lib\\${Windows_Kits_Version}\\um\\x86")
|
||||||
endif()
|
endif()
|
||||||
|
# 获取所有 DirectX 相关的库文件
|
||||||
|
file(GLOB DirectX_LIBS
|
||||||
|
"${DirectX_SDK_LIB_DIR}/d3d9.lib"
|
||||||
|
"${DirectX_SDK_LIB_DIR}/d3d10.lib"
|
||||||
|
"${DirectX_SDK_LIB_DIR}/d3d11.lib"
|
||||||
|
"${DirectX_SDK_LIB_DIR}/d3d12.lib"
|
||||||
|
"${DirectX_SDK_LIB_DIR}/dxgi.lib"
|
||||||
|
"${DirectX_SDK_LIB_DIR}/ddraw.lib"
|
||||||
|
)
|
||||||
|
|
||||||
|
# 使用通配符自动列举源文件
|
||||||
|
file(GLOB_RECURSE SOURCE_FILES "./src/*")
|
||||||
|
set(Third_Include_DIR "include/third_lib/")
|
||||||
|
# 添加功能模块的源文件
|
||||||
|
add_library(WinDevice SHARED
|
||||||
|
${SOURCE_FILES}
|
||||||
|
)
|
||||||
# 设置WinDevice库的包含目录
|
# 设置WinDevice库的包含目录
|
||||||
target_include_directories(WinDevice
|
target_include_directories(WinDevice
|
||||||
PUBLIC
|
PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>
|
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${DirectX_SDK_INCLUDE_DIR}
|
${DirectX_SDK_INCLUDE_DIR}
|
||||||
include/third_lib
|
${Third_Include_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# 链接 d3d 的 lib
|
# 链接 d3d 的 lib
|
||||||
target_link_libraries(WinDevice PRIVATE
|
target_link_libraries(WinDevice PRIVATE ${DirectX_LIBS})
|
||||||
"${DirectX_SDK_LIB_DIR}\\d3d9.lib"
|
|
||||||
"${DirectX_SDK_LIB_DIR}\\d3d10.lib"
|
|
||||||
"${DirectX_SDK_LIB_DIR}\\d3d11.lib"
|
|
||||||
"${DirectX_SDK_LIB_DIR}\\d3d12.lib"
|
|
||||||
"${DirectX_SDK_LIB_DIR}\\ddraw.lib"
|
|
||||||
"${DirectX_SDK_LIB_DIR}\\dxgi.lib")
|
|
||||||
|
|
||||||
# 创建 output 目录
|
# 创建 output 目录
|
||||||
set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/output)
|
set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/output)
|
||||||
@ -75,6 +77,12 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||||||
# Debug 模式下的配置
|
# Debug 模式下的配置
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG")
|
||||||
set(LIBRARY_OUTPUT_PATH "${OUTPUT_DIR}/debug")
|
set(LIBRARY_OUTPUT_PATH "${OUTPUT_DIR}/debug")
|
||||||
|
# 添加测试
|
||||||
|
add_executable(WinDeviceTest "src/main.cpp" ${SOURCE_FILES})
|
||||||
|
target_include_directories(WinDeviceTest
|
||||||
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>
|
||||||
|
PRIVATE ${Third_Include_DIR} ${DirectX_SDK_INCLUDE_DIR})
|
||||||
|
target_link_libraries(WinDeviceTest PRIVATE ${DirectX_LIBS})
|
||||||
else()
|
else()
|
||||||
# Release 模式下的配置
|
# Release 模式下的配置
|
||||||
set(LIBRARY_OUTPUT_PATH "${OUTPUT_DIR}/release")
|
set(LIBRARY_OUTPUT_PATH "${OUTPUT_DIR}/release")
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "x64-Debug",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"configurationType": "Debug",
|
|
||||||
"inheritEnvironments": [ "msvc_x64_x64" ],
|
|
||||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
|
||||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
|
||||||
"cmakeCommandArgs": "",
|
|
||||||
"buildCommandArgs": "",
|
|
||||||
"ctestCommandArgs": ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,7 +1,4 @@
|
|||||||
#ifndef STRING_UTIL_H
|
#include <string>
|
||||||
#define STRING_UTIL_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
|
|
||||||
@ -19,6 +16,3 @@ std::string Wchar2String(const WCHAR* input) {
|
|||||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
|
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
|
||||||
return converter.to_bytes(input);
|
return converter.to_bytes(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // STRING_CONVERSION_H
|
|
@ -1,10 +1,8 @@
|
|||||||
#include "ScreenManager.h"
|
#include "ScreenManager.h"
|
||||||
#include <Windows.h>
|
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
#include "spdlog/sinks/basic_file_sink.h"
|
|
||||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
|
||||||
#include "Utils/StringUtil.h"
|
#include "Utils/StringUtil.h"
|
||||||
#include "Utils/Log.h"
|
#include "Utils/Log.h"
|
||||||
|
#include <dxgi.h>
|
||||||
|
|
||||||
ScreenManager::ScreenManager()
|
ScreenManager::ScreenManager()
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <dxgi.h>
|
||||||
#include <Mmdeviceapi.h>
|
|
||||||
#include <dxgi1_6.h>
|
|
||||||
|
|
||||||
class ScreenManager
|
class ScreenManager
|
||||||
{
|
{
|
||||||
|
8
WinDevice/src/main.cpp
Normal file
8
WinDevice/src/main.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//
|
||||||
|
// Created by zyz on 2023/12/20.
|
||||||
|
//
|
||||||
|
#include "Video/ScreenManager.h"
|
||||||
|
int main() {
|
||||||
|
ScreenManager screenManager;
|
||||||
|
screenManager.UpdateDisplayInfo();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user