Skip to content

Port build system to CMake (2/2 from #5)#8

Merged
andy-shev merged 4 commits into
andy-shev:masterfrom
aaron-sierra:cmake-build
Jan 20, 2025
Merged

Port build system to CMake (2/2 from #5)#8
andy-shev merged 4 commits into
andy-shev:masterfrom
aaron-sierra:cmake-build

Conversation

@aaron-sierra
Copy link
Copy Markdown
Collaborator

This is a redo for #7, requested in #7 (comment).

Aaron Sierra added 4 commits January 16, 2025 12:20
Calling --make-links assumes that iotools can be expected to run on the
host architecture, despite the project intending to support native and
cross-compilation equally well.

Signed-off-by: Aaron Sierra <aaron@bubbl-tek.com>
The DEBUG make variable is replaced by CMAKE_BUILD_TYPE, which defaults
to Debug if undefined. The Debug and Release CFLAGS are aligned with
the original Makefile, all others use CMake defaults.

The project's initial configuration continues to enable static-linking
of iotools by default, unless overridden by "cmake -D STATIC=0".

A new configurable header, config.h.in, is added to tie VER_MAJOR and
VER_MINOR to the implicit PROJECT_VERSION_MAJOR and
PROJECT_VERSION_MINOR variables.

Signed-off-by: Aaron Sierra <aaron@bubbl-tek.com>
From https://cmake.org/cmake/help/latest/policy/CMP0065.html:

CMake 3.3 and below, for historical reasons, always linked executables
on some platforms with flags like -rdynamic to export symbols from the
executables for use by any plugins they may load via dlopen(). CMake 3.4
and above prefer to do this only for executables that are explicitly
marked with the ENABLE_EXPORTS target property.

The OLD behavior of this policy is to always use the additional link
flags when linking executables regardless of the value of the
ENABLE_EXPORTS target property.

The NEW behavior of this policy is to only use the additional link
flags when linking executables if the ENABLE_EXPORTS target property is
set to True.

Signed-off-by: Aaron Sierra <aaron@bubbl-tek.com>
Add an INSTALL_LINKS configuration option to emulate the runtime
--make-links option. It leverages a new and automatically-populated .tag
field in struct cmd_info for easy lookup using readelf.

The CMD_PREFIX define is set from the build script, so that the lookup
mechanism has a good chance of staying in sync.

Embedding the escaped code directly into CMakeLists allows us to use
CMAKE_READELF (circa CMake 3.16), which isn't available from external
scripts.

This mechanism has been tested with readelf and llvm-readelf.

Signed-off-by: Aaron Sierra <aaron@bubbl-tek.com>
@andy-shev andy-shev merged commit e27cb7c into andy-shev:master Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants