SFML: CMake install error on Windows

Subject of the issue

I try to embed SFML in a flutter package for audio recording from microphone.

During, development I used SFML_DIR which worked OK.

Now, I need to improve my build setup with FetchContent usage to allow users (i.e. other developers) to not setup manually SFML for each of their app. I can’t include built SFML in my publications, all the packages are built from the root app by adding the dependency.

The actual issue: At install step, it seems that generated expression is not correctly evaluated: $<TARGET_FILE_DIR:myapp> Erasing cmake_install.cmake content makes build achieve the goal.

Your environment

  • Windows 10 / CMake 3.22
  • SFML 2.5.1 or 2.6 9842c8fdf84208222c71f098bb65c48293efa930
  • VS 2022

Steps to reproduce

Here's my CMakeLists.txt for the package
cmake_minimum_required(VERSION 3.14)
set(PROJECT_NAME "record_windows")
project(${PROJECT_NAME} LANGUAGES CXX)

# This value is used when generating builds using this plugin, so it must
# not be changed
set(PLUGIN_NAME "record_windows_plugin")

add_library(${PLUGIN_NAME} SHARED
  "record_windows.h"
  "record_windows.cpp"
  "record_windows_plugin.cpp"
)

apply_standard_settings(${PLUGIN_NAME})

set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
target_include_directories(${PLUGIN_NAME} INTERFACE
  "${CMAKE_CURRENT_SOURCE_DIR}/include"
)

# Add SFML
set(SFML_BUILD_GRAPHICS FALSE)
set(SFML_BUILD_NETWORK FALSE)
set(SFML_BUILD_WINDOW FALSE)

include(FetchContent)

FetchContent_Declare(
 sfml
 GIT_REPOSITORY https://github.com/SFML/SFML.git
 GIT_TAG 2.5.1
)

FetchContent_MakeAvailable(sfml)
# END Add SFML

target_link_libraries(${PLUGIN_NAME} PRIVATE
  flutter
  flutter_wrapper_plugin
  sfml-audio
  sfml-system
)

set(SFML_OPENAL_DLL_NAME "${CMAKE_CURRENT_SOURCE_DIR}/bin/openal32.dll")

# List of absolute paths to libraries that should be bundled with the plugin
set(record_windows_bundled_libraries
  ""
  $<TARGET_FILE:sfml-audio>
  $<TARGET_FILE:sfml-system>
  ${SFML_OPENAL_DLL_NAME}
  PARENT_SCOPE
)

Setting a hardcoded CMAKE_INSTALL_PREFIX does not change anything.

Expected behavior

Install step should not block build of dependent application.

Actual behavior

17>------ Début de la génération : Projet : INSTALL, Configuration : Debug x64 ------ 17>-- Install configuration: “Debug” 17>-- Installing: C:/mypath/myapp/build/windows/$<TARGET_FILE_DIR:myapp>/./include 17>CMake Error at _deps/sfml-build/cmake_install.cmake:36 (file): 17> file INSTALL cannot make directory 17> “C:/mypath/myapp/build/windows/$<TARGET_FILE_DIR:myapp>/./include”: 17> Invalid argument. 17>Call Stack (most recent call first): 17> plugins/record_windows/cmake_install.cmake:37 (include) 17> cmake_install.cmake:72 (include)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (14 by maintainers)

Most upvoted comments

Yes, C:/Program Files (x86) and C:/Program Files need admin privileges, those are the locations where programs are typically installed.

It’s the CMake default, but in most cases it makes no sense and you’d want to change the CMAKE_INSTALL_DIR to a local directory.

All should be in the archive I gave you. _deps/sfml-build/cmake_install.cmake is available there.