Merge pull request #519 from wolfman2000/wolf-cmake-fixes-shake

Linux cmake improvements as suggested by @shakesoda.
This commit is contained in:
Colby Klein
2015-03-22 13:22:57 -07:00
5 changed files with 352 additions and 39 deletions
+224
View File
@@ -0,0 +1,224 @@
# This was copied from the robotology/ycm project.
#.rst:
# FindFFMPEG
# ----------
#
# Find the native FFMPEG includes and library
#
# This module defines::
#
# FFMPEG_INCLUDE_DIR, where to find avcodec.h, avformat.h ...
# FFMPEG_LIBRARIES, the libraries to link against to use FFMPEG.
# FFMPEG_FOUND, If false, do not try to use FFMPEG.
#
# also defined, but not for general use are::
#
# FFMPEG_avformat_LIBRARY, where to find the FFMPEG avformat library.
# FFMPEG_avcodec_LIBRARY, where to find the FFMPEG avcodec library.
#
# This is useful to do it this way so that we can always add more libraries
# if needed to ``FFMPEG_LIBRARIES`` if ffmpeg ever changes...
#=============================================================================
# Copyright: 1993-2008 Ken Martin, Will Schroeder, Bill Lorensen
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of YCM, substitute the full
# License text for the above reference.)
# Originally from VTK project
find_path(FFMPEG_INCLUDE_DIR1 avformat.h
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/ffmpeg
$ENV{FFMPEG_DIR}/libavformat
$ENV{FFMPEG_DIR}/include/libavformat
$ENV{FFMPEG_DIR}/include/ffmpeg
/usr/local/include/ffmpeg
/usr/include/ffmpeg
/usr/include/libavformat
/usr/include/ffmpeg/libavformat
/usr/local/include/libavformat
)
find_path(FFMPEG_INCLUDE_DIR2 avutil.h
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/ffmpeg
$ENV{FFMPEG_DIR}/libavutil
$ENV{FFMPEG_DIR}/include/libavutil
$ENV{FFMPEG_DIR}/include/ffmpeg
/usr/local/include/ffmpeg
/usr/include/ffmpeg
/usr/include/libavutil
/usr/include/ffmpeg/libavutil
/usr/local/include/libavutil
)
find_path(FFMPEG_INCLUDE_DIR3 avcodec.h
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/ffmpeg
$ENV{FFMPEG_DIR}/libavcodec
$ENV{FFMPEG_DIR}/include/libavcodec
$ENV{FFMPEG_DIR}/include/ffmpeg
/usr/local/include/ffmpeg
/usr/include/ffmpeg
/usr/include/libavcodec
/usr/include/ffmpeg/libavcodec
/usr/local/include/libavcodec
)
find_path(FFMPEG_INCLUDE_DIR4 swscale.h
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/ffmpeg
$ENV{FFMPEG_DIR}/libswscale
$ENV{FFMPEG_DIR}/include/libswscale
$ENV{FFMPEG_DIR}/include/ffmpeg
/usr/local/include/ffmpeg
/usr/include/ffmpeg
/usr/include/libswscale
/usr/include/ffmpeg/libswscale
/usr/local/include/libswscale
)
find_path(FFMPEG_INCLUDE_DIR5 avdevice.h
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/ffmpeg
$ENV{FFMPEG_DIR}/libavdevice
$ENV{FFMPEG_DIR}/include/libavdevice
$ENV{FFMPEG_DIR}/include/ffmpeg
/usr/local/include/ffmpeg
/usr/include/ffmpeg
/usr/include/libavdevice
/usr/include/ffmpeg/libavdevice
/usr/local/include/libavdevice
)
if(FFMPEG_INCLUDE_DIR1)
if(FFMPEG_INCLUDE_DIR2)
if(FFMPEG_INCLUDE_DIR3)
set(FFMPEG_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR1}
${FFMPEG_INCLUDE_DIR2}
${FFMPEG_INCLUDE_DIR3})
endif()
endif()
endif()
if(FFMPEG_INCLUDE_DIR4)
set(FFMPEG_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR}
${FFMPEG_INCLUDE_DIR4})
endif()
if(FFMPEG_INCLUDE_DIR5)
set(FFMPEG_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR}
${FFMPEG_INCLUDE_DIR5}
${FFMPEG_INCLUDE_DIR5}/..)
endif()
find_library(FFMPEG_avformat_LIBRARY avformat
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/lib
$ENV{FFMPEG_DIR}/libavformat
/usr/local/lib
/usr/lib
)
find_library(FFMPEG_avcodec_LIBRARY avcodec
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/lib
$ENV{FFMPEG_DIR}/libavcodec
/usr/local/lib
/usr/lib
)
find_library(FFMPEG_avutil_LIBRARY avutil
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/lib
$ENV{FFMPEG_DIR}/libavutil
/usr/local/lib
/usr/lib
)
if(NOT DISABLE_SWSCALE)
find_library(FFMPEG_swscale_LIBRARY swscale
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/lib
$ENV{FFMPEG_DIR}/libswscale
/usr/local/lib
/usr/lib
)
endif(NOT DISABLE_SWSCALE)
find_library(FFMPEG_avdevice_LIBRARY avdevice
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/lib
$ENV{FFMPEG_DIR}/libavdevice
/usr/local/lib
/usr/lib
)
find_library(_FFMPEG_z_LIBRARY_ z
$ENV{FFMPEG_DIR}
$ENV{FFMPEG_DIR}/lib
/usr/local/lib
/usr/lib
)
if(FFMPEG_INCLUDE_DIR)
if(FFMPEG_avformat_LIBRARY)
if(FFMPEG_avcodec_LIBRARY)
if(FFMPEG_avutil_LIBRARY)
set(FFMPEG_FOUND "YES")
set(FFMPEG_LIBRARIES ${FFMPEG_avformat_LIBRARY}
${FFMPEG_avcodec_LIBRARY}
${FFMPEG_avutil_LIBRARY}
)
if(FFMPEG_swscale_LIBRARY)
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES}
${FFMPEG_swscale_LIBRARY}
)
endif()
if(FFMPEG_avdevice_LIBRARY)
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES}
${FFMPEG_avdevice_LIBRARY}
)
endif()
if(_FFMPEG_z_LIBRARY_)
set( FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES}
${_FFMPEG_z_LIBRARY_}
)
endif()
endif()
endif()
endif()
endif()
mark_as_advanced(
FFMPEG_INCLUDE_DIR
FFMPEG_INCLUDE_DIR1
FFMPEG_INCLUDE_DIR2
FFMPEG_INCLUDE_DIR3
FFMPEG_INCLUDE_DIR4
FFMPEG_INCLUDE_DIR5
FFMPEG_avformat_LIBRARY
FFMPEG_avcodec_LIBRARY
FFMPEG_avutil_LIBRARY
FFMPEG_swscale_LIBRARY
FFMPEG_avdevice_LIBRARY
_FFMPEG_z_LIBRARY_
)
# Set package properties if FeatureSummary was included
if(COMMAND set_package_properties)
set_package_properties(FFMPEG PROPERTIES DESCRIPTION "A complete, cross-platform solution to record, convert and stream audio and video")
set_package_properties(FFMPEG PROPERTIES URL "http://ffmpeg.org/")
endif()
+17
View File
@@ -0,0 +1,17 @@
# Find pcre using standard tools.
# The following will be set:
# PCRE_INCLUDE_DIR
# PCRE_LIBRARY
# PCRE_FOUND
find_path(PCRE_INCLUDE_DIR NAMES pcre.h)
find_library(PCRE_LIBRARY NAMES pcre)
# Properly pass QUIETLY and REQUIRED.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_INCLUDE_DIR PCRE_LIBRARY)
mark_as_advanced(PCRE_INCLUDE_DIR PCRE_LIBRARY)
+70 -28
View File
@@ -39,32 +39,37 @@ set(CPACK_PACKAGE_NAME "StepMania")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Rhythm Game Simulator")
# Prep options that are needed for each platform.
option(WITH_NETWORKING "Build with networking support" ON)
option(WITH_NETWORKING "Build with networking support." ON)
# This option is not yet working, but will likely default to ON in the future.
option(WITH_LTO "Build with Link Time Optimization (LTO)/Whole Program Optimization" OFF)
option(WITH_LTO "Build with Link Time Optimization (LTO)/Whole Program Optimization." OFF)
option(WITH_SSE2 "Build with SSE2 Optimizations" ON)
option(WITH_SSE2 "Build with SSE2 Optimizations." ON)
# This option may go away in the future: if it does, JPEG will always be required.
option(WITH_JPEG "Build with JPEG Image Support" ON)
option(WITH_JPEG "Build with JPEG Image Support." ON)
# Turn this on to set this to a specific release mode.
option(WITH_FULL_RELEASE "Build as a proper, full release." OFF)
# Turn this option off to not use the GPL exclusive components.
option(WITH_GPL_LIBS "Build with GPL libraries." ON)
if(WIN32)
option(WITH_MINIMAID "Build with Mimimaid Lights Support" OFF)
option(WITH_MINIMAID "Build with Mimimaid Lights Support." OFF)
else()
if(LINUX)
option(WITH_FFMPEG "Build with FFMPEG" ON)
option(WITH_TTY "Build with Linux TTY Input Support" OFF)
option(WITH_PROFILING "Build with Profiling Support" OFF)
option(WITH_GLES2 "Build with OpenGL ES 2.0 Support" ON)
option(WITH_GTK2 "Build with GTK2 Support" ON)
option(WITH_OGG "Build with OGG/Vorbis Support" ON)
option(WITH_MP3 "Build with MP3 Support" ON)
option(WITH_PARALLEL_PORT "Build with Parallel Lights I/O Support" OFF)
option(WITH_CRASH_HANDLER "Build with Crash Handler Support" ON)
option(WITH_FFMPEG "Build with FFMPEG." ON)
# Builder beware: later versions of ffmpeg may break!
option(WITH_SYSTEM_FFMPEG "Build with the system's FFMPEG." OFF)
option(WITH_TTY "Build with Linux TTY Input Support." OFF)
option(WITH_PROFILING "Build with Profiling Support." OFF)
option(WITH_GLES2 "Build with OpenGL ES 2.0 Support." ON)
option(WITH_GTK2 "Build with GTK2 Support." ON)
option(WITH_OGG "Build with OGG/Vorbis Support." ON)
option(WITH_MP3 "Build with MP3 Support." ON)
option(WITH_PARALLEL_PORT "Build with Parallel Lights I/O Support." OFF)
option(WITH_CRASH_HANDLER "Build with Crash Handler Support." ON)
endif()
endif()
@@ -103,6 +108,7 @@ set(ENDIANNESS "ENDIAN_LITTLE")
if(WIN32)
set(HAS_OGG TRUE)
set(HAS_MP3 TRUE)
set(SYSTEM_PCRE_FOUND FALSE)
find_package(DirectX REQUIRED)
# FFMPEG...it can be evil.
@@ -128,6 +134,7 @@ if(WIN32)
elseif(MACOSX)
set(HAS_OGG TRUE)
set(HAS_MP3 TRUE)
set(SYSTEM_PCRE_FOUND FALSE)
set(WITH_CRASH_HANDLER TRUE)
# Apple Archs needs to be 32-bit for now.
# When SDL2 is introduced, this may change.
@@ -167,6 +174,11 @@ elseif(LINUX)
include(TestBigEndian)
include(ExternalProject)
if(NOT WITH_GPL_LIBS)
message("Disabling GPL exclusive libraries: no MP3 support.")
set(WITH_MP3 OFF)
endif()
if(WITH_GTK2)
find_package("GTK2" 2.0)
if (${GTK2_FOUND})
@@ -181,6 +193,9 @@ elseif(LINUX)
find_package(X11)
find_package(Pcre)
set(SYSTEM_PCRE_FOUND ${PCRE_FOUND})
find_package("BZip2")
if (NOT(${BZIP2_FOUND}))
message(FATAL_ERROR "Bzip2 support required.")
@@ -274,20 +289,47 @@ elseif(LINUX)
endif()
if(WITH_FFMPEG)
# NEVER use the system ffmpeg. Not worth the hassle.
# --shlibdir=$our_installdir/stepmania-$VERSION
externalproject_add("ffmpeg"
DOWNLOAD_DIR "${SM_EXTERN_DIR}/ffmpeg-linux"
PREFIX "${SM_EXTERN_DIR}/ffmpeg-linux"
GIT_REPOSITORY "git://source.ffmpeg.org/ffmpeg.git"
GIT_TAG "n2.1.3"
CONFIGURE_COMMAND "${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg/configure" "--enable-gpl" "--disable-programs" "--disable-doc" "--disable-avdevice" "--disable-swresample" "--disable-postproc" "--disable-avfilter" "--disable-shared" "--enable-static"
BUILD_COMMAND "make"
UPDATE_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
set(HAS_FFMPEG TRUE)
if (WITH_SYSTEM_FFMPEG)
find_package("FFMPEG")
if(NOT FFMPEG_FOUND)
message(FATAL_ERROR "System ffmpeg not found! Either install the libraries or remove the argument, then try again.")
else()
message(STATUS "-- Warning! Your version of ffmpeg may be too high! If you want to use the system ffmpeg, clear your cmake cache and do not include the system ffmpeg argument.")
set(HAS_FFMPEG TRUE)
endif()
else()
list(APPEND FFMPEG_CONFIGURE
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg/configure"
"--disable-programs"
"--disable-doc"
"--disable-avdevice"
"--disable-swresample"
"--disable-postproc"
"--disable-avfilter"
"--disable-shared"
"--enable-static"
)
if(WITH_GPL_LIBS)
list(APPEND FFMPEG_CONFIGURE
"--enable-gpl"
)
endif()
# NEVER use the system ffmpeg. Not worth the hassle.
# --shlibdir=$our_installdir/stepmania-$VERSION
externalproject_add("ffmpeg"
DOWNLOAD_DIR "${SM_EXTERN_DIR}/ffmpeg-linux"
PREFIX "${SM_EXTERN_DIR}/ffmpeg-linux"
GIT_REPOSITORY "git://source.ffmpeg.org/ffmpeg.git"
GIT_TAG "n2.1.3"
CONFIGURE_COMMAND ${FFMPEG_CONFIGURE}
BUILD_COMMAND "make"
UPDATE_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
set(HAS_FFMPEG TRUE)
endif()
else()
set(HAS_FFMPEG FALSE)
endif()
+3 -1
View File
@@ -1,7 +1,9 @@
include(CMakeProject-lua.cmake)
include(CMakeProject-glew.cmake)
include(CMakeProject-json.cmake)
include(CMakeProject-pcre.cmake)
if (NOT SYSTEM_PCRE_FOUND)
include(CMakeProject-pcre.cmake)
endif()
include(CMakeProject-tomcrypt.cmake)
include(CMakeProject-tommath.cmake)
if (APPLE OR MSVC)
+38 -10
View File
@@ -296,10 +296,13 @@ list(APPEND SMDATA_LINK_LIB
"mad"
"png"
"glew"
"pcre"
"jpeg"
)
if (NOT SYSTEM_PCRE_FOUND)
list(INSERT SMDATA_LINK_LIB 8 "pcre")
endif()
if (WIN32)
list(APPEND SMDATA_LINK_LIB
# The misc libraries are here.
@@ -380,11 +383,25 @@ elseif(APPLE)
)
else() # Unix / Linux
# TODO: Remember to find and locate the zip archive files.
if (HAS_FFMPEG)
if(WITH_SYSTEM_FFMPEG)
list(APPEND SMDATA_LINK_LIB
"${FFMPEG_avformat_LIBRARY}"
"${FFMPEG_avcodec_LIBRARY}"
"${FFMPEG_swscale_LIBRARY}"
"${FFMPEG_avutil_LIBRARY}"
)
else()
list(APPEND SMDATA_LINK_LIB
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg-build/libavformat/libavformat.a"
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg-build/libavcodec/libavcodec.a"
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg-build/libswscale/libswscale.a"
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg-build/libavutil/libavutil.a"
)
endif()
endif()
list(APPEND SMDATA_LINK_LIB
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg-build/libavformat/libavformat.a"
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg-build/libavcodec/libavcodec.a"
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg-build/libswscale/libswscale.a"
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg-build/libavutil/libavutil.a"
"${DL_LIBRARY}"
)
@@ -444,6 +461,10 @@ else() # Unix / Linux
list(APPEND SMDATA_LINK_LIB ${X11_LIBRARIES})
endif()
if(PCRE_FOUND)
list(APPEND SMDATA_LINK_LIB ${PCRE_LIBRARY})
endif()
list(APPEND SMDATA_LINK_LIB
${XRANDR_LIBRARIES}
)
@@ -469,11 +490,15 @@ if(NOT APPLE)
)
else()
if (HAS_FFMPEG)
add_dependencies("${SM_EXE_NAME}" "ffmpeg")
list(APPEND SM_INCLUDE_DIRS
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg"
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg-build"
)
if (WITH_SYSTEM_FFMPEG)
list(APPEND SM_INCLUDE_DIRS "${FFMPEG_INCLUDE_DIR}")
else()
add_dependencies("${SM_EXE_NAME}" "ffmpeg")
list(APPEND SM_INCLUDE_DIRS
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg"
"${SM_EXTERN_DIR}/ffmpeg-linux/src/ffmpeg-build"
)
endif()
endif()
if (HAS_GTK2)
list(APPEND SM_INCLUDE_DIRS "${GTK2_INCLUDE_DIRS}")
@@ -481,6 +506,9 @@ if(NOT APPLE)
if (X11_FOUND)
list(APPEND SM_INCLUDE_DIRS "${X11_INCLUDE_DIR}")
endif()
if (PCRE_FOUND)
list(APPEND SM_INCLUDE_DIRS "${PCRE_INCLUDE_DIR}")
endif()
endif()
else()
list(APPEND SM_INCLUDE_DIRS