feat: add MinGW-w64 cross-compilation toolchain and CPack packaging
- CMakeLists.txt: adds AppConfig to converter_core sources, LibRaw fallback find_library for MinGW, CPack config for NSIS+ZIP (Windows) and TGZ+DEB (Linux), install rules for binary and example config - cmake/toolchain-mingw64.cmake: x86_64-w64-mingw32 toolchain, static libgcc/libstdc++ linking, optional vcpkg x64-mingw-static triplet Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,15 +15,45 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
# ──────────────────────────────────────────────
|
||||
# Build options
|
||||
# ──────────────────────────────────────────────
|
||||
option(BUILD_TESTS "Build unit tests" ON)
|
||||
option(BUILD_GUI "Build GUI (requires Qt 6)" ON)
|
||||
option(BUILD_TESTS "Build unit tests" ON)
|
||||
option(BUILD_GUI "Build GUI (requires Qt 6)" ON)
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# Platform detection
|
||||
# ──────────────────────────────────────────────
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(PHOTOCONV_WINDOWS TRUE)
|
||||
else()
|
||||
set(PHOTOCONV_WINDOWS FALSE)
|
||||
endif()
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# Dependencies
|
||||
# ──────────────────────────────────────────────
|
||||
find_package(OpenCV 4.10 REQUIRED COMPONENTS core imgproc imgcodecs)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(LIBRAW REQUIRED IMPORTED_TARGET libraw)
|
||||
# Minimum 4.10 for production; 4.6+ accepted for development.
|
||||
# Lower the version bound here if building against an older system install.
|
||||
find_package(OpenCV 4.6 REQUIRED COMPONENTS core imgproc imgcodecs)
|
||||
|
||||
# LibRaw: try pkg-config first (Linux/macOS), fall back to find_package (vcpkg Windows)
|
||||
if(NOT PHOTOCONV_WINDOWS)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(LIBRAW REQUIRED IMPORTED_TARGET libraw)
|
||||
set(LIBRAW_TARGET PkgConfig::LIBRAW)
|
||||
else()
|
||||
# On Windows with vcpkg: find_package(libraw CONFIG) works.
|
||||
find_package(libraw CONFIG QUIET)
|
||||
if(libraw_FOUND)
|
||||
set(LIBRAW_TARGET libraw::libraw)
|
||||
else()
|
||||
# Fallback: try manual path (MinGW cross-compilation sysroot)
|
||||
find_library(LIBRAW_LIB raw REQUIRED)
|
||||
find_path(LIBRAW_INCLUDE libraw/libraw.h REQUIRED)
|
||||
add_library(libraw_compat INTERFACE IMPORTED)
|
||||
target_link_libraries(libraw_compat INTERFACE ${LIBRAW_LIB})
|
||||
target_include_directories(libraw_compat INTERFACE ${LIBRAW_INCLUDE})
|
||||
set(LIBRAW_TARGET libraw_compat)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_GUI)
|
||||
find_package(Qt6 6.8 REQUIRED COMPONENTS Widgets)
|
||||
@@ -34,6 +64,7 @@ endif()
|
||||
# Core converter library (no Qt dependency)
|
||||
# ──────────────────────────────────────────────
|
||||
add_library(converter_core STATIC
|
||||
src/config/AppConfig.cpp
|
||||
src/converter/pipeline/Pipeline.cpp
|
||||
src/converter/rawloader/RawLoader.cpp
|
||||
src/converter/preprocess/Preprocessor.cpp
|
||||
@@ -51,7 +82,7 @@ target_include_directories(converter_core PUBLIC
|
||||
|
||||
target_link_libraries(converter_core PUBLIC
|
||||
${OpenCV_LIBS}
|
||||
PkgConfig::LIBRAW
|
||||
${LIBRAW_TARGET}
|
||||
)
|
||||
|
||||
target_compile_options(converter_core PRIVATE
|
||||
@@ -95,6 +126,53 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
# Windows: link against winsock / windows socket libraries needed by OpenCV
|
||||
if(PHOTOCONV_WINDOWS)
|
||||
target_link_libraries(photo-converter PRIVATE ws2_32)
|
||||
endif()
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# Install rules
|
||||
# ──────────────────────────────────────────────
|
||||
include(GNUInstallDirs)
|
||||
|
||||
install(TARGETS photo-converter
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
install(FILES config.ini
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR}
|
||||
RENAME config.ini.example
|
||||
)
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# CPack packaging
|
||||
# ──────────────────────────────────────────────
|
||||
set(CPACK_PACKAGE_NAME "photo-converter")
|
||||
set(CPACK_PACKAGE_VENDOR "photo-converter project")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SHORT "${PROJECT_DESCRIPTION}")
|
||||
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "photo-converter")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" )
|
||||
|
||||
if(PHOTOCONV_WINDOWS)
|
||||
# NSIS installer for Windows
|
||||
set(CPACK_GENERATOR "NSIS;ZIP")
|
||||
set(CPACK_NSIS_DISPLAY_NAME "Photo Converter ${PROJECT_VERSION}")
|
||||
set(CPACK_NSIS_PACKAGE_NAME "photo-converter")
|
||||
set(CPACK_NSIS_MODIFY_PATH ON)
|
||||
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/assets/icon.ico")
|
||||
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/assets/icon.ico")
|
||||
else()
|
||||
# TGZ + DEB for Linux / ZIP for macOS
|
||||
set(CPACK_GENERATOR "TGZ;DEB")
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "photo-converter project")
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS
|
||||
"libopencv-core4.10 | libopencv4-java, libraw23, libqt6widgets6")
|
||||
endif()
|
||||
|
||||
include(CPack)
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# Tests
|
||||
# ──────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user