dcmtk 3.6.7 + vcpkg + cmake

main.cpp

#include <dcmtk/config/osconfig.h>   // make sure OS specific configuration is included first
#include <dcmtk/dcmdata/dctk.h>

int main() {
    OFString version = OFFIS_DCMTK_VERSION_STRING;
    std::cout << "Using DCMTK version " << version << std::endl;
    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.25)

project(core)

set(CMAKE_CXX_STANDARD 23)

set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(Boost_NO_WARN_NEW_VERSIONS 1)
set(CMAKE_NINJA_FORCE_RESPONSE_FILE "ON" CACHE BOOL "Force Ninja to use response files.")


find_package(spdlog REQUIRED)
find_package(asio CONFIG REQUIRED)
find_package(Crow CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(DCMTK CONFIG REQUIRED)
find_package(OpenCV REQUIRED)

find_package(VTK REQUIRED)
include("${VTK_USE_FILE}")
if (NOT VTK_FOUND)
  message(FATAL_ERROR "OffScreenRendering: Unable to find the VTK build folder.")
endif()


file(GLOB SRC_FILES core/src/*.cpp)
file(GLOB SRC_H_FILES core/src/*.h)

add_executable(core ${SRC_FILES} ${SRC_H_FILES})

if ("${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" STREQUAL "/")
    message(WARNING "No vcpkg install dir found, DCMTK definitions are not set")
else()
    target_compile_definitions(core
        PUBLIC
        "DCMTK_PREFIX=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}"
        "DCM_DICT_DEFAULT_PATH=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/dcmtk/dicom.dic:${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/dcmtk/private.dic"
        "DEFAULT_CONFIGURATION_DIR=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/etc/dcmtk/"
        "DEFAULT_SUPPORT_DATA_DIR=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/dcmtk/"
    )
endif()

target_link_libraries(core PRIVATE spdlog::spdlog_header_only asio::asio Crow::Crow nlohmann_json::nlohmann_json DCMTK::DCMTK DCMTK::oflog ${VTK_LIBRARIES} ${OpenCV_LIBS})

vtk_module_autoinit(
  TARGETS core
  MODULES ${VTK_LIBRARIES}
)

vcpkg.json

{
  "dependencies": [
    {
      "name": "spdlog",
      "version>=": "1.12.0"
    },
    {
      "name": "asio",
      "version>=": "1.28.2"
    },
    {
      "name": "crow",
      "version>=": "1.0-5"
    },
    {
      "name": "nlohmann-json",
      "version>=": "3.11.3"
    },
    {
      "name": "dcmtk",
      "version>=": "3.6.7"
    },
    {
      "name": "vtk",
      "version>=": "9.2.0-pv5.11.0#10"
    },
    {
      "name": "opencv",
      "version>=": "4.8.0"
    }
  ],
  "builtin-baseline": "9fd83fa98b5f2ae6188a6ba59a49837061db0a3a"
}

单独的CMakeLists.txt (用vcpkg可以不用)

cmake_minimum_required(VERSION 3.5)
project(MyDCMTKProject)

# Setup the toolchain file from vcpkg

#set(CMAKE_CXX_STANDARD 11)
#set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Find package
find_package(DCMTK CONFIG REQUIRED)


add_executable(main main.cpp)

    if ("${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" STREQUAL "/")
        message(WARNING "No vcpkg install dir found, DCMTK definitions are not set")
    else()
        target_compile_definitions(main
            PUBLIC
                "DCMTK_PREFIX=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}"
                "DCM_DICT_DEFAULT_PATH=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/dcmtk/dicom.dic:${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/dcmtk/private.dic"
                "DEFAULT_CONFIGURATION_DIR=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/etc/dcmtk/"
                "DEFAULT_SUPPORT_DATA_DIR=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/dcmtk/"
        )
    endif()

target_link_libraries(main PRIVATE DCMTK::DCMTK DCMTK::oflog)
target_include_directories(main PRIVATE ${DCMTK_INCLUDE_DIRS})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值