CMake build - weird problem with a .ttf file

CMake build - weird problem with a .ttf file
0

#1

I’ve recently attempted migrating my C++ project to Cocos2d-x 1.17 and moving over from Visual Studio Community to VSCode + standalone Microsoft Visual C++ Build Tools with CMake.

I’ve been encountering a very frustrating problem:

In the “Resources” folder of my project, I have a “.ttf” that is being copied alongside other resources to the binary build folder.

Every time I re-build my application with:

cmake --build .

my build fails, to be precise the defined pre-build step:

cocos_copy_target_res(${APP_NAME} COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})

fails, because the .ttf file sitting there from my previous build cannot be deleted.
If I try to manually delete it, I get a message that “The action cannot be completed because the file is open in System”. (I’m on Windows 7)

I’ve tried looking it up with Process Explorer and indeed the process locking it out is either “System” or “crss.exe”.

No other resource files are locked out this way and all can be freely removed.

The .ttf file can only be deleted after a reboot, obviously rebooting my pc before every change to my code is not an option.

I’ve tried searching for similar problems, but all that turns up is either regarding installed system fonts (which this one is not) or involves a reboot or safe mode.

Anyone have any idea how could I try resolving this?

EDIT/UPDATE:

I’ve found someone having similar problem with something entirely unrelated to cocos2d-x, and it doesn’t look good:

I’d like to know if it’s possible to access a .ttf font in cocos2d-x somehow without using the actual file in resources folder. Or to exclude a specific file in resources from being copied over every time.