3D Slicer Release Build Error (Variable Slicer_WC_LAST_CHANGED_DATE is expected to be defined in SlicerPackageAndUploadTarget)

Hello,

When I build Slicer in my Windows 11 Intel laptop using the following instructions as stated in Slicer website the I got the following error,
Instructions:

mkdir C:\D\S4R
cd /d C:\D\S4R
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 16 2019" -A x64 -DQt5_DIR:PATH=C:\Qt\5.15.2\msvc2019_64\lib\cmake\Qt5 C:\D\S4
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Release

The error is not immediate and it showed after four hours of building.
Thanks for any help.

ERROR:

CMake/LastConfigureStep/CMakeLists.txt:41 (include)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Error at CMake/SlicerPackageAndUploadTarget.cmake:118 (message):
    Variable Slicer_WC_LAST_CHANGED_DATE is expected to be defined.
  Call Stack (most recent call first):
    CMake/LastConfigureStep/CMakeLists.txt:41 (include)


  -- Configuring incomplete, errors occurred!
  See also "C:/Users/merts/Slicer-build/CMakeFiles/CMakeOutput.log".
  See also "C:/Users/merts/Slicer-build/CMakeFiles/CMakeError.log".
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Micro
soft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom buil
d for 'C:\Users\merts\CMakeFiles\64875fd35109041c8e0baea88f0c3fbf\Slicer-mk
dir.rule;C:\Users\merts\CMakeFiles\64875fd35109041c8e0baea88f0c3fbf\Slicer-
download.rule;C:\Users\merts\CMakeFiles\64875fd35109041c8e0baea88f0c3fbf\Sl
icer-update.rule;C:\Users\merts\CMakeFiles\64875fd35109041c8e0baea88f0c3fbf
\Slicer-patch.rule;C:\Users\merts\CMakeFiles\64875fd35109041c8e0baea88f0c3f
bf\Slicer-configure.rule;C:\Users\merts\CMakeFiles\64875fd35109041c8e0baea8
8f0c3fbf\Slicer-build.rule;C:\Users\merts\CMakeFiles\64875fd35109041c8e0bae
a88f0c3fbf\Slicer-forceconfigure.rule;C:\Users\merts\CMakeFiles\64875fd3510
9041c8e0baea88f0c3fbf\Slicer-install.rule;C:\Users\merts\CMakeFiles\6a457aa
83091fe4a6245d53ff14120bf\Slicer-complete.rule;C:\Users\merts\CMakeFiles\2e
18417901a880d0571e033b5beb779a\Slicer.rule;C:\D\S4\CMakeLists.txt' exited w
ith code 1. [C:\Users\merts\Slicer.vcxproj]

Thanks for report :pray:

Here are few questions to help understand what is happening.

Questions

Which version of Slicer source are you building against ?

Which version of CMake are you using ?

And what is the output of the following commands executed in the Slicer source tree:

$ git rev-parse --verify -q --short=7 HEAD
30d8416

$ git show -s --format=%ci 30d8416
2021-12-09 14:36:22 -0500

What is the output associated with the Regular Expression Explorer provided by the cmake-gui.exe corresponding to your version of CMake ? (Tools → Regular Expression Explorer)

image

Possible source of the regression

Regression could have been introduced in the following commit:

Background

The relevant code is here:

It then uses the CMake module SlicerMacroExtractRepositoryInfo.cmake

and uses the CMake function GIT_WC_INFO provided by FindGit.cmake and ultimately run the following to extract the date:

Hello,
I am using Slicer 4.11.20210226, and CMake 3.22.1
When you mean slicer source tree which place do mean exactly?

In CMake GUI, I see empty screen in the Tools/Regular Expression Explorer, you can see my screen in the below.

Regarding Links you provided, how are they related with the issue I experience?

Thank you,

1

Slicer needs to extract date and time from the git log during build. Your build fails because this date&time is in an unexpected format, most likely due to your regional settings (how date&time is formatted). That’s why @jcfr asked to get the an example of a printout of the date from git, and then testing that in CMake’s regular expression explorer. The window is expected to be empty and you copy the content there.

@jcfr can you copy the regular expression that needs to be tested? (it would be error-prone to copy it from the screenshot)

I have changed date&time settings and rerun the build in debug mode this time, and issue persist.

Error Code:

 -- Setting 'CTEST_MODEL' variable with default value 'Experimental'
  -- Setting 'SLICER_PACKAGE_MANAGER_CLIENT_EXECUTABLE' variable with default value 'SLICER_PACKAGE_MANAGER_CLIENT_EXEC
  UTABLE-NOTDEFINED'
  -- Setting 'SLICER_PACKAGE_MANAGER_URL' variable with default value 'SLICER_PACKAGE_MANAGER_URL-NOTDEFINED'
  CMake Warning (dev) at CMake/SlicerMacroExtractRepositoryInfo.cmake:75 (message):
    Skipping repository info extraction: directory [C:/D/S4] is not a GIT or
    SVN checkout
  Call Stack (most recent call first):
    CMake/SlicerPackageAndUploadTarget.cmake:105 (SlicerMacroExtractRepositoryInfo)
    CMake/LastConfigureStep/CMakeLists.txt:41 (include)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Error at CMake/SlicerPackageAndUploadTarget.cmake:118 (message):
    Variable Slicer_WC_LAST_CHANGED_DATE is expected to be defined.
  Call Stack (most recent call first):
    CMake/LastConfigureStep/CMakeLists.txt:41 (include)


  -- Setting 'SLICER_PACKAGE_MANAGER_API_KEY' variable with default value 'OBFUSCATED'
  -- Configuring incomplete, errors occurred!
  See also "C:/Users/merts/Slicer-build/CMakeFiles/CMakeOutput.log".
  See also "C:/Users/merts/Slicer-build/CMakeFiles/CMakeError.log".
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241
,5): error MSB8066: Custom build for 'C:\Users\merts\CMakeFiles\64875fd35109041c8e0baea88f0c3fbf\Slicer-mkdir.rule;C:\U
sers\merts\CMakeFiles\64875fd35109041c8e0baea88f0c3fbf\Slicer-download.rule;C:\Users\merts\CMakeFiles\64875fd35109041c8
e0baea88f0c3fbf\Slicer-update.rule;C:\Users\merts\CMakeFiles\64875fd35109041c8e0baea88f0c3fbf\Slicer-patch.rule;C:\User
s\merts\CMakeFiles\64875fd35109041c8e0baea88f0c3fbf\Slicer-configure.rule;C:\Users\merts\CMakeFiles\64875fd35109041c8e0
baea88f0c3fbf\Slicer-build.rule;C:\Users\merts\CMakeFiles\64875fd35109041c8e0baea88f0c3fbf\Slicer-forceconfigure.rule;C
:\Users\merts\CMakeFiles\64875fd35109041c8e0baea88f0c3fbf\Slicer-install.rule;C:\Users\merts\CMakeFiles\6a457aa83091fe4
a6245d53ff14120bf\Slicer-complete.rule;C:\Users\merts\CMakeFiles\2e18417901a880d0571e033b5beb779a\Slicer.rule;C:\D\S4\C
MakeLists.txt' exited with code 1. [C:\Users\merts\Slicer.vcxproj]

Are you following the example of the build instructions for the location on the Slicer build folder? Are you using “C:/S4R” or “C:/Users/merts/Slicer-build/”? A longer initial build directory could lead to downstream issues.

^([0-9][0-9][0-9][0-9]\\-[0-9][0-9]\\-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [-+][0-9][0-9][0-9][0-9]).*

Copied from Slicer/CMake/FindGit.cmake#L118-L123

Yes, I follow the instructions there and I use C:\D\S4D to build debug release

2

3

I’m just noticing from your screenshots that your “where to build the binaries” is “C:/users/merts/Documents/Slicer_built” which doesn’t seem to match with “C:/D/S4D”. It’s indicating your build is going into your user location instead.

same error.
I have solved this problem now. I am using Slicer 4.13, CMake 3.21.4, VS2019.

@wang_yali Could you explain how did you solve the problem?

The solution is as follows:

  1. We change the variables _WC_LAST_CHANGED_DATE in FindGit.cmake file back to version 4.11

from
fb2196c03635de9e98e600c09eb628b
to
0eabfffa9dbf40a8f0da7f723e339d4
2. Open the SlicerMacroExtractRepositoryInfo.cmake
add set(${wc_info_prefix}_WC_LAST_CHANGED_DATE “0000-00-00”) in the file just like the 4.11v.

@mertsaner @wang_yali Could you both run the following commands in your Slicer source tree ?

Rational: With these results we will be able to update the build-system to properly work without having to do any manual replacement.

Commands to execute

Command 1:

git rev-parse --verify -q --short=7 HEAD

Command 2:

git show -s --format=%ci <output-of-command-1>

Command 3:

git --version

Example of output

To illustrate, here is what I get:

$ git rev-parse --verify -q --short=7 HEAD
fff83f9

$ git show -s --format=%ci fff83f9
2021-12-17 13:11:21 -0500

$ git --version
git version 2.22.0

@jcfr

Here is what I get:

PS C:\D\S4> git rev-parse --verify -q --short=7 HEAD
8eaa925
PS C:\D\S4> git show -s --format=%ci <output-of-command-1>
At line:1 char:26
+ git show -s --format=%ci <output-of-command-1>
+                          ~
The '<' operator is reserved for future use.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupported

PS C:\D\S4> git --version
git version 2.34.1.windows.1
PS C:\D\S4>

@jcfr Second one does not work and gives an error

I did not find any file named FindGit.cmake , Where is it?
Could you also copy the content that I need to change instead picture?

Here ,source folder.
“D:\D\S4\CMake\FindGit.cmake”
“D:\D\S4\CMake\SlicerMacroExtractRepositoryInfo.cmake”

$ git rev-parse --verify -q --short=7 HEAD
d8492ca

$ git show -s --format=%ci d8492ca
2021-12-21 22:15:05 +0800

$ git --version
git version 2.34.1.windows.1