Opened 3 years ago

Closed 3 years ago

#5828 closed Enhancement (fixed)

Add CMake build system support

Reported by: mike.dld Owned by: mike.dld
Priority: Normal Milestone: 2.90
Component: Transmission Version: 2.84+
Severity: Normal Keywords: patch cmake
Cc:

Description

I hereby propose a patch to add CMake build system support. In its current state it has most of the features currently provided by autoconf. Configurable options include:

Name Description Possible values Default value
ENABLE_DAEMON Build daemon ON, OFF ON
ENABLE_GTK Build GTK+ client ON, OFF, AUTO AUTO
ENABLE_QT Build Qt client ON, OFF, AUTO AUTO
ENABLE_UTILS Build utils (create, edit, show) ON, OFF ON
ENABLE_CLI Build command-line client ON, OFF OFF
ENABLE_TESTS Build unit tests ON, OFF ON
ENABLE_LIGHTWEIGHT Optimize libtransmission for low-resource systems ON, OFF OFF
ENABLE_UTP Build µTP support ON, OFF ON
ENABLE_NLS Enable native language support ON, OFF ON
INSTALL_DOC Build/install documentation ON, OFF ON
INSTALL_LIB Install the library (and public headers) ON, OFF OFF
USE_QT5 Use Qt 5 (instead of default Qt 4) ON, OFF OFF
USE_SYSTEM_EVENT2 Use system event2 library ON, OFF, AUTO AUTO
USE_SYSTEM_DHT Use system dht library ON, OFF, AUTO AUTO
USE_SYSTEM_MINIUPNPC Use system miniupnpc library ON, OFF, AUTO AUTO
USE_SYSTEM_NATPMP Use system natpmp library ON, OFF, AUTO AUTO
USE_SYSTEM_UTP Use system utp library (depends on ENABLE_UTP) ON, OFF, AUTO AUTO
WITH_INOTIFY Enable inotify support ON, OFF, AUTO AUTO
WITH_KQUEUE Enable kqueue support ON, OFF, AUTO AUTO
WITH_SYSTEMD Add support for systemd startup notification ON, OFF, AUTO AUTO

AUTO means that we will try to detect whether needed libraries, header files and functions are present in the system to decide on its own whether to turn specific option ON or OFF.

USE_SYSTEM_xxx options are there to be able to override the use of specific libraries. When set to ON, we will always use system library and fail if we cannot find one. When set to OFF, we will always build that library on our own. When set to AUTO, the behavior above applies, so we will try to detect whether library is provided by the system and fallback to building on our own otherwise.

Some of versions of those five libraries (event, dht, miniupnpc, natpmp, utp) do not match those being use by autoconf (read: those stored in third-party subdirectory) at the moment. This could be changed if desired. I decided to implement downloading library archives from github (or any other place) since I wanted this patch to be as non-intrusive as possible. There is an issue at hand where whole third-party directory is being added to search paths for includes which tends to break things if I want to use one library from the system and another from our repository, as both headers are likely to be found in our repository. Reorganizing the directory structure would help, but I don't see much sense in storing third-party source code in the repository anyway.

I spent quite some time on this patch, but it may still not be ideal for everyone. Any reviews and suggestions are kindly welcome.

Attachments (1)

5828-cmake-build-system.patch (53.0 KB) - added by mike.dld 3 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 3 years ago by mike.dld

Updating the patch as my pull request for NATPMP_STATICLIB got merged in.

comment:2 Changed 3 years ago by mike.dld

Updating the patch as my pull request for compiling miniupnpc on FreeBSD got merged in.

comment:3 Changed 3 years ago by mike.dld

Updating the patch to fix configuration and compilation issues (mostly revealed by testing on FreeBSD 10):

  • fix dht library detection (search for dht/dht.h instead of dht.h);
  • fix sys/event.h header detection (prepend sys/types.h so that configuration test passes);
  • add possibility to prefer static libraries via [undocumented] <library>_PREFER_STATIC_LIB cmake options, where <library> is one of DHT, EVENT2, MINIUPNPC, NATPMP, UTP;
  • fix passing of -Wxxx flags boosting warnings level.

Changed 3 years ago by mike.dld

comment:4 Changed 3 years ago by mike.dld

  • Owner set to mike.dld
  • Status changed from new to assigned

comment:5 Changed 3 years ago by mike.dld

  • Milestone changed from None Set to 2.90
  • Resolution set to fixed
  • Status changed from assigned to closed

Current version committed as r14350. Feel free to reopen if I missed something.

Note: See TracTickets for help on using tickets.