Does cmake file name or content support Chinese characters

CMake 3.22.0
1.If cmake file name contains Chinese characters, such as “中文工程_files.cmake”, there is error
Error information:
CMake Error at cmake/FileUtil.cmake:26 (include):
include could not find requested file:

???????_files.cmake

FileUtil.cmake:
function(ly_include_cmake_file_list file)

set(UNITY_AUTO_EXCLUSIONS)

include(${file})  --line 26
  1. Other errors
    The target name “Gem::???.Servers” is reserved or not valid for
    certain CMake features, such as generator expressions, and may result in
    undefined behavior.
  2. Cmake content with chinese
    Code Example:

    Add the project_name to global LY_PROJECTS_TARGET_NAME property

    file(READ “${CMAKE_CURRENT_LIST_DIR}/project.json” project_json)
    string(JSON project_target_name ERROR_VARIABLE json_error GET ${project_json} “project_name”)
    set_property(GLOBAL APPEND PROPERTY LY_PROJECTS_TARGET_NAME ${project_target_name})

If “project_target_name” contains Chinese characters, there is error, the printed project_target_name is ???.

What encoding are you using for the file? CMake should support it, but it will need to be in UTF-8, not any of the other encodings usually in use.

GBK encoding

Yes, CMake won’t support that literally in the file contents of any CMake source. You can hack around it by writing the hex to a file and then reading it into a variable with file(READ). This will allow you to do include(path/to/${nonutf8bytes}.cmake"). But this is obviously outside of the normal patterns; I recommend instead just using UTF-8 for your filenames here.

I have a related question about add_library.
CMake file which runs successfully:
cmake_minimum_required(VERSION 3.20)
project(my)
add_library(myproject_static STATIC MyProject/myproject.cpp)
add_executable(my Demo.cpp MyProject/myproject.h MyProject/myproject.cpp)

CMake file which has error:
cmake_minimum_required(VERSION 3.20)
project(my)
add_library(工程_static STATIC MyProject/myproject.cpp)
add_executable(my Demo.cpp MyProject/myproject.h MyProject/myproject.cpp)

error info:
CMake Error at D:\Code\CMakeLists.txt:3 (add_library):
The target name “工程_static” is reserved or not valid for certain CMake features, such as generator expressions, and may result in undefined behavior.

How to fix the error? Does the first param of add_library support chinese character?

I suspect the name of the target should be ASCII. You can set OUTPUT_NAME to rename the resulting library at least.