我是使用CMake的新手(通常对Makefiles、C和C++都很陌生)。我的任务是将我们当前的构建系统更改为使用CMake生成Makefile并编译代码的系统。我很难破译CMake报告的错误,在搜索这个网站或任何sute时都没有运气。如果这个问题已经在其他地方得到了回答,请直接告诉我,我会提前道歉。
我试图发布一张显示我们当前文件结构崩溃的图片,但我还没有发布图片的信誉点。。。
以下是我在运行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目录中的CMakeLists.txt。CMake/arm/ectat
*ADD_SUBDIRECTORY(expat)
ADD_SUBDIRECTORY(services)
*
这是目录633中的CMakeLists.txt。CMake/arm/ectat*(这将创建库libexpat.a),文件expatfiles.txt仅列出expat所需的源文件(同样的事情也适用于服务CMakeList.txt:
*FILE(READ "expatfiles.txt" contents)
STRING(REGEX REPLACE "n" ";" contents "${contents}")
foreach(expatfile ${contents})
message("${expatfile}")
endforeach()
ADD_LIBRARY(expat ${contents})*
这是633目录中的CMakeLists.txt。CMake/arm/services*
*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}
此特定错误不是由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,请参阅文档)