Loading CMakeList never finishes - cmake

I am currently working on a new project on Clion just been pulled from github repo. However, the CMakeList never seems to stop loading. This is what I get by debugging.
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
At this point it just stops there.

Related

CLion failing to detect C/C++ compiler ABI info

I have a custom toolchain for building projects. And by custom toolchain, I mean a derivative of the Clang C compiler, C++ compiler, and linker.
The project(s) build just fine, but I'm unable to use the Intellij features of CLion, because it can't build a tags database (or whatever it does under the hood) due to not being able to recognize the custom toolchain.
Thus, hitting Tools -> CMake -> Reset Cache and Reload Project spits out:
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=~/<path-to-custom-toolchain>/Toolchain.cmake -G "CodeBlocks - Unix Makefiles" /Users/<project-directory>/src
-- Setting up Toolchain 1.0 at /Users/<tools>/build
-- Setting up Toolchain 1.0 at /Users/<tools>/build
-- The C compiler identification is Clang 7.0.0
-- The CXX compiler identification is Clang 7.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - failed
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - failed
-- Configuring done
Screenshot of the preference options for the project (It's a link because I don't have the rep required to post images yet):
Project Preferences
So my question is, how should I go about solving this problem? Or does this problem exceed the limitations of CLion? Or do I have an incomplete understanding of the problem?

Why is CMake checking for the C++ compiler?

I would like to build a minimal example to build a C program. I used this CMakeLists.txt file:
cmake_minimum_required(VERSION 3.6)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
#set(CMAKE_CXX_COMPILER "arm-none-eabi-g++")
set(CMAKE_EXE_LINKER_FLAGS "--specs=nosys.specs" CACHE INTERNAL "")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
project("funambule")
list(
APPEND src
main.c
)
add_executable(
funambule
${src}
)
When I run cmake .. CMake absolutely want to check the C++ compiler even though I don't need one. How can I prevent it to do this useless check?
-- The C compiler identification is GNU 5.4.1
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /cygdrive/c/Users/NoOne/Home/bin/arm-none-eabi-gcc
-- Check for working C compiler: /cygdrive/c/Users/NoOne/Home/bin/arm-none-eabi-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/CC
-- Check for working CXX compiler: /usr/bin/CC -- broken
...
This is the default behaviour of CMake. To change it, you should specify language for your project using:
project(<PROJECT-NAME> [LANGUAGES])
From CMake documentation:
Optionally you can specify which languages your project supports. Example languages are C, CXX (i.e. C++), Fortran, etc. By default C and CXX are enabled if no language options are given. Specify language NONE, or use the LANGUAGES keyword and list no languages, to skip enabling any languages.

Checking for CMake Variables

I have the following CMake code snippet in my CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
message(STATUS "Before setting - ${MY_VARIABLE}")
# first check
if(NOT DEFINED ${MY_VARIABLE})
set(MY_VARIABLE true)
endif(NOT DEFINED ${MY_VARIABLE})
message(STATUS "After setting - ${MY_VARIABLE}")
# second check
if(NOT DEFINED ${MY_VARIABLE})
message(STATUS "What - ${MY_VARIABLE}")
endif(NOT DEFINED ${MY_VARIABLE})
The output from CMake configuration is:
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/local/bin/cc
-- Check for working C compiler: /usr/local/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/c++
-- Check for working CXX compiler: /usr/local/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Before setting -
-- After setting - true
-- What - true
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/build
Question:
Why does the second check for variable definition report the variable is not defined even though it is defined? Surprisingly, the value of the variable is also printed correctly!
There is a difference between: if(NOT DEFINED VAR_NAME) and if(NOT DEFINED ${VAR_NAME})
The first one refers to the variable and the other to its content.

CMake STREQUAL returning false when it shouldn't

I am trying to compare the CMAKE_CXX_COMPILER_ID to expected IDs to set flags and such, but cmake is giving some pretty weird behavior. I am trying to do this:
message("Compiler ID: '${CMAKE_CXX_COMPILER_ID}'")
if ("${CMAKE_CXX_COMIPLER_ID}" STREQUAL "GNU")
message("Using GNU")
set(warnings "-Wall")
set(options "-std=c++11")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(warnings "/W4 /XW /EHsc")
else ()
message("wtf")
endif()
And I get the output:
-- The C compiler identification is GNU 5.1.0
-- The CXX compiler identification is GNU 5.1.0
-- Check for working C compiler: /usr/sbin/cc
-- Check for working C compiler: /usr/sbin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/sbin/c++
-- Check for working CXX compiler: /usr/sbin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Compiler ID: 'GNU'
wtf
So apparently the compiler id is "GNU", but STREQUAL with "GNU" is false. Similar questions involve an out-of-date cache, but I have cleared it, so I don't think that is my issue. Any Ideas? Thanks.
There is a typo:
if ("${CMAKE_CXX_COMIPLER_ID}" STREQUAL "GNU")
Should be
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")

cmake loads cpu without any effect

Recently I've started using cmake instead of creating make-files manually. Moreover I use kdevelop as an IDE. So, I created simple cmake project with kdevelop. It builds and executes successfully. But the thing is that when I try to run cmake from terminal (without kdevelop involved in the process) I see that cmake just loads the cpu as high as possible and there is no result for about half an hour. I couldn't wait more so I've just kill the process.
Here is my cmake file:
project(robot)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_BUILD_TYPE Debug)
include_directories(include)
add_library(mylib SHARED mylibsrc/mylib.cpp)
Here is how kdevelop starts runs cmake:
/home/sergey/projects/project-test/build> /usr/bin/cmake -DCMAKE_BUILD_TYPE=Debug /home/sergey/projects/project-test/
-- The C compiler identification is GNU 4.7.2
-- The CXX compiler identification is GNU 4.7.2
-- Check for working C compiler: /home/sergey/bin/gcc
-- Check for working C compiler: /home/sergey/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /home/sergey/bin/c++
-- Check for working CXX compiler: /home/sergey/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sergey/projects/project-test/build
I try to run cmake in same way but all I receive is the highest possible cpu load.
kdevelop version - 4.8.4
cmake version - 2.8.9
Can you advice anything about that?
Sorry for my broken English.
You can try adding the --trace option to the cmake call. The problem will still exist, but at least you should see then what is taking so long and can then further investigate. The --debug-output option might also help.
/usr/bin/cmake -DCMAKE_BUILD_TYPE=Debug --trace --debug-output /home/sergey/projects/project-test/