diff --git a/.ci/build/conda.py b/.ci/build/conda.py new file mode 100644 index 0000000..6bf5d62 --- /dev/null +++ b/.ci/build/conda.py @@ -0,0 +1,9 @@ +import subprocess +import sys + +conda = sys.argv[1] if len(sys.argv) >= 2 else "conda" + +subprocess.check_call([ + conda, "install", "--yes", "-c", "conda-forge", + "boost", "cmake", "dcmtk", "icu", "jsoncpp", "ninja", "pkg-config", + "pybind11", "zlib"]) diff --git a/.ci/build/post_build.py b/.ci/build/post_build.py index d2cf928..02be62f 100644 --- a/.ci/build/post_build.py +++ b/.ci/build/post_build.py @@ -35,11 +35,10 @@ os.environ["PYTHONPATH"] = os.pathsep.join([ *os.environ.get("PYTHONPATH", "").split(os.pathsep), python_lib_dir]) -os.environ |= { - "ODIL_OWN_AET": "LOCAL", - "ODIL_PEER_HOST_NAME": "127.0.0.1", - "ODIL_PEER_PORT": "11112", - "ODIL_PEER_AET": "REMOTE"} +os.environ["ODIL_OWN_AET"] = "LOCAL" +os.environ["ODIL_PEER_HOST_NAME"] = "127.0.0.1" +os.environ["ODIL_PEER_PORT"] = "11112" +os.environ["ODIL_PEER_AET"] = "REMOTE" os.environ["PATH"] = os.pathsep.join([ *os.environ["PATH"].split(os.pathsep), os.path.join(workspace, "tests/tools")]) diff --git a/.ci/deb/post_build b/.ci/deb/post_build deleted file mode 100755 index 58cbffc..0000000 --- a/.ci/deb/post_build +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -set -v - -export WORKSPACE=${WORKSPACE:?} -export BUILD_DIR="${WORKSPACE}/${BUILD_DIR:-build}" -export INSTALL_DIR="${WORKSPACE}/${INSTALL_DIR:-install}" - -PYTHON=$(awk -F= '$0 ~ /^PYTHON_EXECUTABLE:/ { print $2 }' ${BUILD_DIR}/CMakeCache.txt) - -export LD_LIBRARY_PATH=${INSTALL_DIR}/lib -export PYTHONPATH=${INSTALL_DIR}/$(${PYTHON} -c 'import os; import sysconfig; print(sysconfig.get_path("purelib", {"posix":"posix_prefix", "nt":"nt"}[os.name], {"base": "."}))') - -export ODIL_OWN_AET=LOCAL -export ODIL_PEER_HOST_NAME=127.0.0.1 -export ODIL_PEER_PORT=11112 -export ODIL_PEER_AET=REMOTE -export PATH=${WORKSPACE}/tests/tools:${PATH} - -cd "${WORKSPACE}/tests/data" -dcmqridx ./ dataset.dcm -dcmqrscp -ll error -c dcmqrscp.config 11112 & -sleep 1 - -cd "${BUILD_DIR}" - -ctest --output-on-failure -R1=$? - -${PYTHON} -m unittest discover -s ${WORKSPACE}/tests/wrappers/ -R2=$? - -kill %1 -cd "${WORKSPACE}/tests/data" -rm -f index.dat RAW_*.dcm - -RETURNCODE=$(if test ${R2} -gt ${R1}; then echo ${R2} ; else echo ${R1}; fi) -exit ${RETURNCODE} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b741dce..2278cb9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,16 +10,20 @@ jobs: fail-fast: false matrix: include: - - { os: "ubuntu-latest", container: "debian:bullseye", packaging: "apt", python: "python3" } - - { os: "ubuntu-latest", container: "debian:bookworm", packaging: "apt", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python3" } - - { os: "ubuntu-latest", container: "ubuntu:focal", packaging: "apt", python: "python3" } - - { os: "ubuntu-latest", container: "ubuntu:jammy", packaging: "apt", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python3" } + - { os: "ubuntu-latest", container: "debian:bullseye", packaging: "apt", python: "python3" } + - { os: "ubuntu-latest", container: "debian:bookworm", packaging: "apt", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python3" } + - { os: "ubuntu-latest", container: "ubuntu:focal", packaging: "apt", python: "python3" } + - { os: "ubuntu-latest", container: "ubuntu:jammy", packaging: "apt", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python3" } + - { os: "ubuntu-latest", packaging: "conda", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python" } # - name: "macOS 11 (Big Sur) + Homebrew" # os: macos-11 # ci_type: brew env: WORKSPACE: "${{ github.workspace }}" CMAKE_OPTIONS: "${{ matrix.cmake_options }}" + defaults: + run: + shell: ${{ contains(matrix.os, 'windows') && 'pwsh' || 'bash -l {0}' }} steps: - name: Provision (Debian, Ubuntu) # Install Python and Git. macOS workers already have this, however for @@ -29,6 +33,14 @@ jobs: DEBIAN_FRONTEND=noninteractive apt-get install -y git python3 if: ${{ contains(matrix.packaging, 'apt') }} + - name: Provision (Micromamba) + uses: mamba-org/setup-micromamba@v1 + with: + init-shell: bash powershell + environment-name: dicomifier + create-args: python=3.11 + if: ${{ contains(matrix.packaging, 'conda') }} + - name: Checkout latest revision uses: actions/checkout@v4 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 49c87da..f22cdc2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,7 @@ find_package(ICU REQUIRED COMPONENTS uc) find_package(JsonCpp REQUIRED) if(WITH_DCMTK) find_package(DCMTK REQUIRED) + find_package(ZLIB REQUIRED) endif() file(GLOB_RECURSE Header_Files "*.h") @@ -24,7 +25,7 @@ add_library(libodil ${Source_Files} ${Header_Files} ${templates}) target_compile_definitions( libodil PUBLIC - BOOST_ASIO_SEPARATE_COMPILATION ${DCMTK_DEFINITIONS} + BOOST_ASIO_SEPARATE_COMPILATION ODIL_VERSION_MAJOR=${Odil_VERSION_MAJOR} $<$:BOOST_ALL_DYN_LINK> $<$:BOOST_UUID_FORCE_AUTO_LINK> @@ -34,21 +35,22 @@ target_compile_definitions( target_include_directories( libodil PUBLIC - $ $ - "$<$:${DCMTK_INCLUDE_DIRS}>") + $ $) target_link_libraries( libodil PUBLIC Boost::date_time Boost::exception Boost::filesystem Boost::log - "$<$:${DCMTK_LIBRARIES}>" ICU::uc JsonCpp::JsonCpp $<$:netapi32> # WARNING Need to link with bcrypt explicitly, # cf. https://github.com/boostorg/uuid/issues/68#issuecomment-430173245 # Not sure why iphlpapi is not linked. "$<$:bcrypt;iphlpapi>") - +if(WITH_DCMTK) + target_link_libraries(libodil PUBLIC DCMTK::DCMTK ZLIB::ZLIB) +endif() + if(APPLE) # WARNING: Boost::log may add -licudata -licui18n -licuu, which cause # problems with macOS/brew diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d9f5278..c35993c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,7 @@ find_package( Boost COMPONENTS exception filesystem log unit_test_framework REQUIRED) find_package(DCMTK REQUIRED) +find_package(ZLIB REQUIRED) find_package(JsonCpp REQUIRED) add_subdirectory(tools) @@ -36,17 +37,16 @@ foreach(test_file ${tests}) target_compile_definitions( test_${test} PRIVATE - BOOST_ASIO_SEPARATE_COMPILATION ${DCMTK_DEFINITIONS} + BOOST_ASIO_SEPARATE_COMPILATION ODIL_VERSION_MAJOR=${Odil_VERSION_MAJOR} $<$:BOOST_ALL_DYN_LINK>) - target_include_directories( - test_${test} PRIVATE ${CMAKE_SOURCE_DIR}/src ${DCMTK_INCLUDE_DIRS}) + target_include_directories(test_${test} PRIVATE ${CMAKE_SOURCE_DIR}/src) target_link_libraries( test_${test} PRIVATE - Boost::unit_test_framework ${DCMTK_LIBRARIES} JsonCpp::JsonCpp + Boost::unit_test_framework DCMTK::DCMTK JsonCpp::JsonCpp ZLIB::ZLIB libodil $<$:Ws2_32>) diff --git a/tests/tools/CMakeLists.txt b/tests/tools/CMakeLists.txt index e3ec9c1..8be3184 100644 --- a/tests/tools/CMakeLists.txt +++ b/tests/tools/CMakeLists.txt @@ -1,14 +1,11 @@ find_package(DCMTK REQUIRED) - -add_definitions(${DCMTK_DEFINITIONS}) -include_directories(${DCMTK_INCLUDE_DIRS}) -link_directories(${DCMTK_LIBRARY_DIRS}) +find_package(ZLIB REQUIRED) file(GLOB headers *.h) file(GLOB files "*.cc") if(USE_BUILTIN_DCMTK_GETSCU) add_executable(dcmtk_getscu ${files} ${headers}) - target_link_libraries(dcmtk_getscu ${DCMTK_LIBRARIES}) + target_link_libraries(dcmtk_getscu DCMTK::DCMTK ZLIB::ZLIB) set_target_properties(dcmtk_getscu PROPERTIES OUTPUT_NAME getscu) endif()