Skip to content
Snippets Groups Projects
Commit 61450f8d authored by Ben Boeckel's avatar Ben Boeckel Committed by Kitware Robot
Browse files

Merge topic 'test-loadable-modules'


52e6c20e SuperbuildTestingMacros: add a function to test loadable modules
f504f00d openimagedenoise: add rpath entries to libraries
92d87743 openxrsdk: add rpath entries to libraries
686166c3 ffmpeg: add rpath entries to the libraries
102c4ce7 python3: do not ship the `__pycache__` directory

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !615
parents b27dc5ff 52e6c20e
No related branches found
No related tags found
2 merge requests!650Revive paraview/release branch and update it to commit used for ParaView 5.12.0,!615SuperbuildPackageMacros: add a function to test loadable modules
Pipeline #379624 passed
......@@ -54,3 +54,170 @@ function (superbuild_add_extract_test name glob_prefix generator output)
endfunction ()
# TODO: Add support for extracting a specific CPack's output.
#[==[.md
Create a test which loads all modules within a directory as being standalone
loadable.
```
superbuild_add_extra_package_test(<package> <generator> <directory>
[EXCLUDES <exclude>...])
```
For a package named `<package>`, find all loadable libraries under
`<directory>` and make sure they are loadable.
If `EXCLUDES` are given, paths matching the exclusion are not tested.
#]==]
function (superbuild_test_loadable_modules package generator dir)
cmake_parse_arguments(PARSE_ARGV 3 _test_loadable "" "" "EXCLUDES")
if (_test_loadable_UNPARSED_ARGUMENTS)
message(FATAL_ERROR
"Unparsed arguments to `superbuild_test_loadable_modules`: "
"${_test_loadable_UNPARSED_ARGUMENTS}")
endif ()
if (WIN32)
return ()
endif ()
find_program(FILE_COMMAND
NAMES file
REQUIRED)
add_test(
NAME "test-package-${package}-${generator}-ldd-resolutions"
COMMAND
"${CMAKE_COMMAND}"
"-Ddirectory=${dir}"
"-Dexcludes=${_test_loadable_EXCLUDES}"
"-Dfile_command=${FILE_COMMAND}"
-D_run_superbuild_test_loadable_modules=ON
-P "${CMAKE_CURRENT_FUNCTION_LIST_FILE}")
set_tests_properties("test-package-${package}-${generator}-ldd-resolutions"
PROPERTIES
DEPENDS "extract-${package}-${generator}")
endfunction ()
if (_run_superbuild_test_loadable_modules)
# Keep the full output on CDash for future inspection.
message("CTEST_FULL_OUTPUT")
if (NOT file_command)
message(FATAL_ERROR
"Missing `file` command to detect filetypes.")
endif ()
function (_superbuild_test_file_type module type)
execute_process(
COMMAND "${file_command}" "${module}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_VARIABLE err
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
if (res)
message(SEND_ERROR
"Failed to run `file` to detect type of '${module}': ${err}")
return ()
endif ()
set(filetype "")
if (out MATCHES ": ELF")
set(filetype "ELF")
elseif (out MATCHES ": Mach-O")
set(filetype "Mach-O")
endif ()
if (filetype)
set("${type}" "${filetype}" PARENT_SCOPE)
else ()
set("${type}" "" PARENT_SCOPE)
endif ()
endfunction ()
function (_superbuild_test_loadable_module module format)
if (format STREQUAL "ELF")
set(command "ldd")
set(ignore_regex "^$")
set(missing_regex " => not found$")
set(libname_regex "^\t(.*) => not found$")
else ()
message(FATAL_ERROR
"Unrecognized binary format: ${format}")
endif ()
execute_process(
COMMAND ${command} "${module}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_VARIABLE err
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
if (res)
message(SEND_ERROR
"Failed to run `${command}` on '${module}': ${err}")
endif ()
string(REPLACE "\n" ";" lines "${out}")
foreach (line IN LISTS lines)
if (line MATCHES "${ignore_regex}")
continue ()
endif ()
if (line MATCHES "${missing_regex}")
string(REGEX REPLACE "${libname_regex}" "\\1" libname "${line}")
message(SEND_ERROR
"'${module}' cannot find library ${libname}")
endif ()
endforeach ()
endfunction ()
file(GLOB binaries "${directory}/bin/*")
file(GLOB macos_binaries "${directory}/MacOS/*")
file(GLOB_RECURSE so_libraries "${directory}/*.so*")
file(GLOB_RECURSE dylib_libraries "${directory}/*.dylib*")
set(expected_format)
if (APPLE)
set(expected_format "Mach-O")
elseif (UNIX)
set(expected_format "ELF")
endif ()
if (NOT expected_format)
message(FATAL_ERROR
"No expected format; nothing to test.")
endif ()
foreach (module IN LISTS binaries macos_binaries so_libraries dylib_libraries)
# Skip symlinks.
if (IS_SYMLINK "${module}")
continue ()
endif ()
set(exclude 0)
foreach (exclude IN LISTS excludes)
if (module MATCHES "${exclude}")
set(exclude 1)
break ()
endif ()
endforeach ()
if (exclude)
continue ()
endif ()
# Skip files not in the expected format.
_superbuild_test_file_type("${module}" module_format)
if (NOT module_format STREQUAL expected_format)
continue ()
endif ()
message(STATUS "Testing ${module}")
_superbuild_test_loadable_module("${module}" "${module_format}")
endforeach ()
endif ()
......@@ -12,6 +12,9 @@ set(ffmpeg_ld_flags "${superbuild_ld_flags}")
if (APPLE AND CMAKE_OSX_DEPLOYMENT_TARGET)
string(APPEND ffmpeg_ld_flags " -isysroot ${CMAKE_OSX_SYSROOT} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif ()
if (UNIX AND NOT APPLE)
string(APPEND ffmpeg_ld_flags " -Wl,-rpath,<INSTALL_DIR>/lib")
endif ()
superbuild_add_project(ffmpeg
DEPENDS zlib pkgconf
......
set(openimagedenoise_options)
if (UNIX AND NOT APPLE)
list(APPEND openimagedenoise_options
-DCMAKE_INSTALL_RPATH:STRING=<INSTALL_DIR>/lib)
endif ()
superbuild_add_project(openimagedenoise
DEPENDS tbb cxx11 ispc python3
LICENSE_FILES
......@@ -10,4 +16,5 @@ superbuild_add_project(openimagedenoise
-DOIDN_APPS:BOOL=OFF
-DCMAKE_INSTALL_NAME_DIR:PATH=<INSTALL_DIR>/lib
-DCMAKE_INSTALL_LIBDIR:STRING=lib
${openimagedenoise_options}
)
set(openxrsdk_options)
if (UNIX AND NOT APPLE)
list(APPEND openxrsdk_options
-DCMAKE_INSTALL_RPATH:STRING=<INSTALL_DIR>/lib)
endif ()
superbuild_add_project(openxrsdk
DEPENDS
jsoncpp
......@@ -12,4 +18,5 @@ superbuild_add_project(openxrsdk
-DDYNAMIC_LOADER:BOOL=ON
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_INSTALL_LIBDIR:STRING=lib
${openxrsdk_options}
)
......@@ -25,7 +25,6 @@ function (superbuild_install_superbuild_python3)
set(modules
__future__
__pycache__
_bootlocale
_collections_abc
_compat_pickle
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment