QIICR / dcmqi

dcmqi (DICOM for Quantitative Imaging) is a free, open source C++ library for conversion between imaging research formats and the standard DICOM representation for image analysis results
https://qiicr.gitbook.io/dcmqi-guide/
BSD 3-Clause "New" or "Revised" License
242 stars 61 forks source link

Can not build outside of a git repo #387

Open blezek opened 4 years ago

blezek commented 4 years ago

Trying to build v 1.2.1 inside Docker, but gailed in super build of v1.2.1 when .git directory not copied.

-- Found Git: /usr/bin/git (found version "2.17.1")
-- Found Git: /usr/bin/git
-- Checking if building a release
-- Checking if building a release - no (found 0 tags)
CMake Error at /root/dependencies/dcmqi/CMake/FindGit.cmake:94 (message):
  Command " rev-parse --verify -q --short=7 HEAD" in directory
  /root/dependencies/dcmqi failed with output:

  fatal: not a git repository (or any of the parent directories): .git
fedorov commented 4 years ago

Interesting. Is this really critical? Can you just use the binaries for 1.2.1? Or check out that specific tag?

Off the top of my head, I don't know if this is fixable or not, some of those dependencies carry over from Slicer SEM.

If there is one person who knows the answer off the top of his head - it would be @jcfr!

blezek commented 4 years ago

@fedorov, it's not absolutely critical for our projects, but anyone checking out your source code would not be able to build dcmqi. I may swap to using the pre-built binaries, however, because we deploy to several different platforms it is always better to build from scratch.

jcfr commented 4 years ago

short answer

To be specific, out of source builds are supported. After checking out sources using git, it is possible to build the project in the directory of your choice.

What is not supported is to build the project downloading the pre-generated source archives associated with Github Release.

long answer

but anyone checking out your source code would not be able to build dcmqi

Checking out the source using git is expected to work, the following test confirms this:

git clone git@github.com:QIICR/dcmqi.git -b v1.2.1
~/Software/cmake-3.15.2-Linux-x86_64/bin/cmake -S dcmqi/ -B dcmqi-build
cmake --build dcmqi-build/ -- -j8
[...]
-- Checking if building a release
-- Checking if building a release - yes (found tags v1.2.1)
-- Configuring DCMQI version [1.2.1]
--   DCMQI_WC_REVISION [1e82977]
--   DCMQI_WC_TAG [v1.2.1]
--   DCMQI_WC_URL [git@github.com:QIICR/dcmqi.git]
[...]
[100%] Completed 'DCMQI'
[100%] Built target DCMQI

In your Dockerfile, I suggest you use ninja (for automatic build parallelization) and do the following:

RUN \
  git clone git@github.com:QIICR/dcmqi.git -b v1.2.1 && \
  cmake -G Ninja \
    -DCMAKE_BUILD_TYPE:STRING=Release \
    -DCMAKE_INSTALL_PREFIX:PATH=/path/to/install \
    -S dcmqi/ \
    -B dcmqi-build \
  && \
  cmake --build dcmqi-build/ && \
  cmake --build dcmqi-build/dcmqi-build --target install && \
  rm -rf dcmqi dcmqi-build

What does not work is building using the pre-generated source archive associated with GitHub release.

proposed solution

Update CMake/dcmqiVersion.cmake to do the following:

fedorov commented 4 years ago

Thank you for chiming in @jcfr!

but anyone checking out your source code would not be able to build dcmqi

@blezek my point is that you can currently build from a github checkout, and you have binaries for all platforms. So far no one raised a concern about not being able to build from a source package. Is it really critical to be able to build from those source packages?