Skip to content

Commit

Permalink
Fix ffmpeg build on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey Clark committed Jul 23, 2015
1 parent 4f5f54a commit 84c1fdf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ include(InstallRequiredSystemLibraries)

set(EXECUTABLE_NAME "attract")

find_package( PkgConfig REQUIRED )
find_package( EXPAT )
find_package( OpenAL REQUIRED )

Expand All @@ -47,6 +46,9 @@ endif()
if( WIN32 )
set(SFML_STATIC_LIBRARIES TRUE)
add_definitions( -DAL_LIBTYPE_STATIC )
if( ${CMAKE_BUILD_TYPE} STREQUAL "Release" )
list( APPEND sfmlcomponents main )
endif()
endif()
find_package( SFML 2 COMPONENTS ${sfmlcomponents} REQUIRED )

Expand Down
14 changes: 9 additions & 5 deletions cmake_modules/FindFFmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
# FFMPEG_FOUND - All required components and the core library were found
# FFMPEG_INCLUDE_DIRS - Combined list of all components include dirs
# FFMPEG_LIBRARIES - Combined list of all componenets libraries
# FFMPEG_STATIC_LIBRARIES
# FFMPEG_VERSION_STRING - Version of the first component requested
#
# For each requested component the following variables are defined:
#
# FFMPEG_<component>_FOUND - The component was found
# FFMPEG_<component>_INCLUDE_DIRS - The components include dirs
# FFMPEG_<component>_LIBRARIES - The components libraries
# FFMPEG_<component>_STATIC_LIBRARIES
# FFMPEG_<component>_VERSION_STRING - The components version string
# FFMPEG_<component>_VERSION_MAJOR - The components major version
# FFMPEG_<component>_VERSION_MINOR - The components minor version
Expand All @@ -19,7 +21,7 @@
# <component> is the uppercase name of the component


find_package(PkgConfig QUIET)
find_package(PkgConfig)

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_lib_suffix 64)
Expand All @@ -32,9 +34,7 @@ function(find_ffmpeg_library component header)
set(FFMPEG_${component_u}_FOUND FALSE PARENT_SCOPE)
set(FFmpeg_${component}_FOUND FALSE PARENT_SCOPE)

if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_FFMPEG_${component} QUIET lib${component})
endif()
pkg_check_modules(PC_FFMPEG_${component} lib${component})

find_path(FFMPEG_${component}_INCLUDE_DIR
NAMES
Expand Down Expand Up @@ -74,6 +74,7 @@ function(find_ffmpeg_library component header)

set(FFMPEG_${component_u}_INCLUDE_DIRS ${FFMPEG_${component}_INCLUDE_DIR} PARENT_SCOPE)
set(FFMPEG_${component_u}_LIBRARIES ${FFMPEG_${component}_LIBRARY} PARENT_SCOPE)
set(FFMPEG_${component_u}_STATIC_LIBRARIES ${PC_FFMPEG_${component}_STATIC_LIBRARIES} PARENT_SCOPE)

mark_as_advanced(FFMPEG_${component}_INCLUDE_DIR FFMPEG_${component}_LIBRARY)

Expand All @@ -86,8 +87,10 @@ function(find_ffmpeg_library component header)
set(FFMPEG_INCLUDE_DIRS "${FFMPEG_INCLUDE_DIRS}" PARENT_SCOPE)

list(APPEND FFMPEG_LIBRARIES ${FFMPEG_${component}_LIBRARY})
list(APPEND FFMPEG_STATIC_LIBRARIES ${PC_FFMPEG_${component}_STATIC_LIBRARIES})
list(REMOVE_DUPLICATES FFMPEG_LIBRARIES)
set(FFMPEG_LIBRARIES "${FFMPEG_LIBRARIES}" PARENT_SCOPE)
set(FFMPEG_STATIC_LIBRARIES "${FFMPEG_STATIC_LIBRARIES}" PARENT_SCOPE)

set(FFMPEG_${component_u}_VERSION_STRING "unknown" PARENT_SCOPE)
set(_vfile "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h")
Expand All @@ -111,6 +114,7 @@ endfunction()

set(FFMPEG_INCLUDE_DIRS)
set(FFMPEG_LIBRARIES)
set(FFMPEG_STATIC_LIBRARIES)

if(NOT FFmpeg_FIND_COMPONENTS)
message(FATAL_ERROR "No FFmpeg components requested")
Expand Down Expand Up @@ -146,6 +150,6 @@ endforeach()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFmpeg
FOUND_VAR FFMPEG_FOUND
REQUIRED_VARS FFMPEG_${_first_comp}_LIBRARIES FFMPEG_${_first_comp}_INCLUDE_DIRS
REQUIRED_VARS FFMPEG_${_first_comp}_LIBRARIES FFMPEG_${_first_comp}_STATIC_LIBRARIES FFMPEG_${_first_comp}_INCLUDE_DIRS
VERSION_VAR FFMPEG_${_first_comp}_VERSION_STRING
HANDLE_COMPONENTS)
11 changes: 9 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ set( libs squirrel )

if ( SFML_STATIC_LIBRARIES )
pkg_check_modules( PC_SFML sfml )
if ( NOT NO_MOVIE )
remove( PC_SFML_STATIC_LIBRARIES sfml-audio-s )
endif()
list( APPEND libs ${PC_SFML_STATIC_LIBRARIES} )
else()
list( APPEND libs ${SFML_LIBRARIES} )
Expand Down Expand Up @@ -84,7 +87,11 @@ if ( NOT NO_MOVIE )
endif()
list( APPEND sources media.hpp media.cpp )
include_directories( ${OPENAL_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS} )
list( APPEND libs ${FFMPEG_LIBRARIES} ${OPENAL_LIBRARIES} audiolib )
if( WIN32 )
list( APPEND libs audiolib ${FFMPEG_STATIC_LIBRARIES} )
else()
list( APPEND libs audiolib ${FFMPEG_LIBRARIES} )
endif()
add_definitions( -DWITH_MOVIE )
endif()

Expand Down Expand Up @@ -112,7 +119,7 @@ if( APPLE )
endif()

if ( WIN32 )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mconsole")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-static")
endif()

Expand Down

0 comments on commit 84c1fdf

Please sign in to comment.