aesophor / wmderland

🌳 X11 tiling window manager using space partitioning trees
https://www.reddit.com/r/unixporn/comments/fb8ve1/wmderland_104_time_to_move_on/
MIT License
410 stars 15 forks source link

Addition of a build system generator #12

Closed elfring closed 5 years ago

elfring commented 5 years ago

I suggest to reuse a higher level build system than your current make script so that powerful checks for software features will become easier.

aesophor commented 5 years ago

I've added CMakeLists.txt in the staging branch

I noticed that using the old Makefile, the compiled binary is only 92 KB in size, while using CMake the binary is 668 KB in size.

Using old Makefile (92 KB):

$ g++ -std=c++14 -flto -Os -Wall -lpthread -lX11 -lglog -o Wmderland src/*.cpp
$ size Wmderland
   text    data     bss     dec     hex filename
  55235    2056     384   57675    e14b Wmderland

Using CMake (668 KB):

$ cmake .
$ make
$ size Wmderland 
   text    data     bss     dec     hex filename
 442400    2096     368  444864   6c9c0 Wmderland

So I think perhaps the .text section has included lots of unused symbols for debugging? But even if I set this in CMakeLists.txt, the binary size is still over 600 KB.

set(CMAKE_CXX_FLAGS "-std=c++14 -flto -Os -Wall -lpthread")

Any idea?

aesophor commented 5 years ago

Problem solved in 2880b55c68d4755b16eda07664d75a00e8b00428

First I moved the line project(Wmderland) to the first line of CMakeLists.txt, and then the compiled executable size drops from 668 KB to 143 KB miraculously :confused:

Then I made the following changes:

and the size drops to 92 KB!

Note: a CMake cheatsheet I've found http://www.brianlheim.com/2018/04/09/cmake-cheat-sheet.html