Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@ if(WIN32)
find_package(dlfcn-win32 REQUIRED)
set(CMAKE_DL_LIBS dlfcn-win32::dl)
endif()
if(MINGW)
string(REPLACE "iconv" "pthread" MLT_PTHREAD_LIBS "${Iconv_LIBRARY}")
endif()
endif()

find_package(SDL2)
Expand Down
10 changes: 9 additions & 1 deletion src/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ set_target_properties(mlt PROPERTIES
)

if(WIN32)
include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES Threads::Threads)
check_symbol_exists(nanosleep "pthread.h;pthread_time.h" HAVE_PTHREAD_NANOSLEEP_WIN32)
unset(CMAKE_REQUIRED_LIBRARIES)

if(MINGW)
target_link_libraries(mlt PRIVATE ${MLT_PTHREAD_LIBS})
target_link_libraries(mlt PRIVATE Threads::Threads)
target_link_options(mlt PRIVATE -Wl,--output-def,${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/libmlt-${MLT_VERSION_MAJOR}.def)
install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/libmlt-${MLT_VERSION_MAJOR}.def" DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
Expand All @@ -145,6 +150,8 @@ if(WIN32)
endif()
endif()

configure_file(mlt_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/mlt_config.h)

if(NOT (WIN32 OR RELOCATABLE))
if(APPLE)
target_compile_definitions(mlt PRIVATE PREFIX_DATA="${CMAKE_INSTALL_FULL_DATADIR}/mlt" PREFIX_LIB="${CMAKE_INSTALL_FULL_LIBDIR}/mlt")
Expand All @@ -167,6 +174,7 @@ install(TARGETS mlt

# Install the generated export header
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mlt_export.h
${CMAKE_CURRENT_BINARY_DIR}/mlt_config.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mlt-${MLT_VERSION_MAJOR}/framework
)

Expand Down
4 changes: 4 additions & 0 deletions src/framework/mlt_config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* mlt_config.h. Generated by cmake from mlt_config.h.in */

/* Defined when a pthread library has an implementation for nanosleep() (win32-only) */
#cmakedefine HAVE_PTHREAD_NANOSLEEP_WIN32
3 changes: 2 additions & 1 deletion src/framework/mlt_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,13 @@ typedef void *(*mlt_thread_function_t)(void *); /**< generic thread functio
#endif

#ifdef _WIN32
#include "mlt_config.h"
#include <pthread.h>
/* Win32 compatibility function declarations */
#if !defined(__MINGW32__)
MLT_EXPORT int usleep(unsigned int useconds);
#endif
#ifndef WIN_PTHREADS_TIME_H
#ifndef HAVE_PTHREAD_NANOSLEEP_WIN32
MLT_EXPORT int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
#endif
MLT_EXPORT int setenv(const char *name, const char *value, int overwrite);
Expand Down
6 changes: 3 additions & 3 deletions src/melt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ target_link_libraries(melt PRIVATE mlt Threads::Threads)
target_compile_definitions(melt PRIVATE VERSION="${MLT_VERSION}")

if(SDL2_FOUND AND NOT ANDROID)
target_link_libraries(melt PRIVATE SDL2::SDL2)
target_compile_definitions(melt PRIVATE HAVE_SDL2)
if(MINGW)
target_link_libraries(melt PRIVATE ${MLT_PTHREAD_LIBS})
target_compile_definitions(melt PRIVATE main=SDL_main)
target_link_libraries(melt PRIVATE mingw32 SDL2main SDL2)
target_link_libraries(melt PRIVATE mingw32 SDL2::SDL2main SDL2::SDL2)
else()
target_link_libraries(melt PRIVATE SDL2::SDL2)
endif()
endif()

Expand Down
3 changes: 0 additions & 3 deletions src/modules/avformat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ endif()

if(WIN32)
target_compile_definitions(mltavformat PRIVATE AVDATADIR="share/ffmpeg/")
if(MINGW)
target_link_libraries(mltavformat PRIVATE ${MLT_PTHREAD_LIBS})
endif()
endif()

if(USE_AVDEVICE AND AVDEVICE_FOUND)
Expand Down
4 changes: 0 additions & 4 deletions src/modules/sdl2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ else()
target_link_libraries(mltsdl2 PRIVATE m)
endif()

if(MINGW)
target_link_libraries(mltsdl2 PRIVATE ${MLT_PTHREAD_LIBS})
endif()

set_target_properties(mltsdl2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${MLT_MODULE_OUTPUT_DIRECTORY}")

install(TARGETS mltsdl2 LIBRARY DESTINATION ${MLT_INSTALL_MODULE_DIR})
Expand Down
3 changes: 2 additions & 1 deletion src/win32/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <mlt_config.h>
#include "../framework/mlt_properties.h"
#include "../framework/mlt_log.h"

Expand All @@ -46,7 +47,7 @@ int usleep(unsigned int useconds)
return 0;
}

#ifndef WIN_PTHREADS_TIME_H
#ifndef HAVE_PTHREAD_NANOSLEEP_WIN32
int nanosleep(const struct timespec * rqtp, struct timespec * rmtp)
{
if (rqtp->tv_nsec > 999999999) {
Expand Down
Loading