Issues in configuring software with VTK Dependency - Fails in VTK cmake files

I’ve been trying to configure and build ElmerFemGUI with VTK support, but it is failing when the VTK cmake files start looking for libGLEW.so. More specifically it actually has found the file, but it breaks in vtkDetectLibraryType.cmake:23.

The glew library is found at /usr/lib/x86_64-linux-gnu/libGLEW.so

 CMake Error at /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtkDetectLibraryType.cmake:23 (message):
   The `PATH` argument is required.
 Call Stack (most recent call first):
   /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/FindGLEW.cmake:19 (vtk_detect_library_type)
   /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/VTK-vtk-module-find-packages.cmake:256 (find_package)
   /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtk-config.cmake:150 (include)
   ElmerGUI/CMakeLists.txt:106 (FIND_PACKAGE)

 Configuring incomplete, errors occurred!
 See also "/zfs_pool/Engineering/elmerfem/build/CMakeFiles/CMakeOutput.log".
 See also "/zfs_pool/Engineering/elmerfem/build/CMakeFiles/CMakeError.log".

I was able to track it down to some variable called vdlt. I tried performing tests to get it to print out the path, but I was getting blank messages. I was able to get the GLEW_LIBRARY variable to print the path in FindGlew.cmake. It seems to me that the path name is failing to be passed to vtk_detect_library_type, and I don’t know why. My attempts to debug this are among my first attempts to touch cmake, so I don’t really know what I’m doing.

How do I fix this?

9.1 may have had bugs, but I don’t see any fixes since then either. The code shows PATH is being passed "${GLEW_LIBRARY}"; I suspect this variable is empty. What value does it have in you build?

Tools that may help:

  • cmake --debug-find when configuring ElmerGUI
  • cmake --trace-expand when configuring ElmerGUI

I inserted a printout of ARGC, ARGV, and ARGN.

The resulting output is below, and below that is the result of using the flags you suggested. It appears that vtk_detect_library_type is recognizing the existence of three arguments. It recognizes PATH as one of the arguments. VIM automatically gives it special font as if it is a recognized keyword or something similar. I also don’t know if keywords or reserved words are treated as arguments under normal conditions. Then there is the inclusion of

""
"PATH"
""

cmake_parse_arguments. I recognize that the idea is that “_PATH” will be added to the base name of some variable to create a new variable name, but many of the examples I have found online have structured that process a bit differently and often include the use of set().

 ARGC 3
 ARGV glew_library_type;PATH;/usr/lib/x86_64-linux-gnu/libGLEW.so
 ARGN PATH;/usr/lib/x86_64-linux-gnu/libGLEW.so
 CMake Error at /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtkDetectLibraryType.cmake:25 (message):
   The `PATH` argument is required.
 Call Stack (most recent call first):
   /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/FindGLEW.cmake:19 (vtk_detect_library_type)
   /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/VTK-vtk-module-find-packages.cmake:256 (find_package)
   /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtk-config.cmake:150 (include)
   ElmerGUI/CMakeLists.txt:106 (FIND_PACKAGE)

 Configuring incomplete, errors occurred!
 See also "/zfs_pool/Engineering/elmerfem/build/CMakeFiles/CMakeOutput.log".
 See also "/zfs_pool/Engineering/elmerfem/build/CMakeFiles/CMakeError.log".

Below is the output of cmake --debug-find --trace-expand starting at cmake_parse_arguments.

/usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtkDetectLibraryType.cmake(17):  cmake_parse_arguments(PARSE_ARGV 1 vdlt  PATH  )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(85):  foreach(arg_name vdlt  )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(86):  set(PARSE_ARGV_vdlt )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(89):  foreach(option 1 )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(90):  set(PARSE_ARGV_1 FALSE )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(93):  set(PARSE_ARGV_UNPARSED_ARGUMENTS )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(95):  set(insideValues FALSE )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(96):  set(currentArgName )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(99):  foreach(currentArg PATH; )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(100):  list(FIND _optionNames PATH optionIndex )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(101):  list(FIND _singleArgNames PATH singleArgIndex )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(102):  list(FIND _multiArgNames PATH multiArgIndex )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(104):  if(-1 EQUAL -1 AND -1 EQUAL -1 AND -1 EQUAL -1 )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(105):  if(insideValues )
/usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtkDetectLibraryType.cmake(112):  else()
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(113):  list(APPEND PARSE_ARGV_UNPARSED_ARGUMENTS PATH )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(133):  foreach(arg_name vdlt  1 )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(134):  set(PARSE_ARGV_vdlt  PARENT_SCOPE )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(134):  set(PARSE_ARGV_1 FALSE PARENT_SCOPE )
/zfs_pool/Engineering/elmerfem/cmake/Modules/CMakeParseArguments.cmake(136):  set(PARSE_ARGV_UNPARSED_ARGUMENTS PATH PARENT_SCOPE )
/usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtkDetectLibraryType.cmake(21):  message(ARGC 3 )
ARGC 3
/usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtkDetectLibraryType.cmake(22):  message(ARGV glew_library_type;PATH;/usr/lib/x86_64-linux-gnu/libGLEW.so )
ARGV glew_library_type;PATH;/usr/lib/x86_64-linux-gnu/libGLEW.so
/usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtkDetectLibraryType.cmake(23):  message(ARGN PATH;/usr/lib/x86_64-linux-gnu/libGLEW.so )
ARGN PATH;/usr/lib/x86_64-linux-gnu/libGLEW.so
/usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtkDetectLibraryType.cmake(24):  if(NOT DEFINED vdlt_PATH )
/usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtkDetectLibraryType.cmake(25):  message(FATAL_ERROR The `PATH` argument is required. )
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtkDetectLibraryType.cmake:25 (message):
  The `PATH` argument is required.
Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/FindGLEW.cmake:19 (vtk_detect_library_type)
  /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/VTK-vtk-module-find-packages.cmake:256 (find_package)
  /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtk-config.cmake:150 (include)
  ElmerGUI/CMakeLists.txt:106 (FIND_PACKAGE)


CMake Debug Log at /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/VTK-vtk-module-find-packages.cmake:256 (find_package):
  find_package considered the following paths for GLEW.cmake

    /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/patches/99/FindGLEW.cmake

  The file was found at

    /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/FindGLEW.cmake

  

Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtk-config.cmake:150 (include)
  ElmerGUI/CMakeLists.txt:106 (FIND_PACKAGE)


CMake Debug Log at ElmerGUI/CMakeLists.txt:106 (FIND_PACKAGE):
  find_package considered the following paths for VTK.cmake

    /zfs_pool/Engineering/elmerfem/cmake/Modules/FindVTK.cmake
    /usr/share/cmake-3.22/Modules/FindVTK.cmake
    /zfs_pool/Engineering/elmerfem/ElmerGUI/cmake/Modules/FindVTK.cmake
    /usr/share/cmake-3.22/Modules/FindVTK.cmake

  The file was not found.

    /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/VTKConfig.cmake
    /usr/lib/x86_64-linux-gnu/cmake/vtk-9.1/vtk-config.cmake



CMake Debug Log at ElmerGUI/CMakeLists.txt:106 (FIND_PACKAGE):


-- Configuring incomplete, errors occurred!
See also "/zfs_pool/Engineering/elmerfem/build/CMakeFiles/CMakeOutput.log".
See also "/zfs_pool/Engineering/elmerfem/build/CMakeFiles/CMakeError.log".

I have figured out what the

""
"PATH"
"""

means.

I still went and replaced it with

  cmake_parse_arguments(PARSE_ARGV 1 vdlt 
          "${options}" 
          "${args}" 
          "${list_args}")

And the same output is obtained. ARGN still returns that PATH and the <path> are not parsed.

I have found a hacky way to get around the problem. That method is directly access the ARGN[1] via

  list(GET ARGN 1 ARGN1)
  message("ARGN1 = ${ARGN1}")
  set(vdlt_PATH ${ARGN1})

This obviously shouldn’t be necessary, but I can find no reason as to why cmake_parse_arguments does not parse the arguments properly in this situation. The arguments are clearly there, but they are not processing almost as if cmake itself has a bug (which I highly doubt).