Skip to content
GitLab
  • Explore
  • Sign in
  • Register
  • CMakeCMake
  • CMakeCMake
  • Issues
  • #24537

target_sources: CMake 3.26.0-rc4 refuses FILE_SET arguments

Hi,

I was trying to play with c++ modules with the new capabilities in CMake 3.26.0-rc4 but I got an error and I am not sure were the issue is. I was following this blog post.

The error:

CMake Error at ****/vcpkg/scripts/buildsystems/vcpkg.cmake:585 (_add_executable):
  Cannot find source file:

    FILE_SET

I opened an issue with vcpkg, but so far they are saying it is an issue with CMake so I am opening an issue here too.

That is what I do:

  add_executable(${targetNameTests})

  target_sources(${targetNameTests}
    PRIVATE
      ${ADD_TEST_TARGET_MAINFILE}
      ${ADD_TEST_TARGET_PRIVATEFILES}
      ${ADD_TEST_TARGET_TESTFILES}
    PUBLIC
      ${ADD_TEST_TARGET_PUBLICFILES}
      FILE_SET ${targetNameTests}_cxx_modules TYPE CXX_MODULES FILES ${ADD_TEST_TARGET_MODULEFILES}
      #FILE_SET ${targetNameTests}_cxx_header_unit TYPE CXX_MODULE_HEADER_UNITS FILES ${ADD_TEST_TARGET_HEADERUNITFILES}
    INTERFACE
      ${ADD_TEST_TARGET_INTERFACEFILES}
  )

Basically, the issue seems that executables refuse target_sources with FILESET of type CXX_MODULES ( I guess they would refuse CXX_MODULE_HEADER_UNITS also), I am pretty that is a bug with either CMake or vcpkg since if we are not allowed FILESET in executable that mean executable can't have c++ modules.

Thank you for your time!

Edited Feb 24, 2023 by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking