I have a head folder called Tutorial and sub folder called MathFunctions each having one code each
I wrote CMakeLists.txt for both the folders and used cmake in cmd promptand it is working fine.
CMakeLists.txt in head folder has the following:
CMAKE_MINIMUM_REQUIRED ( VERSION 2.6)
PROJECT (Tutorial)
SET (Tutorial_VERSION_MAJOR 1)
SET (Tutorial_VERSION_MINOR 0)
CONFIGURE_FILE (
"${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
"${PROJECT_BINARY_DIR}/TutorialConfig.h "
)
INCLUDE_DIRECTORIES ("${PROJECT_BINARY_DIR}")
OPTION (USE_MYMATH "Use tutorial provided math implementation" ON)
if (USE_MYMATH)
INCLUDE_DIRECTORIES ("${PROJECT_SOURCE_DIR}/MathFunctions")
ADD_SUBDIRECTORY (MathFunctions)
SET (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
endif (USE_MYMATH)
ADD_EXECUTABLE (Tutorial tutorial.c)
TARGET_LINK_LIBRARIES (Tutorial ${EXTRA_LIBS})
CMakeLists.txt in sub folder has the following:
CMAKE_MINIMUM_REQUIRED ( VERSION 2.6)
add_library (MathFunctions mysqrt.c )
and in command prompt :
C:\home\Tutorial\BUILD>cmake ..
-- Building for: Visual Studio 9 2008
-- Check for working C compiler using: Visual Studio 9 2008
-- Check for working C compiler using: Visual Studio 9 2008 --
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 9 2008
-- Check for working CXX compiler using: Visual Studio 9 2008
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/home/Tutorial/BUILD
Later I made some modifications in MathFunctions.c .I made no changes in Tutorial.c. So i want to re generate make files only for MathFunctions folder. But I am not able to do it. I am getting the following error
C:\home\Tutorial\BUILD>cmake ../MathFunctions
CMake Error: The source "C:/home/Tutorial/MathFunctions/CMakeLists.txt" does not match the source "C:/home/Tutorial/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
I cannot figure out why this error is coming.
Please help
Thanks
Best Answer
OK, I know this is ancient but...had a similar problem, same error message.
There is a command under File on the GUI that cleans out the cache. This did not work the first time but eventually it did. I thrashed around a bit, adding cmake to the user path, reboot, don't know if any of that helped.
I got into trouble initially by trying to run cmake on a CMakeLists.txt that was NOT the root. This error popped up when I tried again with the proper source directory. V3.1.3.