No rule to make target 'mesh2D.h', needed by 'all-am' - automake

I have the following project tree :
src
├── Converters
├── datamodel
Inside datamodel/ I have a header that I want to include in a source cpp file inside Converters/.
However I get the following error :
No rule to make target 'mesh2D.h', needed by 'all-am'
This is my automake Makefile.am inside Converters/:
include $(top_srcdir)/adm_local/unix/make_common_start.am
AM_CPPFLAGS+= \
-I$(top_srcdir)/src/datamodel
libSource_SOURCES=\
source.cpp \
source.h
include_HEADERS=\
mesh2D.h
SUBDIRS=
include $(top_srcdir)/adm_local/unix/make_common_end.am
Thanks for your help!

I would move the
include_HEADERS = mesh2D.h
line to datamodel/Makefile.am if you are using recursive make, or
include_HEADERS += %reldir%/mesh2D.h
to datamodel/Makefile-files if you use a single Makefile.am with per-directory includes or
include_HEADERS += datamodel/mesh2D.h
if you are using a single Makefile.am without per-directory includes.
Note that using include_HEADERS will install the mesh2D.h file into /usr/local/include. If mesh2D.h is just needed to compile your program, use noinst_HEADERS instead of include_HEADERS to include mesh2D.h in the distribution tarball (make dist) without installing it (make install).

Related

Bitbake not finding files specified in SRC_URI when changing directory name

I'm writing a recipe that copies some configuration files over to my image (like a cramfs.conf that goes into /etc/modprobe.d to disable cramfs). Here is the structure of my recipe directory:
.
├── compliance-config.bb
└── configs
└── fs
├── 1-1-1-1-cramfs.conf
├── 1-1-1-2-freevxfs.conf
...
In my recipe I do the following:
SRC_URI += "file://fs"
do_install() {
install -d ${D}${sysconfdir}/modprobe.d/
install -m 0644 ${WORKDIR}/fs/*.conf ${D}${sysconfdir}/modprobe.d/
}
This works, but when I change the folder name of fs to something more descriptive (and of course accordingly change the SRC_URI and path in do_install()), it doesn't find the files anymore and gives me (Edit: to clarify, this error happens when I change the directory name from fs to fsconfigs for example, tried different names to make sure I don't accidentally name it in a forbidden way, names like abctest also don't work).
ERROR: compliance-config-1.0-r0 do_fetch: Fetcher failure: Unable to find file file://fsconfigs anywhere. The paths that were searched were:
[...long list of paths...]
So I thought I needed to do a clean build, but running bitbake -c clean <image> or bitbake -fc cleanall <image> beforehand doesn't help.
Why does bitbake not find my files if I change the specified directory?
This is a better :
.
├── compliance-config.bb
└── files
├── 1-1-1-1-cramfs.conf
├── 1-1-1-2-freevxfs.conf
Then add SRC_URI += "file://fsconfigs" for instance.
You should know that the default FILESPATH variable is the default set of directories the OpenEmbedded build system uses when searching for patches and files.
The default value for the FILESPATH variable is defined in the base.bbclass as follow :
FILESPATH = "${#base_set_filespath(["${FILE_DIRNAME}/${BP}", \
"${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files"], d)}"
Here ${BP} stand for the base recipe name and your Package Version: ${BPN}-${PV}
If you want the build system to look in directories other than the defaults, the best practiec is to extend the FILESPATH variable by using the FILESEXTRAPATHS variable.
Note that SRC_URI is used to specify files, not directories.
https://docs.yoctoproject.org/ref-manual/variables.html?highlight=filesextrapaths

Configuration files in separate directory in case of Autotools

I am implementing CPPUTEST for my application along with Autotools, but the final makefile generated in subdirectories is not able to make the final build.
Folder Structure:
|
+- Build_output: holds executable for CPPUTEST
+- Configure : holds `configure.ac` and `Makefile.am`
+- Src: contains source files that contain functions and makefile.am
+- Test: contains test file
+- build: shell script for creating executables.
Snapshot added: build structure
build structure continue
Usually I see example of autotools every where configuration files is kept outside, not inside the configure folder.
Configure.ac inside configure folder:
AC_INIT([cpputest], [1.0], [])
AM_INIT_AUTOMAKE([
-Wall -Werror foreign subdir-objects
])
AC_PROG_CXX
AC_CONFIG_FILES([
Makefile
../src/Makefile
../test/Makefile
])
AC_OUTPUT
Makefile.am inside configure folder:
SUBDIRS = \
../src \
../test
Shell script present outside "build"
#!/bin/sh
cd configure
autoreconf -i
./configure
make check
When I run my shell script, the make file is getting generated inside src and test folder but when I try make check
it executes cd ../.. ---> screenshot attached
./build execution
Is there any other option needed to add in configure.ac or makefile.am ?

Visual Studio Solution Style using CMakelists [duplicate]

I have a CMake project that looks like this:
project/
CMakeLists.txt
subprojectA/
CMakeLists.txt
include/
headerA.hpp
src/
libraryA.cpp
subprojectB/
CMakeLists.txt
src/
mainB.cpp
The "library" subproject, A, is compiled as a static library, becoming libsubprojectA.a. The "main" project, B, is compiled as a binary and depends on the library. mainB.cpp includes a reference to headerA.hpp.
Here is subprojectA/CMakeLists.txt:
project(SubProjectA)
include_directories(include)
add_library(subprojectA STATIC src/libraryA.cpp)
set(${PROJECT_NAME}_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/include
CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE)
And here is subprojectB/CMakeLists.txt:
project(SubProjectB)
include_directories(${SubProjectA_INCLUDE_DIRS})
add_executable(mainBinary src/mainB.cpp)
target_link_libraries(mainBinary subprojectA)
The main Project CMakeLists.txt looks like:
project(Project)
add_subdirectory(subprojectB)
add_subdirectory(subprojectA)
Note that subprojectB, the main project, is listed before subprojectA.
Here's the problem. When I first run "cmake" on this project, ${SubProjectA_INCLUDE_DIRS} is not set within SubProjectB.
What I think is happening is that the CMakeLists for SubProjectB loads first, when ${SubProjectA_INCLUDE_DIRS} has not yet been set. It sets its own include path to an empty string as a result. However, even though libsubprojectA.a gets built successfully before mainBinary, the include path was already set empty beforehand. As a result, I get this error when trying to make mainBinary:
subprojectB/src/mainB.cpp:1:23: fatal error: headerA.hpp: No such file or directory
#include "headerA.hpp"
^
It's a workaround to put subprojectA before subprojectB in the main Project CMakeLists in the declarative world of CMake. What I really want is to know the proper way to indicate to CMake that the include_directories(${SubProjectA_INCLUDE_DIRS}) line depends on the definitions that exist inside SubProjectA's CMakeLists. Is there a better way to do this?
If you want to express that include directory subprojectA/include is an interface of the library subprojectA, attach this property to the target with target_include_directories command:
subprojectA/CMakeLists.txt:
project(SubProjectA)
add_library(subprojectA STATIC src/libraryA.cpp)
# PUBLIC adds both:
# 1) include directories for compile library and
# 2) include directories for library's interface
target_include_directories(subprojectA PUBLIC include)
So any executable(or other library) which linked with subprojectA will have this include directory automatically:
subprojectB/CMakeLists.txt:
project(SubProjectB)
add_executable(mainBinary src/mainB.cpp)
target_link_libraries(mainBinary subprojectA)
Of course, for use last command properly you need to process directory with library before one with executable:
CMakeLists.txt:
project(Project)
add_subdirectory(subprojectA)
add_subdirectory(subprojectB)

CMake Include Directories not found

I have a library project whose hierarchy looks something like this:
Root:
+ src/
+ apple.cpp
+ bananas/
+ bananas.cpp
...
+ include/
+ apple.h
+ bananas/
+ bananas.h
...
I've been using Visual Studio to compile it and it works fine but now I want to diversify it by allowing the library to be compiled using CMake. I've created the following CMakeLists.txt file (located in Root):
cmake_minimum_required(VERSION 2.8) # Version 2.8 required
file(GLOB_RECURSE HEADERS # Fetch all of the Lib's Headers
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp
)
file(GLOB_RECURSE SOURCES # Fetch all of the Lib's Srcs
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
)
add_library( # Create the Library from Srcs
HoneycombGameEngine ${SOURCES}
)
target_include_directories( # Add the Headers to the Lib
HoneycombGameEngine
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
It compiles with CMake and generates its files, however when I run make to actually compile the library, I get an error in the bananas.cpp file (first file it chooses to compile) that it cannot find the bananas.h header file. If it is relevant, the bananas.cpp include header statement looks like this:
#include "..\..\include\bananas\bananas.h"
I'm not exactly sure what I'm doing wrong, this my first time using CMake so I mostly wrote my CMakeLists file using bits and examples from the internet. Anything that could point me in the right direction and help me solve this issue is much appreciated.
You are only get all .h inside include directory.
Bananas.h is inside bananas directory. Then you have to use something like it:
file(GLOB_RECURSE HEADERS # Fetch all of the Lib's Headers
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
${CMAKE_CURRENT_SOURCE_DIR}/include/bananas/*.h
)

Can't compile executable with CMake

I started with the following directory structure:
project
exec
executable.exe
lib
src
include
config
<cmake-generated config file>
I created the library in the lib/src folder by using a CMakefile in the lib/src folder. The exe would compile.
Then, I moved my CMakeFile up to /lib, making sure to change the source file paths to /src/*
Now, when I try to compile, all my libraries compile and link fine, but when I try to link the executable, I get /usr/bin/ld: cannot find -lconfig.
Does anyone have any idea why this happens or how to fix it?
Here is some of my code:
./CMakeLists.txt:
include_directories(config)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
ADD_SUBDIRECTORY(libs) #library sources
ADD_SUBDIRECTORY(exec) #executable sources
CONFIGURE_FILE(${core_SOURCE_DIR}/config/config.h.in
${core_SOURCE_DIR}/config/config.h)
./libs/CMakeLists.txt:
file(GLOB src ...)
file(GLOB header ...)
add_library(lib ${src} ${header})
./exec/CMakeLists:
add_executable(executable executable.cpp)
link_directories(${core_SOURCE_DIR}/lib) #not sure if this is required
target_link_libraries(executable ${lots_of_libs})
Every library in lots_of_libs can be found as a .a file in the lib directory
One problem, probably not risolutive, is this:
link_directories(${core_SOURCE_DIR}/lib) #not sure if this is required
should be:
link_directories(${PROJECT_BINARY_DIR}/lib)
or:
link_directories(${LIBRARY_OUTPUT_PATH})
Anyway, normally you wouldn't need to add to your link_directories the path to a library that is built within the project, even if you have specified a different LIBRARY_OUTPUT_PATH

Resources