I have a tiny library with its own cmake file. I am trying to add this library to the platformio ploject. I create a "CMakeListsUser.txt" and add this line "add_subdirectory(GLibc)" here and when I reload the cmake project I get an infinite loop.
I use cmake version 3.26.0-rc1
CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)
project("project" C CXX)
include(CMakeListsPrivate.txt)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsUser.txt)
include(CMakeListsUser.txt)
endif()
add_custom_target(
Production ALL
COMMAND platformio -c clion run "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(
Debug ALL
COMMAND platformio -c clion debug "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_executable(Z_DUMMY_TARGET ${SRC_LIST})
CMakeListsUser.txt
add_subdirectory(GCLib)
SET(CMAKE_C_COMPILER "${ENV_HOME_PATH}/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc.exe")
SET(CMAKE_CXX_COMPILER "${ENV_HOME_PATH}/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-g++.exe")
SET(CMAKE_CXX_FLAGS "-Wno-frame-address -std=gnu++11 -fexceptions -fno-rtti -mlongcalls -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -MMD")
SET(CMAKE_C_FLAGS "-Wno-frame-address -std=gnu99 -Wno-old-style-declaration -mlongcalls -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -MMD")
Library cmake file:
cmake_minimum_required(VERSION 3.24)
project("GCLib" VERSION 1.0.0 LANGUAGES C CXX DESCRIPTION "Library for C++")
set(PROJECT_PREFIX GCLib-${GCLib_VERSION})
include(CMakeListsOptions.txt)
include(CMakeListsFiles.txt)
add_library(GCLib
${HEADER_FILES}
${SOURCE_FILES})
add_library(GCLib::GCLib ALIAS GCLib)
target_include_directories(GCLib
PUBLIC
$<BUILD_INTERFACE:${GCLib_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_PREFIX}>
PRIVATE
src)
export(PACKAGE GCLib)
Terminal:
> cmake.exe -DCMAKE_BUILD_TYPE=esp32doit-devkit-v1 "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2022.3.2/bin/ninja/win/x64/ninja.exe" -G Ninja -S C:\Users\Me\CLionProjects\GInvertor -B C:\Users\Me\CLionProjects\GInvertor\cmake-build-esp32doit-devkit-v1
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Tiny mode is enable
-- 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= C:/Program Files/JetBrains/CLion 2022.3.2/bin/mingw/bin/gcc.exe
CMAKE_CXX_COMPILER= C:/Program Files/JetBrains/CLion 2022.3.2/bin/mingw/bin/g++.exe
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Tiny mode is enable
-- 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= C:/Program Files/JetBrains/CLion 2022.3.2/bin/mingw/bin/gcc.exe
CMAKE_CXX_COMPILER= C:/Program Files/JetBrains/CLion 2022.3.2/bin/mingw/bin/g++.exe
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Tiny mode is enable
-- 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= C:/Program Files/JetBrains/CLion 2022.3.2/bin/mingw/bin/gcc.exe
CMAKE_CXX_COMPILER= C:/Program Files/JetBrains/CLion 2022.3.2/bin/mingw/bin/g++.exe
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Tiny mode is enable
-- 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= C:/Program Files/JetBrains/CLion 2022.3.2/bin/mingw/bin/gcc.exe
CMAKE_CXX_COMPILER= C:/Program Files/JetBrains/CLion 2022.3.2/bin/mingw/bin/g++.exe
Cmake changed the CMAKE_CXX_COMPILER variable, but it shouldn't.
When I remove add_subdirectory(GLibc)
from CMakeListsUser.txt everything works perfectly
How can I fix this? Sorry, but I'm new to cmake