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()
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)
Related
I'm trying to generate a static library and install it using Cmake and Visual Studio Code, but the files are not installed where I want to.
The folder structure is as follows:
Main_Folder
- Poly
- - CMakeLists.txt
- - src
- - - Poly.cpp
- - - Poly.h
- Test
- - TestLibs
- - - TestLibs.cpp
- - - TestLibs.h
This is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.0.0)
project(poly)
set(CMAKE_BUILD_TYPE Debug)
#Bring the headers, such as Student.h into the project
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*")
#Generate the static library from the sources
add_library(poly STATIC ${SOURCES})
#Set the location for library installation
install(
TARGETS poly
LIBRARY DESTINATION /Main_Folder/Test/TestLibs/Poly
ARCHIVE DESTINATION /Main_Folder/Test/TestLibs/Poly
RUNTIME DESTINATION /Main_Folder/Test/TestLibs/Poly
)
And this is my cmake_install.cmake:
# Install script for directory: Main_Folder/Poly
# Set the install prefix
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local")
endif()
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
# Set the install configuration name.
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
if(BUILD_TYPE)
string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
else()
set(CMAKE_INSTALL_CONFIG_NAME "Debug")
endif()
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
endif()
# Set the component getting installed.
if(NOT CMAKE_INSTALL_COMPONENT)
if(COMPONENT)
message(STATUS "Install component: \"${COMPONENT}\"")
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
else()
set(CMAKE_INSTALL_COMPONENT)
endif()
endif()
# Install shared libraries without execute permission?
if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
set(CMAKE_INSTALL_SO_NO_EXE "0")
endif()
# Is this installation the result of a crosscompile?
if(NOT DEFINED CMAKE_CROSSCOMPILING)
set(CMAKE_CROSSCOMPILING "FALSE")
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES "/Main_Folder/Test/TestLibs/Poly/libpoly.a")
if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
file(INSTALL DESTINATION "/Main_Folder/Test/TestLibs/Poly/" TYPE STATIC_LIBRARY FILES "/home/myUser/git/Main_Folder/Test/TestLibs/Poly/libpoly.a")
endif()
The library (libpoly.a) is created, but instead of being installed in /Main_Folder/Test/TestLibs/Poly is found on /Main_Folder/Poly and I dont understand what I'm missing.
I'm using Linux and cmake 3.17.3, I don't know if this might cause the issue.
let say i have a new yocto image call stargazer-cmd
what file should i edit so that every time i source poky/oe-init-env
it display as a build option to the user?
kj#kj-Aspire-V3-471G:~/stm32Yoctominimal$ source poky/oe-init-build-env build-mp1/
### Shell environment set up for builds. ###
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
core-image-sato
meta-toolchain
meta-ide-support
I wish to add stargazer-cmd on top of core-image-minimal, i am not sure what to google and what is the file i need to change.
Let me explain how to add a custom configuration to the OpenEmbedded build process.
First of all, here is the process that is done when running:
source poky/oe-init-build-env
The oe-init-build-env script initializes OEROOT variable to point to the location of the script itself.
The oe-init-build-env script sources another file $OEROOT/scripts/oe-buildenv-internal which will:
Check if OEROOT is set
Set BUILDDIR to your custom build directory name $1, or just build if you do not provide one
Set BBPATH to the poky/bitbake folder
Adds $BBPATH/bin and OEROOT/scripts to PATH (This will enable commands like bitbake and bitbake-layers ...)
Export BUILDDIR and PATH to the next file
The oe-init-build-env script continues by running the final build script with:
TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir
The oe-setup-builddir script will:
Check if BUILDDIR is set
Create the conf directory under $BUILDDIR
Sources a template file that will check if there is a TEMPLATECONF variable is set:
. $OEROOT/.templateconf
That file contains:
# Template settings
TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf}
it means that if TEMPLATECONF variable is not set, set it to meta-poky/conf, and that is where the default local.conf and bblayers.conf are coming from.
Copy $TEMPLATECONF to $BUILDDIR/conf/templateconf.cfg
Set some variables pointing to custom local.conf and bblayers.conf:
OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample"
OECORELOCALCONF="$TEMPLATECONF/local.conf.sample"
OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt"
In the oe-setup-builddir there is a comment saying that TEMPLATECONF can point to a directory:
#
# $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf
#
Copy local.conf.sample and bblayers.conf.sample from TEMPLATECONF directory into BUIDDIR/conf:
cp -f $OECORELOCALCONF "$BUILDDIR/conf/local.conf"
sed -e "s|##OEROOT##|$OEROOT|g" \
-e "s|##COREBASE##|$OEROOT|g" \
$OECORELAYERCONF > "$BUILDDIR/conf/bblayers.conf"
Finally it will print what is inside OECORENOTESCONF which points to TEMPLATECONF/conf-notes.txt:
[ ! -r "$OECORENOTESCONF" ] || cat $OECORENOTESCONF
and by default that is located under meta-poky/conf/conf-notes.txt:
### Shell environment set up for builds. ###
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
core-image-sato
meta-toolchain
meta-ide-support
You can also run generated qemu images with a command like 'runqemu qemux86'
Other commonly useful commands are:
- 'devtool' and 'recipetool' handle common recipe tasks
- 'bitbake-layers' handles common layer tasks
- 'oe-pkgdata-util' handles common target package tasks
So, now, after understanding all of that, here is what you can do:
Create a custom template directory for your project, containing:
local.conf.sample
bblayers.conf.sample
conf-notes.txt
Do not forget to set the path to poky in bblayers.conf to ##OEROOT## as it will be set automatically by the build script.
Set your custom message in conf-notes.txt
Before any new build, just set TEMPLATECONF:
TEMPLATECONF="<path/to/template-directory>" source poky/oe-init-build-env <build_name>
Then, you will find a build with your custom local.conf and bblayers.conf with additional file conf/templateconf.cfg containing the path of TEMPLATECONF
conf/conf-notes.txt in your layer.
OECORENOTESCONF should point to the file.
I'm trying to configure a template project for my STM32 blue pill board with CMake and cmake-tools for Visual Studio Code. It builds just fine, but the Intellisense feature of cmake-tools seems not to work with an external library (libopencm3 in this case).
This is most likely a configuration error on my side. Following my CMakeLists.txt. The toolchain is defined in a seperate .cmake file.
set(PRJ_NAME STM32_Template_Project)
cmake_minimum_required(VERSION 3.6)
project(${PRJ_NAME} C ASM)
set(COMMON_FLAGS "-mcpu=${MCU_ARCH} -mthumb -mthumb-interwork -mfloat-abi=${MCU_FLOAT_ABI} -ffunction-sections -fdata-sections -g -fno-common -fmessage-length=0 -DSTM32F1")
if (MCU_FLOAT_ABI STREQUAL hard)
set(COMMON_FLAGS "${COMMON_FLAGS} -mfpu=${MCU_FPU}")
endif ()
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")
set(CMAKE_C_FLAGS "${COMMON_FLAGS} -std=gnu99")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections -T ${CMAKE_SOURCE_DIR}/${MCU_LINKER_SCRIPT}")
set(DEFINITIONS "${DEFINITIONS} -D${MCU_LINE}")
set(LIBOPENCM3_DIR "../libopencm3")
#headers
include_directories(sys)
include_directories(Inc)
include_directories(${LIBOPENCM3_DIR}/include)
# libopencm3
# Make sure that git submodule is initialized and updated
if (NOT EXISTS ${LIBOPENCM3_DIR}/Makefile)
message(FATAL_ERROR "libopencm3 submodule not found. Initialize with 'git submodule update --init' in the source directory")
endif()
add_custom_target(libopencm3 make TARGETS=stm32/f1 WORKING_DIRECTORY ${LIBOPENCM3_DIR})
link_directories(${LIBOPENCM3_DIR}/lib)
#files
file(GLOB_RECURSE USER_SOURCES Src/*.c)
set(CMSIS_STARTUP startup_${MCU_LINE}.s)
set(SOURCE_FILES ${USER_SOURCES} ${CMSIS_STARTUP} ${MCU_LINKER_SCRIPT})
# target
add_executable(${PROJECT_NAME}.elf ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME}.elf opencm3_stm32f1)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=${PROJECT_SOURCE_DIR}/build/${PROJECT_NAME}.map")
set(HEX_FILE ${PROJECT_SOURCE_DIR}/build/${PROJECT_NAME}.hex)
set(BIN_FILE ${PROJECT_SOURCE_DIR}/build/${PROJECT_NAME}.bin)
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
COMMENT "Building ${HEX_FILE} \nBuilding ${BIN_FILE}")
I am not very experienced with CMake and cmake-tools.
I have a working Yocto image for a RaspberryPi3. I want to add 3 script files /etc/ppp/peers/. I would have thought that adding non-compiled files to the root file-system was a fairly generic thing to do but the only examples I can find are using compiled files and inheriting the autotools recipe.
Is there an example of how to add text files or script files to a Yocto root filesystem this somewhere?
Either a How To write up or an existing recipe that takes a set of text files and places them onto the target's rootfs.
I must be missing something because I cannot get the file files onto the system.
I tried using do_deploy, but that puts files into my ../tmp/deploy/images/raspberrypi3/etc/ppp/ which would be helpful for scripts to aid in image deployment. It is not what I want though as the scripts need to be on the target.
Running a do_install() with or without a blank do_compile() has not resulted in things getting onto the target either. Unless there is something about using ${sysconfdir} or ${IMAGE_ROOTFS} or ${S} or ${D} or ${DEPLOYDIR} or ${WORKDIR} which is particular to the Pi. I'd provide an example of my script but having changed it so many times in the last two days there is not much worth of sharing just one iteration.
Anything that resembles the following with;
${IMAGE_ROOTFS} possibly substituted for ${D} or missing
do_install replaced with do_deploy.
There are probably other permutations that I have tried.
#
# Copy the ppp script files for <vendor> chips to the target filesystem
# These files are based on the details provided in
#
SUMMARY = "PPP Scripts for ..."
SECTION = "net"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
DESCRIPTION = "A set of Linux PPP scripts blar blar"
RDEPENDS_${PN} = "ppp"
SRC_URI += "file://<provider>-ppp"
SRC_URI += "file://<provider>-chat-connect"
SRC_URI += "file://<provider>-chat-disconnect"
S = "${WORKDIR}"
#PACKAGES =+ "${PN} ${PN}-staticdev"
#DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
#D = "${DEPLOYDIR}"
inherit allarch
# Install script on target's root file-system
do_install () {
# Install init script and default settings
install -d ${IMAGE_ROOTFS}${sysconfdir}
install -d ${IMAGE_ROOTFS}${sysconfdir}/ppp/
install -d ${IMAGE_ROOTFS}${sysconfdir}/ppp/peers/
install -m 0755 ${S}/<provider>-ppp ${IMAGE_ROOTFS}${sysconfdir}/ppp/peers/
install -m 0755 ${S}/<provider>-chat-connect ${IMAGE_ROOTFS}${sysconfdir}/ppp/peers/
install -m 0755 ${S}/<provider>-chat-disconnect ${IMAGE_ROOTFS}${sysconfdir}/ppp/peers/
}
# Mark the files which are part of this package
FILES_${PN} += "${sysconfdir}/ppp/"
FILES_${PN} += "${sysconfdir}/ppp/peers/"
FILES_${PN} += "${sysconfdir}/ppp/peers/<provider>-ppp"
FILES_${PN} += "${sysconfdir}/ppp/peers/<provider>-chat-connect"
FILES_${PN} += "${sysconfdir}/ppp/peers/<provider>-chat-disconnect"
I can find a lot of helloworld.c and automate examples. There must be some basic ones for adding scripts somewhere? My googlefu is very weak, I blame a lingering cold.
You should be using install -m 0755 ${WORKDIR}/<provider>-ppp ${D}${sysconfdir}/ppp/peer in your recipe. Have you added the resulting package to your image recipe? You could look at ${WORKDIR}/packages-split/${PN} to confirm that your files have been properly packaged.
I have doxygen 1.8.5 and Doxverilog (for doxygen 1.7.0). Following the instructions quoted below I get messages saying that patches have previously been applied. Then some of the HUNKs fail.
If I proceed anyway and set up the verilog.cfg, running doxygen with this cfg produces
"Warning: ignoring unsupported tag `OPTIMIZE_OUTPUT_VERILOG =' at line 35, file verilog.cfg"
Then blank output.
The instructions I'm using to setup doxverilog are:
install the doxygen-1.7.0 sources
1. copy the Verilog files verilogparser.y verlogscanner.l and the source files to the doxygen-1.7.0\src directory
2. copy the patch file verilog.patch to directory doxygen-1.7.0
3. open a shell in the doxygen-1.7.0 directory
3.1 configure doxygen
sh configure
3.2 make patch # patch -p1 < verilog.patch
4 compile the source files
make all
5 If the compilation was successful create a doxygen configuration file with # doxygen -s -g verilog.cfg
In the configuration file you should see the option OPTIMIZE_OUTPUT_VERILOG.
The file patterns for the Verilog parser are *.v and *.V