Skip to content

Commit aadad0a

Browse files
authored
Another bunch of MSVC related fixes and improvements (#1199)
* Make sure dirent is available on MSVC It is a header only library with a single header (dirent.h). vcpkg installs this header with a custom logic to the global include path. However in other environments without modification upstream has to be treated like a usual library n cmake. "Linking" against the interface makes sure, that it is found and that the include paths are available for us. To conver both scenarios we use a FindDirent.cmake * Don't require Kwalify for tests on MSVC Kwalify is used to validate MLT's YAML files, but it is not available for MSVC easily (eg. via vcpkg). This is only relevant for local setups, because for CI it is covered by other plattforms and the results of YAML validation are plattform independent * Add missing direct.h include for getcwd on MSVC * Add fftw3 dependency to vcpkg build * Fix spelling and duplicated entry in CMake preset * Enable build of tests on MSVC CI * Add optional libexif dep to vcpkg
1 parent df783b3 commit aadad0a

File tree

8 files changed

+52
-14
lines changed

8 files changed

+52
-14
lines changed

.github/workflows/build-windows-msvc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ jobs:
5050
- name: Install MLT
5151
run: |
5252
cmake --install build
53+
54+
- name: Run tests
55+
run: |
56+
ctest --test-dir build -C Debug

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ endif()
190190

191191
if (MSVC)
192192
find_package(PThreads4W REQUIRED)
193+
find_package(Dirent 1.26 REQUIRED)
193194
endif ()
194195
find_package(Threads REQUIRED)
195196
find_package(PkgConfig REQUIRED)
@@ -335,7 +336,10 @@ endif()
335336

336337
if(BUILD_TESTING)
337338
find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS Core Test)
338-
find_package(Kwalify REQUIRED)
339+
if(NOT MSVC)
340+
# Kwalify is not available for MSVC easily (eg. via vcpkg)
341+
find_package(Kwalify REQUIRED)
342+
endif()
339343
enable_testing()
340344
endif()
341345

CMakePresets.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"binaryDir": "${sourceDir}/build",
99
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
1010
"cacheVariables": {
11-
"BUILD_TESTING": "OFF",
11+
"BUILD_TESTING": "ON",
1212
"SWIG_PYTHON": "OFF",
1313
"MOD_AVFORMAT": "ON",
1414
"MOD_DECKLINK": "OFF",
@@ -32,7 +32,7 @@
3232
"MOD_RTAUDIO": "OFF",
3333
"MOD_RUBBERBAND": "ON",
3434
"MOD_SDL2": "ON",
35-
"MOD_DOX": "OFF",
35+
"MOD_SPATIALAUDIO": "OFF",
3636
"MOD_VIDSTAB": "OFF",
3737
"MOD_VORBIS": "ON",
3838
"MOD_XINE": "OFF",

cmake/FindDirent.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
find_package(Dirent CONFIG)
2+
3+
if(NOT Dirent_FOUND)
4+
include(FindPackageHandleStandardArgs)
5+
6+
find_path(Dirent_INCLUDE_DIR
7+
NAMES dirent.h
8+
)
9+
10+
find_package_handle_standard_args(Dirent
11+
REQUIRED_VARS
12+
Dirent_INCLUDE_DIR
13+
)
14+
15+
if(Dirent_FOUND AND NOT TARGET dirent)
16+
add_library(dirent INTERFACE)
17+
set_target_properties(dirent PROPERTIES
18+
INTERFACE_INCLUDE_DIRECTORIES "${Dirent_INCLUDE_DIR}"
19+
)
20+
endif()
21+
endif()

src/framework/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ target_compile_options(mlt PRIVATE ${MLT_COMPILE_OPTIONS})
8787
target_link_libraries(mlt PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
8888

8989
if(MSVC)
90-
target_link_libraries(mlt PRIVATE msvccompat PThreads4W::PThreads4W)
90+
target_link_libraries(mlt PRIVATE msvccompat PThreads4W::PThreads4W dirent)
9191
else()
9292
target_link_libraries(mlt PRIVATE m)
9393
endif()

src/modules/xml/consumer_xml.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#ifndef _MSC_VER
3131
#include <unistd.h>
32+
#else
33+
#include <direct.h>
3234
#endif
3335

3436
#define ID_SIZE 128

src/tests/CMakeLists.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ function(add_qt_test)
1818
mlt++
1919
${ARG_LINK_LIBRARIES}
2020
)
21+
if(MSVC)
22+
target_link_libraries(${_testname} PRIVATE PThreads4W::PThreads4W)
23+
endif()
24+
2125
target_include_directories(${_testname} PRIVATE ${arg_INCLUDE_DIRS})
2226
add_test(NAME "QtTest:${arg_TEST_NAME}" COMMAND ${_testname})
2327

@@ -51,12 +55,13 @@ if(MOD_QT6)
5155
)
5256
endif()
5357

54-
55-
file(GLOB YML_FILES "${CMAKE_SOURCE_DIR}/src/modules/*/*.yml")
56-
foreach(YML_FILE ${YML_FILES})
57-
get_filename_component(FILE_NAME ${YML_FILE} NAME)
58-
file(RELATIVE_PATH KWALIFY_TEST_NAME "${CMAKE_SOURCE_DIR}/src/modules" ${YML_FILE})
59-
if(NOT FILE_NAME MATCHES "resolution_scale.yml")
60-
add_test(NAME "kwalify:${KWALIFY_TEST_NAME}" COMMAND ${Kwalify_EXECUTABLE} -f "${CMAKE_SOURCE_DIR}/src/framework/metaschema.yaml" ${YML_FILE})
61-
endif()
62-
endforeach()
58+
if(Kwalify_FOUND)
59+
file(GLOB YML_FILES "${CMAKE_SOURCE_DIR}/src/modules/*/*.yml")
60+
foreach(YML_FILE ${YML_FILES})
61+
get_filename_component(FILE_NAME ${YML_FILE} NAME)
62+
file(RELATIVE_PATH KWALIFY_TEST_NAME "${CMAKE_SOURCE_DIR}/src/modules" ${YML_FILE})
63+
if(NOT FILE_NAME MATCHES "resolution_scale.yml")
64+
add_test(NAME "kwalify:${KWALIFY_TEST_NAME}" COMMAND ${Kwalify_EXECUTABLE} -f "${CMAKE_SOURCE_DIR}/src/framework/metaschema.yaml" ${YML_FILE})
65+
endif()
66+
endforeach()
67+
endif()

vcpkg.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"libebur128",
1616
"gdk-pixbuf",
1717
"rubberband",
18-
"libvorbis"
18+
"libvorbis",
19+
"fftw3",
20+
"libexif"
1921
]
2022
}

0 commit comments

Comments
 (0)