CMakeLists修改?

时间:2019-03-20 14:15:58

标签: c++ cmake

我们有如下build.cmake文件

cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

# 
# Define the name of the supported targets
# 
set(BUILD_TARGETS unit_test)

# 
# Baseline used for the CMAKE Tools
# 
set(CMAKE_TOOLS_BASELINE    
    "${CMAKE_Repo}"   "${PROJECT_KEY}"   "${CMAKE_REV}")

# 
# Revision of the GTest framework used to execute unit test of the module.
# 
if( ("${TARGET}" STREQUAL "unit_test") )
   set(GTEST_BASELINE          "casatool"     "rev_0.2")
endif()

# 
# Tools to be used by the project they doesn't contains code to be compiled,
# if a tool contains code then it shall be handled as a module.
# 
if( ("${COMPILER}" STREQUAL "GNU") )
set(TOOLS
        "GNU_tools"                     "casatool"  "rev_1"
    )
endif()

##############################################################################
# TARGET: unit_test 
##############################################################################

# 
# Specify the common modules that this module requires to compile, in unit
# test only the header folders will be added, the imlementations must be
# stubs.
# 
set(MODULES_unit_test
    )

# 
# For unit test the local modules refer to the module that is
# going to be tested, if headers from other modules are required
# please add the path to INC_DIR
# 
set(LOCAL_MODULES_unit_test
    )

# 
# Include only Folders
# 
set(INC_DIR_unit_test
        "${CMAKE_CURRENT_LIST_DIR}/src"
        "${CMAKE_CURRENT_LIST_DIR}/unit_test/src"
        "${CMAKE_CURRENT_LIST_DIR}/unit_test/stubs"
        "${CMAKE_CURRENT_LIST_DIR}/../../Common"
        "${CMAKE_CURRENT_LIST_DIR}/../../../../../tools/dev_tools_ford_autosar_production_sip/BSW/Com"
        "${CMAKE_CURRENT_LIST_DIR}/../../../../../tools/dev_tools_ford_autosar_production_sip/BSW/Det"
        #"${CMAKE_CURRENT_LIST_DIR}/../../../../../tools/dev_tools_ford_autosar_production_sip/BSW/Os"
        "${CMAKE_CURRENT_LIST_DIR}/../../AUTOSAR/Appl/GenData"
        "${CMAKE_CURRENT_LIST_DIR}/../../AUTOSAR/Appl/GenData/Components"
        "${CMAKE_CURRENT_LIST_DIR}/../../Startup/include"
        "${CMAKE_CURRENT_LIST_DIR}/../../../../variants/S32K148/startup"
        "${CMAKE_CURRENT_LIST_DIR}/../../../../variants/S32K148/include"
        "${CMAKE_CURRENT_LIST_DIR}/../../CDD/QSPI/include"
        "${CMAKE_CURRENT_LIST_DIR}/../../CDD/QSPI/include/src"
        "${CMAKE_CURRENT_LIST_DIR}/../../Common"
    )

# 
# Directories that contain project specific source.
# 
set(BIN_SRC_DIR_unit_test
        "${CMAKE_CURRENT_LIST_DIR}/unit_test/src"
        "${CMAKE_CURRENT_LIST_DIR}/unit_test/stubs"
    )

# 
# Specific source files.
# 
set(BIN_SRC_FILES_unit_test
   )

# 
# Add here all the custom precompiled libraries specific for
# your project.
# 
set(CUSTOM_LIB_unit_test
    )

##############################################################################
# Set custom compiler/assambler/linker flags, is importante to use
# PARENT_SCOPE for the variables that are being set to behave properlly.
##############################################################################
function(customConfig)
endfunction()

##############################################################################
# Set custom dependencies to the target
##############################################################################
function(addTargetDependencies)
endfunction()

##############################################################################
# This function is invoked after the configuration is done, at this
# moment the targets are already created.
##############################################################################
function(postConfig)
endfunction()

并且CMakelist.txt文件是

cmake_minimum_required(VERSION 3.3 FATAL_ERROR)

#
# Include the library configuration files.
#
include(library.cmake)

message("-------------------------------")
#
# Add the source directories to each target
#
addFilesToLib("${LIB_SRC_DIR}" "${LIB_SRC_FILES}")

构建此文件时,我们将在下面列出一些错误。链接似乎有问题,因为该错误是ld返回1退出状态。.下面详细列出了错误列表

D:\Sourcetree_gen3_build\S32K>build.bat avas_platform/app/Test/QSPI_CDD GNU unit_test run
-- Performing Synchronize...
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Sourcetree_gen3_build/build/avas_platform/app/Test/QSPI_CDD/sync
-- Building unit_test...
-------- System Details ---------
Target           : unit_test
OS               : Windows
Compiler         : GNU
Compiler Version : 4.9.3
---------------------------------
[  0%] Built target SystemDetails
[ 76%] Built target gtest_unit_test_0
[ 84%] Linking CXX executable D:\Sourcetree_gen3_build\bin\avas_platform\app\Test\QSPI_CDD\unit_test\GNU\QSPI_CDD.exe
CMakeFiles\unit_test.dir/objects.a(SWC_QSPI_CDD_UT.cpp.obj): In function `QSPI_DRV_SetLut':
D:/Sourcetree_gen3_build/S32K/avas_platform/app/Test/QSPI_CDD/../../CDD/QSPI/include/quadspi_driver.h:346: undefined reference to `g_qspiBase'
CMakeFiles\unit_test.dir/objects.a(SWC_QSPI_CDD_UT.cpp.obj): In function `QSPI_DRV_SetAhbSeqId':
D:/Sourcetree_gen3_build/S32K/avas_platform/app/Test/QSPI_CDD/../../CDD/QSPI/include/quadspi_driver.h:436: undefined reference to `g_qspiBase'
CMakeFiles\unit_test.dir/objects.a(SWC_QSPI_CDD_UT.cpp.obj): In function `qspi_drv_transfer':
D:/Sourcetree_gen3_build/S32K/avas_platform/app/Test/QSPI_CDD/src/qspi_drv.c:922: undefined reference to `QSPI_DRV_IpRead'
D:/Sourcetree_gen3_build/S32K/avas_platform/app/Test/QSPI_CDD/src/qspi_drv.c:926: undefined reference to `QSPI_DRV_IpWrite'
CMakeFiles\unit_test.dir/objects.a(SWC_QSPI_CDD_UT.cpp.obj): In function `Z13qspi_drv_openP19QSPI_DRV_APP_CONFIG':
D:/Sourcetree_gen3_build/S32K/avas_platform/app/Test/QSPI_CDD/src/qspi_drv.c:1039: undefined reference to `QSPI_DRV_Init'
CMakeFiles\unit_test.dir/objects.a(SWC_QSPI_CDD_UT.cpp.obj): In function `Z13qspi_drv_readjPhj':
D:/Sourcetree_gen3_build/S32K/avas_platform/app/Test/QSPI_CDD/src/qspi_drv.c:1174: undefined reference to `ApplFblTimeDelay(unsigned int)'
CMakeFiles\unit_test.dir/objects.a(SWC_QSPI_CDD_UT.cpp.obj): In function `Z14qspi_drv_writejPhj':
D:/Sourcetree_gen3_build/S32K/avas_platform/app/Test/QSPI_CDD/src/qspi_drv.c:1263: undefined reference to `ApplFblTimeDelay(unsigned int)'
CMakeFiles\unit_test.dir/objects.a(SWC_QSPI_CDD_UT.cpp.obj): In function `Z21qspi_drv_send_commandjh':
D:/Sourcetree_gen3_build/S32K/avas_platform/app/Test/QSPI_CDD/src/qspi_drv.c:1423: undefined reference to `QSPI_DRV_IpCommand'
CMakeFiles\unit_test.dir/objects.a(SWC_QSPI_CDD_UT.cpp.obj): In function `Z27qspi_drv_send_erase_commandjh':
D:/Sourcetree_gen3_build/S32K/avas_platform/app/Test/QSPI_CDD/src/qspi_drv.c:1470: undefined reference to `QSPI_DRV_IpErase'
D:/Sourcetree_gen3_build/S32K/avas_platform/app/Test/QSPI_CDD/src/qspi_drv.c:1479: undefined reference to `ApplFblTimeDelay(unsigned int)'
CMakeFiles\unit_test.dir/objects.a(SWC_QSPI_CDD_UT.cpp.obj): In function `Z16qspi_drv_is_busyj':
D:/Sourcetree_gen3_build/S32K/avas_platform/app/Test/QSPI_CDD/src/qspi_drv.c:1728: undefined reference to `QSPI_DRV_IpGetStatus'
CMakeFiles\unit_test.dir/objects.a(SWC_QSPI_CDD_UT.cpp.obj):SWC_QSPI_CDD_UT.cpp:(.data+0x0): undefined reference to `qspi1_Config0'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\unit_test.dir\build.make:124: recipe for target 'D:/Sourcetree_gen3_build/bin/avas_platform/app/Test/QSPI_CDD/unit_test/GNU/QSPI_CDD.exe' failed
mingw32-make.exe[3]: *** [D:/Sourcetree_gen3_build/bin/avas_platform/app/Test/QSPI_CDD/unit_test/GNU/QSPI_CDD.exe] Error 1
CMakeFiles\Makefile2:104: recipe for target 'CMakeFiles/unit_test.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/unit_test.dir/all] Error 2
CMakeFiles\Makefile2:116: recipe for target 'CMakeFiles/unit_test.dir/rule' failed
mingw32-make.exe[1]: *** [CMakeFiles/unit_test.dir/rule] Error 2
Makefile:130: recipe for target 'unit_test' failed
mingw32-make.exe: *** [unit_test] Error 2

我希望得到某种支持以解决该问题。您能告诉我这是正确的CMakeLists.txt中的问题吗?如果是这样,我如何更新我的CMakeLists.txt

0 个答案:

没有答案