Problem to Build with CMake

Hello experts,

today I changed a little detail in my CMakeLists.txt. Now I have the following CMake Error:

CMake Error at /usr/share/root/cmake/ROOTConfig-targets.cmake:26 (endforeach):
  endforeach An ENDFOREACH command was found outside of a proper FOREACH
  ENDFOREACH structure.  Or its arguments did not match the opening FOREACH
  command.
Call Stack (most recent call first):
  /usr/share/root/cmake/ROOTConfig.cmake:81 (include)
  event_extraction/CMakeLists.txt:14 (find_package)

Now I have no idea what the problem is and i can’t compile my algorithm.
But in the past 2 months the algorthm works fine with the CMakeLists.txt.
My CMakeLists.txt looks like this:

find_package(ROOT REQUIRED COMPONENTS Net)
include(${ROOT_USE_FILE}) 
include_directories(${ROOT_INCLUDE_DIRS})
target_link_libraries(event_extraction ${ROOT_LIBRARIES})

Best regards,
B.

Hi,
are you compiling this inside Athena?

No, i think with gcc centos7.

Is that all of your CMake configuration? What was the change after which you started having problems?

My only change in the txt-File was to add a other class. Also i think in the past month there was an update from ROOT. I added now the CMake.txt-File.

CMakeLists.txt (1.9 KB)

Alright, last question: what version of ROOT are you using (master’s HEAD from today, v6-10-02, other)?

I use the version v6-10-00

Can you post the contents of /usr/share/root/cmake/ROOTConfig-targets.cmake where the problem occurs?

i think the problem schould be in this part:

set(CMAKE_IMPORT_FILE_VERSION 1)

set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
  list(APPEND _expectedTargets ${_expectedTarget})
  if(NOT TARGET ${_expectedTarget})
    list(APPEND _targetsNotDefined ${_expectedTarget})
  endif()
  if(TARGET ${_expectedTarget})
    list(APPEND _targetsDefined ${_expectedTarget})
  endif()
endforeach()

Alright, this is the version of that file that I get when I compile:

# ROOTConfig-targets.cmake
set(CMAKE_IMPORT_FILE_VERSION 1)

# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
foreach(_expectedTarget ROOT::vectorDict ROOT::listDict ROOT::forward_listDict ROOT::dequeDict ROOT::mapDi
  list(APPEND _expectedTargets ${_expectedTarget})
  if(NOT TARGET ${_expectedTarget})
    list(APPEND _targetsNotDefined ${_expectedTarget})
  endif()
  if(TARGET ${_expectedTarget})
    list(APPEND _targetsDefined ${_expectedTarget})
  endif()
endforeach()

Somehow one line got deleted from your ROOT installation. Delete that file and build+install ROOT again, it should regenerate the correct file.

(the foreach line to be specific)

Yes the foreach-line is missing in my code. But I didn’t build ROOT. I took it from the epel-repository. After I reinstalled it nothing chanced and the line still missing. The only solution right now is to uncomment the endforeach()-line. Than I can compile my algorithm.

The installation present in the epel-repository is broken, you should report it to the maintainers.
If it is an option for you, you can download working pre-compiled ROOT binaries here, or you can even compile ROOT from source.

Okay thank you for your advice.

Only one question remaining: Can you maybe give me the whole foreach-line? It is cut off.

It’s not just the foreach line that’s missing. Here are the first lines of the file:

# Generated by CMake

if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
   message(FATAL_ERROR "CMake >= 2.6.0 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.6)
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------

# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)

# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
foreach(_expectedTarget ROOT::vectorDict ROOT::listDict ROOT::forward_listDict ROOT::dequeDict ROOT::mapDict ROOT::map2Dict ROOT::unordered_mapDict ROOT::multimapDict ROOT::multimap2Dict ROOT::unordered_multimapDict ROOT::setDict ROOT::unordered_setDict ROOT::multisetDict ROOT::unordered_multisetDict ROOT::complexDict ROOT::valarrayDict ROOT::coreconttestUnit ROOT::testTypeTraits ROOT::Cling ROOT::coremetaclingtestUnit ROOT::MultiProc ROOT::Rint ROOT::Thread ROOT::corethreadtestUnit ROOT::Imt ROOT::New ROOT::corebasetestUnit ROOT::Core ROOT::rmkdepend ROOT::MathCore ROOT::MathMore ROOT::Matrix ROOT::Minuit ROOT::Fumili ROOT::Physics ROOT::MLP ROOT::Quadp ROOT::Foam ROOT::Smatrix ROOT::SPlot ROOT::GenVector ROOT::Genetic ROOT::FFTW ROOT::Hist ROOT::testTProfile2Poly ROOT::testTHn ROOT::HistPainter ROOT::Spectrum ROOT::SpectrumPainter ROOT::Unfold ROOT::Hbook ROOT::Tree ROOT::TreePlayer ROOT::treetreeplayertestUnit ROOT::TreeViewer ROOT::RIO ROOT::testTBufferMerger ROOT::SQLIO ROOT::XMLIO ROOT::XMLParser ROOT::Net ROOT::RootAuth ROOT::Bonjour ROOT::Krb5Auth ROOT::SrvAuth ROOT::rootd ROOT::RLDAP ROOT::Gpad ROOT::Graf ROOT::Postscript ROOT::mathtext ROOT::GX11 ROOT::GX11TTF ROOT::ASImage ROOT::ASImageGui ROOT::Gviz ROOT::FITSIO ROOT::Graf3d ROOT::X3d ROOT::Eve ROOT::RGL ROOT::GLEW ROOT::FTGL ROOT::Gviz3d ROOT::Gui ROOT::Ged ROOT::FitPanel ROOT::GuiBld ROOT::GuiHtml ROOT::Recorder ROOT::SessionViewer ROOT::Proof ROOT::ProofPlayer ROOT::ProofDraw ROOT::ProofBench ROOT::pq2 ROOT::Html ROOT::EG ROOT::VMC ROOT::Geom ROOT::GeomBuilder ROOT::GeomPainter ROOT::root ROOT::minicern ROOT::MemStat ROOT::rootn.exe ROOT::roots.exe ROOT::ssh2rpd ROOT::xpdtest ROOT::root.exe ROOT::proofserv.exe ROOT::hadd ROOT::rootnb.exe ROOT::g2root ROOT::h2root ROOT::rootcling ROOT::PyROOT ROOT::JupyROOT ROOT::RMySQL ROOT::TMVA ROOT::TMVAGui ROOT::PyMVA)
  list(APPEND _expectedTargets ${_expectedTarget})
  if(NOT TARGET ${_expectedTarget})
    list(APPEND _targetsNotDefined ${_expectedTarget})
  endif()
  if(TARGET ${_expectedTarget})
    list(APPEND _targetsDefined ${_expectedTarget})
  endif()
endforeach()
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
  unset(_targetsDefined)
  unset(_targetsNotDefined)
  unset(_expectedTargets)
  set(CMAKE_IMPORT_FILE_VERSION)
  cmake_policy(POP)
  return()
endif()
if(NOT "${_targetsDefined}" STREQUAL "")
  message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
endif()
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)

oh okay i see. thank you.

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