nuttx/cmake
Ansh Rai 03876a22ae cmake: Sanitize NAME for _main symbol generation
Program names containing '-' (for example, renaming hello to
hello-world via PROGNAME) previously generated an invalid identifier
<NAME>_main when constructing the main= compiler definition and the
APP_MAIN target property used during builtin list generation. This
caused the CMake build to fail because '-' is not a valid character in
a C identifier.

This mirrors the Make-based fix (Application.mk's PROGSYM) for the
traditional build.

Introduce NAME_SYM, a sanitized copy of NAME with '-' replaced by '_',
and use it only where an internal C identifier is required: the
main= COMPILE_DEFINITIONS property and the APP_MAIN target property.
Leave NAME unchanged everywhere else, including CMake target/output
names and the APP_NAME property, where hyphens are valid.

The standalone/loadable executable path (MODULE/DYNLIB/kernel build)
does not rename main() and therefore requires no sanitization because
each executable is linked independently rather than merged into a
shared builtin image.

Testing (WSL2 Ubuntu, x86_64):
- BOARD_CONFIG=sim/nsh, CONFIG_EXAMPLES_HELLO_PROGNAME="hello-world":
  clean CMake configure/build; 'hello-world' runs and prints
  'Hello, World!!'
- Reverted to CONFIG_EXAMPLES_HELLO_PROGNAME="hello": reconfigured
  and rebuilt; 'hello' runs and prints 'Hello, World!!' (no
  regression)

Fixes #19447

Signed-off-by: Ansh Rai <anshrai331@gmail.com>
2026-07-17 13:04:26 -03:00
..
menuconfig.cmake cmake: add olddefconfig target for CMake builds 2026-04-02 13:16:54 +08:00
nuttx_3rdparty.cmake cmake: Moved the creation of the nxtmpdir folder to the root CMake file 2026-04-22 06:22:36 +08:00
nuttx_add_application.cmake cmake: Sanitize NAME for _main symbol generation 2026-07-17 13:04:26 -03:00
nuttx_add_dependencies.cmake style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
nuttx_add_library.cmake cmake(feat):define elf option and enable apps module build 2026-01-19 14:45:37 +08:00
nuttx_add_module.cmake cmake: migrate to SPDX identifier 2024-09-10 11:34:40 +08:00
nuttx_add_romfs.cmake cmake/romfs: invoke passwd helper scripts via POSIX shell 2026-07-09 22:41:11 +08:00
nuttx_add_subdirectory.cmake cmake: pass exclusion list to nuttx_add_subdirectory 2025-10-03 11:34:56 +08:00
nuttx_add_symtab.cmake style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
nuttx_create_symlink.cmake cmake: nuttx_create_symlink: Remove warning for CMP0205 2026-05-26 15:11:35 -03:00
nuttx_export_header.cmake cmake: migrate to SPDX identifier 2024-09-10 11:34:40 +08:00
nuttx_extensions.cmake cmake(enhance):cmake support DYNLIB build 2026-01-19 14:45:37 +08:00
nuttx_generate_headers.cmake style: Fix "the the" typo across the codebase. 2026-03-23 11:07:49 +01:00
nuttx_generate_outputs.cmake arch/tricore: Remove tasking compiler tool specific code from 2025-09-26 13:26:31 +02:00
nuttx_generate_sim_ld.cmake cmake:bugfix refine gen sim link script to independent cmake module 2024-09-15 10:01:07 +08:00
nuttx_kconfig.cmake cmake: Fix SIM_TOOLCHAIN using CMake on macOS. 2026-05-25 14:32:48 +02:00
nuttx_mkconfig.cmake cmake: Enhance .config handling and comparison logic 2026-02-26 09:46:02 -03:00
nuttx_mkversion.cmake cmake(bugfix):fix VERSION genarator strip error in CMake build 2025-06-18 15:45:30 -04:00
nuttx_multiple_link.cmake boards/arm/qemu: Fix KASAN global sections placement in linker script 2026-07-03 07:51:11 +02:00
nuttx_overrides.cmake cmake(bugfix):change default compile obj extension to .o 2026-01-27 20:54:26 +08:00
nuttx_parse_function_args.cmake cmake: migrate to SPDX identifier 2024-09-10 11:34:40 +08:00
nuttx_process_config.cmake cmake(enhance):include-style defconfig can modified via menuconfig 2026-01-15 15:42:17 -03:00
nuttx_redefine_symbols.cmake cmake: migrate to SPDX identifier 2024-09-10 11:34:40 +08:00
nuttx_remove_compile_options.cmake style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
nuttx_sethost.cmake tools/rust: Fix aarch64 NuttX Rust target specs 2026-05-29 10:25:10 +02:00
nuttx_source_file_properties.cmake cmake: migrate to SPDX identifier 2024-09-10 11:34:40 +08:00
nuttx_toolchain.cmake cmake/nuttx_toolchain.cmake: track preprocessed include deps 2026-06-04 17:22:43 +08:00
savedefconfig.cmake !build: add build-time password generation with mkpasswd tool. 2026-04-14 16:06:30 +08:00
symtab.c.in cmake: migrate to SPDX identifier 2024-09-10 11:34:40 +08:00