fix: build for windows instruction
This commit is contained in:
parent
ccff2dde9a
commit
e92dcc54a8
@ -20,12 +20,15 @@ FILE(GLOB LIBRARY_SOURCES src/lib/*.cpp)
|
||||
FILE(GLOB WIN_SOURCES src/platform/win32_init.cpp)
|
||||
|
||||
if(WIN32)
|
||||
# windows executable
|
||||
add_executable(ncmdump_exec
|
||||
${COMMON_HEADERS}
|
||||
${COMMON_SOURCES}
|
||||
${EXECUTABLE_SOURCES}
|
||||
${WIN_SOURCES}
|
||||
)
|
||||
|
||||
# windows library
|
||||
add_library(ncmdump_lib SHARED
|
||||
${COMMON_HEADERS}
|
||||
${COMMON_SOURCES}
|
||||
@ -34,6 +37,11 @@ if(WIN32)
|
||||
${WIN_SOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(ncmdump_lib PRIVATE src/include)
|
||||
set_target_properties(ncmdump_lib PROPERTIES OUTPUT_NAME "libncmdump")
|
||||
target_link_libraries(ncmdump_lib TagLib::tag)
|
||||
|
||||
# msvc 需要额外调整编译选项
|
||||
if(MSVC)
|
||||
# 强制所有配置(Debug/Release 等)使用静态 C 运行时库
|
||||
foreach(flag_var
|
||||
@ -48,15 +56,8 @@ if(WIN32)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
target_include_directories(ncmdump_lib PRIVATE src/include)
|
||||
|
||||
target_compile_definitions(ncmdump_exec PRIVATE TAGLIB_STATIC)
|
||||
|
||||
set_target_properties(ncmdump_lib PROPERTIES OUTPUT_NAME "libncmdump")
|
||||
|
||||
target_link_libraries(ncmdump_lib TagLib::tag)
|
||||
|
||||
else()
|
||||
# linux / macOS executable
|
||||
add_executable(ncmdump_exec
|
||||
${COMMON_HEADERS}
|
||||
${COMMON_SOURCES}
|
||||
@ -68,7 +69,7 @@ endif()
|
||||
set_target_properties(ncmdump_exec PROPERTIES OUTPUT_NAME "ncmdump")
|
||||
target_include_directories(ncmdump_exec PRIVATE src/include)
|
||||
|
||||
# link to taglib
|
||||
# executable link to taglib
|
||||
target_link_libraries(ncmdump_exec TagLib::tag)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
@ -82,7 +83,6 @@ if(WIN32)
|
||||
else()
|
||||
install(TARGETS ncmdump_exec
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
endif()
|
||||
|
20
README.md
20
README.md
@ -83,21 +83,27 @@ git clone https://github.com/taurusxin/ncmdump.git
|
||||
|
||||
### Windows
|
||||
|
||||
Windows 下,首先使用 vcpkg 来安装 taglib 库,或者手动下载 taglib 的源码,参照[官方文档](https://github.com/taglib/taglib/blob/master/INSTALL.md#building-taglib-msvc)使用 CMake 来构建 taglib 库,当然还需要额外安装依赖。当然首选还是推荐使用 vcpkg 来管理依赖。
|
||||
首先需要安装 Visual Studio 2022 和 cmake,并安装 C++ 桌面开发环境,然后安装 [vcpkg](https://github.com/microsoft/vcpkg)
|
||||
|
||||
```shell
|
||||
# 安装 taglib 的静态库
|
||||
vcpkg install taglib:x64-windows-static
|
||||
# 安装 vcpkg 并安装 taglib 的静态库
|
||||
git clone https://github.com/microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.bat
|
||||
|
||||
# 配置项目,替换 %VCPKG_ROOT% 为你的 vcpkg 安装路径
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake -B build
|
||||
./vcpkg install taglib:x64-windows-static
|
||||
```
|
||||
|
||||
进入源码目录并配置项目
|
||||
|
||||
```shell
|
||||
# 使用 cmake 配置项目,替换 %VCPKG_ROOT% 为你的 vcpkg 安装路径
|
||||
cmake -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -B build
|
||||
|
||||
# 编译项目
|
||||
cmake --build build -j 8 --config Release
|
||||
```
|
||||
|
||||
手动编译 taglib 的方法参见[官方文档](https://github.com/taglib/taglib/blob/master/INSTALL.md#building-taglib),与 vcpkg 类似,使用 `cmake --install --prefix` 命令来指定安装 taglib 路径,最后在配置本项目时的 CMake 中指定 `CMAKE_PREFIX_PATH` 参数来指定 taglib 库的安装路径即可
|
||||
|
||||
### macOS / Linux
|
||||
|
||||
macOS 下,你可以使用 Homebrew 来安装 taglib 库,Linux 下,你可以使用 apt / pacman 等包管理器来安装 taglib 库
|
||||
|
Loading…
x
Reference in New Issue
Block a user