我是使用CMake的新手(對於C++來說,對於Makefiles,C,&來說是相當新的)。我的任務是將我們當前的構建系統更改爲使用CMake生成Makefiles並編譯我們的代碼的系統。我很難破譯CMake報告的錯誤,並且沒有運氣搜索這個網站或任何sute。如果這個問題已經在其他地方得到解答,請直接告訴我,我會提前通知你。解密CMake錯誤
我曾試圖發佈顯示我們當前文件結構的破壞的形象,但我沒有信譽點張貼圖片...
下面是我在同時運行接收錯誤cmake。 & 使:
*[email protected]:~/633.CMake$ cmake .
xmlrole.c
xmltok.c
xmlparse.c
sysMon.cpp
-- Configuring done
-- Generating done
-- Build files have been written to: /home/chrisk/633.CMake
[email protected]:~/633.CMake$ make
[ 25%] Building C object arm/expat/CMakeFiles/expat.dir/xmlrole.c.o
[ 50%] Building C object arm/expat/CMakeFiles/expat.dir/xmltok.c.o
[ 75%] Building C object arm/expat/CMakeFiles/expat.dir/xmlparse.c.o
/home/chrisk/633.CMake/arm/expat/xmlparse.c: In function 'XML_Status
/home/chrisk/633.CMake/arm/expat/xmlparse.c: In function 'XML_Status XML_Parse(XML_ParserStruct*, const char*, int, int)':
/home/chrisk/633.CMake/arm/expat/xmlparse.c:1488:14: warning: enumeration value 'XML_FINISHED' not handled in switch
Linking C static library libexpat.a
[ 75%] Built target expat
[100%] Building CXX object arm/services/CMakeFiles/services.dir/sysMon.cpp.o
In file included from /home/projects/OMAP-L137/timesys/factory-current/build_armv5l- timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink- 1_65_01/dsplink/gpp/inc/usr/dsplink.h:52:0,
from /home/chrisk/633.CMake/dsp/included/flagIOBuffer.h:4,
from /home/chrisk/633.CMake/arm/framework/memoryManagerBase.h:4,
from /home/chrisk/633.CMake/arm/framework/memoryManager.h:4,
from /home/chrisk/633.CMake/arm/services/sysMon.cpp:9:
/home/projects/OMAP-L137/timesys/factory-current/build_armv5l-timesys-linux- uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/usr/linkcfgdefs.h:824:37: error: 'MAX_DSPS' was not declared in this scope
In file included from /home/chrisk/633.CMake/arm/services/sysMon.cpp:16:0:
/home/chrisk/633.CMake/arm/logging/logger.h:43:17: note: the mangling of 'va_list' has changed in GCC 4.4
make[2]: *** [arm/services/CMakeFiles/services.dir/sysMon.cpp.o] Error 1
make[1]: *** [arm/services/CMakeFiles/services.dir/all] Error 2
make: *** [all] Error 2
[email protected]:~/633.CMake$
這裏是的CMakeLists.txt在項目源目錄:
*INCLUDE(CMakeForceCompiler)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(633.CMake)
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR arm)
this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
SET(FACTORY_CURRENT /home/projects/OMAP-L137/timesys/factory-current)
SET(TOOLCHAIN_LOC ${FACTORY_CURRENT}/build_armv5l-timesys-linux- uclibcgnueabi/toolchain/bin)
specify the cross compiler
SET(CMAKE_C_COMPILER ${TOOLCHAIN_LOC}/armv5l-timesys-linux-uclibcgnueabi-g++)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_LOC}/armv5l-timesys-linux-uclibcgnueabi-g++)
SET(CMAKE_C_FLAGS "-Wall -c")
SET(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
where is the target environment
SET(CMAKE_FIND_ROOT_PATH /home/projects/OMAP-L137/timesys/factory-current)
SET(PROJECT_SOURCE_DIR /home/chrisk/633.CMake/)
search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
ADD_SUBDIRECTORY(arm)*
這裏是的CMakeLists.txt在目錄633.CMake/arm/expat
*ADD_SUBDIRECTORY(expat)
ADD_SUBDIRECTORY(services)
*
這裏是的CMakeLists.txt在目錄633.CMake/ARM /外籍*(這將創建庫libexpat.a,因爲它應該)和文件expatfiles。 TXT只是列出了所需的外籍人士的源文件(同樣適用於服務的CMakeLists.txt:
*FILE(READ "expatfiles.txt" contents)
STRING(REGEX REPLACE "\n" ";" contents "${contents}")
foreach(expatfile ${contents})
message("${expatfile}")
endforeach()
ADD_LIBRARY(expat ${contents})*
這裏是CMAK eLists.txt目錄633.CMake/ARM /服務*
*INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/arm/framework ${CMAKE_SOURCE_DIR}/arm/io_master ${CMAKE_SOURCE_DIR}/arm/flagDictionary
${CMAKE_SOURCE_DIR}/arm/logging ${CMAKE_SOURCE_DIR}/dsp/included ${CMAKE_SOURCE_DIR}/dsp/mb)
INCLUDE_DIRECTORIES(${FACTORY_CURRENT}/build_armv5l-timesys-linux- uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/usr)
INCLUDE_DIRECTORIES(/home/projects/OMAP-L137/timesys/factory-20120925-633/build_armv5l- timesys-linux-uclibcgnueabi/DSPLink-1_65_01/DSPLink-1_65_01/dsplink/gpp/inc/usr)
INCLUDE_DIRECTORIES(/home/projects/OMAP- L137/SDK/OMAPL137_arm_1_00_00_11/dsplink_linux_1_65_00_03/dsplink/gpp/src/inc/sys/Linux)
FILE(READ "servicesfiles.txt" contents)
STRING(REGEX REPLACE "\n" ";" contents "${contents}")
foreach(servicesfiles ${contents})
message("${servicesfiles}")
endforeach()
ADD_LIBRARY(services ${contents}
「expatfiles.txt只是列出了expat所需的源文件」不這樣做。 CMake無法檢測到這個文件的變化,所以如果你修改它,cmake將不會自動構建新添加的文件。只需在相應的CMakeLists.txt中列出它們即可。 – SirDarius
您看到的錯誤是'make'錯誤,而不是'cmake'錯誤,這些錯誤看起來像來自編譯器。你可能想檢查你的源代碼。 – SethMMorton