Several CMake-related improvements and bugfixes #23

Merged
xavi merged 15 commits from cmake-fixes into main 2025-01-19 08:35:06 +01:00
Owner
No description provided.
xavi added 14 commits 2025-01-19 08:21:21 +01:00
networkingmenu.cpp was always being built, but the CLIENT_SERVER macro
was used to comment out the implementation. A more orthodox way to
achieve the same effect without relying on macros is to let the build
system decide whether this source file should be built.
According to the documentation [1], EXISTS only has well-defined
behaviour when an absolute path is given. This fixes a bug where
re-configuring the project would fail because CMake would inadverently
jump to the invalid branch.

[1]: https://cmake.org/cmake/help/latest/command/if.html#exists
Otherwise, cpack/debian.cmake would be unable to propagate the required
version for speed-dreams-data to CPACK_DEBIAN_PACKAGE_DEPENDS [1] when
SD_ASSUME_DATADIR is defined.

[1]: https://cmake.org/cmake/help/latest/cpack_gen/deb.html#variable:CPACK_DEBIAN_PACKAGE_DEPENDS
CMAKE_SOURCE_DIR already points to the directory for the top-level
CMakelists.txt [1], so SOURCE_DIR is redundant.

[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_SOURCE_DIR.html
CMAKE_CURRENT_LIST_DIR already holds the path to the directory for the
current list file. [1]

[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_LIST_DIR.html
The build system relied on overly complex logic already defined by the
GNUInstallDirs module [1], which is already included by the top-level
CMakeLists.txt.

[1]: https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
There is no need to assign this variable every time macros.cmake is
included.
There is no need to assign CMAKE_MODULE_PATH every time macros.cmake is
included.
SD_BUILD_INFO_COMPILER_NAME is redundant since CMAKE_CXX_COMPILER_ID can
already be used for this purpose, even if their values are not
identical.
config.h is always generated from config.h.in.cmake, so IN_SOURCETREE
did not provide any actual value.
CMake discourages in-tree builds (i.e., when PROJECT_SOURCE_DIR equals
PROJECT_BINARY_DIR), and so is the use of a clobber script for in-tree
builds.
Having an uninstall target is unjustified extra maintenance burden for
no benefit.

Instead, it is recommended to install to a CMAKE_INSTALL_PREFIX that the
user can easily remove e.g.: by deleting a directory as a
non-privileged user.
CPack does not install to CMAKE_INSTALL_PREFIX, but
CPACK_PACKAGING_INSTALL_PREFIX. However, the executables' rpath
would still be configured for ${CMAKE_INSTALL_PREFIX}/${SD_LIBDIR}/lib
instead of ${CPACK_PACKAGING_INSTALL_PREFIX}/${SD_LIBDIR}/lib,
making executables to fail to find their respective shared libraries.

Unfortunately, CPACK_PACKAGING_INSTALL_PREFIX is not defined by CMake,
but CPack, so it is not available from this context, so this commit
assumes its default value. [1]

[1]: https://cmake.org/cmake/help/latest/variable/CPACK_PACKAGING_INSTALL_PREFIX.html
CMakeLists.txt: Remove reference to INSTALL_SD_CMAKE
Some checks failed
/ build (pull_request) Has been cancelled
3efbcb9b2b
This macro had already been removed by the commit below. Moreover,
in-tree builds are discouraged by CMake.

commit cf18241a16
Author: Xavier Del Campo Romero <xavi.dcr@tutanota.com>
Date:   Sat Dec 28 14:13:38 2024 +0100

    cmake: Get SD_DATADIR from speed-dreams-data package
xavi added the
bug
enhancement
labels 2025-01-19 08:26:36 +01:00
xavi force-pushed cmake-fixes from 3efbcb9b2b to 48bea8cf25 2025-01-19 08:33:19 +01:00 Compare
xavi merged commit ec61c3700e into main 2025-01-19 08:35:06 +01:00
xavi deleted branch cmake-fixes 2025-01-19 08:35:08 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: speed-dreams/speed-dreams-code#23
No description provided.