Maybe this has been asked before but I could not find anything, that answers my question precisely.
I created a New arm cortex cmsis cpp project in eclipse. This gave me the default folder structure. I build the debug config and now have the generated makefiles in the debug folder. From here I can Do "make clean" and "make and everything compiles fine. The makefiles (including the sub mk files) were to static for my needs, so I changed them to be more generic (I only tell the make where the src folders are and it scans all the folders for c and cpp files and builds All the obj files and dependencies). I also took the makefile out of the debug folder and put it one level up into the project folder. So all together, I changed the location of the makefile and made it more dynamic. Now when I run "make", everything runs fine. Everything is compiled BUT the generated .elf and .bin have a different size, compared to files, that were created with the original files. I can See in the terminal that make creates the same files in the same order with the same flags. Everything is identical except that the location of the files now is in ./ instead of ../ How is this possible?
Most object files and binaries contain information about the location of the source files, so that the debugger can locate them. There may be other changes such as date and time stamps (although it's unlikely this will change the size of the output).
You can run something like strings myprog | sort on both old and new programs and see if the strings in your program are now different sizes.
Related
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.)
I need to generate *.hie files for all of my Haskell module files in a project managed by Haskell Stack. I do this, by adding the -fwrite-ide-info compilation flag to stack.yaml in the following form:
ghc-options:
"$locals": -fwrite-ide-info
Let's say the project consists of one package with a library and an executable. A stripped down package.cabal would be
name: package
library
exposed-modules:
Package.Exposed.Module
ghc-options: -fwrite-ide-info
executable binary
main-is: Main.hs
ghc-options: -fwrite-ide-info
build-depends:
package
Then, I run stack build.
During the compilation, the *.hie files are generated in the .stack-work directory.
To be exact, respectively, the library and executable files are in
path/to/project/package/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/Package/...
path/to/project/package/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/binary/binary-tmp/...
I need the *.hie files in the actual source directories, and, low and behold, those *.hie files show up for the library, but not for the executable.
Now my question: How does Haskell Stack handle *.hie files. Are they handled in a special way, e.g., are they copied to the source files, where they can be found by programs making use of them (one such program that I want to use is weeder)? If not, I have no idea how those *.hie files showed up. Do you have any suggestions?
Thank you!
So, it seems that Haskell Stack does not copy/move hie files to the source folders. Maybe it did that at some point, because otherwise I have no idea how the files popped up there. After deletion of the hie files in the source folders, weeder actually uses the hie files in the .stack-work directories. I apologize for the confusion.
I just took over a GCC project containing a makefile that has way to many include folders and source files listed. I started removing one by one and verified by compiling, but wondered, is there some way of looking at the compiled output (map files for instance?) and compare that to the makefile to clean out unnecessary files?
I'm not saying this will make any difference to the finished project, but I like to quickly look at the Makefile to see what this project involves. Now it looks like it involves "everything"
After an error occurred because of a missing flag or incorrectly set environment variable, is it possible to continue compiling once the mistake has been fixed?
I regularly use CMake and make to compile toolkits that take quite a while to compile and, also regularly, I accidentally set variables incorrectly in the process. Just now for example, I was attempting to include OpenInventor headers which on my machine are located in the directory /Users/user/software/prod/coin/include/Inventor.
I mistakenly passed
-DINVENTOR_INCLUDE_DIR=/Users/user/software/prod/coin/include/Inventor
rather than the correct
-DINVENTOR_INCLUDE_DIR=/Users/user/software/prod/coin/include
This only became an issue after 30 minutes when about 95% of the compilation was completed. Because I knew that reconfiguring using CMake would force a recompilation from scratch, I tried to add -I/Users/user/software/prod/coin/include to CMAKE_CXX_FLAGS in CMakeCache.txt but to no avail–it still recompiled from scratch. Since only a single source file actually includes the headers in question, it would be desirable if I could start compiling from the point where it exited with an error once the relevant path has been corrected. How can I do this and, as an aside, why does it force the compiler to start from scratch?
I'm using CMake version 3.11.1 and clang (Apple LLVM version 9.1.0) on macOS 10.13
CMake does not need to recompile everything just because it regenerates its makefiles. It will still perform normal make avoidance operations. However CMake does track the compiler options used to build each target, so if you make a change in the compiler options for all the targets then they'll all need to be rebuilt.
If this compiler option is only needed for one target, you can add it to just that target an no others, with something like this:
set_property(SOURCE my_source.c APPEND PROPERTY
COMPILE_FLAGS -I/foo/bar)
then it should only rebuild that one source file.
CMake looks for files' "last modified" times to decide which files need recompilation. But if you change the input to CMake itself, then it needs to regenerate the Makefiles and therefore recompile everything. But still, one hack may be possible...
CMake stores information about the include directories and the libraries to be linked in various text files in the build directory. So one hack (not recommended, but works) can be to modify these text files.
In the particular example that you mentioned, the hack would be to search and replace all occurrences of /Users/user/software/prod/coin/include/Inventor with /Users/user/software/prod/coin/include in all the files of the build directory.
(As an aside, if you don't already know, you can use make -j <n> to build using multiple threads which can considerably decrease the build times.)
I'm working on my first project using cmake, and for the most part it's been going well but I've run into one problem I can't figure out.
Let's say I have my CMakeLists.txt file located at ~/project/build. I would like for the output from cmake (not the binaries, but the makefile/configuration files) to be independent of where I run cmake from.
As an example, if my terminal is sitting in the ~/project/build directory, calling cmake ~/project/build creates the makefile and everything else within the ~/project/build directory. This is the behaviour that I'd like. If I call cmake ~/project/build from anywhere else, it creates the makefile and everything else in whatever directory the terminal called the program from.
Is it possible to force cmake to generate its makefile and associated files in the same folder as the CMakeLists.txt file? I've taken a look through the documentation and I've had no problems figuring out how to change binary output directories, but I can't really find any mention of what I'm trying to do.
I realize this is a pretty minor annoyance (it's not that hard to move into my build folder before building the project) but I'm just wondering if it's possible and if there's some reason it wouldn't be advised.
You have to use 2 commands for this
1) cmake -B "Dest path(Any path in which u want to generate the output files)" -H"Source path(root CMakeLists.txt path)"
2) cmake --build "Dest path"