cmake - how do i do add_cd_file but for directories - c++

I am trying to add cygwin to the reactos project. everytime i try doing
add_cd_file(${CMAKE_CURRENT_SOURCE_DIR}/cygwin DESTINATION reactos/cygwin FOR all)
It fails because it is not a file, I have tried to use copy but that just copies the file, it does not add it to the destination. So my question is how do I do something like this add_cd_dir?

Related

Is there a way to copy a directory full of files and change their file extentions in a Dockerfile

Problem
I want to copy all the files in a directory over to my container, changing the extension.
Setup
Lets say I want my local directory src/* copied into the container at /work/
src/ contains a bunch of files with extensions like .txt.
I want to COPY them over and change their extensions to .textfile.
Currently I am doing
COPY src/file1.txt /work/file1.textfile
COPY src/file2.txt /work/file2.textfile
COPY src/file3.txt /work/file3.textfile
...
This works file but create a bunch of layers in my image and I'd like to just have it done in one step.
What I've tried
COPY src/*.text /work/*.textfile
This doesn't work.
Work around
I installed util-linux and used the rename command like so:
COPY src/*.txt /work/
RUN rename '.txt' '.textfile' /work
But this is undesirable as the command comes as a package.
Question
Is there a way to do this simply as a dockerfile command?

Scons set s directory as NoClean

I'm using scons as my build system of c++.
There's a sub directory that contains a static library.
I've tried to set:
NoClean("${PATH_TO_DIR}")
But the files in this directory are still removed by scons -c.
Is there a way to prevent this command from removing all files generated in this directory?
The flag -c works more or less like this:
List all the files that could be built by this call of scons if the flag was not there.
Add to the list relevant files marked to be cleaned with Clean().
Delete from the list the files marked with NoClean() (non-recursively).
Remove all the files that are remaining on the list from the filesystem.
SCons is very focused on files and it doesn't work that well with directories. Usually, it just creates them automatically whenever they are needed and for the rest of the time it pretends they doesn't exist and it is all a flat file-system. It doesn't even delete automatically created directories so your NoClean() is double-ineffective :-) (You would need to call Clean() on the directory for SCons to be able to remove it during cleaning.)
I think your only option is to call NoClean() for every file that you create in this directory. (If you have the list/set of those files lying somewhere, you can just call NoClean() once, passing the list to it.)
scons -c . will only remove the target file under the certain directory. So this is a fallback to resolve my problem.

Is there a way with conan to export an empty directory?

Considering a folder (called parent_folder) containing an empty folder (called empty_son_folder) and another one that is not empty (called not_empty_son_folder) and the following exports_sources method:
exports_sources = ["parent_folder*"]
Only not_empty_son_folder is exported.
Is there a way with conan to force to copy an empty folder in export source method?
As #Yumnosch said it is possible to add a dummy file to force conan to include this folder or create this folder later in the receipe (#drodri's solution).
If the need is to have files generated by some test programs, both solutions work.
It is also possible to create such a folder directly in the test program that needs it.

Add source to an existing automake program

I would like to edit an existing software to add a new source file (Source.cpp).
But, I can't manage the compilation process (it seems to be automake and it looks very complicated).
The software (iperf 2: https://sourceforge.net/projects/iperf2/files/?source=navbar) is compiled using a classical ./configure make then make install.
If I just add the file to the corresponding source and include directory, I got this error message:
Settings.cpp:(.text+0x969) : undefined reference to ...
It looks like the makefile isn't able to produce the output file associated with my new source file (Source.cpp). So, I probably need to indicate it manually somewhere.
I searched a bit in the project files and it seemed that the file to edit was: "Makefile.am".
I added my source to the variable iperf_SOURCES in that file but it didn't workded.
Could you help me to find the file where I need to indicate my new source file (it seems a pretty standard compilation scheme but I never used automake softwares and this one seems very complicated).
Thank you in advance
This project is built with the autotools, as you already figured out.
The makefiles are built by automake. It takes its input in files that usually have a am file name extension.
The iperf program is built by the makefile generated from src/Makefile.am. This is indicated by:
bin_PROGRAMS = iperf
All (actually this is a simplification, but which holds in this case) source files of a to be built binary are in the corresponding name_SOURCES variable, thus in this case iperf_SOURCES. Just add your source file to the end of that list, like so (keeping their formatting):
iperf_SOURCES = \
Client.cpp \
# lines omitted
tcp_window_size.c \
my_new_file.c
Now, to reflect this change in any future generated src/Makefile you need to run automake. This will modify src/Makefile.in, which is a template that is used by config.sub at the end of configure to generate the actual makefile.
Running automake can happen in various ways:
If you already have makefiles that were generated after an configure these should take care of rebuilding themselves. This seems to fail sometimes though!
You could run automake (in the top level directory) by hand. I've never done this, as there is the better solution to...
Run autoreconf --install (possibly add --force to the arguments) in the top level directory. This will regenerate the entire build system, calling all needed programs such as autoheader, autoconf and of course automake. This is my favorite solution.
The later two options require calling configure again, IMO ideally doing an out of source built:
# in top level dir
mkdir build
cd build
../configure # arguments
make # should now also compile and link your new source file

How to use SQLite in C++ program using Code::Blocks?

I'm a complete beginner with Code::Blocks and SQLite, and have some basic knowledge with C++. I'm currently using Ubuntu 11.04.
I have downloaded SQLite Amalgamation here. When I extracted the zip file, there are four files inside: shell.c, sqlite3.c, sqlite3.h, and sqlite3ext.h. If I simply add those files to a (for example) a console project, it gives out an error: the .c's of the downloaded sqlite each have their own main function. Removing those from the project, the errors are gone and I can call #include "sqlite3.h". I am trying to follow this, and tried the first two lines of code from here and it gives out an error: undefined reference to sqlite3_open.
I think adding those .h's directly to a console project isn't the right way to use it, though I'm not sure.
How exactly should I use those? What should I do to use those for my C++ program?
Any help is greatly appreciated. :)
EDIT: I also tried to create a .a file of those sqlite files by following this. When I try it, it gives out an error: cannot find -lsqlite.
I got it! Though there was something that I did that caused problems.. I forget to remove the .a file that I added at Project > Build Options > Linker Settings earlier, which caused problems..
Here are the steps I made to add SQLite: (for those that might have the same problems)
Copy the files extracted from the SQLite Amalgamation to the directory of the project.
Add the sqlite files (Project > Add Files) EXCEPT the shell.c (it is the one that causes the multiple function error)
Compile it (Yes, a simple Ctrl+f9).
here are errors: undefined reference to pthread_mutexattr..... These are fixed by going to Project > Build Options > Highlight 'the Project Name' above Debug and Release at the top left corner > Linker settings, and adding "-lpthread" (without quotes) to Other linker options:.
Some more errors are found: undefined reference to dlopen, dlerror..... Add '"-ldl"' just below the '"-lpthread"' added earlier.
DONE :)
I didn't find a complete answer for Windows as a beginner, and at the beginning it is very painful to understand everything. So here's what worked for me.
Download the SQlite Amalgamation file.
Open Code::Blocks -> New Project -> Choose static library
Unzip the file you have downloaded and copy the folder/contents to your new project directory. Add all the files to the project and build the project.
You will find a ProjectName.a file in the bin/Debug or bin/Release directory. Copy that file to your actual SQlite project directory.
Go to Code::Blocks Project->Build options. Select 'Linker Settings' tab and add the path to the .a file. Don't close it yet!!!
In 'Search Directories' tab, select the 'Compiler' tab, add the path to the Amalgamation header files, or copy the header files to your directory (you can add the header files to your project) and in the 'Linker' tab add the path to the .a file
Now Compile!!! Hopefully this will run
That is all, I wish it'll save some searching time for another noob
You will need to compile the sqlite code first, and then just #include "sqlite3.h" into your project where you need it.
UPD:
Try this:
Download this package from sqlite site and extract it somewhere, say, into a folder called "sqlite". Open terminal, and go into this folder. Inside of it, run
./configure
sudo make
sudo make install
and see what happens. It should build itself automatically. Consult the README file that is inside the archive too.