summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorTuomas Virtanen <katajakasa@gmail.com>2016-01-04 04:33:59 +0200
committerTuomas Virtanen <katajakasa@gmail.com>2016-01-04 04:33:59 +0200
commit537ca31915603d7ed47ab4374a74058e340125c7 (patch)
treeb3c19e8dae778385021ea08be596022d952ccab5 /cmake
Initial commit; Not done yet though, needs more work.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindSDL2.cmake54
-rw-r--r--cmake/Findcunit.cmake41
-rw-r--r--cmake/Findffmpeg.cmake74
3 files changed, 169 insertions, 0 deletions
diff --git a/cmake/FindSDL2.cmake b/cmake/FindSDL2.cmake
new file mode 100644
index 0000000..c0b43bc
--- /dev/null
+++ b/cmake/FindSDL2.cmake
@@ -0,0 +1,54 @@
+# A Simple SDL2 Finder.
+# (c) Tuomas Virtanen 2016 (Licensed under MIT license)
+# Usage:
+# find_package(SDL2)
+#
+# Declares:
+# * SDL2_FOUND
+# * SDL2_INCLUDE_DIRS
+# * SDL2_LIBRARIES
+#
+
+set(SDL2_SEARCH_PATHS
+ /usr/local/
+ /usr/
+ /opt
+)
+
+find_path(SDL2_INCLUDE_DIR SDL2/SDL.h
+ HINTS
+ PATH_SUFFIXES include
+ PATHS ${SDL2_SEARCH_PATHS}
+)
+
+find_library(SDL2_LIBRARY
+ NAMES SDL2
+ HINTS
+ PATH_SUFFIXES lib
+ PATHS ${SDL2_SEARCH_PATHS}
+)
+
+if(MINGW)
+ find_library(SDL2MAIN_LIBRARY
+ NAMES SDL2main
+ HINTS
+ PATH_SUFFIXES lib
+ PATHS ${SDL2_SEARCH_PATHS}
+ )
+else()
+ SET(SDL2MAIN_LIBRARY "")
+endif()
+
+if(SDL2_INCLUDE_DIR AND SDL2_LIBRARY)
+ SET(SDL2_FOUND TRUE)
+endif()
+
+if(SDL2_FOUND)
+ SET(SDL2_LIBRARIES ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY})
+ SET(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
+ MESSAGE(STATUS "Found SDL2: ${SDL2_LIBRARIES}")
+else()
+ MESSAGE(WARNING "Could not find SDL2")
+endif()
+
+mark_as_advanced(SDL2MAIN_LIBRARY SDL2_LIBRARY SDL2_INCLUDE_DIR SDL2_SEARCH_PATHS)
diff --git a/cmake/Findcunit.cmake b/cmake/Findcunit.cmake
new file mode 100644
index 0000000..ee982b0
--- /dev/null
+++ b/cmake/Findcunit.cmake
@@ -0,0 +1,41 @@
+# A Simple CUnit Finder.
+# (c) Tuomas Virtanen 2016 (Licensed under MIT license)
+# Usage:
+# find_package(cunit)
+#
+# Declares:
+# * CUNIT_FOUND
+# * CUNIT_INCLUDE_DIRS
+# * CUNIT_LIBRARIES
+#
+
+set(CUNIT_SEARCH_PATHS
+ /usr/local/
+ /usr
+ /opt
+)
+
+find_path(CUNIT_INCLUDE_DIR CUnit/CUnit.h
+ HINTS
+ PATH_SUFFIXES include
+ PATHS ${CUNIT_SEARCH_PATHS}
+)
+find_library(CUNIT_LIBRARY cunit
+ HINTS
+ PATH_SUFFIXES lib
+ PATHS ${CUNIT_SEARCH_PATHS}
+)
+
+if(CUNIT_INCLUDE_DIR AND CUNIT_LIBRARY)
+ set(CUNIT_FOUND TRUE)
+endif()
+
+if(CUNIT_FOUND)
+ SET(CUNIT_LIBRARIES ${CUNIT_LIBRARY})
+ SET(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR})
+ message(STATUS "Found CUnit: ${CUNIT_LIBRARY}")
+else()
+ message(WARNING "Could not find CUnit.")
+endif()
+
+mark_as_advanced(CUNIT_LIBRARY CUNIT_INCLUDE_DIR)
diff --git a/cmake/Findffmpeg.cmake b/cmake/Findffmpeg.cmake
new file mode 100644
index 0000000..40d0114
--- /dev/null
+++ b/cmake/Findffmpeg.cmake
@@ -0,0 +1,74 @@
+# A Simple FFMPEG Finder.
+# (c) Tuomas Virtanen 2016 (Licensed under MIT license)
+# Usage:
+# find_package(ffmpeg COMPONENTS avcodec avutil ...)
+#
+# Declares:
+# * FFMPEG_FOUND
+# * FFMPEG_INCLUDE_DIRS
+# * FFMPEG_LIBRARIES
+#
+# Also declares ${component}_FOUND for each component, eg. avcodec_FOUND etc.
+#
+
+set(FFMPEG_SEARCH_PATHS
+ /usr/local
+ /usr
+ /opt
+)
+
+set(FFMPEG_COMPONENTS
+ avcodec
+ avformat
+ avdevice
+ avfilter
+ avresample
+ avutil
+ swresample
+ swscale
+)
+
+set(FFMPEG_INCLUDE_DIRS)
+set(FFMPEG_LIBRARIES)
+set(FFMPEG_FOUND TRUE)
+
+# Walk through all components declared above, and try to find the ones that have been asked
+foreach(comp ${FFMPEG_COMPONENTS})
+ list(FIND ffmpeg_FIND_COMPONENTS ${comp} _index)
+ if(${_index} GREATER -1)
+ # Component requested, try to look up the library and header for it.
+ find_path(${comp}_INCLUDE_DIR lib${comp}/${comp}.h
+ HINTS
+ PATH_SUFFIXES include
+ PATHS ${FFMPEG_SEARCH_PATHS}
+ )
+ find_library(${comp}_LIBRARY lib${comp}
+ HINTS
+ PATH_SUFFIXES lib
+ PATHS ${FFMPEG_SEARCH_PATHS}
+ )
+
+ # If library and header was found, set proper variables
+ # Otherwise print out a warning!
+ if(${comp}_LIBRARY AND ${comp}_INCLUDE_DIR)
+ set(${comp}_FOUND TRUE)
+ list(APPEND FFMPEG_INCLUDE_DIRS ${${comp}_INCLUDE_DIR})
+ list(APPEND FFMPEG_LIBRARIES ${${comp}_LIBRARY})
+ else()
+ set(FFMPEG_FOUND FALSE)
+ set(${comp}_FOUND FALSE)
+ MESSAGE(WARNING "Could not find component: ${comp}")
+ endif()
+
+ # Mark the temporary variables as hidden in the ui
+ mark_as_advanced(${${comp}_LIBRARY} ${${comp}_INCLUDE_DIR})
+ endif()
+endforeach()
+
+if(FFMPEG_FOUND)
+ MESSAGE(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES}")
+else()
+ MESSAGE(WARNING "Could not find FFMPEG")
+endif()
+
+mark_as_advanced(FFMPEG_COMPONENTS FFMPEG_SEARCH_PATHS)