我有一個名爲Tutorial的頭文件夾和名爲MathFunctions的子文件夾,每個文件夾各有一個代碼 我爲這兩個文件夾編寫CMakeLists.txt,並在cmd中使用cmake promptand它工作正常。一旦在整個項目中使用cmake後在子目錄中使用Cmake的問題
的CMakeLists.txt在頭文件夾具有以下:
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在子文件夾具有以下:
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
add_library (MathFunctions mysqrt.c)
和在命令提示:
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
後來我在MathFunctions.c中做了一些修改,我在Tutorial.c中沒做任何修改。所以我想爲MathFunctions文件夾重新生成make文件。但我無法做到。我收到以下錯誤
C:\home\Tutorial\BUILD>cmake ../MathFunctions
CMake的錯誤:源「C:/home/Tutorial/MathFunctions/CMakeLists.txt」不匹配源「C:/home/Tutorial/CMakeLists.txt」使用生成緩存。用另一個源目錄重新運行cmake。
我不明白爲什麼會出現這個錯誤。 請幫忙 謝謝
如果您再次運行CMake,請將其作爲「cmake」運行。或者使用與第一次運行相同的確切命令行。 CMake在運行時緩存主頂級源目錄和主頂級構建目錄的原始值。運行「cmake」。說使用當前目錄CMakeCache.txt文件中找到的源和生成目錄。運行CMake時,也會使用緩存的信息。運行它與其主要參數不同的源目錄是一個錯誤,並會產生你得到的錯誤信息... – DLRdave