Skip to content

Commit

Permalink
[vxl] Revise deps, enable CI, add test port (microsoft#41310)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt authored Oct 11, 2024
1 parent 3754416 commit 9558037
Show file tree
Hide file tree
Showing 20 changed files with 394 additions and 57 deletions.
33 changes: 33 additions & 0 deletions ports/vxl/cmake-package.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/config/cmake/Modules/UseVXL.cmake b/config/cmake/Modules/UseVXL.cmake
index fba90e4..e7b3b62 100644
--- a/config/cmake/Modules/UseVXL.cmake
+++ b/config/cmake/Modules/UseVXL.cmake
@@ -77,7 +77,7 @@ if(VXL_CONFIG_CMAKE)
include_directories(SYSTEM ${VXL_VCL_INCLUDE_DIRS} ${VXL_CORE_INCLUDE_DIRS})

# Add link directories needed to use VXL.
- link_directories(${VXL_LIBRARY_DIR})
+ # [vcpkg skip] link_directories(${VXL_LIBRARY_DIR})

if(VXL_CMAKE_DOXYGEN_DIR)
# Allow use of VXL's cmake/doxygen framework
diff --git a/config/cmake/Modules/VXLConfig_export.cmake.in b/config/cmake/Modules/VXLConfig_export.cmake.in
index 78eaf51..c69b7d8 100644
--- a/config/cmake/Modules/VXLConfig_export.cmake.in
+++ b/config/cmake/Modules/VXLConfig_export.cmake.in
@@ -1,6 +1,4 @@
# vxl/config/cmake/VXLConfig_export.cmake.in
-# also configured by CMake to
-# @PROJECT_BINARY_DIR@/config/cmake/export/VXLConfig.cmake
#
# This CMake module is configured by VXL's build process to export the
# project settings for use by client projects. A client project may
@@ -33,7 +31,7 @@ set(VXL_LIBRARY_DIR "@CMAKE_INSTALL_PREFIX@/lib")

# The VXL CMake support directory.
# Clients projects should not use the Find*.cmake files in this directory.
-set(VXL_CMAKE_DIR "@CMAKE_INSTALL_PREFIX@/share/vxl/cmake")
+set(VXL_CMAKE_DIR "@CMAKE_INSTALL_PREFIX@/share/vxl")

# VXL Configuration options. You don't have to build with the same options as VXL, but it often helps.
set(BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
55 changes: 55 additions & 0 deletions ports/vxl/devendor.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
diff --git a/config/cmake/Modules/FindGEOTIFF.cmake b/config/cmake/Modules/FindGEOTIFF.cmake
index bcc8fc5..ed9420e 100644
--- a/config/cmake/Modules/FindGEOTIFF.cmake
+++ b/config/cmake/Modules/FindGEOTIFF.cmake
@@ -18,7 +18,7 @@ if (${VXL_USE_GEOTIFF})

# If this FORCE variable is unset or is FALSE, try to find a native library.
if( NOT VXL_FORCE_V3P_GEOTIFF )
- include( ${MODULE_PATH}/NewCMake/FindGEOTIFF.cmake )
+ find_package(GeoTIFF CONFIG REQUIRED)
if( GEOTIFF_FOUND )
set(VXL_USING_NATIVE_GEOTIFF "YES")
endif()
diff --git a/config/cmake/Modules/VXLConfig_export.cmake.in b/config/cmake/Modules/VXLConfig_export.cmake.in
index 86bb564..c69b7d8 100644
--- a/config/cmake/Modules/VXLConfig_export.cmake.in
+++ b/config/cmake/Modules/VXLConfig_export.cmake.in
@@ -152,6 +152,10 @@ set(VXL_TIFF_INCLUDE_DIR "@TIFF_INCLUDE_DIR@")
set(VXL_TIFF_LIBRARIES "@TIFF_LIBRARIES@")

set(VXL_GEOTIFF_FOUND "@GEOTIFF_FOUND@")
+if(VXL_GEOTIFF_FOUND)
+ include(CMakeFindDependencyMacro)
+ find_dependency(GeoTIFF CONFIG)
+endif()
set(VXL_GEOTIFF_INCLUDE_DIR "@GEOTIFF_INCLUDE_DIR@")
set(VXL_GEOTIFF_LIBRARIES "@GEOTIFF_LIBRARIES@")

diff --git a/core/vgl/vgl_clip.hxx b/core/vgl/vgl_clip.hxx
index 9ff64f8..10c986a 100644
--- a/core/vgl/vgl_clip.hxx
+++ b/core/vgl/vgl_clip.hxx
@@ -144,7 +144,7 @@ namespace {

#elif HAS_CLIPPER

-#include <clipper.hxx>
+#include <clipper.hpp>

namespace {
//: Creates a Clipper polygon from a vgl_polygon.
diff --git a/v3p/CMakeLists.txt b/v3p/CMakeLists.txt
index 251ef9a..78a84fc 100644
--- a/v3p/CMakeLists.txt
+++ b/v3p/CMakeLists.txt
@@ -48,6 +48,9 @@ CMAKE_DEPENDENT_OPTION( VXL_FORCE_V3P_RPLY "Use V3P instead of any native RPLY l
mark_as_advanced( VXL_FORCE_V3P_RPLY )

if(VXL_BUILD_CORE_IMAGING)
+ add_subdirectory(openjpeg2)
+elseif(0)
+ # not used by core and vcl
include(${VXL_CMAKE_DIR}/FindZLIB.cmake)
if (VXL_FORCE_V3P_ZLIB OR ( NOT VXL_USING_NATIVE_ZLIB ) AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/zlib)
add_subdirectory(zlib)
File renamed without changes.
28 changes: 28 additions & 0 deletions ports/vxl/file_formats.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 3483f9c..5040676 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -60,6 +60,10 @@ if(VXL_BUILD_CORE_IMAGING)
if(VXL_BUILD_CORE_NUMERICS)
add_subdirectory (vil/algo)
endif()
+else()
+ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/vil)
+ file(WRITE ${PROJECT_BINARY_DIR}/vil/vil_config.h "/* core imaging disabled */")
+ install(FILES ${PROJECT_BINARY_DIR}/vil/vil_config.h DESTINATION include/vxl/core/vil)
endif()


diff --git a/core/vpgl/file_formats/CMakeLists.txt b/core/vpgl/file_formats/CMakeLists.txt
index cd33c8e..e2501d3 100644
--- a/core/vpgl/file_formats/CMakeLists.txt
+++ b/core/vpgl/file_formats/CMakeLists.txt
@@ -8,7 +8,7 @@ set( vpgl_file_formats_sources
)

include(${VXL_CMAKE_DIR}/FindTIFF.cmake)
-if(TIFF_FOUND)
+if(VXL_BUILD_CORE_IMAGING)
include_directories(${TIFF_INCLUDE_DIR})
include( ${VXL_CMAKE_DIR}/FindGEOTIFF.cmake)
if(GEOTIFF_FOUND)
13 changes: 0 additions & 13 deletions ports/vxl/fix_dependency.patch

This file was deleted.

60 changes: 60 additions & 0 deletions ports/vxl/int_64.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/core/vsl/Templates/vsl_vector_io+uint_64-.cxx b/core/vsl/Templates/vsl_vector_io+uint_64-.cxx
index 8807c44..a8090ca 100644
--- a/core/vsl/Templates/vsl_vector_io+uint_64-.cxx
+++ b/core/vsl/Templates/vsl_vector_io+uint_64-.cxx
@@ -1,6 +1,6 @@
#include <vxl_config.h>

-#if VXL_HAS_INT_64 && !( VXL_INT_64_IS_LONG || VXL_INT_IS_LONG_LONG )
+#if VXL_HAS_INT_64 && !( VXL_INT_64_IS_LONG )
#include <vsl/vsl_vector_io.hxx>
VSL_VECTOR_IO_INSTANTIATE(vxl_uint_64);

diff --git a/core/vsl/vsl_binary_explicit_io.h b/core/vsl/vsl_binary_explicit_io.h
index 9ff669f..87fff4f 100644
--- a/core/vsl/vsl_binary_explicit_io.h
+++ b/core/vsl/vsl_binary_explicit_io.h
@@ -141,7 +141,7 @@ macro (int);
macro (unsigned int);
macro (long);
macro (unsigned long);
-#if VXL_HAS_INT_64 && ! ( VXL_INT_64_IS_LONG || VXL_INT_64_IS_LONGLONG )
+#if VXL_HAS_INT_64 && ! ( VXL_INT_64_IS_LONG )
macro (vxl_int_64);
macro (vxl_uint_64);
#endif
@@ -486,7 +486,7 @@ inline std::size_t vsl_convert_from_arbitrary_length(const unsigned char* buffer

/////////////////////////////////////////////////////////////////////////

-#if VXL_HAS_INT_64 && !( VXL_INT_64_IS_LONG || VXL_INT_64_IS_LONGLONG )
+#if VXL_HAS_INT_64 && !( VXL_INT_64_IS_LONG )

//: Decode a buffer of arbitrary length integers
// Converts from the integers from the arbitrary length format into
diff --git a/core/vsl/vsl_binary_io.cxx b/core/vsl/vsl_binary_io.cxx
index c36142b..af76327 100644
--- a/core/vsl/vsl_binary_io.cxx
+++ b/core/vsl/vsl_binary_io.cxx
@@ -65,7 +65,7 @@ MACRO_MAKE_INTEGER_READ_WRITE(short);
MACRO_MAKE_INTEGER_READ_WRITE(unsigned short);
MACRO_MAKE_INTEGER_READ_WRITE(long);
MACRO_MAKE_INTEGER_READ_WRITE(unsigned long);
-#if VXL_HAS_INT_64 && !( VXL_INT_64_IS_LONG || VXL_INT_64_IS_LONGLONG)
+#if VXL_HAS_INT_64 && !( VXL_INT_64_IS_LONG )
MACRO_MAKE_INTEGER_READ_WRITE(vxl_int_64);
MACRO_MAKE_INTEGER_READ_WRITE(vxl_uint_64);
#endif
diff --git a/core/vsl/vsl_binary_io.h b/core/vsl/vsl_binary_io.h
index d38478a..1a68137 100644
--- a/core/vsl/vsl_binary_io.h
+++ b/core/vsl/vsl_binary_io.h
@@ -376,7 +376,7 @@ void vsl_b_read(vsl_b_istream& is,unsigned long& n );
inline void vsl_print_summary(std::ostream& os, unsigned long n )
{ os << n; }

-#if VXL_HAS_INT_64 && !( VXL_INT_64_IS_LONG || VXL_INT_64_IS_LONGLONG )
+#if VXL_HAS_INT_64 && !( VXL_INT_64_IS_LONG )

//: Write to vsl_b_ostream
void vsl_b_write(vsl_b_ostream& os,vxl_int_64 n );
File renamed without changes.
13 changes: 13 additions & 0 deletions ports/vxl/mingw.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/core/vul/vul_temp_filename.cxx b/core/vul/vul_temp_filename.cxx
index 87649e8..1fb263a 100644
--- a/core/vul/vul_temp_filename.cxx
+++ b/core/vul/vul_temp_filename.cxx
@@ -11,7 +11,7 @@

#if defined (_MSC_VER) || defined(__MINGW32__)

-# include <Windows.h>
+# include <windows.h>
#else
#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
// Helper functions for Unix
13 changes: 13 additions & 0 deletions ports/vxl/omit-broken-install.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/vcl/CMakeLists.txt b/vcl/CMakeLists.txt
index dd83858..243d57b 100644
--- a/vcl/CMakeLists.txt
+++ b/vcl/CMakeLists.txt
@@ -115,7 +115,7 @@ vxl_configure_file(${CMAKE_CURRENT_LIST_DIR}/vcl_where_root_dir.h.in ${PROJECT_B

include_directories(${PROJECT_BINARY_DIR})
set( vcl_sources
- vcl_legacy_aliases.h ${VCL_COMPILER_DETECTION_HEADER}
+ vcl_legacy_aliases.h
vcl_deprecated.cxx vcl_deprecated.h

vcl_cmath.h
25 changes: 25 additions & 0 deletions ports/vxl/openjpeg.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/config/cmake/Modules/FindOpenJPEG2.cmake b/config/cmake/Modules/FindOpenJPEG2.cmake
index c76bc44..41dc198 100644
--- a/config/cmake/Modules/FindOpenJPEG2.cmake
+++ b/config/cmake/Modules/FindOpenJPEG2.cmake
@@ -62,6 +62,8 @@ set(OPENJPEG2_DEFINITIONS "")

if(OPENJPEG2_FOUND)
set(VXL_USING_NATIVE_OPENJPEG2 "YES")
+elseif(NOT ENABLE_OPENJPEG)
+ set(VXL_USING_NATIVE_OPENJPEG2 "YES") # to disable internal lib, too
else()
if( EXISTS ${VXL_ROOT_SOURCE_DIR}/v3p/openjpeg2/openjpeg.h)
set(OPENJPEG2_FOUND TRUE)
diff --git a/v3p/openjpeg2/CMakeLists.txt b/v3p/openjpeg2/CMakeLists.txt
index 67b184e..354180b 100644
--- a/v3p/openjpeg2/CMakeLists.txt
+++ b/v3p/openjpeg2/CMakeLists.txt
@@ -49,6 +49,7 @@ if(VXL_MATH_LIBRARY_FOUND)
endif()
mark_as_advanced(VXL_MATH_LIBRARY_FOUND)
set_target_properties(openjpeg2 PROPERTIES
+ OUTPUT_NAME vxl_openjpeg
VERSION 2.0.0
DEFINE_SYMBOL OPJ_EXPORTS)
endif()
81 changes: 58 additions & 23 deletions ports/vxl/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
set(VXL_BUILD_CORE_IMAGING OFF)
if("core-imaging" IN_LIST FEATURES)
set(VXL_BUILD_CORE_IMAGING ON)
if(EXISTS "${CURRENT_INSTALLED_DIR}/include/openjpeg.h")
set(VXL_BUILD_CORE_IMAGING OFF)
message(WARNING "Can't build VXL CORE_IMAGING features with non built-in OpenJpeg. Please remove OpenJpeg, and try install VXL again if you need them.")
endif()
if(VCPKG_TARGET_IS_WINDOWS)
# Cf. https://vxl.github.io/vxl-users-faq.html
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()

vcpkg_from_github(
Expand All @@ -14,52 +10,91 @@ vcpkg_from_github(
SHA512 4c6f6dcd793a50cbbc9c7f61c561ed4a747ded67e3dceb09792998c0f0d4294445a441fed668d59297560f196274b1c25593ce67b0aa7597cbb773328e8612c0
HEAD_REF master
PATCHES
fix_dependency.patch
testlib.patch
fix_limits.patch
cmake-package.diff
devendor.diff
disable-tests.diff
file_formats.diff
int_64.diff
limits.diff
mingw.diff
omit-broken-install.diff
openjpeg.diff
)
file(GLOB_RECURSE vendored_sources "${SOURCE_PATH}/v3p/*.c" "${SOURCE_PATH}/v3p/*.cpp" "${SOURCE_PATH}/v3p/*.cxx")
list(FILTER vendored_sources EXCLUDE REGEX "/(netlib|openjpeg2)/")
file(REMOVE_RECURSE ${vendored_sources})

vcpkg_check_features(OUT_FEATURE_OPTIONS options
FEATURES
core-imaging VXL_BUILD_CORE_IMAGING
openjpeg ENABLE_OPENJPEG
)

if(VCPKG_TARGET_IS_MINGW)
list(APPEND options -DVXL_HAS_DBGHELP_H=FALSE) # needs patches
endif()

set(USE_WIN_WCHAR_T OFF)
if(VCPKG_TARGET_IS_WINDOWS)
set(USE_WIN_WCHAR_T ON)
endif()

# Avoid try-run which doesn't work for cross-builds.
# Users may override with VCPKG_CMAKE_CONFIGURE_OPTIONS.
string(COMPARE EQUAL "${VCPKG_TARGET_ARCHITECTURE}" "x64" VXL_HAS_SSE2_HARDWARE_SUPPORT)
set(VCL_HAS_LFS ON)
if(VCPKG_TARGET_IS_WINDOWS)
set(VCL_HAS_LFS OFF)
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DVXL_BUILD_EXAMPLES=OFF
${options}
-DBUILD_TESTING=OFF
-DVXL_BUILD_CORE_IMAGING=${VXL_BUILD_CORE_IMAGING}
-DCMAKE_POLICY_DEFAULT_CMP0120=OLD # vxl needs WriteCompilerDetectionHeader
-DVCL_HAS_LFS=${VCL_HAS_LFS}
-DVXL_BUILD_CONTRIB=OFF
-DVXL_BUILD_EXAMPLES=OFF
-DVXL_HAS_SSE2_HARDWARE_SUPPORT=${VXL_HAS_SSE2_HARDWARE_SUPPORT}
-DVXL_FORCE_V3P_BZLIB2=OFF
-DVXL_USING_NATIVE_BZLIB2=TRUE # for disable build built-in bzip2 (v3p/bzlib/CMakeLists.txt#L10-L26)
-DVXL_FORCE_V3P_CLIPPER=ON # TODO : need add clipper port to turn off
-DVXL_FORCE_V3P_CLIPPER=OFF
-DVXL_FORCE_V3P_DCMTK=OFF
-DVXL_FORCE_V3P_GEOTIFF=OFF
-DVXL_FORCE_V3P_J2K=OFF
-DVXL_FORCE_V3P_JPEG=OFF
-DVXL_FORCE_V3P_OPENJPEG2=ON # TODO : need fix compile error when using openjpeg port to turn off
-DVXL_FORCE_V3P_OPENJPEG2=ON # vendored 1.2; vxl needs old API.
-DVXL_FORCE_V3P_PNG=OFF
-DVXL_FORCE_V3P_TIFF=OFF
-DVXL_FORCE_V3P_ZLIB=OFF
-DVXL_USE_DCMTK=OFF # TODO : need fix dcmtk support to turn on
-DVXL_USE_DCMTK=OFF
-DVXL_USE_GEOTIFF=ON
-DVXL_USE_WIN_WCHAR_T=${USE_WIN_WCHAR_T}
MAYBE_UNUSED_VARIABLES
ENABLE_OPENJPEG
VXL_USE_DCMTK
VXL_USING_NATIVE_BZLIB2
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup()
vcpkg_cmake_config_fixup(CONFIG_PATH share/vxl/cmake)
vcpkg_copy_pdbs()

file(COPY "${SOURCE_PATH}/vcl/vcl_msvc_warnings.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include/vxl/vcl")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
# Remove tests which assume that the source dir still exists
# Don't provide source dir; test lib not installed.
file(REMOVE "${CURRENT_PACKAGES_DIR}/include/vxl/vcl/vcl_where_root_dir.h")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/vxl/core/testlib")

vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/vxl/cmake/VXLConfig.cmake" "${CURRENT_BUILDTREES_DIR}" "") # only used in comment
file(COPY "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

file(INSTALL "${SOURCE_PATH}/core/vxl_copyright.h" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
set(file_list "${SOURCE_PATH}/core/vxl_copyright.h")
if("openjpeg" IN_LIST FEATURES)
file(COPY_FILE "${SOURCE_PATH}/v3p/openjpeg2/license.txt" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/openjpeg2 license.txt")
vcpkg_list(APPEND file_list "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/openjpeg2 license.txt")
endif()
vcpkg_install_copyright(FILE_LIST ${file_list} COMMENT [[
vcl includes Netlib software from https://www.netlib.org/. Most netlib software
packages have no restrictions on their use but it is recommended to check with
the authors to be sure. (https://www.netlib.org/misc/faq.html#2.3)
]])
6 changes: 6 additions & 0 deletions ports/vxl/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vxl provides CMake targets:

find_package(VXL CONFIG REQUIRED)
include("${VXL_CMAKE_DIR}/UseVXL.cmake")
# Example: numerics library 'vnl'.
target_link_libraries(main PRIVATE $<TARGET_NAME:vnl>)
Loading

0 comments on commit 9558037

Please sign in to comment.