Skip to content
Snippets Groups Projects
Commit c093f04c authored by Palana's avatar Palana
Browse files

add static linking options for ffmpeg and wxwidgets to cmake

parent 534ed54c
No related branches found
No related tags found
No related merge requests found
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(PC_LIBAVUTIL QUIET libavutil) pkg_check_modules(PC_LIBAVUTIL QUIET libavutil)
set(LIBAVUTIL_DEFINITIONS ${PC_LIBAVUTIL_CFLAGS_OTHER}) set(LIBAVUTIL_STANDARD_DEFINITIONS ${PC_LIBAVUTIL_CFLAGS_OTHER}
CACHE STRING
"Libavutil required CFLAGS")
set(LIBAVUTIL_STATIC_DEFINITIONS ${PC_LIBAVUTIL_STATIC_CFLAGS_OTHER}
CACHE STRING
"Libavutil static required CFLAGS")
find_path(LIBAVUTIL_INCLUDE_DIR libavutil/avutil.h find_path(LIBAVUTIL_STANDARD_INCLUDE_DIR libavutil/avutil.h
HINTS ${PC_LIBAVUTIL_INCLUDEDIR} ${PC_LIBAVUTIL_INCLUDE_DIRS} HINTS ${PC_LIBAVUTIL_INCLUDEDIR}
${PC_LIBAVUTIL_INCLUDE_DIRS}
PATH_SUFFIXES libavutil) PATH_SUFFIXES libavutil)
find_library(LIBAVUTIL_LIBRARY NAMES libavutil avutil find_path(LIBAVUTIL_STATIC_INCLUDE_DIR libavutil/avutil.h
HINTS ${PC_LIBAVUTIL_LIBDIR} ${PC_LIBAVUTIL_LIBRARY_DIRS}) HINTS ${PC_LIBAVUTIL_STATIC_INCLUDEDIR}
${PC_LIBAVUTIL_STATIC_INCLUDE_DIRS}
PATH_SUFFIXES libavutil)
if(NOT LIBAVUTIL_STANDARD_LIBRARIES)
set(LIBAVUTIL_STANDARD_LIBRARIES_ "")
foreach(lib ${PC_LIBAVUTIL_LIBRARIES})
find_library(_lib_file NAMES ${lib}
HINTS ${PC_LIBAVUTIL_LIBDIR}
${PC_LIBAVUTIL_LIBRARY_DIRS})
if(_lib_file)
list(APPEND LIBAVUTIL_STANDARD_LIBRARIES_ ${_lib_file})
endif()
unset(_lib_file CACHE)
endforeach()
set(LIBAVUTIL_STANDARD_LIBRARIES ${LIBAVUTIL_STANDARD_LIBRARIES_}
CACHE STRING
"Libavutil (dynamic) libraries")
unset(LIBAVUTIL_STANDARD_LIBRARIES_)
endif()
if(NOT LIBAVUTIL_STATIC_LIBRARIES)
set(LIBAVUTIL_STATIC_LIBRARIES_ "")
set(lib_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}
${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_SHARED_MODULE_SUFFIX})
foreach(lib ${PC_LIBAVUTIL_STATIC_LIBRARIES})
find_library(_lib_file NAMES ${lib}
HINTS ${PC_LIBAVUTIL_LIBDIR}
${PC_LIBAVUTIL_LIBRARY_DIRS})
if(_lib_file)
list(APPEND LIBAVUTIL_STATIC_LIBRARIES_ ${_lib_file})
else()
list(APPEND LIBAVUTIL_STATIC_LIBRARIES_ ${lib})
endif()
unset(_lib_file CACHE)
endforeach()
set(CMAKE_FIND_LIBRARY_SUFFIXES ${lib_suffixes})
unset(lib_suffixes)
set(LIBAVUTIL_STATIC_LIBRARIES ${LIBAVUTIL_STATIC_LIBRARIES_}
CACHE STRING
"Libavutil static libraries")
unset(LIBAVUTIL_STATIC_LIBRARIES_)
endif()
set(LIBAVUTIL_INCLUDE_DIRS ${LIBAVUTIL_INCLUDE_DIR})
set(LIBAVUTIL_LIBRARIES ${LIBAVUTIL_LIBRARY}) if(Libavutil_FIND_COMPONENTS AND
Libavutil_FIND_COMPONENTS STREQUAL "static")
set(LIBAVUTIL_DEFINITION ${LIBAVUTIL_STATIC_DEFINITIONS})
set(LIBAVUTIL_INCLUDE_DIR ${LIBAVUTIL_STATIC_INCLUDE_DIR})
set(LIBAVUTIL_LIBRARY ${LIBAVUTIL_STATIC_LIBRARIES})
else()
set(LIBAVUTIL_DEFINITION ${LIBAVUTIL_STANDARD_DEFINITIONS})
set(LIBAVUTIL_INCLUDE_DIR ${LIBAVUTIL_STANDARD_INCLUDE_DIR})
set(LIBAVUTIL_LIBRARY ${LIBAVUTIL_STANDARD_LIBRARIES})
endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libavutil DEFAULT_MSG find_package_handle_standard_args(Libavutil DEFAULT_MSG
LIBAVUTIL_INCLUDE_DIR LIBAVUTIL_LIBRARY) LIBAVUTIL_INCLUDE_DIR LIBAVUTIL_LIBRARY)
mark_as_advanced(LIBAVUTIL_INCLUDE_DIR LIBAVUTIL_LIBRARY)
if(LIBAVUTIL_FOUND)
set(LIBAVUTIL_DEFINITIONS ${LIBAVUTIL_DEFINITION})
set(LIBAVUTIL_INCLUDE_DIRS ${LIBAVUTIL_INCLUDE_DIR})
set(LIBAVUTIL_LIBRARIES ${LIBAVUTIL_LIBRARY})
endif()
mark_as_advanced(
LIBAVUTIL_STANDARD_DEFINITIONS
LIBAVUTIL_STANDARD_INCLUDE_DIRS
LIBAVUTIL_STANDARD_LIBRARIES
LIBAVUTIL_STATIC_DEFINITIONS
LIBAVUTIL_STATIC_INCLUDE_DIRS
LIBAVUTIL_STATIC_LIBRARIES
)
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(PC_LIBSWRESAMPLE QUIET libswresample) pkg_check_modules(PC_LIBSWRESAMPLE QUIET libswresample)
set(LIBSWRESAMPLE_DEFINITIONS ${PC_LIBSWRESAMPLE_CFLAGS_OTHER}) set(LIBSWRESAMPLE_STANDARD_DEFINITIONS ${PC_LIBSWRESAMPLE_CFLAGS_OTHER}
CACHE STRING
"Libswresample required CFLAGS")
set(LIBSWRESAMPLE_STATIC_DEFINITIONS ${PC_LIBSWRESAMPLE_STATIC_CFLAGS_OTHER}
CACHE STRING
"Libswresample static required CFLAGS")
find_path(LIBSWRESAMPLE_INCLUDE_DIR libswresample/swresample.h find_path(LIBSWRESAMPLE_STANDARD_INCLUDE_DIR libswresample/swresample.h
HINTS ${PC_LIBSWRESAMPLE_INCLUDEDIR} ${PC_LIBSWRESAMPLE_INCLUDE_DIRS} HINTS ${PC_LIBSWRESAMPLE_INCLUDEDIR}
${PC_LIBSWRESAMPLE_INCLUDE_DIRS}
PATH_SUFFIXES libswresample) PATH_SUFFIXES libswresample)
find_library(LIBSWRESAMPLE_LIBRARY NAMES libswresample swresample find_path(LIBSWRESAMPLE_STATIC_INCLUDE_DIR libswresample/swresample.h
HINTS ${PC_LIBSWRESAMPLE_LIBDIR} ${PC_LIBSWRESAMPLE_LIBRARY_DIRS}) HINTS ${PC_LIBSWRESAMPLE_STATIC_INCLUDEDIR}
${PC_LIBSWRESAMPLE_STATIC_INCLUDE_DIRS}
PATH_SUFFIXES libswresample)
if(NOT LIBSWRESAMPLE_STANDARD_LIBRARIES)
set(LIBSWRESAMPLE_STANDARD_LIBRARIES_ "")
foreach(lib ${PC_LIBSWRESAMPLE_LIBRARIES})
find_library(_lib_file NAMES ${lib}
HINTS ${PC_LIBSWRESAMPLE_LIBDIR}
${PC_LIBSWRESAMPLE_LIBRARY_DIRS})
if(_lib_file)
LIST(APPEND LIBSWRESAMPLE_STANDARD_LIBRARIES_
${_lib_file})
endif()
unset(_lib_file CACHE)
endforeach()
set(LIBSWRESAMPLE_STANDARD_LIBRARIES
${LIBSWRESAMPLE_STANDARD_LIBRARIES_}
CACHE STRING
"Libswresample (dynamic) libraries")
unset(LIBSWRESAMPLE_STANDARD_LIBRARIES_)
endif()
if(NOT LIBSWRESAMPLE_STATIC_LIBRARIES)
set(LIBSWRESAMPLE_STATIC_LIBRARIES_ "")
set(lib_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}
${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_SHARED_MODULE_SUFFIX})
foreach(lib ${PC_LIBSWRESAMPLE_STATIC_LIBRARIES})
find_library(_lib_file NAMES ${lib}
HINTS ${PC_LIBSWRESAMPLE_LIBDIR}
${PC_LIBSWRESAMPLE_LIBRARY_DIRS})
if(_lib_file)
list(APPEND LIBSWRESAMPLE_STATIC_LIBRARIES_
${_lib_file})
else()
list(APPEND LIBSWRESAMPLE_STATIC_LIBRARIES_ ${lib})
endif()
unset(_lib_file CACHE)
endforeach()
set(CMAKE_FIND_LIBRARY_SUFFIXES ${lib_suffixes})
set(LIBSWRESAMPLE_STATIC_LIBRARIES ${LIBSWRESAMPLE_STATIC_LIBRARIES_}
CACHE STRING
"Libswresample static libraries")
unset(LIBSWRESAMPLE_STATIC_LIBRARIES_)
endif()
set(LIBSWRESAMPLE_INCLUDE_DIRS ${LIBSWRESAMPLE_INCLUDE_DIR})
set(LIBSWRESAMPLE_LIBRARIES ${LIBSWRESAMPLE_LIBRARY}) if(Libswresample_FIND_COMPONENTS AND
Libswresample_FIND_COMPONENTS STREQUAL "static")
set(LIBSWRESAMPLE_DEFINITION ${LIBSWRESAMPLE_STATIC_DEFINITIONS})
set(LIBSWRESAMPLE_INCLUDE_DIR ${LIBSWRESAMPLE_STATIC_INCLUDE_DIR})
set(LIBSWRESAMPLE_LIBRARY ${LIBSWRESAMPLE_STATIC_LIBRARIES})
else()
set(LIBSWRESAMPLE_DEFINITION ${LIBSWRESAMPLE_STANDARD_DEFINITIONS})
set(LIBSWRESAMPLE_INCLUDE_DIR ${LIBSWRESAMPLE_STANDARD_INCLUDE_DIR})
set(LIBSWRESAMPLE_LIBRARY ${LIBSWRESAMPLE_STANDARD_LIBRARIES})
endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libswresample DEFAULT_MSG find_package_handle_standard_args(Libswresample DEFAULT_MSG
LIBSWRESAMPLE_INCLUDE_DIR LIBSWRESAMPLE_LIBRARY) LIBSWRESAMPLE_INCLUDE_DIR LIBSWRESAMPLE_LIBRARY)
mark_as_advanced(LIBSWRESAMPLE_INCLUDE_DIR LIBSWRESAMPLE_LIBRARY)
if(LIBSWRESAMPLE_FOUND)
set(LIBSWRESAMPLE_DEFINITIONS ${LIBSWRESAMPLE_DEFINITION})
set(LIBSWRESAMPLE_INCLUDE_DIRS ${LIBSWRESAMPLE_INCLUDE_DIR})
set(LIBSWRESAMPLE_LIBRARIES ${LIBSWRESAMPLE_LIBRARY})
endif()
mark_as_advanced(
LIBSWRESAMPLE_STANDARD_DEFINITIONS
LIBSWRESAMPLE_STANDARD_INCLUDE_DIRS
LIBSWRESAMPLE_STANDARD_LIBRARIES
LIBSWRESAMPLE_STATIC_DEFINITIONS
LIBSWRESAMPLE_STATIC_INCLUDE_DIRS
LIBSWRESAMPLE_STATIC_LIBRARIES
)
...@@ -22,11 +22,18 @@ elseif(UNIX) ...@@ -22,11 +22,18 @@ elseif(UNIX)
else() else()
endif() endif()
find_package(Libavutil REQUIRED) option(USE_STATIC_FFMPEG "Link ffmpeg statically (if possible)" false)
if(USE_STATIC_FFMPEG)
set(FFMPEG_STATIC "static")
endif()
find_package(Libavutil REQUIRED ${FFMPEG_STATIC})
include_directories(${LIBAVUTIL_INCLUDE_DIRS}) include_directories(${LIBAVUTIL_INCLUDE_DIRS})
add_definitions(${LIBAVUTIL_DEFINITIONS})
find_package(Libswresample REQUIRED) find_package(Libswresample REQUIRED ${FFMPEG_STATIC})
include_directories(${LIBSWRESAMPLE_INCLUDE_DIRS}) include_directories(${LIBSWRESAMPLE_INCLUDE_DIRS})
add_definitions(${LIBSWRESAMPLE_DEFINITIONS})
add_library(libobs SHARED add_library(libobs SHARED
obs.c obs.c
......
option(USE_STATIC_WX "Link wxWidgets statically" false)
if(USE_STATIC_WX)
set(wxWidgets_USE_STATIC true)
endif()
find_package(wxWidgets COMPONENTS core base REQUIRED) find_package(wxWidgets COMPONENTS core base REQUIRED)
include("${wxWidgets_USE_FILE}") include("${wxWidgets_USE_FILE}")
...@@ -25,9 +29,45 @@ function(wx_required_version) ...@@ -25,9 +29,45 @@ function(wx_required_version)
endfunction() endfunction()
wx_required_version() wx_required_version()
if(USE_STATIC_WX)
#unpack -llib to static library names
set(WX_LIBRARIES "")
set(lib_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}
${CMAKE_DYNAMIC_LIBRARY_SUFFIX} ${CMAKE_SHARED_OBJECT_SUFFIX})
foreach(lib ${wxWidgets_LIBRARIES})
string(SUBSTRING ${lib} 0 2 _l)
if(_l STREQUAL "-l")
string(SUBSTRING ${lib} 2 -1 libname)
find_library(lib_file NAMES ${libname}
HINTS ${wxWidgets_LIBRARY_DIRS})
if(lib_file)
list(APPEND WX_LIBRARIES ${lib_file})
else()
list(APPEND WX_LIBRARIES ${lib})
endif()
unset(lib_file CACHE)
else()
list(APPEND WX_LIBRARIES ${lib})
endif()
endforeach()
if(APPLE)
find_library(lzma NAMES lzma)
if(lzma)
link_libraries(${lzma})
endif()
endif()
set(CMAKE_FIND_LIBRARY_SUFFIXES ${lib_suffixes})
unset(lib_suffixes)
link_libraries(${WX_LIBRARIES})
unset(WX_LIBRARIES)
else()
link_libraries(${wxWidgets_LIBRARIES})
endif()
include_directories(SYSTEM ${obs_SOURCE_DIR}/libobs) include_directories(SYSTEM ${obs_SOURCE_DIR}/libobs)
link_libraries(${wxWidgets_LIBRARIES} libobs) link_libraries(libobs)
if(WIN32) if(WIN32)
set(obs_platform_src set(obs_platform_src
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment