Reputation: 427
I am trying to install my external package, which is built fine by the cross-compile toolchain but fails on the install step with the error
Install the project...
-- Install configuration: "Release"
-- Installing: /home/username/Projects/ProjectName/ProjectName_software/ProjectName_OS/build_ProjectName_os_raspberrypi3/target/home/username/Projects/ProjectName/ProjectName_software/ProjectName_
OS/build_ProjectName_os_raspberrypi3/build/APPNAME/APPNAME
APPNAME: installs files in /home/userName/Projects/ProjectName/ProjectName_software/ProjectName_OS/build_ProjectName_os_raspberrypi3/target//home/username/Projects/ProjectName/ProjectName
_software/ProjectName_OS/build_ProjectName_os_raspberrypi3
package/pkg-generic.mk:315: recipe for target '/home/alex/Projects/BlackBox/bbefx_software/BBEFX_OS/build_bbefx_os_raspberrypi3/build/BBEFX_CORE/.stamp_
target_installed' failed
I am guessing that the path prefixed by --Installing is the one generated by the package makefile and the one prefixed by APPNAME is the one that buildroot is expecting APPNAME to install to. Hence why the .stamp_target_install fails
The obvious issue is that the path buildroot expects is
/target//home/username/
This isn't the path that I would like to install to (usr/bin would be preferable). However I can't see how to specify a path within the package make file, which is as follows:
APPNAME_SITE = $(TOPDIR)/../../APPNAME
APPNAME_SITE_METHOD = local
APPNAME_INSTALL_TARGET = YES
$(eval $(cmake-package))
With the CMakeLists.txt being:
#
# 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()
Upvotes: 0
Views: 3966
Reputation: 5956
This line:
install (TARGETS APPNAME DESTINATION ${CMAKE_BINARY_DIR})
is wrong. According to the CMake documentation, CMAKE_BINARY_DIR
is the The path to the top level of the build tree., which is why your binary gets installed in the wrong place.
Please replace this line with:
install (TARGETS APPNAME DESTINATION bin)
Upvotes: 3