I have a set of files. Compiled with gcc49 under FreeBSD. The default makefile, created by me. Well, that's not the problem.
Ok, I decided to compile with CMake.
- When compiling with default makefiles(gcc49) output target size is : 5 MB
- When compiling with cmake(gcc49, same flags as in makefile default) output target is : 12 MB
My question is, why are so big differences in size.
I want the file to end, to be as small size, it was ok 5mb.
What should I do to make my 5mb file( with cmake)
THX all
You are invoking the compiler with different options in the two cases.
CMake already sets a bunch of compiler and linker options for you that best suit your project. Unfortunately, if you are new to CMake it is not always obvious to see why a particular option is being set and how to change it idiomatically.
For the Makefile generator, to find out which options CMake passes to the compiler you can set the VERBOSE
environment variable when invoking make
on the shell:
$ VERBOSE=1 make
Compare the commands used by CMake to the ones that you use when building manually. Once you identified the culprit, do some further research on how to best change that particular build option with CMake.
CMake builds debug configuration per default. If you haven't switched to release the binaries are build as debug resulting an increased size.
You can test again release, eg.:
cd release_dir
cmake -DCMAKE_BUILD_TYPE=Release ..
make