Skip to content

cmake --install . --prefix <some_path> failed in some cases #971

@vinser52

Description

@vinser52

Environment Information

  • UMF version (hash commit or a tag): main branch
  • OS(es) version(s): Ubuntu 22.04
  • cmake version : 3.22.1

Please provide a reproduction of the bug:

git clone https://github.com/oneapi-src/unified-memory-framework.git
cd unified-memory-framework
mkdir build && cd build
cmake .. \
    -DUMF_BUILD_EXAMPLES=OFF \
    -DUMF_BUILD_BENCHMARKS=OFF \
    -DUMF_BUILD_BENCHMARKS_MT=OFF \
    -DUMF_FORMAT_CODE_STYLE=OFF \
    -DUMF_DEVELOPER_MODE=ON \
    -DUMF_BUILD_SHARED_LIBRARY=ON \
    -DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON \
    -DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON \
    -DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON \
    -DUMF_BUILD_CUDA_PROVIDER=ON \
    -DUMF_BUILD_GPU_TESTS=OFF \
    -DUMF_BUILD_GPU_EXAMPLES=OFF \
    -DCMAKE_INSTALL_LOCAL_ONLY=TRUE

make -j$(nproc)

cmake --install . --prefix umf_install

How often bug is revealed:

Always when these two conditions are true:

  1. CMake version < 3.28
  2. The UMF_LEVEL_ZERO_INCLUDE_DIR is not specified and we fetch the Level Zero loader at the build time.

Actual behavior:

The cmake --install . --prefix umf_install fails with the following error:

-- Install configuration: "Release"
-- Installing: /workdir/umf_repo/build/umf_install/./include/level_zero/ze_api.h
-- Installing: /workdir/umf_repo/build/umf_install/./include/level_zero/ze_ddi.h
-- Installing: /workdir/umf_repo/build/umf_install/./include/level_zero/zes_api.h
-- Installing: /workdir/umf_repo/build/umf_install/./include/level_zero/zes_ddi.h
-- Installing: /workdir/umf_repo/build/umf_install/./include/level_zero/zet_api.h
-- Installing: /workdir/umf_repo/build/umf_install/./include/level_zero/zet_ddi.h
-- Installing: /workdir/umf_repo/build/umf_install/./include/level_zero/layers/zel_tracing_api.h
-- Installing: /workdir/umf_repo/build/umf_install/./include/level_zero/layers/zel_tracing_ddi.h
-- Installing: /workdir/umf_repo/build/umf_install/./include/level_zero/layers/zel_tracing_register_cb.h
-- Installing: /workdir/umf_repo/build/umf_install/./include/level_zero/loader/ze_loader.h
-- Installing: /workdir/umf_repo/build/umf_install/lib/libze_loader.so.1.19.2
-- Installing: /workdir/umf_repo/build/umf_install/lib/libze_loader.so.1
-- Installing: /workdir/umf_repo/build/umf_install/lib/libze_loader.so
CMake Error at _deps/level-zero-loader-build/source/cmake_install.cmake:99 (file):
  file cannot create directory: /usr/local/lib/pkgconfig.  Maybe need
  administrative privileges.
Call Stack (most recent call first):
  _deps/level-zero-loader-build/cmake_install.cmake:70 (include)
  cmake_install.cmake:47 (include)

Expected behavior:

The cmake --install . --prefix umf_install succeed.

Details

The root cause of the issue is the following:

  1. The macro FetchContent_MakeAvailable, used to fetch L0 loader, includes a subproject using the add_subdirectory command. As a result the L0 loader added as a subproject. And it is added to the installation rules, but it should not because we do not want to install L0 as a part of UMF installation.
  2. When we call FetchContent_MakeAvailable macro the EXCLUDE_FROM_ALL argument is provided which should fix the issue. But it was added in version 3.28. That is why the issue is reproduced only with cmake < 3.28. I caught the issue with cmake 3.22.1 on one machine, but it works with cmake 3.30.2 on another.

There is a discussion on StackOverflow about the same issue. It describes, as a possible solution for cmake < 3.28, exactly what we had in the past in our cmake config:

FetchContent_GetProperties(level-zero-loader)
if(NOT level-zero-loader_POPULATED)
    FetchContent_Populate(level-zero-loader)
endif()

But we switched to the FetchContent_MakeAvailable macro because the FetchContent_Populate is deprecated (see #734 and #814).

Additional information about Priority and Help Requested:

Are you willing to submit a pull request with a proposed change? No. I do not know what is the right solution.

Requested priority: (Showstopper, High, Medium, Low)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions