Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use proper versioning on CMakeLists.txt - pkgconf versions are wrong otherwise #2310

Closed
PerikiyoXD opened this issue Apr 7, 2024 · 1 comment · Fixed by #2311
Closed
Labels
build & packaging Build system and packaging related
Milestone

Comments

@PerikiyoXD
Copy link

PREFACE

Bug report stacktrace (blame me)

xmake-io/xmake#4940
msys2/MINGW-packages#20581

What happens?

On MSYS2, CMake is used to build Capstone,
On ArchLinux, GNU Make is used to build Capstone.

Packaging in ArchLinux shows proper version in the pkgconf.
Packaging in MSYS2 shows bogus version in the pkgconf.

Why?

ArchLinux case

When built with GNU Make it uses pkconfig.mk to generate capstone.pc

# Package version of Capstone for Makefile.
# To be used to generate capstone.pc for pkg-config

# version major & minor 
PKG_MAJOR = 5
PKG_MINOR = 0

# version bugfix level. Example: PKG_EXTRA = 1
PKG_EXTRA = 1

# version tag. Examples: rc1, b2, post1 - or just comment out for no tag
PKG_TAG = 

If we grab out built package:
https://archlinux.org/packages/extra/x86_64/capstone/download/
It will show proper version (Extracted for convenience):

Name: capstone
Description: Capstone disassembly engine
Version: 5.0.1
libdir=/usr/lib
includedir=/usr/include/capstone
archive=${libdir}/libcapstone.a
Libs: -L${libdir} -lcapstone
Cflags: -I${includedir}
archs=arm aarch64 m68k mips powerpc sparc systemz x86 xcore tms320c64x m680x evm riscv mos65xx wasm bpf sh tricore

Version: 5.0.1
No problem for ArchLinux so far.

BUT...

MSYS case

When built with CMake it uses CMakeLists project version definition to generate capstone.pc
Here are the relevant bits:

# Version definition (Already see what happens?)
project(capstone
    VERSION 5.0
)

# Generation step (Added messages for debugging purposes)

## installation
if(CAPSTONE_INSTALL)
    include("GNUInstallDirs")

    install(FILES ${HEADERS_COMMON} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/capstone)

    message("PROJECT_VERSION_MAJOR: ${PROJECT_VERSION_MAJOR}")
    message("PROJECT_VERSION_MINOR: ${PROJECT_VERSION_MINOR}")
    message("PROJECT_VERSION_PATCH: ${PROJECT_VERSION_PATCH}")

    configure_file(capstone.pc.in ${CMAKE_BINARY_DIR}/capstone.pc @ONLY)

# All other code is irrelevant

Hmm... CMake says 5.0... It should be 5.0.1 Why?

Let's look at the generated capstone.pc!

If we grab out built package (CLANG64 variant, which is the one I found first and later confirmed it's across all MSYS2 Environments):
https://mirror.msys2.org/mingw/clang64/mingw-w64-clang-x86_64-capstone-5.0.1-1-any.pkg.tar.zst
And see the contents of the capstone.pc:

prefix=/clang64
exec_prefix=${prefix}
libdir=/clang64/lib
includedir=/clang64/include

Name: capstone
Description: Capstone disassembly engine
Version: 5.0.
URL: https://www.capstone-engine.org/
archive=${libdir}/libcapstone.a
Libs: -L${libdir} -lcapstone
Cflags: -I${includedir}/capstone
archs=

Oh noes! It is 5.0!
But even worse, it's bogus because it's 5.0., caused by that missing variable... in CMake.

PROJECT_VERSION_PATCH wasn't defined.

It's required to use the PATCH version!

PerikiyoXD added a commit to PerikiyoXD/capstone that referenced this issue Apr 7, 2024
@Rot127 Rot127 added the build & packaging Build system and packaging related label Apr 7, 2024
@Rot127 Rot127 added this to the v5.0.2 milestone Apr 7, 2024
PerikiyoXD added a commit to PerikiyoXD/capstone that referenced this issue Apr 7, 2024
kabeor pushed a commit that referenced this issue Apr 22, 2024
Update CMakeLists.txt version to 5.0.1
Fix #2310
@Rot127
Copy link
Collaborator

Rot127 commented Apr 22, 2024

Closed by #2311

@Rot127 Rot127 closed this as completed Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build & packaging Build system and packaging related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants