# it seems to generate recursion and continue to print logs

**URL:** https://discourse.cmake.org/t/it-seems-to-generate-recursion-and-continue-to-print-logs/10601
**Category:** Usage
**Created:** [April 6, 2024, 3:01pm UTC](https://discourse.cmake.org/t/it-seems-to-generate-recursion-and-continue-to-print-logs/10601 "2024-04-06T15:01:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![zhenye-tang](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zhenye-tang/32/4475_2.png) [@zhenye-tang](https://discourse.cmake.org/u/zhenye-tang)
#### Post date: [April 6, 2024, 3:01pm UTC](https://discourse.cmake.org/t/it-seems-to-generate-recursion-and-continue-to-print-logs/10601/1 "2024-04-06T15:01:05Z")

</div>

Use `cmake ..` After the command, it seems to generate recursion and continue to print logs. Who can help me solve this problem? thanks

```auto
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/bin/cc

-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/bin/cc

-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/bin/cc

-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/bin/cc

-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/bin/cc

-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/bin/cc

```

My cmake script is as follows：

```auto
cmake_minimum_required(VERSION 3.10)
project(led_blink_mmu)

set(LINKER_SCRIPT_PATH ${CMAKE_CURRENT_LIST_DIR}/link.lds)
set(CMAKE_C_COMPILER "/usr/bin/arm-none-eabi-gcc")
set(CMAKE_ASM_COMPILER "/usr/bin/arm-none-eabi-gcc")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -march=armv7-a -nostdlib -O0")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=armv7-a")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T${LINKER_SCRIPT_PATH} -Wl,-Map=led_blink_mmu.map")

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

enable_language(C CXX ASM)

file(GLOB C_SOURCES *.c *.s)
include_directories(./)
# # Generate executable
add_executable(led_blink_mmu
        ${C_SOURCES}
)

```

---

<div class="post-metadata">

### Author: ![zhenye-tang](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zhenye-tang/32/4475_2.png) [@zhenye-tang](https://discourse.cmake.org/u/zhenye-tang)
#### Post date: [April 6, 2024, 3:06pm UTC](https://discourse.cmake.org/t/it-seems-to-generate-recursion-and-continue-to-print-logs/10601/2 "2024-04-06T15:06:43Z")

</div>

I found that putting `enable_language(C CXX ASM)` before `set(CMAKE_C_COMPILER "/usr/bin/arm-none-eabi-gcc")` would not be a problem. Why?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [April 6, 2024, 10:06pm UTC](https://discourse.cmake.org/t/it-seems-to-generate-recursion-and-continue-to-print-logs/10601/3 "2024-04-06T22:06:29Z")

</div>

All of those variables between `project()` and `enable_language()` should not be set by the project. They belong in a toolchain file. CMake will use that toolchain file in private sub-builds that it performs to interrogate the compiler to work out various details about it. Once you move all the `set(...)` calls to a toolchain file, you would add `-DCMAKE_TOOLCHAIN_FILE=/path/to/your/toolchain/file` to your `cmake` command line.

The `project()` call will enable the C and CXX languages by default. The toolchain file is read as part of the first call to `project()`. You can tell `project()` to enable a different set of languages using the `LANGUAGES` keyword, so you wouldn’t even need a separate `enable_languages()` call.

---

<div class="post-metadata">

### Author: ![zhenye-tang](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zhenye-tang/32/4475_2.png) [@zhenye-tang](https://discourse.cmake.org/u/zhenye-tang)
#### Post date: [April 15, 2024, 4:48am UTC](https://discourse.cmake.org/t/it-seems-to-generate-recursion-and-continue-to-print-logs/10601/4 "2024-04-15T04:48:59Z")

</div>

I found that the toolchain configuration needs to be put before the `project(led_blink_mmu)`
