ninja appends its default installation path to my DESTDIR [duplicate] - installation

I'm using to building code with CMake; but I'm now faced with using meson to build a certain repository. With CMake and make, if I use something like:
cmake -DCMAKE_INSTALL_PREFIX=/some/where` build_dir
make -C build_dir
make -C build_dir install
then instead of the files going under /usr/local by default, they will go under /some/where, e.g. /some/where/bin for executables, /some/where/lib, for libraries etc.
What's the meson equivalent of doing this?
Inspired by: What is CMake equivalent of 'configure --prefix=DIR && make all install '?

It's actually similar to the autotools convention in terms of the switch:
meson setup --prefix=/path/of/installation/destination build_dir
ninja -C build_dir
ninja -C build_dir install
(you could drop the first ninja command; ninja install will build before it installs.)

Related

How to properly use dockcross for cross-compilation?

Some Background
I am trying to cross-compile an app I have for RaspberryPi 3B. I have installed dockcross as below:
docker run --rm dockcross/linux-armv6 > ./dockcross
chmod +x ./dockcross
mv ./dockcross ~/bin/
On my host, macOS high sierra, I can compile and link without a problem.
Issue
First I run: dockcross cmake -Bbuild -H.. After that running dockcross make, naturally, compiler gives an error: <some-lib/some-lib.h> not found.
After this I accessed the container bash by dockcross bash and installed all missing libs and their headers to container. Unfortunately, error is same and compiler can't find headers. Contents of my CMakeLists.txt:
cmake_minimum_required (VERSION 3.0)
project (myLibProject)
include_directories(
.
/usr/include
)
link_directories(
/usr/lib
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
file(GLOB SOURCES
"include/*.h"
"src/*.cpp"
)
add_library(myLibProject ${SOURCES})
target_link_libraries(myLibProject some-lib)
When dry-run make - make -n - I can't see the include directive for folders other than current - . - folder :
/usr/bin/arm-linux-gnueabihf-g++ -I/work/. -std=c++11 -o CMakeFiles/myLibProject.dir/src/src1.cpp.o -c /work/src/src1.cpp
If I manually run the above command by adding -I/usr/include, compiler successfully compiles src1.cpp.o
Questions
Why CMake haven't picked-up other directories? They are present at container linux.
My project have a lot of dependencies, for example boost. How should I modify my CMakeLists.txt to properly compile my projects using dockcross?

make without makefile after cmake

I try to use the c++ language bindings for the ev3dev lego brick: https://github.com/ddemidov/ev3dev-lang-cpp
The instruction is as follows:
mkdir build
cd build
cmake .. -DEV3DEV_PLATFORM=EV3
make
I am running windows and have cmake and mingw available. After running cmake it creates some files in the build directory. However: There is no makefile which could be picked of by make. So I am wondering how iam supposed to compile these bindings
On Windows, CMake generates a MSVC solution by default. Check for a .sln file in your build directory.
The instructions you linked are assuming a Unix-ish platform, where the default is to create Makefiles.
If you actually want Makefiles on Windows, add -G "Unix Makefiles" to the cmake line.
If you want to use MSVC as compiler but work on the command line, another option is -G "NMake Makefiles", and calling nmake after that.
Make sure to delete your build directory before trying to build a new generator target. CMake can be touchy about that.
Check cmake --help for a list of available options. (Especially the generator targets are platform-specific.)

LLVM3.8 Makefile.config, Makefile.common and Makefile.rule missing in build folder

so I'm learning about llvm and I decided to build the 3.8 from the tars that I downloaded from LLVM site.
Everything works fine and I managed to build the sources in a separate build folder.
(After downloading all the sources)
$cd llvm3.8/build
$cmake -G "Unix Makefiles" ../llvm
$make -j 4
$make install
so my dir looks a bit like this:
llvm3.8/
llvm3.8/build
llvm3.8/llvm
While learning how to write a LLVM pass I noticed that my build folder is missing these files:
Makefile.config
Makefile.common
Makefile.rule
that I use in the Makefile I have written for the pass I've implemented.
What I know is that the source has these files:
$cd llvm3.8/llvm
$ls:
CMakeLists.txt README.txt llvm.spec.in
CODE_OWNERS.TXT autoconf projects
CREDITS.TXT bindings resources
LICENSE.TXT cmake test
LLVMBuild.txt configure tools
Makefile docs unittests
Makefile.common examples utils
Makefile.config.in include
Makefile.rules lib
while my build folder doesn't.
$ cd llvm3.8/build
$ ls
CMakeCache.txt cmake libexec
CMakeFiles cmake_install.cmake projects
CPackConfig.cmake compile_commands.json share
CPackSourceConfig.cmake docs test
DummyConfigureOutput examples tools
LLVMBuild.cmake include unittests
Makefile install_manifest.txt utils
bin lib
Is my build folder containing what it is supposed to contain?
Maybe the pass must be written in the sources llvm3.8/llvm?
Thanks for the help.
You are suppose to write your pass in llvm/lib/Transforms/YourPassName
Create a directory in build:
mkdir -p llvm3.8/build/lib/Transforms/YourPassName
I would recommend you to use cmake. As autoconf is going to be deprecated in llvm3.9. For it:
Add entry in llvm/lib/Transforms/CMakeLists.txt
add_subdirectory(YourPassName)
After putting the entry, create CMakeLists.Txt in llvm/lib/Transforms/YourPassName like the other llvm passes.
Now use
cmake ../llvm3.8
From inside the pass directory:
make
Also if you have install llvm and want to do standalone, use the approach given in this answer: https://stackoverflow.com/a/37308946/4946286

Cross platform alternative `mkdir -p` in makefile + cmake

I'm writing makefile, that works with cmake. makefile just creates the build directory and start cmake in it, if build directory is not created yet, or redirects targets to makefile created by cmake, if it already exists. I used mkdir -p to create a build directory, but it is not cross platform.
Is there any cross platform variant for mkdir -p? May be cmake provides alternative command, like it does autoconf?
You can use cmake -E make_directory (see documentation). If the parent directories are not existing, it does create all directories up the given one.
If you use it inside a CMake script itself, e.g. as pre-build step: ${CMAKE_COMMAND} -E make_directory
References
Creating a directory in CMake
cmake: make_directory in built time

Automake adding flags to install.sh

I am using autotools to build some packages that I want the headers to be installed only if they are changed.
I see that install.sh has a flag -C for installing only if different, but how do i set that flag in autotools?
In my Makefile.am I am providing nobase_libhello_include_HEADERS = file1.h file2.h if that helps.
You override the install command when calling configure:
./configure INSTALL="/usr/bin/install -C"

Resources