How to exclude directory from make check - compilation

I use some third party library in my project which I need to compile into the code. But I want to not run make check in the subdirectory of the library.
How can I achieve this?
Right now, I am including the library by adding a line
SUBDIRS += libsomelibrary
to Makefile.am.

Related

cmake: how to force a project not to use cache?

Projects generate a CMakeCache.txt file, and as a result the cmake instructions of the CMakeLists.txt will not run twice if the CMakeLists.txt is not changed.
I would like a specific project to not generate a CMakeCache.txt file (or alternatively, to ignore the one that has been generated). I would like this to be automated, i.e. not to have to delete the file manually.
Context: I am using colcon to compile several projects, and I would like the cache to be ignored only for a specific package, no all.
(An alternative could be to be able to force the execution of a specific macro, independently of whether or not the CMakeLists.txt file has been changed or not.)

cmake-gui show blank except source code directory and binaries directory

After installing cmake-3.8.1-win64-x64 I got thisenter image description here
So what can I do with this? Thanks.
cmake-gui does not help you create cmake configuration files, it parses these files to generate and configure projects.
In your source code directory, you should have a CMakeLists.txt file which defines the rules for CMAKE to configure your problem. That directory should be entered into the first box.
Next, you get to decide where to build the binaries. We could do it in the source directory, but the generated artifacts could pollute what is already there. "Cleaning" the build by deleting all of those artifacts while keeping the original sources is tedious at best, so it's a good idea to make an empty directory and use that as your binaries path.
Once you have those fields entered, you should be able to "Generate" or "Configure" your project. If you need help creating a CMakeLists.txt file (that's really the complicated part), then check out their tutorial.

Compiling and embedding lua into a C++ application

For portability reasons, I'd like to compile lua from source when I compile my C++ code. I use lua to read input file.
If I understand correctly, lua's readme mentions that it's possible to do that through src/Makefile. I can't really read it that well. Has anyone figured out how to do it?
is it possible to have it in one command? gcc ....
bonus: how to put it in cmake ?
Lua has a makefile that needs your target platform to build to so you will need to specify make [target platform].
But that is right in the beginning of the readme.
You could try to call the make command from inside your build process.
Cheers
[UPDATE based on the comments]
If you use:
make a PLAT=[target platform]
on the command line in the src directory it will only build the liblua.a library for the target platform then you will just need to copy that file to wherever you need and link against it.

gnu make, include and clean target

I am working on a system which is composed of many projects and makefiles. Each makefile includes .inc files from it`s dependencies. If a dependency is missing, it complains and tells the user to compile the dependency first. This part works ok. Problem is the clean target.
If a dependency is cleaned first and it`s inc file is deleted (since inc files include compile time options and hard paths, we prefer to delete them), then Makefile fails to load the .inc file and aborts. So the mechanism that makes sure we have the right dependencies, does not let us call the clean target -which does not require the dependencies-.
Is there any way to include or ignore .inc files according to the rule?
PS: Since we are already using "-" for error checking so that is not an option.
the canonical way to prevent including when cleaning is as follows:
ifneq ($(MAKECMDGOALS),clean)
include $(some .inc files)
endif
as described here https://www.gnu.org/software/make/manual/make.html#Goals
although if i understand correctly the errors you are experiencing are not because of the failed includes, which you are already supressing with -include, but because your makefile is dependent on some values from the includes.
to help you fix that we will need some code which demonstrates the problem. please read here for how to do so: https://stackoverflow.com/help/minimal-reproducible-example and http://www.sscce.org/

Passing C/C++ #defines to makefile

I develop C/C++ using the Eclipse IDE. Eclipse also generates a makefile which I don't want to edit as it will simply be overwritten.
I want to use that makefile for nightly build within Hudson.
How do I pass #defines which are made in the project file of the IDE to the makefile ? (and why doesn't Eclipse already include them in the generated makefile?)
I actually had this figured out once, then accidentally overwrote it :-( But at least I know that it can be done...
If you are running make from the command line, use
make CPPFLAGS=-DFOO
which will add -DFOO to all compilations. See also CFLAGS, CXXFLAGS, LDFLAGS in the make manual.
You could write a small program to include the headers and write a makefile fragment which you include in the main makefile (requires GNU make).
This is a fairly ugly solution that requires a fair amount of hand hackery. More elegant would be to parse the project file and write the makefile fragment.
For GCC use -D define.
OP commented below that he wants to pass the define into make and have it pass it on to GCC.
Make does not allow this. Typically you just add another make rule to add defines. For instance 'make release' vs 'make debug'. As the makefile creator you make the two rules and have the defines right in the make file. Now if Eclipse is not putting the defines into the makefile for you, I would say Eclipse is broken.
If you're using autotools another options is to have 2 directories 'bin/debug' and 'bin/release'.
# Simple bootstrap script.
# Remove previously generated filed and call autoreconf.
# At the end configure 2 separate builds.
echo "Setting up Debug configuration: bin/debug"
../../configure CXXFLAGS="-g3 -O0 -DDEBUG=1"
echo "Setting up Release configuration: bin/release"
cd bin/release/
../../configure CXXFLAGS="-O2"
Setup Eclipse. Open the project's properties (Project->Properties->C/C++ Build->Builder Settings) and set the Build Location->Build Directory to
${workspace_loc:/helloworld/bin/debug}
Replacing 'helloworld' with your project's directory relative to the workspace (or you can supply an absolute path ${/abs/path/debug}). Do the same thing with the Release config, replacing "/debug" with "release" at the end of the path.
This method seems like a waste of disk space, but a valid alternative to achieve completely separate builds.

Resources