Following my question What can cause a CMake option not work? I attempted to find out whether there is any difference between using clean-all.cmake and manually deleting the build directory. After running clean-all, I still experience the option problem. When I remove the build subdirectory, I receive the error message below:
-- Looking for include file pthread.h
-- Looking for include file pthread.h - not found
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
CMake Error at /usr/local/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
/usr/local/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake-3.2/Modules/FindThreads.cmake:204 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
cmake/Dependencies.cmake:11 (find_package)
CMakeLists.txt:53 (include)
and the log file only contains:
Determining if files pthread.h exist failed with the following output:
Source:
/* */
#include <pthread.h>
int main(void){return 0;}
And, since that, the system keeps telling that error. So, it looks like there is a difference :) ; what is it? Is it possible that my CMakeLists.txt leads to some internal error?
PS: After having this permanent error, I started to look for its reason, building up my CMakeLists.txt again, starting with deleted build subdirectory.
At the beginning, I have
option (CLEAN_ALL "Make a cleanup before building" OFF)
later
if(CLEAN_ALL)
include(cmake/clean-all.cmake)
endif(CLEAN_ALL)
and the cmake file is
# clean-all.cmake
# Cleans all subdirectories in the build subdirectory
set(cmake_generated ${CMAKE_BINARY_DIR}/CMakeCache.txt
${CMAKE_BINARY_DIR}/cmake_install.cmake
${CMAKE_BINARY_DIR}/Makefile
${CMAKE_BINARY_DIR}/CMakeFiles
# Above this, the common directories, below the project-specific ones
${CMAKE_BINARY_DIR}/bin
${CMAKE_BINARY_DIR}/lib
${CMAKE_BINARY_DIR}/QtGUI
${CMAKE_BINARY_DIR}/test
)
foreach(file ${cmake_generated})
if (EXISTS ${file})
file(REMOVE_RECURSE ${file})
endif()
endforeach(file)
It looks like the error is reproducible: deleting build and switching the option ON, I receive the error mentioned. At the same time, with option OFF, it builds OK. Is there anything harmful with using that clean-all?