Permalink
Browse files

Improve CMakeLists

  • Loading branch information...
astoeckel committed Jan 17, 2016
1 parent 84bfac7 commit 481598b520ba9e6f7fce6349672f9e3995fd81ca
Showing with 110 additions and 11 deletions.
  1. +7 −5 CMakeLists.txt
  2. +97 −0 CMakeModules/FindFFMPEG.cmake
  3. 0 { → cmake}/FindFFMPEG.cmake
  4. +6 −6 src/CMakeLists.txt
View
@@ -1,8 +1,10 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
-PROJECT(acinerella C)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
+PROJECT(acinerella)
-SET(CMAKE_MODULE_PATH .)
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
+SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
-INCLUDE(FindFFMPEG)
+FIND_PACKAGE(FFMPEG REQUIRED)
-ADD_SUBDIRECTORY(src/ bin/)
+ADD_SUBDIRECTORY(src/)
@@ -0,0 +1,97 @@
+# - Try to find ffmpeg libraries (libavcodec, libavformat, libavutil and swscale)
+# Once done this will define
+#
+# FFMPEG_FOUND - system has ffmpeg or libav
+# FFMPEG_INCLUDE_DIR - the ffmpeg include directory
+# FFMPEG_LIBRARIES - Link these to use ffmpeg
+# FFMPEG_LIBAVCODEC
+# FFMPEG_LIBAVFORMAT
+# FFMPEG_LIBAVUTIL
+# FFMPEG_SWSCALE
+# FFMPEG_SWRESAMPLE
+#
+# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
+# Modified for other libraries by Lasse Kärkkäinen <tronic>
+# Modified for Hedgewars by Stepik777
+# Modified for Netgen by Christoph Lehrenfeld (2015) (current version)
+# Modified for Acinerella by Andreas Stöckel (2016) (add SWRESAMPLE)
+#
+# Redistribution and use is allowed according to the terms of the New
+# BSD license.
+#
+
+if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
+ # in cache already
+ set(FFMPEG_FOUND TRUE)
+else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
+ # use pkg-config to get the directories and then use these values
+ # in the FIND_PATH() and FIND_LIBRARY() calls
+ find_package(PkgConfig)
+ if (PKG_CONFIG_FOUND)
+ pkg_check_modules(_FFMPEG_AVCODEC libavcodec)
+ pkg_check_modules(_FFMPEG_AVFORMAT libavformat)
+ pkg_check_modules(_FFMPEG_AVUTIL libavutil)
+ pkg_check_modules(SWSCALE libswscale)
+ pkg_check_modules(SWRESAMPLE libswresample)
+ endif (PKG_CONFIG_FOUND)
+
+ find_path(FFMPEG_AVCODEC_INCLUDE_DIR
+ NAMES libavcodec/avcodec.h
+ PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
+ PATH_SUFFIXES ffmpeg libav
+ )
+
+ find_library(FFMPEG_LIBAVCODEC
+ NAMES avcodec
+ PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+ )
+
+ find_library(FFMPEG_LIBAVFORMAT
+ NAMES avformat
+ PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+ )
+
+ find_library(FFMPEG_LIBAVUTIL
+ NAMES avutil
+ PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+ )
+
+ find_library(FFMPEG_SWSCALE
+ NAMES swscale
+ PATHS ${SWSCALE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+ )
+
+ find_library(FFMPEG_SWRESAMPLE
+ NAMES swresample
+ PATHS ${SWRESAMPLE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+ )
+
+ if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT)
+ set(FFMPEG_FOUND TRUE)
+ endif()
+
+ if (FFMPEG_FOUND)
+ set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR})
+
+ set(FFMPEG_LIBRARIES
+ ${FFMPEG_LIBAVCODEC}
+ ${FFMPEG_LIBAVFORMAT}
+ ${FFMPEG_LIBAVUTIL}
+ ${FFMPEG_SWSCALE}
+ ${FFMPEG_SWRESAMPLE}
+ )
+
+ endif (FFMPEG_FOUND)
+
+ if (FFMPEG_FOUND)
+ if (NOT FFMPEG_FIND_QUIETLY)
+ message(STATUS "Found FFMPEG or Libav: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
+ endif (NOT FFMPEG_FIND_QUIETLY)
+ else (FFMPEG_FOUND)
+ if (FFMPEG_FIND_REQUIRED)
+ message(FATAL_ERROR "Could not find libavcodec or libavformat or libavutil")
+ endif (FFMPEG_FIND_REQUIRED)
+ endif (FFMPEG_FOUND)
+
+endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
+
File renamed without changes.
View
@@ -1,6 +1,8 @@
# Set the FFMpeg include path
INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIR})
+SET(CMAKE_C_STANDARD 11)
+
# Write the platform decision code
IF(UNIX)
SET(__PLATFORM PLATFORM_LINUX)
@@ -9,10 +11,8 @@ ELSE()
ENDIF()
CONFIGURE_FILE(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
-#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -O0")
-
# Add the acinerella library
-ADD_LIBRARY(acinerella SHARED acinerella.c)
+ADD_LIBRARY(acinerella SHARED acinerella.c acinerella.h)
IF (UNIX)
TARGET_LINK_LIBRARIES(acinerella avformat avcodec avutil swscale pthread z m)
@@ -21,6 +21,6 @@ ELSE (UNIX)
ENDIF (UNIX)
# Add the test application
-ADD_EXECUTABLE(test test.c)
-TARGET_LINK_LIBRARIES(test acinerella)
-
+ADD_EXECUTABLE(demo demo.c)
+TARGET_LINK_LIBRARIES(demo acinerella)
+INSTALL(TARGETS acinerella LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)

0 comments on commit 481598b

Please sign in to comment.