From ae0b9c8af2a4f48bbd2f3f54cc6874aa2685e813 Mon Sep 17 00:00:00 2001 From: Jack Wright <68773585+Ethirix@users.noreply.github.com> Date: Sun, 3 May 2026 23:22:16 +0100 Subject: [PATCH 1/3] Reworked `CMake` to align better with package manager standards `CMakeLists` and `CMakePresets` completely redesigned to better support intended usage with package managers and developer intentions. Now instead of trying to specifically decide between 'shared' or 'static' targets, `CPack` will now only include the files relating to that type of install: - Runtime - shared `.dll`/`.so` - Developer - everything else (static library, headers, `CMake` files) When interacting with the project from another CMake project, the library has two components: `Static` and `Shared` which allow you to link between your chosen library type. --- CMakeLists.txt | 36 +++--- CMakePresets.json | 213 +++++++++++++++++++++++++------ libvlmath/CMakeLists.txt | 56 +++++++- libvlmath/matrix.cpp | 5 +- libvlmath/matrix.hpp | 4 +- libvlmath/matrix.ipp | 32 +++-- packaging/CMakeLists.txt | 126 ++++++++++++++++++ packaging/libvlmathConfig.cmake | 50 ++++++++ toolchains/gcc-x64-linux.cmake | 1 + toolchains/gcc-x86-linux.cmake | 1 + toolchains/mingw64-x64-win.cmake | 1 + toolchains/mingw64-x86-win.cmake | 1 + 12 files changed, 444 insertions(+), 82 deletions(-) create mode 100644 packaging/CMakeLists.txt create mode 100644 packaging/libvlmathConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index cb4070f..98425d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,23 @@ -cmake_minimum_required(VERSION 3.24) -project(libvlmath) +cmake_minimum_required(VERSION 3.30) +project(libvlmath + VERSION 0.0.1 + HOMEPAGE_URL "https://github.com/VolcanusLucis/libvlmath" +) -# Project is already pre-pended with lib -set(CMAKE_SHARED_LIBRARY_PREFIX "") -set(CMAKE_STATIC_LIBRARY_PREFIX "") +# VARIABLES -add_subdirectory(${PROJECT_NAME}) +option(libvlmath_INCLUDE_PACKAGING "Include packaging rules for libvlmath" "${PROJECT_IS_TOP_LEVEL}") -install(TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) +# PROJECT + +if (DEFINED libvlmath_SHARED_LIBS) + set(BUILD_SHARED_LIBS ${libvlmath_SHARED_LIBS}) +endif () + +add_subdirectory(libvlmath) + +# PACKAGING -install(DIRECTORY ${PROJECT_SOURCE_DIR}/${PROJECT_NAME} - DESTINATION "include" - FILES_MATCHING - PATTERN "*.hpp" - PATTERN "*.tpp" -) \ No newline at end of file +if (libvlmath_INCLUDE_PACKAGING) + add_subdirectory(packaging) +endif () \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json index 8dc1c87..c001e26 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,8 +1,8 @@ { - "version": 10, + "version": 4, "cmakeMinimumRequired": { "major": 3, - "minor": 24, + "minor": 30, "patch": 0 }, @@ -10,11 +10,26 @@ { "name": "base", "hidden": true, - "binaryDir": "${sourceDir}/build/${presetName}/", - "installDir": "${sourceDir}/install/${presetName}/${sourceDirName}" + "binaryDir": "${sourceDir}/build/${presetName}" }, { - "name": "ninja-multi-config", + "name": "runtime", + "cacheVariables": { + "BUILD_SHARED_LIBS": "ON", + "libvlmath_RUNTIME_BUILD": "YES" + }, + "hidden": true + }, + { + "name": "devel", + "cacheVariables": { + "BUILD_SHARED_LIBS": "OFF", + "libvlmath_RUNTIME_BUILD": "NO" + }, + "hidden": true + }, + { + "name": "ninja", "description": "Ninja Multi-Config Generator", "hidden": true, "generator": "Ninja Multi-Config", @@ -25,6 +40,7 @@ "name": "gcc-x64-linux", "description": "GCC x64 Linux Toolchain", "toolchainFile": "${sourceDir}/toolchains/gcc-x64-linux.cmake", + "hidden": true, "condition": { "type": "equals", "lhs": "${hostSystemName}", @@ -35,6 +51,7 @@ "name": "gcc-x86-linux", "description": "GCC x86 Linux Toolchain", "toolchainFile": "${sourceDir}/toolchains/gcc-x86-linux.cmake", + "hidden": true, "condition": { "type": "equals", "lhs": "${hostSystemName}", @@ -44,86 +61,200 @@ { "name": "mingw64-x64-win", "description": "MinGW64 x64 Windows Toolchain", - "toolchainFile": "${sourceDir}/toolchains/mingw64-x64-win.cmake" + "toolchainFile": "${sourceDir}/toolchains/mingw64-x64-win.cmake", + "hidden": true }, { "name": "mingw64-x86-win", "description": "MinGW64 x86 Windows Toolchain", - "toolchainFile": "${sourceDir}/toolchains/mingw64-x86-win.cmake" + "toolchainFile": "${sourceDir}/toolchains/mingw64-x86-win.cmake", + "hidden": true + }, + + { + "name": "ninja-mingw64-x64-win-devel", + "displayName": "MinGW64 Windows x64 - Developer", + "inherits": ["ninja", "devel", "mingw64-x64-win"] }, - { "name": "ninja-mingw64-x64-win", "displayName": "MinGW64 Windows x64", - "inherits": ["ninja-multi-config", "mingw64-x64-win"] + "inherits": ["ninja", "runtime", "mingw64-x64-win"] + }, + + { + "name": "ninja-mingw64-x86-win-devel", + "displayName": "MinGW64 Windows x86 - Developer", + "inherits": ["ninja", "devel", "mingw64-x86-win"] }, { "name": "ninja-mingw64-x86-win", "displayName": "MinGW64 Windows x86", - "inherits": ["ninja-multi-config", "mingw64-x86-win"] + "inherits": ["ninja", "runtime", "mingw64-x86-win"] }, + { + "name": "ninja-gcc-x64-linux-devel", + "displayName": "GCC Linux x64 - Developer", + "inherits": ["ninja", "devel", "gcc-x64-linux"] + }, { "name": "ninja-gcc-x64-linux", "displayName": "GCC Linux x64", - "inherits": ["ninja-multi-config", "gcc-x64-linux"] + "inherits": ["ninja", "runtime", "gcc-x64-linux"] + }, + + { + "name": "ninja-gcc-x86-linux-devel", + "displayName": "GCC Linux x86 - Developer", + "inherits": ["ninja", "devel", "gcc-x86-linux"] }, { "name": "ninja-gcc-x86-linux", "displayName": "GCC Linux x86", - "inherits": ["ninja-multi-config", "gcc-x86-linux"] + "inherits": ["ninja", "runtime", "gcc-x86-linux"] } ], "buildPresets": [ { - "name": "ninja-mingw64-x64-win-debug", - "displayName": "Debug - Windows x64 MinGW64", - "configurePreset": "ninja-mingw64-x64-win", - "configuration": "Debug" + "name": "debug", + "configuration": "Debug", + "hidden": true + }, + { + "name": "release", + "configuration": "Release", + "hidden": true + }, + { + "name": "mingw64-x64-win-devel", + "configurePreset": "ninja-mingw64-x64-win-devel", + "hidden": true }, { - "name": "ninja-mingw64-x64-win-release", - "displayName": "Release - Windows x64 MinGW64", + "name": "mingw64-x64-win", "configurePreset": "ninja-mingw64-x64-win", - "configuration": "Release" + "hidden": true }, + { - "name": "ninja-mingw64-x86-win-debug", - "displayName": "Debug - Windows x86 MinGW64", - "configurePreset": "ninja-mingw64-x86-win", - "configuration": "Debug" + "name": "mingw64-x86-win-devel", + "configurePreset": "ninja-mingw64-x86-win-devel", + "hidden": true }, { - "name": "ninja-mingw64-x86-win-release", - "displayName": "Release - Windows x86 MinGW64", + "name": "mingw64-x86-win", "configurePreset": "ninja-mingw64-x86-win", - "configuration": "Release" + "hidden": true }, - + { - "name": "ninja-gcc-x64-linux-debug", - "displayName": "Debug - Linux x64 GCC", - "configurePreset": "ninja-gcc-x64-linux", - "configuration": "Debug" + "name": "gcc-x64-linux-devel", + "configurePreset": "ninja-gcc-x64-linux-devel", + "hidden": true }, { - "name": "ninja-gcc-x64-linux-release", - "displayName": "Release - Linux x64 GCC", + "name": "gcc-x64-linux", "configurePreset": "ninja-gcc-x64-linux", - "configuration": "Release" + "hidden": true }, + { - "name": "ninja-gcc-x86-linux-debug", - "displayName": "Debug - Linux x86 GCC", - "configurePreset": "ninja-gcc-x86-linux", - "configuration": "Debug" + "name": "gcc-x86-linux-devel", + "configurePreset": "ninja-gcc-x86-linux-devel", + "hidden": true }, { - "name": "ninja-gcc-x86-linux-release", - "displayName": "Release - Linux x86 GCC", + "name": "gcc-x86-linux", "configurePreset": "ninja-gcc-x86-linux", - "configuration": "Release" + "hidden": true + }, + + + { + "name": "mingw64-x86-win-debug", + "displayName": "MinGW64 x86 Windows [Debug]", + "inherits": ["mingw64-x86-win", "debug"] + }, + { + "name": "mingw64-x86-win-devel-debug", + "displayName": "MinGW64 x86 Windows - Developer [Debug]", + "inherits": ["mingw64-x86-win-devel", "debug"] + }, + { + "name": "mingw64-x64-win-debug", + "displayName": "MinGW64 x64 Windows [Debug]", + "inherits": ["mingw64-x64-win", "debug"] + }, + { + "name": "mingw64-x64-win-devel-debug", + "displayName": "MinGW64 x64 Windows - Developer [Debug]", + "inherits": ["mingw64-x64-win-devel", "debug"] + }, + + { + "name": "mingw64-x86-win-release", + "displayName": "MinGW64 x86 Windows [Release]", + "inherits": ["mingw64-x86-win", "release"] + }, + { + "name": "mingw64-x86-win-devel-release", + "displayName": "MinGW64 x86 Windows - Developer [Release]", + "inherits": ["mingw64-x86-win-devel", "release"] + }, + { + "name": "mingw64-x64-win-release", + "displayName": "MinGW64 x64 Windows [Release]", + "inherits": ["mingw64-x64-win", "release"] + }, + { + "name": "mingw64-x64-win-devel-release", + "displayName": "MinGW64 x64 Windows - Developer [Release]", + "inherits": ["mingw64-x64-win-devel", "release"] + }, + + + { + "name": "gcc-x86-linux-debug", + "displayName": "GCC x86 Linux [Debug]", + "inherits": ["gcc-x86-linux", "debug"] + }, + { + "name": "gcc-x86-linux-devel-debug", + "displayName": "GCC x86 Linux - Developer [Debug]", + "inherits": ["gcc-x86-linux-devel", "debug"] + }, + { + "name": "gcc-x64-linux-debug", + "displayName": "GCC x64 Linux [Debug]", + "inherits": ["gcc-x64-linux", "debug"] + }, + { + "name": "gcc-x64-linux-devel-debug", + "displayName": "GCC x64 Linux - Developer [Debug]", + "inherits": ["gcc-x64-linux-devel", "debug"] + }, + + { + "name": "gcc-x86-linux-release", + "displayName": "GCC x86 Linux [Release]", + "inherits": ["gcc-x86-linux", "release"] + }, + { + "name": "gcc-x86-linux-devel-release", + "displayName": "GCC x86 Linux - Developer [Release]", + "inherits": ["gcc-x86-linux-devel", "release"] + }, + { + "name": "gcc-x64-linux-release", + "displayName": "GCC x64 Linux [Release]", + "inherits": ["gcc-x64-linux", "release"] + }, + { + "name": "gcc-x64-linux-devel-release", + "displayName": "GCC x64 Linux - Developer [Release]", + "inherits": ["gcc-x64-linux-devel", "release"] } ] } \ No newline at end of file diff --git a/libvlmath/CMakeLists.txt b/libvlmath/CMakeLists.txt index 92e1fb4..68159ce 100644 --- a/libvlmath/CMakeLists.txt +++ b/libvlmath/CMakeLists.txt @@ -1,6 +1,54 @@ -add_library(${PROJECT_NAME} - matrix.cpp +add_library(libvlmath) +add_library(VolcanusLucis::libvlmath ALIAS libvlmath) + +target_compile_definitions(libvlmath PUBLIC + LIBVLMATH_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} + LIBVLMATH_VERSION_MINOR=${PROJECT_VERSION_MINOR} + LIBVLMATH_VERSION_PATCH=${PROJECT_VERSION_PATCH} +) + +# May remain unused. +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(libvlmath_ARCH_SUFFIX 64) +else () + set(libvlmath_ARCH_SUFFIX "") +endif () + +# Project is already pre-pended with lib +set_target_properties(libvlmath PROPERTIES + PREFIX "" + IMPORT_PREFIX "" + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} +) + +target_sources(libvlmath + PUBLIC + FILE_SET HEADERS + BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} + FILES + matrix.hpp + matrix.ipp +) + +target_sources(libvlmath PRIVATE + matrix.cpp +) + +target_compile_features(libvlmath PUBLIC cxx_std_23) +target_include_directories(libvlmath PUBLIC + $ + $ ) -target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23) -target_include_directories(${PROJECT_NAME} PUBLIC "${PROJECT_SOURCE_DIR}") \ No newline at end of file +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + if (NOT CMAKE_CROSSCOMPILING) + if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + set_property(CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${PROJECT_SOURCE_DIR}/install/${PROJECT_NAME}") + else () + set_property(CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "/usr/local") + endif () + else () + set_property(CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${PROJECT_SOURCE_DIR}/install/${PROJECT_NAME}") + endif () +endif () \ No newline at end of file diff --git a/libvlmath/matrix.cpp b/libvlmath/matrix.cpp index c6d24de..60f87d7 100644 --- a/libvlmath/matrix.cpp +++ b/libvlmath/matrix.cpp @@ -1,5 +1,6 @@ #include -namespace maths +bool vl::math::test() { -} \ No newline at end of file + return true; +} diff --git a/libvlmath/matrix.hpp b/libvlmath/matrix.hpp index 7210f97..992fc13 100644 --- a/libvlmath/matrix.hpp +++ b/libvlmath/matrix.hpp @@ -4,8 +4,10 @@ #include #include -namespace maths +namespace vl::math { + bool test(); + template requires (std::is_arithmetic_v && Rows > 1 && Columns >= 1) class matrix diff --git a/libvlmath/matrix.ipp b/libvlmath/matrix.ipp index f9cb6f4..1d5a2fe 100644 --- a/libvlmath/matrix.ipp +++ b/libvlmath/matrix.ipp @@ -3,10 +3,10 @@ #include -namespace maths +namespace vl::math { - template requires (std::is_arithmetic_v && Rows > 1 && - Columns >= 1) + template + requires (std::is_arithmetic_v && Rows > 1 && Columns >= 1) constexpr matrix::matrix() { if constexpr (Rows != Columns) return; @@ -30,8 +30,8 @@ namespace maths } } - template requires (std::is_arithmetic_v && Rows > 1 && - Columns >= 1) + template + requires (std::is_arithmetic_v && Rows > 1 && Columns >= 1) constexpr matrix::matrix(std::array, Rows> array) { for (std::size_t x = 0; x < Rows; x++) @@ -43,8 +43,8 @@ namespace maths } } - template requires (std::is_arithmetic_v && Rows > 1 && - Columns >= 1) + template + requires (std::is_arithmetic_v && Rows > 1 && Columns >= 1) constexpr matrix::matrix(const Type(&matrix)[Rows][Columns]) { for (std::size_t row = 0; row < Rows; row++) @@ -70,8 +70,8 @@ namespace maths return arr_[index]; } - template requires (std::is_arithmetic_v && Rows > 1 && - Columns >= 1) + template + requires (std::is_arithmetic_v && Rows > 1 && Columns >= 1) constexpr std::array matrix::operator[](std::size_t index) const { return arr_[index]; @@ -171,8 +171,8 @@ namespace maths return *this; } - template requires (std::is_arithmetic_v && Rows > 1 && - Columns >= 1) + template + requires (std::is_arithmetic_v && Rows > 1 && Columns >= 1) constexpr matrix& matrix::operator*=(const Type& scalar) { for (std::size_t x = 0; x < Rows; x++) @@ -186,8 +186,8 @@ namespace maths return *this; } - template requires (std::is_arithmetic_v && Rows > 1 && - Columns >= 1) + template + requires (std::is_arithmetic_v && Rows > 1 && Columns >= 1) constexpr matrix& matrix::operator/=(const Type& scalar) { for (std::size_t x = 0; x < Rows; x++) @@ -284,18 +284,16 @@ namespace maths return {}; } - //https://semath.info/src/inverse-cofactor-ex4.html Type inverse = static_cast(1.0) / det; if constexpr (Rows == 2 && Columns == 2) { - return maths::matrix{{ + return matrix {{ {arr_[1][1] * inverse, -arr_[0][1] * inverse}, {-arr_[1][0] * inverse, arr_[0][0] * inverse} }}; } - // Suspiciously close to Determinant code - very boilerplate-y - // TODO: Move Laplace expansion to own function + // Laplace Expansion (slightly different from determinant) matrix m = {}; for (std::size_t row = 0; row < Rows; row++) { diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt new file mode 100644 index 0000000..d155c9f --- /dev/null +++ b/packaging/CMakeLists.txt @@ -0,0 +1,126 @@ +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) + +# SETUP + +if (NOT DEFINED libvlmath_INSTALL_CMAKEDIR) + set(libvlmath_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/libvlmath" + CACHE STRING "Path to libvlmath CMake files" + ) +endif () + +# INSTALL TARGETS + +install(TARGETS libvlmath EXPORT libvlmathTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libvlmath_Runtime + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libvlmath_Runtime + NAMELINK_COMPONENT libvlmath_Development + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libvlmath_Development + FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libvlmath COMPONENT libvlmath_Development +) + +# INSTALL EXPORT TARGETS + +if (BUILD_SHARED_LIBS) + set(libvlmath_BUILD_TYPE Shared) +else () + set(libvlmath_BUILD_TYPE Static) +endif () + +install(EXPORT libvlmathTargets + DESTINATION ${libvlmath_INSTALL_CMAKEDIR} + NAMESPACE VolcanusLucis:: + FILE libvlmath${libvlmath_BUILD_TYPE}Targets.cmake + COMPONENT libvlmath_Development +) + +write_basic_package_version_file( + libvlmathConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/libvlmathConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/libvlmathConfigVersion.cmake + DESTINATION ${libvlmath_INSTALL_CMAKEDIR} + COMPONENT libvlmath_Development +) + +# INSTALL DOCS + +set(CMAKE_INSTALL_DOCDIR ${CMAKE_INSTALL_DATAROOTDIR}/doc/libvlmath) +install(FILES + ${PROJECT_SOURCE_DIR}/README.md + ${PROJECT_SOURCE_DIR}/LICENSE + DESTINATION ${CMAKE_INSTALL_DOCDIR} + COMPONENT libvlmath_Documentation +) + +# EXPORTS + +export(EXPORT libvlmathTargets + NAMESPACE VolcanusLucis:: +) + +export(PACKAGE libvlmath) + +# PACKAGING + +set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A linear maths library for use in or with 3D applications.") +# set(CPACK_PACKAGE_DESCRIPTION_FILE path/to/file) +set(CPACK_PACKAGE_VENDOR "Volcanus Lucis") +set(CPACK_PROJECT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set(CPACK_PROJECT_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(CPACK_PROJECT_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) +set(CPACK_VERBATIM_VARIABLES ON) +# set(CPACK_RESOURCE_FILE_WELCOME path/to/file) +set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE) +set(CPACK_RESOURCE_FILE_README ${PROJECT_SOURCE_DIR}/README.md) +set(CPACK_TOPLEVEL_TAG ${PROJECT_NAME}) + +if (NOT DEFINED CPACK_GENERATOR) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # TODO: Support Package Manager Packaging [DEB, RPM] + set(CPACK_GENERATOR TGZ TXZ) + elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") + if (CMAKE_VERSION VERSION_GREATER_EQUAL 4.3) + set(CPACK_GENERATOR ZIP_LZMA2) + else () + set(CPACK_GENERATOR ZIP) + endif () + endif () +endif () + +if (DEFINED libvlmath_RUNTIME_BUILD AND libvlmath_RUNTIME_BUILD) + set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) + set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE) + set(CPACK_COMPONENTS_ALL libvlmath_Runtime libvlmath_Documentation) +endif () + +include(CPack) + +cpack_add_component(libvlmath_Runtime + DISPLAY_NAME Runtime + DESCRIPTION "Shared libraries and executables" + REQUIRED + INSTALL_TYPES Full Developer Minimal +) + +cpack_add_component(libvlmath_Development + DISPLAY_NAME Development + DESCRIPTION "Headers and static libraries required for building" + INSTALL_TYPES Full Developer +) + +cpack_add_component(libvlmath_Documentation + DISPLAY_NAME Documentation + DESCRIPTION "Documentation relating to libvlmath" + INSTALL_TYPES Full Developer +) + +cpack_add_install_type(Full) +cpack_add_install_type(Developer DISPLAY_NAME "SDK Development") +cpack_add_install_type(Minimal) \ No newline at end of file diff --git a/packaging/libvlmathConfig.cmake b/packaging/libvlmathConfig.cmake new file mode 100644 index 0000000..d0983b4 --- /dev/null +++ b/packaging/libvlmathConfig.cmake @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 3.30) + +set(libvlmathBuildTypes Static Shared) +set(libvlmathBuildStatic NO) +set(libvlmathBuildShared NO) + +foreach (libvlmathBuildType IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS) + if (libvlmathBuildType IN_LIST libvlmathBuildTypes) + set(libvlmathBuild${libvlmathBuildType} YES) + else () + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "libvlmath does not recognise component `${libvlmathBuildType}`.") + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) + return() + endif () +endforeach () + +if (libvlmathBuildStatic AND libvlmathBuildShared) + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "libvlmath `Static` and `Shared` components are mutually exclusive.") + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) + return() +endif () + +set(libvlmathStaticTargets "${CMAKE_CURRENT_LIST_DIR}/libvlmathStaticTargets.cmake") +set(libvlmathSharedTargets "${CMAKE_CURRENT_LIST_DIR}/libvlmathSharedTargets.cmake") + +macro(libvlmathLoadTargets type) + if (NOT EXISTS "${libvlmath${type}Targets}") + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "libvlmath ${type} targets not found.") + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) + return() + endif () + include("${libvlmath${type}Targets}") +endmacro() + +if (libvlmathBuildShared + OR (DEFINED libvlmath_SHARED_LIBS AND libvlmath_SHARED_LIBS) + OR (BUILD_SHARED_LIBS AND EXISTS ${libvlmathSharedTargets}) + OR (NOT BUILD_SHARED_LIBS AND NOT EXISTS ${libvlmathStaticTargets}) +) + libvlmathLoadTargets(Shared) +elseif (libvlmathBuildStatic + OR (DEFINED libvlmath_SHARED_LIBS AND NOT libvlmath_SHARED_LIBS) + OR (BUILD_SHARED_LIBS AND NOT EXISTS ${libvlmathSharedTargets}) + OR (NOT BUILD_SHARED_LIBS AND EXISTS ${libvlmathStaticTargets}) +) + libvlmathLoadTargets(Static) +endif () \ No newline at end of file diff --git a/toolchains/gcc-x64-linux.cmake b/toolchains/gcc-x64-linux.cmake index dd55bd9..0581261 100644 --- a/toolchains/gcc-x64-linux.cmake +++ b/toolchains/gcc-x64-linux.cmake @@ -1,4 +1,5 @@ set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR x86_64) set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_COMPILER g++) diff --git a/toolchains/gcc-x86-linux.cmake b/toolchains/gcc-x86-linux.cmake index 268635d..cafcfb6 100644 --- a/toolchains/gcc-x86-linux.cmake +++ b/toolchains/gcc-x86-linux.cmake @@ -1,4 +1,5 @@ set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR i386) set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_COMPILER g++) diff --git a/toolchains/mingw64-x64-win.cmake b/toolchains/mingw64-x64-win.cmake index 01092ca..0c3eb6b 100644 --- a/toolchains/mingw64-x64-win.cmake +++ b/toolchains/mingw64-x64-win.cmake @@ -1,4 +1,5 @@ set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR AMD64) set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) diff --git a/toolchains/mingw64-x86-win.cmake b/toolchains/mingw64-x86-win.cmake index e74ef68..385e1a1 100644 --- a/toolchains/mingw64-x86-win.cmake +++ b/toolchains/mingw64-x86-win.cmake @@ -1,4 +1,5 @@ set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR X86) set(CMAKE_C_COMPILER i686-w64-mingw32-gcc) set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) From 94f9ca25f95a295091f2097c8eed336e4f5318c4 Mon Sep 17 00:00:00 2001 From: Jack Wright <68773585+Ethirix@users.noreply.github.com> Date: Thu, 7 May 2026 16:52:10 +0100 Subject: [PATCH 2/3] X-platform build supports new preset naming --- .github/workflows/pr-xplat-build-test.yml | 2 ++ libvlmath/CMakeLists.txt | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/pr-xplat-build-test.yml b/.github/workflows/pr-xplat-build-test.yml index db17e50..3effae8 100644 --- a/.github/workflows/pr-xplat-build-test.yml +++ b/.github/workflows/pr-xplat-build-test.yml @@ -43,6 +43,7 @@ jobs: compiler: [ mingw64, gcc ] architecture: [ x64, x86 ] target: [ win, linux ] + development-build: [ true, false ] build-type: [ debug, release ] exclude: - target: win @@ -57,6 +58,7 @@ jobs: build-tool: ${{ matrix.build-tool }} build-type: ${{ matrix.build-type }} compiler: ${{ matrix.compiler }} + development-build: ${{ matrix.development-build }} target: ${{ matrix.target }} build-all: diff --git a/libvlmath/CMakeLists.txt b/libvlmath/CMakeLists.txt index 68159ce..264ca0f 100644 --- a/libvlmath/CMakeLists.txt +++ b/libvlmath/CMakeLists.txt @@ -18,6 +18,7 @@ endif () set_target_properties(libvlmath PROPERTIES PREFIX "" IMPORT_PREFIX "" + DEBUG_POSTFIX "d" VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) From b064b628028984eacec1d72ab659812598f1b547 Mon Sep 17 00:00:00 2001 From: Jack Wright <68773585+Ethirix@users.noreply.github.com> Date: Fri, 8 May 2026 03:18:52 +0100 Subject: [PATCH 3/3] Minor edits to workflows Slight changes to `codeql.yml` and `pr-xplot-build-test.yml` to conform to some changes on GitHub end. --- .github/workflows/codeql.yml | 13 +++++-------- .github/workflows/pr-xplat-build-test.yml | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2bca686..0eecdba 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,5 +1,8 @@ name: CodeQL on: + push: + branches: [ "master" ] + tags: [ '**' ] pull_request: branches: [ "master" ] @@ -16,12 +19,7 @@ jobs: matrix: include: - language: c-cpp - build-mode: manual - manual-command-list: > - cmake -S . -B ./build -G "Ninja Multi-Config" - -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS="-O3 -Wall -std=c++23" - - cmake --build ./build --config Release + build-mode: none - language: actions build-mode: none @@ -33,9 +31,8 @@ jobs: with: language: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} - manual-command-list: ${{ matrix.manual-command-list }} - run-codeql: + verify-codeql: permissions: contents: none diff --git a/.github/workflows/pr-xplat-build-test.yml b/.github/workflows/pr-xplat-build-test.yml index 3effae8..6fdabcf 100644 --- a/.github/workflows/pr-xplat-build-test.yml +++ b/.github/workflows/pr-xplat-build-test.yml @@ -61,7 +61,7 @@ jobs: development-build: ${{ matrix.development-build }} target: ${{ matrix.target }} - build-all: + verify-compilation-task: if: always() runs-on: ubuntu-latest needs: [check-files, build]