diff --git a/CMakeLists.txt b/CMakeLists.txt index e0bf2e423..214452221 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,6 @@ include(InstallRequiredSystemLibraries) set(EXECUTABLE_NAME "attract") -find_package( PkgConfig REQUIRED ) find_package( EXPAT ) find_package( OpenAL REQUIRED ) @@ -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 ) diff --git a/cmake_modules/FindFFmpeg.cmake b/cmake_modules/FindFFmpeg.cmake index 438b58168..94a49864f 100644 --- a/cmake_modules/FindFFmpeg.cmake +++ b/cmake_modules/FindFFmpeg.cmake @@ -4,6 +4,7 @@ # 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: @@ -11,6 +12,7 @@ # FFMPEG__FOUND - The component was found # FFMPEG__INCLUDE_DIRS - The components include dirs # FFMPEG__LIBRARIES - The components libraries +# FFMPEG__STATIC_LIBRARIES # FFMPEG__VERSION_STRING - The components version string # FFMPEG__VERSION_MAJOR - The components major version # FFMPEG__VERSION_MINOR - The components minor version @@ -19,7 +21,7 @@ # 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) @@ -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} QUIET) find_path(FFMPEG_${component}_INCLUDE_DIR NAMES @@ -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) @@ -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") @@ -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") @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9af6b5174..98b4d78b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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} ) @@ -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() @@ -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()