解密CMake错误

时间:2013-12-19 21:21:13

标签: c++ c linux cmake omap

我是使用CMake的新手(对于Makefiles,C和一般的C ++来说相当新)。我的任务是将当前的构建系统更改为使用CMake生成Makefile并编译代码的系统。我无法破译CMake报告的错误,并且没有运气搜索本网站或任何有关此事的任何内容。如果这个问题已经在其他地方得到解答,请指导我,我会提前报告。

我试图发布一张图片,显示我们当前文件结构的细分但我没有信誉点来发布图片......

以下是运行 cmake时收到的错误。 &的 使

*chrisk@DEVSERVER:~/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
chrisk@DEVSERVER:~/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
chrisk@DEVSERVER:~/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)*

以下是目录 633.CMake / arm / expat

中的CMakeLists.txt
*ADD_SUBDIRECTORY(expat)
ADD_SUBDIRECTORY(services)
*

以下是 633.CMake / arm / expat * 目录中的CMakeLists.txt(这会创建库 libexpat.a as它应该)和文件 expatfiles.txt 只列出expat所需的源文件(同样适用于服务CMakeLists.txt:

*FILE(READ "expatfiles.txt" contents)
STRING(REGEX REPLACE "\n" ";" contents "${contents}")
foreach(expatfile ${contents})
message("${expatfile}")
endforeach()
ADD_LIBRARY(expat ${contents})*

目录 633.CMake / arm / services *

目录中的CMakeLists.txt
*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}

1 个答案:

答案 0 :(得分:3)

这个特殊错误不是由于CMake造成的。而是看到这一行:

/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``

问题是缺少符号MAX_DSPS。在源树中执行递归grep,并查看此MAX_DSPS应该来自何处。它可能是头文件中定义的宏(或全局变量),您无法包含它,或者它可能是您需要在编译时通过CMakeLists.txt文件提供的宏(请参阅以下文档:关于如何在CMake中执行此操作的add_definitions