交叉编译器生成错误-***目标模式不包含'%'。停止

时间:2018-09-10 10:46:01

标签: linux gcc cmake cross-compiling mingw-w64

我尝试在Linux上使用Windows的交叉编译器(minw64)进行构建,但出现以下错误。

[ 90%] Built target vsl.lang.types
Scanning dependencies of target copyFoms_vslation
[ 90%] Built target copyFoms_vslation
src/vslation/CMakeFiles/vslation.Gps.dir/build.make:152: *** target pattern contains no '%'.  Stop.
CMakeFiles/Makefile2:201: recipe for target 'src/vslation/CMakeFiles/vslation.Xps.dir/all' failed
make[1]: *** [src/vslation/CMakeFiles/vslation.Xps.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

我将cmake与以下命令配合使用:

cmake -DCMAKE_TOOLCHAIN_FILE=/home/vagrant/toolchain.cmake ../../src-gen

我的工具链文件如下:

SET(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_CROSS_COMPILING TRUE)

SET(LIBRARY_PATH /home/vagrant/mingw64/lib/)
SET(CMAKE_INCLUDE_PATH /home/vagrant/mingw64/include/)

SET(CMAKE_FIND_ROOT_PATH /home/vagrant/mingw64/)

INCLUDE_DIRECTORIES(SYSTEM
 "/home/vagrant/mingw64/include"
)

#SET(CMAKE_SYSROOT /home/vagrant/mingw64/)

# specify the cross compiler
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)

SET(CMAKE_CXX_COMPILER_AR x86_64-w64-mingw32-gcc-ar)
SET(CMAKE_CXX_COMPILER_RANLIB x86_64-w64-mingw32-gcc-ranlib)

SET(CMAKE_C_COMPILER_AR x86_64-w64-mingw32-gcc-ar)
SET(CMAKE_C_COMPILER_RANLIB x86_64-w64-mingw32-gcc-ranlib)

# Cmake Path - Version 3.12.1
SET(CMAKE_COMMAND /home/vagrant/cmake/cmake-3.12.1-Linux-x86_64/bin/cmake)
SET(CMAKE_CPACK_COMMAND /home/vagrant/cmake/cmake-3.12.1-Linux-x86_64/bin/cpack)
SET(CMAKE_CTEST_COMMAND /home/vagrant/cmake/cmake-3.12.1-Linux-x86_64/bin/ctest)
SET(CMAKE_EDIT_COMMAND /home/vagrant/cmake/cmake-3.12.1-Linux-x86_64/bin/cmake-gui)

# Rti Libs
SET(RTI_INCLUDE_DIRS /home/vagrant/mingw64/include/rti1516e)

# Poco Libs
SET(PocoFoundation_DIR /home/vagrant/mingw64/lib/cmake/Poco)
SET(PocoJSON_DIR /home/vagrant/vagrant/lib/cmake/Poco)
SET(PocoNet_DIR /home/vagrant/vagrant/lib/cmake/Poco)
SET(PocoUtil_DIR /home/vagrant/vagrant/lib/cmake/Poco)
SET(PocoXML_DIR /home/vagrant/vagrant/lib/cmake/Poco)
SET(Poco_DIR /home/vagrant/vagrant/lib/cmake/Poco)

# Pvsomip Libs
SET(vsomeip_DIR /home/vagrant/mingw64/lib/cmake/vsomeip)

# 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(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_INSTALL_RPATH )

我尝试将库分开保存。不要对toolcahin.cmake

中的库配置有任何好奇心

这是CMakeLists.txt。希望对您有所帮助。

cmake_minimum_required(VERSION 3.4)

if(MSVC)
    message(FATAL_ERROR "MSVC not supported")
endif()

if(${CMAKE_CXX_COMPILER} MATCHES "mingw64")
    set(MINGW64 true)
    set(FMU_BINARY_DIR binaries/win64)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPOCO_WIN32_UTF8")
elseif(${CMAKE_CXX_COMPILER} MATCHES "mingw32")
    set(MINGW32 true)
    set(FMU_BINARY_DIR binaries/win32)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPOCO_WIN32_UTF8")
else()
    set(USE_VSOMEIP true)
    set(FMU_BINARY_DIR binaries/linux64)
endif()

find_path(RTI_INCLUDE_DIRS NAMES RTI
 PATH_SUFFIXES include/rti1516e
 DOC "The rti1516e include files"
)
if(RTI_INCLUDE_DIRS)
  #message(STATUS "rti1516e headers found: ${RTI_INCLUDE_DIRS}")
else()
  message(FATAL_ERROR "rti1516e headers NOT found")
endif (RTI_INCLUDE_DIRS)
set(RTI_LIBRARIES rti1516e fedtime1516e)

find_package(Poco 1.8.1 COMPONENTS Util JSON Net Foundation REQUIRED)
if(USE_VSOMEIP)
    find_package (vsomeip 2.6.2 REQUIRED)
    include_directories(include ${RTI_INCLUDE_DIRS} ${Poco_INCLUDE_DIRS} ${VSOMEIP_INCLUDE_DIRS})
    set(LIBS ${RTI_LIBRARIES} ${Poco_LIBRARIES} ${VSOMEIP_LIBRARIES})
else()
    include_directories(include ${RTI_INCLUDE_DIRS} ${Poco_INCLUDE_DIRS})
    set(LIBS ${RTI_LIBRARIES} ${Poco_LIBRARIES})
endif()

set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -s")
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -U__STRICT_ANSI__ -DRTI_USES_STD_FSTREAM -Wno-deprecated -Wno-deprecated-declarations")

subdirs(src/model src/gtl/lang/manager src/vslation src/gtl/lang/types )

0 个答案:

没有答案