I want to tell CMake to output files and folders to a different folder instead of the current folder. I'm talking about the generated files by CMake below:
file: CMakeCache.txt
dir: CMakeFiles/
file: Makefile
dir: bin/
file: cmake_install.cmake
Is there a way to let CMake output these files and folders in another folder?
I wrote a tool that executes CMake from the root of the project-directory, as a result my project-directory gets messed up with the generated files and folders listed above.
Here a link what I want:
http://pastebin.com/cxykCi5M
Hope this will clarify more what I want.
You can use the undocumented command line options -B and -H to specify your build directory and source directory respectively. So, from your project's root, you can do:
cmake -Bbuild -H.
(Where build is your build directory path.)
Related
i have a question (i suppose that it's stupid but i've difficult). I'm try to compile with cmake (not cmake-gui!!!) opencv. The problem is that i need to change the build folder. I give you an example:
I have the source code and the cmakelist on directory /home/xxx/opencv/
I would like to execute cmake and put the build into /home/yyy/lib_opencv/ and subsequently call make install....
With cmake-gui i don't have a problem. But i have to use the cmake command shell.
Can you help me? I hope that i have explained clearly the problem
First, create a directory you want build files to be in and cd there
mkdir /home/yyy/lib_opencv/
cd /home/yyy/lib_opencv/
Then just run cmake and point it to OpenCV source dir:
cmake /home/xxx/opencv/
I have the folder/files /sources/{configure.ac,Makefile.am,...}
How can I execute Automake command so files/folder configure, Makefile, and autom4te.cache are not generated in /sources but in /mydir ?
Thanks
The directory from which you run configure will be the root directory of where the generated files are put.
cd /mydir
/sources/configure
(Although beware; this is not as common as running ./configure right in the source tree. You're supposed to account for it when writing a GNU-compliant configure script, but nonetheless some packages will not build this way.)
I am getting kind of frustrated with cmake, as I am trying to learn it and use it properly.
Here is my setup:
I have a directory called ~/project. In this directory, I have:
build directory
source directory
includes directory.
CMakeLists.txt file.
The contents of this CMakeLists.txt file is:
cmake_minimum_required(VERSION 2.8)
project(myProject)
subdirs(source)
I also have another CMakeLists.txt in ~/project/source, and its content is:
cmake_minimum_required(VERSION 2.8)
include_directories("~/project/includes")
add_executable(exec entry.cpp)
Now, I go into the build directory which is empty, and do cmake ... This works fine. However I then see a 'source' directory get created as shown here.
Why is this being created? I do not know what is going on. As I understand it, it should not be doing this, it should give me everything I see here, except for the 'source' directory.
Thanks.
Inside your build directory, CMake re-creates the whole directory structure of your project. The rational is, to keep the project structure. Image a bigger project with several levels of subfolders and sources, libraries and tests scattered in a meaningful way. To run a test, you follow the structure where the test's source is located, just in the build directory instead of the source directory.
As your project, at least as far as CMake knows it, is only the source subdirectory, only this folder is created.
If you really have just the source project, I am not sure whether would be better to place the CMake project just inside source.
I'm building project with CMake. While configuration and building I'm in directory project/build . How can I change the directory in CMake and execute a bash script from another directory.
execute_process( COMMAND cd ../ ) - doesn't work. When I execute this CMake doesn't change its directory and I'm again in project/build.
The WORKING_DIRECTORY directive of the execute_process command lets you directly specify the directory the script is to be run from.
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/script.sh args
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
With ${CMAKE_SOURCE_DIR} you get the source path. Executing a binary from the source directory would be
execute_process(${CMAKE_SOURCE_DIR}/bin/myscript.sh)
If you need to handle files from the build directory you have to add them like
execute_process(${CMAKE_SOURCE_DIR}/bin/myscript.sh ${CMAKE_CURRENT_BINARY_DIR}/input.txt)
Overall the variables CMAKE_SOURCE_DIR, CMAKE_CURRENT_SOURCE_DIR, CMAKE_BINARY_DIR, and CMAKE_CURRENT_BINARY_DIR are very helpful. You can find a more complete list at http://www.cmake.org/Wiki/CMake_Useful_Variables
I am installing cufflinks on my Mac OS X, and here is the instruction:
http://cufflinks.cbcb.umd.edu/tutorial.html
Under Installing the SAM tools I follow the instructions below
Download the SAM tools
Unpack the SAM tools tarball and cd to the SAM tools source directory.
Build the SAM tools by typing make at the command line.
Choose a directory into which you wish to copy the SAM tools binary, the included library libbam.a, and the library headers. A common choice is /usr/local/.
Copy libbam.a to the lib/ directory in the folder you've chosen above (e.g. /usr/local/lib/)
Create a directory called "bam" in the include/ directory (e.g. /usr/local/include/bam)
Copy the headers (files ending in .h) to the include/bam directory you've created above (e.g. /usr/local/include/bam)
Copy the samtools binary to some directory in your PATH.
I've done the fist 7 steps, but I am not sure how to proceed with the last step (#8): should I use the command:
sudo cp -a samtools-0.1.18 /usr/local/
or into some other directories? What does the PATH in step 8 indicate? Thanks!
To answer your question I will go over some basic linux knowledge that has helped me understand binaries and their locations.
In linux, you can run a binary by typing in a complete path to the binary and the binary will run. For example, if I have a binary named foo in /usr/local/bin, I would run the command /usr/local/bin/foo and the foo binary would be run.
The purpose of the PATH is a shortcut so that you don't need to type in the complete path to the binary, just the name of the binary. PATH is a variable that contains all of the directories that have binaries that you want to have the shortcut apply to. So, referring to the previous example, if /usr/local/bin is in my PATH variable, then I could just run foo.
So, to answer your question, you can tell which directories that are in your PATH by running the command echo $PATH and if one of the directories is where your samtools binaries are, your good!! If not, you can move your samtools binaries to one of those directories so that you don't have to put the full path everytime you want to run the binaries.