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

[libraw] Re-fix non-thread-safe library installation, always export pkgconfig files, add usage #19593

Merged
merged 18 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions ports/libraw/CONTROL

This file was deleted.

36 changes: 36 additions & 0 deletions ports/libraw/fix-install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 47f3869..136549b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -544,7 +544,7 @@ SET_TARGET_PROPERTIES(raw_r PROPERTIES OUTPUT_NAME "raw_r")
# -- Files to install -------------------------------------------------------------------------------------

# Configure and install data file for packaging.
-IF(NOT WIN32)
+IF(1)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/data/libraw.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libraw.pc @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libraw.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig)

@@ -570,8 +570,8 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/libraw/libraw.h
# Install Shared binary files.
INSTALL(TARGETS raw
RUNTIME DESTINATION bin
- LIBRARY DESTINATION lib${LIB_SUFFIX}
- ARCHIVE DESTINATION lib${LIB_SUFFIX}
+ LIBRARY DESTINATION lib${LIB_SUFFIX}/manual-link
+ ARCHIVE DESTINATION lib${LIB_SUFFIX}/manual-link
)

INSTALL(TARGETS raw_r
diff --git a/cmake/data/libraw.pc.cmake b/cmake/data/libraw.pc.cmake
index aede5f2..ffeefc2 100644
--- a/cmake/data/libraw.pc.cmake
+++ b/cmake/data/libraw.pc.cmake
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
-libdir=${prefix}/lib@LIB_SUFFIX@
+libdir=${prefix}/lib@LIB_SUFFIX@/manual-link
includedir=${prefix}/include/libraw

Name: @PROJECT_NAME@
67 changes: 24 additions & 43 deletions ports/libraw/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,47 @@ vcpkg_from_github(
PATCHES
findlibraw_debug_fix.patch
lcms2_debug_fix.patch
# Move the non-thread-safe library to manual-link. This is unfortunately needed
# because otherwise libraries that build on top of libraw have to choose.
fix-install.patch
)

file(COPY ${LIBRAW_CMAKE_SOURCE_PATH}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
file(COPY ${LIBRAW_CMAKE_SOURCE_PATH}/cmake DESTINATION ${SOURCE_PATH})
file(COPY "${LIBRAW_CMAKE_SOURCE_PATH}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
file(COPY "${LIBRAW_CMAKE_SOURCE_PATH}/cmake" DESTINATION "${SOURCE_PATH}")

vcpkg_configure_cmake(
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved
PREFER_NINJA
OPTIONS
-DINSTALL_CMAKE_MODULE_PATH=${CURRENT_PACKAGES_DIR}/share/libraw
-DINSTALL_CMAKE_MODULE_PATH=${CURRENT_PACKAGES_DIR}/share/${PORT}
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved
-DENABLE_EXAMPLES=OFF
-DCMAKE_DEBUG_POSTFIX=d
)

vcpkg_install_cmake()
vcpkg_cmake_install()

file(READ ${CURRENT_PACKAGES_DIR}/include/libraw/libraw_types.h LIBRAW_H)
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
string(REPLACE "#ifdef LIBRAW_NODLL" "#if 1" LIBRAW_H "${LIBRAW_H}")
else()
string(REPLACE "#ifdef LIBRAW_NODLL" "#if 0" LIBRAW_H "${LIBRAW_H}")
endif()
file(WRITE ${CURRENT_PACKAGES_DIR}/include/libraw/libraw_types.h "${LIBRAW_H}")

if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
# Rename thread-safe version to be "raw.lib". This is unfortunately needed
# because otherwise libraries that build on top of libraw have to choose.
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/raw.lib ${CURRENT_PACKAGES_DIR}/debug/lib/rawd.lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/raw_r.lib ${CURRENT_PACKAGES_DIR}/lib/raw.lib)
if(NOT VCPKG_BUILD_TYPE STREQUAL "release")
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/raw_rd.lib ${CURRENT_PACKAGES_DIR}/debug/lib/rawd.lib)
endif()
vcpkg_copy_pdbs()

# Cleanup
file(GLOB RELEASE_EXECUTABLES ${CURRENT_PACKAGES_DIR}/bin/*.exe)
file(REMOVE ${RELEASE_EXECUTABLES})
if(NOT VCPKG_BUILD_TYPE STREQUAL "release")
file(GLOB DEBUG_EXECUTABLES ${CURRENT_PACKAGES_DIR}/debug/bin/*.exe)
file(REMOVE ${DEBUG_EXECUTABLES})
endif()
endif()
vcpkg_fixup_pkgconfig()

if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libraw/libraw_types.h"
"#ifdef LIBRAW_NODLL" "#if 1"
)
else()
if(VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
file(REMOVE ${CURRENT_PACKAGES_DIR}/bin/raw.dll ${CURRENT_PACKAGES_DIR}/debug/bin/rawd.dll)
endif()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libraw/libraw_types.h"
"#ifdef LIBRAW_NODLL" "#if 0"
)
endif()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")

# Rename cmake module into a config in order to allow more flexible lookup rules
file(RENAME ${CURRENT_PACKAGES_DIR}/share/libraw/FindLibRaw.cmake ${CURRENT_PACKAGES_DIR}/share/libraw/libraw-config.cmake)
file(RENAME "${CURRENT_PACKAGES_DIR}/share/${PORT}/FindLibRaw.cmake" "${CURRENT_PACKAGES_DIR}/share/${PORT}/libraw-config.cmake")

if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/libraw)
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
endif()

vcpkg_copy_pdbs()

file(INSTALL ${SOURCE_PATH}/COPYRIGHT DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${SOURCE_PATH}/COPYRIGHT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

11 changes: 11 additions & 0 deletions ports/libraw/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
The package libraw is compatible with built-in CMake targets:

find_package(libraw CONFIG REQUIRED)
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved
# For non-thread-safe version
target_compile_definitions(main PRIVATE ${LibRaw_DEFINITIONS})
target_include_directories(main PRIVATE ${LibRaw_INCLUDE_DIR})
target_link_libraries(main PRIVATE ${LibRaw_LIBRARIES})
# For thread-safe version
target_compile_definitions(main PRIVATE ${LibRaw_r_DEFINITIONS})
target_include_directories(main PRIVATE ${LibRaw_INCLUDE_DIR})
target_link_libraries(main PRIVATE ${LibRaw_r_LIBRARIES})
15 changes: 15 additions & 0 deletions ports/libraw/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "libraw",
"version-string": "201903",
"port-version": 4,
"description": "raw image decoder library",
"homepage": "https://www.libraw.org",
"dependencies": [
"jasper",
"lcms",
{
"name": "vcpkg-cmake",
"host": true
}
]
}
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3565,8 +3565,8 @@
"port-version": 2
},
"libraw": {
"baseline": "201903-3",
"port-version": 0
"baseline": "201903",
"port-version": 4
},
"librdkafka": {
"baseline": "1.7.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libraw.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "29570f7c291c82fff29831f09cba7d3080250fc5",
"version-string": "201903",
"port-version": 4
},
{
"git-tree": "659d20658809488ab3cfccf30d85870ce06615e0",
"version-string": "201903-3",
Expand Down