The build settings are stored in the <proj_name>.cyprj file and not the <proj_name>.cyprj.<username> file. So, the settings are actually being applied to the project file itself and not the user file. You can open up the .cyprj file and search for this flag, you should be able to see it.
Let me know if I'm understanding your issue differently.
Hmm.. so why when I try delete all <proj_name>.cyprj.<username> files and build project using
"C:\Program Files (x86)\Cypress\PSoC Creator\4.3\PSoC Creator\bin\cyprjmgr.exe" -wrk "<path_to_proj>\<proj_name>.cywrk" -build command in the result I see:
Project 1 of 2: Pre-build Steps...
Project 1 of 2: Compiling...
arm-none-eabi-gcc.exe -mcpu=cortex-m0 -mthumb -I. -IGenerated_Source\PSoC4 -Wa,-alh=.\CortexM0\ARM_GCC_541\Debug/main.lst -g -D DEBUG -Wall -ffunction-sections -ffat-lto-objects -Os -c main.c -o .\CortexM0\ARM_GCC_541\Debug\main.o
arm-none-eabi-gcc.exe -mcpu=cortex-m0 -mthumb -I. -IGenerated_Source\PSoC4 -Wa,-alh=.\CortexM0\ARM_GCC_541\Debug/cyfitter_cfg.lst -g -D DEBUG -Wall -ffunction-sections -ffat-lto-objects -Os -c Generated_Source\PSoC4\cyfitter_cfg.c -o .\CortexM0\ARM_GCC_541\Debug\cyfitter_cfg.o
But when these files are included, I can build a project with the NDEBUG flag. It looks like without these additional config files (.<username>) project is building in the DEBUG mode by default.
Right click on your project > Configuration > Release if you want to change the configuration from Debug to Release mode. This configuration is what gets used during build. And like you already observed, it doesn't depend on any config files.
Please, Could you try this scenario in yours some project:
1. Change build configuration on Release (rebuild the project) <- on this step, build shall be correct (Release configuration)
2. After that delete all files with .<username> extension and build using <path_to_build_program>/cyprjmgr.exe -wrk "<path_to_proj>\ <proj_name>.cywrk" -build <- here build is incorrect (Debug configuration), despite of change build configuration to Release
Am I doing something wrong? I would like to delete those files because during working in a team on the same project with system version control, and nobody wants temporary files with some other username.