View Full Version : [SOLVED] CMake creates bigger executable than plain make
t1497f35
February 19th, 2012, 05:25 PM
Hi,
The same source code compiled with cmake and make is attached. CMake's executable is like 530 kb, make's one is like 470 kb. Anyone knows why?
How to test:
CMake: go to "bin" dir and run "cmake .." then "make"
Make: from root dir of the project type "make"
EDIT: for the code to actually compile libgtkmm-3.0-dev must be installed.
Arndt
February 19th, 2012, 07:30 PM
Hi,
The same source code compiled with cmake and make is attached. CMake's executable is like 530 kb, make's one is like 470 kb. Anyone knows why?
How to test:
CMake: go to "bin" dir and run "cmake .." then "make"
Make: from root dir of the project type "make"
EDIT: for the code to actually compile libgtkmm-3.0-dev must be installed.
What are the actual linking commands in the two cases?
nebukadnezzar
February 21st, 2012, 07:38 PM
That's because CMake defaults to debug mode (as in, it adds -g to gcc, or whichever compiler you are using).
Use 'cmake -DCMAKE_BUILD_TYPE=Release' when invoking cmake (or change it via cmake-gui).
t1497f35
February 21st, 2012, 08:16 PM
Thanks, however after I run
cmake -DCMAKE_BUILD_TYPE='Release' .. and make
I still get the same approx. 60 kb file size increase compared to the plain makefile solution.
Using Ubuntu 11.10 amd64.
SevenMachines
February 21st, 2012, 08:52 PM
Looking at running cmake with
$ make VERBOSE=1shows its passing -rdynamic to the linker, whereas the straight make version does not. Therefore, from man gcc
This instructs the linker to add all symbols, not only used ones, to the dynamic symbol table.That might be worth a look
t1497f35
February 21st, 2012, 09:18 PM
Thanks a lot, it works!
I added SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") (since this seems to disable -rdynamic) to the main CMakeLists.txt file and the app size is fine now without even specifying the build type as "release"!
Powered by vBulletin® Version 4.2.2 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.