Skip to content

build error (and suggested fix). CMake has trouble with variables containing '/' characters #6

@geoffthorpe

Description

@geoffthorpe

I am encountering a build failure and, upon a little inspection, the issue seems to be here;

foreach(HEADER IN LISTS HEADERS_REQUIRED)
check_include_file(${HEADER} ${HEADER}_OK)
if(NOT ${HEADER}_OK)
message(FATAL_ERROR "header file ${HEADER} not found")
endif()
endforeach(HEADER)

In particular, the HEADERS_REQUIRED variable contains two files; libvdeplug.h and slirp/libslirp.h. It seems that the latter is the problem, because it has a '/' in the path, and using that as part of a variable name (as the second parameter to check_include_file, on line 31) fails on my version of CMake. The following hack allows the build to complete and the resulting tools seem to do what they're supposed to;

 foreach(HEADER IN LISTS HEADERS_REQUIRED)
-  check_include_file(${HEADER} ${HEADER}_OK)
-  if(NOT ${HEADER}_OK)
+  check_include_file(${HEADER} FOOBAR_OK)
+  if(NOT FOOBAR_OK)
     message(FATAL_ERROR "header file ${HEADER} not found")
   endif()
 endforeach(HEADER)

Here, the same result variable is used for each/every header detection, which seems reasonable because you're not remembering/using these detection results later on - the build fails immediately unless they're TRUE. Otherwise, I assume another strategy would be required for having per-header detection variables. The precise CMake rules on what variable names can and can't be is not very clear, but the guidance is to keep it to alphanumeric + '_' + '-'; https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#variables

BTW, this VDE stuff is awesome. Extremely useful. :-) Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions