meson.build: ERROR: File does not exist, while in reality it does - meson-build

From a trivial meson.build file, I get the following error:
meson.build:27:0: ERROR: File dataStructures.hpp does not exist.
dataStructures.hpp,
The meson.build file is:
headers += [
'dataStructures.hpp',
'interface.hpp',
'platform.hpp',
'progArgs.hpp',
]
The file reported as missing is present and it is in the same directory the meson.build file is.
If I remove the 'dataStructures.hpp' string from the list, I get the same error for the second file 'interface.hpp'.
What am I doing wrong?
More details follow.
> CC=clang CXX=clang++ meson /dev/shm/test-build
The Meson build system
Version: 0.52.0
Source dir: /home/pietrom/myProgs/test
Build dir: /dev/shm/test-build
Build type: native build
Project name: test
Project version: 0.0.1
C++ compiler for the host machine: clang++ (clang 8.0.1 "clang version 8.0.1 (tags/RELEASE_801/final)")
C++ linker for the host machine: GNU ld.bfd 2.32
Host machine cpu family: x86_64
Host machine cpu: x86_64
src/meson.build:27:0: ERROR: File dataStructures.hpp does not exist.
A full log can be found at /dev/shm/test-build/meson-logs/meson-log.txt
In the full log there is no much more than what already reported.
This is the project directory structure:
test/
meson.build
src/
meson.build
sources
config/
meson.build
sources
testers/
meson.build
sources
utilities/
meson.build
sources

As you don't provide all meson.build file contents, and most importantly the place where it happens - meson.build:27:0: ERROR: File dataStructures.hpp does not exist. - points at line 27 in some meson.build file, I'll try to make a guess that you build executable in root meson.build file, i.e. in test/meson.build however your headers are inside test/src. If that's the case, you don't need to have this array of headers at all, just add
inc = include_directories('./src')
some_test_exe = executable('mytest',
test_sources,
...
include_directories : inc
)
include_directories function creates include object with path relative to your source root.

Related

How do I tell meson setup about the location of a dependency?

I'm trying to build celluloid, which uses meson. I ran meson, but it failed to find an appropriate version of mpv:
Determining dependency 'mpv' with pkg-config executable '/usr/bin/pkg-config'
Called `/usr/bin/pkg-config --modversion mpv` -> 1
Found CMake: /usr/bin/cmake (3.13.4)
Determining dependency 'mpv' with CMake executable '/usr/bin/cmake'
Try CMake generator: auto
Called `/usr/bin/cmake --trace-expand -DNAME=mpv .` in /tmp/celluloid-0.20/build/meson-private/cmake_mpv -> 0
Dependency mpv found: NO (tried pkgconfig and cmake)
src/meson.build:125:0: ERROR: Dependency "mpv" not found, tried pkgconfig and cmake
so I downloaded and built the latest mpv release (0.33.0), built and installed it at /opt/mpv.
Now - how do I tell meson to take mpv from this new path?
Note: The relevant snippet of the meson files seems to be:
executable('celluloid', sources,
dependencies: [
libgtk,
libgio,
meson.get_compiler('c').find_library('m', required: false),
dependency('mpv', version: '>= 1.107'),
dependency('epoxy')
],
link_with: extra_libs,
include_directories: includes,
c_args: cflags,
install: true
)
You tell meson about your dependency by letting pkgconfig know about your dependency...
and that can be done by adding your dependency's path to the PKG_CONFIG_PATH environment variable; it is delimited by colons, just like PATH, e.g. /opt/foo:/opt/extra/baz.
Remember that you may also need to add associated paths to LD_LIBRARY_PATH after building and installing with a custom-built directory.

How to set CMake variable to include directory

When trying to build this library with Cmake from the Developer Command Prompt for VS, I get this error
CMake Error at cmake/FindEigen.cmake:77 (MESSAGE):
Failed to find Eigen - Could not find eigen3 include directory, set
EIGEN_INCLUDE_DIR to path to eigen3 include directory, e.g.
/usr/local/include/eigen3.
I'd like find out what was intended of me here: am I to set EIGEN_INCLUDE_DIR with a command line argument or by editing the make file?
I've tried cmake -D EIGEN_INGLUDE_DIR=C:\Users\a\Downloads\eigen-3.3.7\eigen-3.3.7 . but received the same error.
cmake -D EIGEN_INGLUDE_DIR=C:\Users\a\Downloads\eigen-3.3.7\eigen-3.3.7 . failed without creating any files (cmake .. at least started building) and gave me this error
CMake Error: The source "C:/Users/a/Downloads/RpolyPlusPlus-master/RpolyPlusPlus-master/build/CMakeLists.txt" does not match the source "C:/Users/a/Downloads/RpolyPlusPlus-master/RpolyPlusPlus-master/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
So I just ended up adding this to the .cmake file:
# TODO: Add standard Windows search locations for Eigen.
LIST(APPEND EIGEN_CHECK_INCLUDE_DIRS
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
/opt/local/include
/usr/include
C:\\Users\\a\\Downloads\\eigen-3.3.7) <---------------------------------------

How to use CMake to create a package that installs to '/etc' and '/var'?

I've got CMake (3.02) installing to a DESTDIR when I invoke:
$ make -C build DESTDIR=$(pwd)/build/rootfs install
This results in a file layout that I'm happy with: binaries are located in the .../build/rootfs/usr/local/bin directory and the init scripts are in .../build/rootfs/etc/init.d. To accomplish that, I used a mixture of relative and absolute paths in my CMakeLists.txt file:
set(CPACK_SET_DESTDIR ON)
...
INCLUDE(CPack)
...
set(ROOTFS_BIN_DIR bin)
set(ROOTFS_ETC_INITD_DIR /etc/init.d)
...
INSTALL(TARGETS myDaemon DESTINATION ${ROOTFS_BIN_DIR})
INSTALL(PROGRAMS myDaemon.sh RENAME myDaemon DESTINATION ${ROOTFS_ETC_INITD_DIR})
With that, I think 'working', I'm trying to create a simple tarball package which will eventually become a debian package (with pre/post install/remove scripts) but when I invoke:
$ make -C build DESTDIR=$(pwd)/build/rootfs package
I'm getting errors because cpack is attempting to write my init scripts to the system's /etc/init.d directory (instead of $(pwd)/build/rootfs/etc/init.d). If I wanted that, then $sudo !! would solve the problem. The error (replaced full path with ...):
CMake Error at .../build_src/cmdServer/cmake_install.cmake:44 (file):
file INSTALL cannot copy file
".../src/cmdServer/cmdServer.sh" to
"/etc/init.d/cmdServer".
I'm not using a lot of CPACK directives: in my top level CMakeLists.txt file I have:
SET(CPACK_SET_DESTDIR ON)
SET(CPACK_GENERATOR TGZ)
INCLUDE(CPack)
How can I package my init scripts correctly?
I've been referencing:
https://cmake.org/pipermail/cmake/2008-April/020833.html
and https://cmake.org/pipermail/cmake/2006-November/011890.html

No such file or directory -- Building an RPM with CPACK using custom spec file

I'm trying to build an RPM with CPACK using my own .spec file. In following the tutorial from here.
I'm getting an error when building the RPM:
No such file or directory
It has to do with the Source0 line in the .spec file
I've got this in my CMakeLists.txt file:
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/my_project.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/my_project.spec" #ONLY IMMEDIATE)
SET(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_BINARY_DIR}/my_project.spec")
SET(CPACK_PACKAGE_RELEASE 2)
INCLUDE(CPack)
This works and generates a .spec file. In my .spec.in file, it's got:
Buildroot: #CMAKE_CURRENT_BINARY_DIR#/_CPack_Packages/Linux/RPM/#CPACK_PACKAGE_FILE_NAME#
Name: #CPACK_PACKAGE_NAME#
Version: #CPACK_PACKAGE_VERSION#
Release: #CPACK_PACKAGE_RELEASE#%{dist}
Summary: Blah blah
Vendor: #CPACK_PACKAGE_VENDOR#
License: MIT
Source0: https://github.com/me/%{name}/archive/%{version}.tar.gz
BuildRequires: gcc, make, cmake
BuildRequires: doxygen, graphviz, doxygen-latex
%description
<SNIPPED>
Then I get rhe error
CPackRPM:Debug: *** error: File /home/me/projects/my_project/build/_CPack_Packages/Linux/RPM/SOURCES/1.0.0.0.tar.gz: No such file or directory
That error is due to the Source0 line I imagine.
If I do this instead, I get a little different error:
CPackRPM:Debug: *** error: File /home/me/projects/my_project/build/_CPack_Packages/Linux/RPM/SOURCES/my_project: No such file or directory
And somewhat related, this doesn't seem to generate an SRPM either. I need one of those to submit to Fedora for inclusion in package db.

generate CMakeList.text for OS X

I'm trying to create a plugin for OBS using C, and compiling it using cmake .. && make see - https://github.com/jp9000/obs-studio/wiki/Install-Instructions#mac-osx
when running cmake .. && make from cmd it gives me an error that cmake: command not found and when I run it from the program it gives me an error - CMake Error: The source directory "/Users/gerwin/Desktop/soOBS" does not appear to contain CMakeList.text specify --help for usage, or press the help button on the cmake GUI
How can I generate a CMakeList.Text to compile my soOBS script to a .so file?
One problem is that cmake is not in your path. So, if you type cmake from your command line it cannot be found. The other problem is that you are not specifying correctly your source directory: you have to specify as source directory the location of the main/root CMakeLists.txt.
So, proceed as follow:
Locate your cmake executable, obtaining your <full path to cmake>
Open a shell
Go to your source directory (location of the main/root of obs-studio CMakeLists.txt)
mkdir build
cd build
<full path to cmake> ..The first argument .. is your source directory, location of the main CMakeLists.txt
make