CMAKE 文件:
# CMakeList.txt: dcmstore 的 CMake 项目,在此处包括源代码并定义
# 项目特定的逻辑。
#
set(CMAKE_PREFIX_PATH "C:\\workshop\\dcmtk-3.6.7-win64-support-MD-iconv-msvc-17.0\\zlib-1.2.12")
list(APPEND CMAKE_PREFIX_PATH "C:/workshop/insall")
set(ZLIB_LIBRARY "C:\\workshop\\dcmtk-3.6.7-win64-support-MD-iconv-msvc-17.0\\zlib-1.2.12\\lib")
set(ZLIB_INCLUDE_DIR "C:\\workshop\\dcmtk-3.6.7-win64-support-MD-iconv-msvc-17.0\\zlib-1.2.12\\include")
message(STATUS "prefix path is ${CMAKE_PREFIX_PATH}")
find_library(varzlib_d zlib_d)
link_directories(${ZLIB_LIBRARY} )
link_directories(${ZLIB_INCLUDE_DIR} )
find_package(DCMTK CONFIG REQUIRED)
message(STATUS "DCMTK_LIBRARIES configuration: ${DCMTK_LIBRARIES}")
message(STATUS "DCM INCLUDE DIR: ${DCMTK_INCLUDE_DIRS}")
#list(APPEND CMAKE_LIBRARY_PATH ${DCMTK_LIBPATH})
include_directories(${DCMTK_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} )
# 将源代码添加到此项目的可执行文件。
add_executable (dcmstore "dcmstore.cpp" "dcmstore.h")
target_link_libraries(dcmstore LINK_PRIVATE ${varzlib_d} DCMTK::DCMTK)
#target_link_libraries(dcmstore ${DCMTK_LIBRARIES})
#target_link_libraries(dcmstore DCMTK::DCMTK)
if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET dcmstore PROPERTY CXX_STANDARD 20)
endif()
# TODO: 如有需要,请添加测试并安装目标。
问题: 使用Visual studio调试时,提示找不到dcmtk的动态库。
解决,通过launch.vs.json 配置DCMTK的dll地址:
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"name": "dcmstore.exe (dcmstore\\dcmstore.exe)",
"project": "CMakeLists.txt",
"projectTarget": "dcmstore.exe (dcmstore\\dcmstore.exe)",
"args": [
"4443"
],
"type": "default",
"env": { "PATH": "${env.PATH};C:/workshop/insall/bin/" }
}
]
}