An issue in my CMakeLists.txt

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

_Geant4 Version:_11.2.1
_Operating System:_Windows 10
_Compiler/Version:_Visual Studio 2022/17.10
_CMake Version:_3.29.3


Dear all,
I prepared a small project and it runs perfectly. Then, I changed my device and reinstalled geant4 and all simple examples, B1, B2, etc. work correctly and get results and geometry. However, my prepared project does not work due to the following message:

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:4 (project)
Configuring incomplete, errors occurred!

My CMakeLists.txt is attached.

All other examples work correctly

Any help to fix the issue is highly appreciated.
CMakeLists.txt (475 Bytes)

Is there are other output before this? If failure is happening at the project call, then this is usually a symptom of a compiler/system setup issue. It certainly works fine locally on a macOS machine, so there’s nothing fundamentally wrong with the script.

Thank you for your response.

Yes, The full message is:

"
Error message
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.

Update the VERSION argument value or use a … suffix to tell
CMake that the project does not need compatibility with older versions.

Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
The C compiler identification is MSVC 19.40.33811.0
The CXX compiler identification is MSVC 19.40.33811.0
Detecting C compiler ABI info
Detecting C compiler ABI info - failed
Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe
Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.29/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler

"C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: 'C:/Users/morad.hamad/Geant4/geant4-v11.2.1/11.2.1/share/Geant4/examples/Research Project/StepsByStepConstruction/5-CollimatorsAndDetector/build/CMakeFiles/CMakeScratch/TryCompile-77tv00'

Run Build Command(s): "C:/Program Files/Microsoft Visual Studio/2022/Professional/MSBuild/Current/Bin/amd64/MSBuild.exe" cmTC_5a0ab.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:n
MSBuild version 17.10.4+10fbfbf2e for .NET Framework

Build started 8/3/2024 8:12:38 PM.



Project "C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj" on node 1 (default targets).

PrepareForBuild:

  Creating directory "cmTC_5a0ab.dir\Debug\".

  Structured output is enabled. The formatting of compiler diagnostics will reflect the error hierarchy. See https://aka.ms/cpp/structured-output for more details.

  Creating directory "C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\Debug\".

  Creating directory "cmTC_5a0ab.dir\Debug\cmTC_5a0ab.tlog\".

InitializeBuildStatus:

  Creating "cmTC_5a0ab.dir\Debug\cmTC_5a0ab.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.

  Touching "cmTC_5a0ab.dir\Debug\cmTC_5a0ab.tlog\unsuccessfulbuild".

ClCompile:

  C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64\CL.exe /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_5a0ab.dir\Debug\\" /Fd"cmTC_5a0ab.dir\Debug\vc143.pdb" /external:W3 /Gd /TC /errorReport:queue "C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\testCCompiler.c"

  Microsoft (R) C/C++ Optimizing Compiler Version 19.40.33811 for x64

  Copyright (C) Microsoft Corporation.  All rights reserved.

  cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_5a0ab.dir\Debug\\" /Fd"cmTC_5a0ab.dir\Debug\vc143.pdb" /external:W3 /Gd /TC /errorReport:queue "C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\testCCompiler.c"

  testCCompiler.c

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003: The specified task executable "CL.exe" could not be run. System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.dir\Debug\cmTC_5a0ab.tlog'. [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at System.IO.FileSystemEnumerableIterator`1.CommonInit() [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at System.IO.Directory.GetFiles(String path, String searchPattern) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.Utilities.TrackedDependencies.ExpandWildcards(ITaskItem[] expand) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.Utilities.CanonicalTrackedOutputFiles.InternalConstruct(ITask ownerTask, ITaskItem[] tlogFiles, Boolean constructOutputsFromTLogs) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.CPPTasks.CL.PostExecuteTool(Int32 exitCode) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.CPPTasks.TrackedVCToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.CPPTasks.CL.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.Execute() [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

Done Building Project "C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj" (default targets) -- FAILED.



Build FAILED.



"C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj" (default target) (1) ->

(ClCompile target) -> 

  C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003: The specified task executable "CL.exe" could not be run. System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.dir\Debug\cmTC_5a0ab.tlog'. [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at System.IO.FileSystemEnumerableIterator`1.CommonInit() [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at System.IO.Directory.GetFiles(String path, String searchPattern) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.Utilities.TrackedDependencies.ExpandWildcards(ITaskItem[] expand) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.Utilities.CanonicalTrackedOutputFiles.InternalConstruct(ITask ownerTask, ITaskItem[] tlogFiles, Boolean constructOutputsFromTLogs) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.CPPTasks.CL.PostExecuteTool(Int32 exitCode) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.CPPTasks.TrackedVCToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.CPPTasks.CL.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(755,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.Execute() [C:\Users\morad.hamad\Geant4\geant4-v11.2.1\11.2.1\share\Geant4\examples\Research Project\StepsByStepConstruction\5-CollimatorsAndDetector\build\CMakeFiles\CMakeScratch\TryCompile-77tv00\cmTC_5a0ab.vcxproj]



    0 Warning(s)

    1 Error(s)



Time Elapsed 00:00:00.82

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)

Configuring incomplete, errors occurred!
"

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.