我正在尝试安装我的外部软件包,这是由交叉编译工具链构建的,但在安装步骤中出现错误
APPNAME_SITE = $(TOPDIR)/../../APPNAME
APPNAME_SITE_METHOD = local
APPNAME_INSTALL_TARGET = YES
$(eval $(cmake-package))
我猜测--Installing前缀的路径是包makefile生成的路径,APPNAME前缀的路径是buildroot期望APPNAME安装的路径。因此.stamp_target_install失败的原因
显而易见的问题是buildroot所期望的路径是
#
# CMake options
#
# CMake version
cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
option(BUILD_DOC "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND})
# project name
project(APPNAME)
IF(NOT CMAKE_BUILD_TYPE)
MESSAGE(STATUS "No build type selected, default to Release")
SET(CMAKE_BUILD_TYPE "Release")
ENDIF()
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
IF(CMAKE_BUILD_TYPE AND
NOT uppercase_CMAKE_BUILD_TYPE MATCHES "^(DEBUG|RELEASE)$")
MESSAGE(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
ENDIF()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDEBUG)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++14")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -std=c++14")
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++14")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -w -std=c++14")
endif()
# enable c++
enable_language(C CXX)
# project version
set(VERSION_MAJOR 0)
set(VERSION_MINOR 1)
set(VERSION_PATCH 0)
# Find all sources and headers in the source folder
file(GLOB_RECURSE APPNAME_SOURCES "source/*.cpp")
file(GLOB_RECURSE APPNAME_HEADERS "source/*.hpp" "source/*.h")
# Add header directories, remove dupes
set (APPNAME_INCLUDE_DIRS "")
foreach (_headerFile ${APPNAME_HEADERS})
get_filename_component(_dir ${_headerFile} PATH)
list (APPEND APPNAME_INCLUDE_DIRS ${_dir})
endforeach()
list(REMOVE_DUPLICATES APPNAME_INCLUDE_DIRS)
# Add sources and headers to exec
add_executable (APPNAME ${APPNAME_SOURCES})
target_include_directories(APPNAME PRIVATE ${APPNAME_INCLUDE_DIRS})
# Add Libs to link
find_package(libconfigpp REQUIRED)
find_package(Boost COMPONENTS system log REQUIRED)
include_directories(${LIBCONFIGPP_INCLUDE_DIR} $Boost_INCLUDE_DIRS)
target_link_libraries(APPNAME ${Boost_LIBRARIES} ${LIBCONFIGPP_LIBRARIES})
add_definitions(-DBOOST_LOG_DYN_LINK)
# Add platform specific Libs and preproc macros
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_definitions(-DSYSTEM_LINUX)
add_definitions(-D__UNIX_JACK__ )
find_package(libjack REQUIRED)
target_link_libraries(APPNAME ${JACK_LIBRARIES})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(APPNAME Threads::Threads)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
add_definitions(-DSYSTEM_DARWIN)
add_definitions(-D__MACOSX_CORE__)
find_library(COREMIDI_LIBRARY CoreMIDI)
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
find_library(COREAUDIO_LIBRARY CoreAudio)
target_link_libraries(APPNAME ${COREFOUNDATION_LIBRARY} ${COREMIDI_LIBRARY} ${COREAUDIO_LIBRARY})
endif()
set(CONFIGFILE source/APPNAME_CONFIG.cfg)
#file(COPY ${CONFIGFILE} DESTINATION ${CMAKE_BINARY_DIR})
install (TARGETS APPNAME DESTINATION ${CMAKE_BINARY_DIR})
#
# Build Documentation
#
find_package(Doxygen)
if(BUILD_DOC)
if(NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
endif()
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/source/doc/Doxyfile.in)
set(DOXYFILE ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(${DOXYFILE_IN} ${DOXYFILE} @ONLY)
add_custom_target(DOC
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
add_custom_command(TARGET DOC
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/source/doc/Documentation.html ${CMAKE_SOURCE_DIR}/doc
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
endif()
这不是我想要安装的路径(usr / bin会更好)。但是,我无法看到如何在包生成文件中指定路径,如下所示:
(\d{7,}(?:\,\d{7,})*)
CMakeLists.txt为:
14435356,123254356
1343545,1323544
答案 0 :(得分:3)
这一行:
install (TARGETS APPNAME DESTINATION ${CMAKE_BINARY_DIR})
错了。根据CMake文档,CMAKE_BINARY_DIR
是构建树顶层的路径。,这就是您的二进制文件安装在错误位置的原因。
请将此行替换为:
install (TARGETS APPNAME DESTINATION bin)