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:
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.
Cmake content with chinese
Code Example:
Add the project_name to global LY_PROJECTS_TARGET_NAME property
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?