Skip to content
Closed
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
23 changes: 21 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ configure_file (

add_definitions(-DVERSION_FILE_PRESENT -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP -DGPAC_DISABLE_REMOTERY -DNO_GZIP)

# Set global CRT policy to dynamic (/MD) before any targets are defined
# This ensures all targets use the same CRT to avoid linker errors
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-DGPAC_64_BITS)
endif()
Expand Down Expand Up @@ -156,8 +162,10 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (EXTRA_LIBS ${EXTRA_LIBS} iconv)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")


set (EXTRA_LIBS ${EXTRA_LIBS} -lm -lpthread -ldl)
# Add platform-specific system libraries
if(NOT WIN32)
set (EXTRA_LIBS ${EXTRA_LIBS} -lm -lpthread -ldl)
endif()

find_package (PkgConfig)

Expand Down Expand Up @@ -240,6 +248,11 @@ if (PKG_CONFIG_FOUND AND WITH_HARDSUBX)
set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${LEPTONICA_INCLUDE_DIRS})
endif (PKG_CONFIG_FOUND AND WITH_HARDSUBX)

# Add GPAC library directory to linker search path on Windows
if(WIN32)
link_directories("C:/Program Files/GPAC/sdk/lib")
endif()

add_executable (ccextractor ${SOURCEFILE} ${FREETYPE_SOURCE} ${UTF8PROC_SOURCE})

########################################################
Expand All @@ -253,6 +266,12 @@ endif (PKG_CONFIG_FOUND)


target_link_libraries (ccextractor ${EXTRA_LIBS})

# Add legacy_stdio_definitions to resolve CRT import symbols on Windows
if(MSVC)
target_link_libraries(ccextractor legacy_stdio_definitions.lib)
endif()

target_include_directories (ccextractor PUBLIC ${EXTRA_INCLUDES})

# ccx_rust (Rust) calls C functions from ccx (like decode_vbi).
Expand Down
11 changes: 11 additions & 0 deletions src/lib_ccx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ pkg_check_modules (GPAC REQUIRED gpac)
set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${GPAC_INCLUDE_DIRS})
set (EXTRA_LIBS ${EXTRA_LIBS} ${GPAC_LIBRARIES})

# Add GPAC library directory to linker search path on Windows
if(WIN32 AND GPAC_LIBRARY_DIRS)
link_directories(${GPAC_LIBRARY_DIRS})
endif()

if (WITH_FFMPEG)
find_package(PkgConfig)

Expand Down Expand Up @@ -60,6 +65,12 @@ endif (WITH_OCR)
aux_source_directory ("${PROJECT_SOURCE_DIR}/lib_ccx/" SOURCEFILE)

add_library (ccx ${SOURCEFILE} ccx_dtvcc.h ccx_dtvcc.c ccx_encoders_mcc.c ccx_encoders_mcc.h)

# Ensure ccx library uses dynamic CRT to match main executable
if(MSVC)
set_property(TARGET ccx PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()

target_link_libraries (ccx ${EXTRA_LIBS})
target_include_directories (ccx PUBLIC ${EXTRA_INCLUDES})

Expand Down
9 changes: 9 additions & 0 deletions src/rust/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ corrosion_import_crate(
FEATURES ${FEATURES}
)

# Ensure Rust library uses dynamic CRT to match main executable
if(MSVC)
set_property(TARGET ccx_rust PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
# Override Rust's default static CRT linkage
set_target_properties(ccx_rust PROPERTIES
INTERFACE_LINK_OPTIONS "/NODEFAULTLIB:libcmt;/DEFAULTLIB:msvcrt"
)
endif()

add_test(
NAME ccx_rust_test
COMMAND $<TARGET_FILE:Rust::Cargo> test
Expand Down
Loading