0
我有以下的CMake文件多個源建設的cmake
cmake_minimum_required(VERSION 2.6)
# Locate GTest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
include_directories(../src/gcc_xml_parsing)
file(GLOB info_model
"../src/info_model/*.h"
"../src/info_model/*.cpp"
"../src/gcc_xml_parsing/*.h"
"../src/gcc_xml_parsing/*.cpp"
"../src/messages_filed_with_values/*.h"
"../src/messages_filed_with_values/*.cpp"
)
# Link runTests with what we want to test and the GTest and pthread library
add_executable(runTests_xml unit/gcc_xml_parsing/ut_XMLFile.cpp ${info_model})
add_executable(runTests_hexDumpUtil unit/info_model/ut_HexDumpUtil.cpp ${info_model})
add_executable(runTests_cstruct unit/info_model/ut_CStruct.cpp ${info_model})
add_executable(runTests_primitive_type_field unit/info_model /ut_PrimitiveTypeField.cpp ${info_model})
add_executable(runTests_enumField unit/info_model/ut_EnumField.cpp ${info_model})
add_executable(runTests_ArrayOfFields unit/info_model/ut_ArrayType.cpp ${info_model})
target_link_libraries(runTests_xml ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex)
target_link_libraries(runTests_hexDumpUtil ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex)
target_link_libraries(runTests_cstruct ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex)
target_link_libraries(runTests_primitive_type_field ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex)
target_link_libraries(runTests_enumField ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex)
target_link_libraries(runTests_ArrayOfFields ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex)
一般來說,程序編譯精細製作和運行生成文件之後。問題是,make文件爲每個add_executable構建$ {info_model}的源文件(makefile爲每個可執行文件構建所有* .o文件,如何修復它?謝謝。
編輯: 修改後在我的cmake(根據這個職位的第一個答案),我的應用程序編譯罰款,但有聯動的問題,整個日誌很大,因此,我要粘貼僅第一部分:
Linking CXX executable runTests_ArrayOfFields
libinfo_model_lib.a(XMLFile.cpp.o): In function `bool boost::regex_search<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const* ....
嗨,我已經更新了我的cmake,但在鏈接過程中仍然存在問題。請看看我上面的編輯。謝謝 – friko
@friko這是一個與衆不同的問題。你應該創建一個新的問題來詳細描述鏈接器問題。此外,您提供的錯誤消息被截斷,因此無法查看哪個符號實際上丟失。 – ComicSansMS
好的,無論如何,謝謝你的幫助,「加」你 – friko