From 0b683b9a8ef043371d5cbb2d9bf1057d821e6ec5 Mon Sep 17 00:00:00 2001 From: DevWiki Date: Mon, 30 Oct 2023 16:44:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=BC=94=E7=A4=BAdemo?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + WinDevice/CMakeLists.txt | 19 +++++++++++-------- WinDeviceDemo/WinDeviceDemo.cpp | 16 ++++++++++++++++ WinDeviceDemo/WinDeviceDemo.h | 8 ++++++++ 4 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 WinDeviceDemo/WinDeviceDemo.cpp create mode 100644 WinDeviceDemo/WinDeviceDemo.h diff --git a/.gitignore b/.gitignore index 5a23e7d..e1440ac 100644 --- a/.gitignore +++ b/.gitignore @@ -79,3 +79,4 @@ CMakeLists.txt.user* */out */lib */cmake* +*/build diff --git a/WinDevice/CMakeLists.txt b/WinDevice/CMakeLists.txt index 854ddcf..79b3951 100644 --- a/WinDevice/CMakeLists.txt +++ b/WinDevice/CMakeLists.txt @@ -27,6 +27,15 @@ if (ENABLE_UTF8_SOURCE) endif() endif() +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + # Debug 模式下的配置 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG") + set(LIBRARY_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/build/debug/lib") +else() + # Release 模式下的配置 + set(LIBRARY_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/build/release/lib") +endif() + # 使用通配符自动列举源文件 file(GLOB PROJECT_SOURCES src/*.cpp @@ -54,13 +63,8 @@ target_include_directories(WinDevice PRIVATE src ) -# 设置库文件输出目录相对于 WinDevice 项目的根目录 -set(LIB_OUTPUT_DIR "${CMAKE_SOURCE_DIR}/lib") -# 设置库的输出路径 -set_target_properties(WinDevice PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR} # 设置静态库输出路径 - LIBRARY_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR} # 设置动态链接库输出路径 -) +target_include_directories(WinDevice PUBLIC "${CMAKE_SOURCE_DIR}/src") +target_include_directories(WinDevice PRIVATE "${CMAKE_SOURCE_DIR}/include/third_lib") # 设置发布目录,例如 "install" 文件夹 set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/install") @@ -72,5 +76,4 @@ install(TARGETS WinDevice ) target_link_libraries(WinDevice PRIVATE dxguid) - target_compile_definitions(WinDevice PRIVATE -DWINDEVICE_EXPORTS) diff --git a/WinDeviceDemo/WinDeviceDemo.cpp b/WinDeviceDemo/WinDeviceDemo.cpp new file mode 100644 index 0000000..a675c1f --- /dev/null +++ b/WinDeviceDemo/WinDeviceDemo.cpp @@ -0,0 +1,16 @@ +// WinDeviceDemo.cpp: 定义应用程序的入口点。 +// + +#include "WinDeviceDemo.h" +#include "Video/ScreenManager.h" + +using namespace std; + +int main() +{ + cout << "Hello CMake." << endl; + + ScreenManager screenManager; + screenManager.UpdateDisplayInfo(); + return 0; +} diff --git a/WinDeviceDemo/WinDeviceDemo.h b/WinDeviceDemo/WinDeviceDemo.h new file mode 100644 index 0000000..9c11dee --- /dev/null +++ b/WinDeviceDemo/WinDeviceDemo.h @@ -0,0 +1,8 @@ +// WinDeviceDemo.h: 标准系统包含文件的包含文件 +// 或项目特定的包含文件。 + +#pragma once + +#include + +// TODO: 在此处引用程序需要的其他标头。