ebiggers / libdeflate

Heavily optimized library for DEFLATE/zlib/gzip compression and decompression

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build type does not default to Release with CMake 3.10 and earlier

jkbonfield opened this issue · comments

Since switching to cmake, the build type has switched from being optimised by default to debug non-optimised by default. Yes, this just caught me out and caused me to wonder why my program had got so much slower.

Please make the default release.

Also I couldn't get the cmake command to work as mentioned in README. I don't know enough about cmake to understand the errors.

$ cmake -B build && cmake --build build
CMake Error: The source directory "/nfs/disk54/badger/src/htslib-1.17/libdeflate-1.17/build" does not exist.

cmake -B isn't even a valid command line argument in my version it seems, so I'm not sure what this is meant to do. What does work is:

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=release

Release is already the default. See lines 3-7 of the top-level CMakeLists.txt.

Which version of CMake are you using?

It works for me even with CMake 3.7, which is the minimum version supported (the top-level CMakeLists.txt has cmake_minimum_required(VERSION 3.7)), though that version does need the old-school approach of manually creating the build directory as you mentioned:

$ mkdir build && cd build && ~/cmake-3.7.2-Linux-x86_64/bin/cmake .. && make -j8
-- No build type selected; defaulting to Release
...

Hmm, I was using cmake 3.10, which came with Ubuntu Bionic.

Odd that it built a non-optimised version then. It was definitely the case as I noticed it with the test libdeflate_gzip binary being so much slower. I did a make clean and make VERBOSE=1 to double check. When I explicitly specified the version it cured it.

Not sure what's going on.

Maybe cmake just hates me as much as I hate it. :-)

It turns out that with CMake 3.10 and earlier, the part of CMakeLists.txt that sets the default build type to Release is running but not actually taking effect. #302 fixes it.

Thanks Eric! I was about to have another investigation this morning, but this is good to hear.