Closed A-F-V closed 8 months ago
Hey @A-F-V thanks for opening this issue. I'd definitely be interested in setting up support for vcpkg and conan. Nothing is in the works yet but I will try to find some time to look into this more.
Hi @jeremy-rifkin, I am happy to contribute. Just started on a fork. We can take this offline but to summarise the features I wanted to create for consideration:
1) Make the installation find_package
able
2) Create a vcpkg port (which is basically just the wrapper of a fetch content)
3) Also have a configuration option to add a prefix to the macros in case of conflict with other libraries assert macros
For what it's worth, I'd probably use the vcpkg port as well
So I have a working vcpkg
portfile written, but the issue is that we can't submit them to the official ports repo until we make the CMakeLists.txt
product debug
library as well as a release
library:
The /lib/cmake folder should be merged with /debug/lib/cmake and moved to /share/libassert/cmake.
Please use the helper function `vcpkg_cmake_config_fixup()` from the port vcpkg-cmake-config.`
The following cmake files were found outside /share/libassert. Please place cmake files in /share/libassert.
/home/user/vcpkg/packages/libassert_x64-linux/lib/cmake/assert/assert-config-version.cmake
/home/user/vcpkg/packages/libassert_x64-linux/lib/cmake/assert/assert_targets.cmake
/home/user/vcpkg/packages/libassert_x64-linux/lib/cmake/assert/assert_targets-release.cmake
/home/user/vcpkg/packages/libassert_x64-linux/lib/cmake/assert/assert-config.cmake
Mismatching number of debug and release binaries. Found 0 for debug but 1 for release.
Debug binaries
Release binaries
/home/user/vcpkg/packages/libassert_x64-linux/lib/libassert.a
Debug binaries were not found
Found 3 post-build check problem(s). To submit these ports to curated catalogs, please first correct the portfile:
/home/user/projects/libassert-vcpkg-test/./ports/libassert/portfile.cmake
The portfile
is just:
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO jeremy-rifkin/libassert
REF a94970435d077666d8c712ececb5993c546732c2
SHA512 9d952a291fa2fe4a4bf80f5ccf132f9c36729d342522d80eb7339591a4a0658aa0e223b650fa39aeea9f787fc4c0972e058950f9396e7ccbdbb1eb03c5629baf
HEAD_REF master
)
################################################
# NOTE: This doesn't contain the feature flags for libassert
# but just a basic implementation as an example
################################################
vcpkg_configure_cmake(
SOURCE_PATH "${SOURCE_PATH}"
PREFER_NINJA
)
vcpkg_install_cmake()
# vcpkg_fixup_cmake_targets() <-- uncomment this once debug library in CMakeLists.txt
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tests")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug")
file(
INSTALL "${SOURCE_PATH}/LICENSE"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}"
RENAME copyright)
Now, it is still possible to install libassert
from your own vcpkg
portfile or custom registry.
If you want to test that out, you can try it by downloading this example project.
Run $ vcpkg build libassert --overlay-ports=./ports
from the directory containing this project, and you should see it build successfully (albeit with some warnings about how it can't be officially submitted yet):
[user@MSI libassert-vcpkg-test]$ vcpkg build libassert --overlay-ports=./ports
Detecting compiler hash for triplet x64-linux...
-- Installing port from location: /home/user/projects/libassert-vcpkg-test/./ports/libassert
-- Using cached jeremy-rifkin-libassert-a94970435d077666d8c712ececb5993c546732c2.tar.gz.
-- Using source at /home/user/vcpkg/buildtrees/libassert/src/3c546732c2-75bc8cf19e
-- Found external ninja('1.11.1').
-- Configuring x64-linux-dbg
-- Configuring x64-linux-rel
-- Building x64-linux-dbg
-- Building x64-linux-rel
-- Installing: /home/user/vcpkg/packages/libassert_x64-linux/share/libassert/copyright
-- Performing post-build validation
The /lib/cmake folder should be merged with /debug/lib/cmake and moved to /share/libassert/cmake.
Please use the helper function `vcpkg_cmake_config_fixup()` from the port vcpkg-cmake-config.`
The following cmake files were found outside /share/libassert. Please place cmake files in /share/libassert.
/home/user/vcpkg/packages/libassert_x64-linux/lib/cmake/assert/assert-config-version.cmake
/home/user/vcpkg/packages/libassert_x64-linux/lib/cmake/assert/assert_targets.cmake
/home/user/vcpkg/packages/libassert_x64-linux/lib/cmake/assert/assert_targets-release.cmake
/home/user/vcpkg/packages/libassert_x64-linux/lib/cmake/assert/assert-config.cmake
Mismatching number of debug and release binaries. Found 0 for debug but 1 for release.
Debug binaries
Release binaries
/home/user/vcpkg/packages/libassert_x64-linux/lib/libassert.a
Debug binaries were not found
Found 3 post-build check problem(s). To submit these ports to curated catalogs, please first correct the portfile:
/home/user/projects/libassert-vcpkg-test/./ports/libassert/portfile.cmake
-- Performing post-build validation done
Stored binary cache: "/home/user/.cache/vcpkg/archives/7a/7adc93afcff479f915aa65ff391624e986fa92680b2450e2ec3fcf1769af965f.zip"
How did you make the package FindPackage
able?
It'll only be FindPackage
available currently in Release
mode because the CMakeLists.txt
in the repo doesn't build dedicated Debug
and Release
artifacts
We'll need a small tweak to fix that 👍
Thank you @GavinRay97! It's probably time for me to bite the bullet and actually learn cmake. I'm hoping to have time this week to do so.
It'll only be
FindPackage
available currently inRelease
mode because theCMakeLists.txt
in the repo doesn't build dedicatedDebug
andRelease
artifactsWe'll need a small tweak to fix that 👍
So FindPackage(assert CONFIG REQUIRED)
is all you would need?
@jeremy-rifkin I can also PR it, but aye, as terrible as it is, it's one of those thing you just suck up in the sake of "it gets less and less awful the more you know how to use it", especially the more modern features 😅
I fucking hate CMake. Worst C++ build tool, but everyone uses it. I like XMake and Meson/Bazel a lot better. Or even Gradle lol.
@A-F-V Exactly, but with the example above, it would only work if your CMake project was being built in Release
mode for the reasons mentioned.
It should be only a couple of lines to get a dedicated Debug asset but I don't think either Jeremy or I have had the time
The last step we'd want to add for the vcpkg
port is just a section containing the FEATURE FLAGS
that users can enable
option(ASSERT_DECOMPOSE_BINARY_LOGICAL "Enables expression decomposition of && and ||" OFF)
option(ASSERT_LOWERCASE "Enables assert alias for ASSERT" OFF)
option(ASSERT_USE_MAGIC_ENUM "Use the MagicEnum library to print better diagnostics for enum classes" ON)
So to make these user-configurable when people install from vcpkg
, we translate them like this:
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
expression_decomposition ASSERT_DECOMPOSE_BINARY_LOGICAL
lowercase_assert ASSERT_LOWERCASE
use_magic_enum ASSERT_USE_MAGIC_ENUM
)
vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS
${FEATURE_OPTIONS}
)
This thread has not been updated so far, what's the status?
Hi @shrinktofit, I have a PR open to to add cpptrace to vcpkg https://github.com/microsoft/vcpkg/pull/34217 but that depends on https://github.com/microsoft/vcpkg/pull/34382 to add libdwarf to vcpkg, and the pr has stalled a bit. Once cpptrace is added to vcpkg then libassert can be added.
I think maybe I just got the libdwarf pr working
Pr opened at vcpkg https://github.com/microsoft/vcpkg/pull/35094
And now the pr has been merged!
Are there any plans to create a port for vcpkg?