Skip to content

Commit

Permalink
Build bundled libjpeg as static library.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedtd committed Aug 10, 2015
1 parent e0677b9 commit 453b0f4
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 103 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ if(BuildPortableVersion)
endif()

if(UseInternalJPEG)
set(SharedDefines ${SharedDefines} "USE_INTERNAL_JPEG")
add_subdirectory(lib/jpeg-8c)
else()
find_package(JPEG REQUIRED)
endif()

if(UseInternalZlib)
Expand Down
72 changes: 0 additions & 72 deletions CMakeModules/FindJPEG.cmake

This file was deleted.

6 changes: 1 addition & 5 deletions code/rd-common/tr_image_jpg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
* (stdio.h is sufficient on ANSI-conforming systems.)
* You may also wish to include "jerror.h".
*/
#ifdef USE_INTERNAL_JPEG
#define JPEG_INTERNALS
#include "jpeg-8c/jpeglib.h"
#else

#include <jpeglib.h>
#endif

static void R_JPGErrorExit(j_common_ptr cinfo)
{
Expand Down
15 changes: 4 additions & 11 deletions code/rd-vanilla/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ if(BuildSPRdVanilla OR BuildJK2SPRdVanilla)

# Files

# JPEG
if(UseInternalJPEG)
file(GLOB_RECURSE J_SRC "${OpenJKLibDir}/jpeg-8c/*.c" "${OpenJKLibDir}/jpeg-8c/*.h")
source_group("jpeg-8c" FILES ${J_SRC})
set(SPRDVanillaFiles ${SPRDVanillaFiles} ${J_SRC})
else()
find_package(JPEG REQUIRED)
set(SPRDVanillaRendererIncludeDirectories ${SPRDVanillaRendererIncludeDirectories} ${JPEG_INCLUDE_DIR})
set(SPRDVanillaRendererLibraries ${SPRDVanillaRendererLibraries} ${JPEG_LIBRARIES})
endif()

# GHOUL 2
set(SPRDVanillaG2Files
"${SPDir}/ghoul2/G2.h"
Expand All @@ -61,6 +50,10 @@ if(BuildSPRdVanilla OR BuildJK2SPRdVanilla)
source_group("ghoul2" FILES ${SPRDVanillaG2Files})
set(SPRDVanillaFiles ${SPRDVanillaFiles} ${SPRDVanillaG2Files})

# Transparently use either bundled or system jpeg.
list(APPEND SPRDVanillaRendererIncludeDirectories ${JPEG_INCLUDE_DIR})
list(APPEND SPRDVanillaRendererLibraries ${JPEG_LIBRARIES})

# Transparently use either bundled or system libpng. Order is important --
# libpng used zlib, so it must come before it on the linker command line.
list(APPEND SPRDVanillaRendererIncludeDirectories ${PNG_INCLUDE_DIRS})
Expand Down
6 changes: 1 addition & 5 deletions codemp/rd-common/tr_image_jpg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
* (stdio.h is sufficient on ANSI-conforming systems.)
* You may also wish to include "jerror.h".
*/
#ifdef USE_INTERNAL_JPEG
#define JPEG_INTERNALS
#include "jpeg-8c/jpeglib.h"
#else

#include <jpeglib.h>
#endif

static void R_JPGErrorExit(j_common_ptr cinfo)
{
Expand Down
12 changes: 3 additions & 9 deletions codemp/rd-vanilla/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,9 @@ set(MPVanillaRendererCommonFiles
source_group("common" FILES ${MPVanillaRendererCommonFiles})
set(MPVanillaRendererFiles ${MPVanillaRendererFiles} ${MPVanillaRendererCommonFiles})

if(UseInternalJPEG)
file(GLOB_RECURSE MPVanillaRendererJpegFiles "${OpenJKLibDir}/jpeg-8c/*.c" "${OpenJKLibDir}/jpeg-8c/*.h")
source_group("jpeg-8c" FILES ${MPVanillaRendererJpegFiles})
set(MPVanillaRendererFiles ${MPVanillaRendererFiles} ${MPVanillaRendererJpegFiles})
else()
find_package(JPEG REQUIRED)
set(MPVanillaRendererIncludeDirectories ${MPVanillaRendererIncludeDirectories} ${JPEG_INCLUDE_DIR})
set(MPVanillaRendererLibraries ${MPVanillaRendererLibraries} ${JPEG_LIBRARIES})
endif()
# Transparently use either bundled or system libjpeg.
list(APPEND MPVanillaRendererIncludeDirectories ${JPEG_INCLUDE_DIR})
list(APPEND MPVanillaRendererLibraries ${JPEG_LIBRARIES})

# Transparently use either bundled or system libpng. Order is important --
# libpng used zlib, so it must come before it on the linker command line.
Expand Down
76 changes: 76 additions & 0 deletions lib/jpeg-8c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# We only execute this script if the user wants to use our bundled libjpeg.
#
# It is built as a static relocatable library, and linked into any target that
# requires it.

# This only has effect in this directory (lib/jpeg-8c).
include_directories(include/)

add_library(bundled_libjpeg STATIC include/jpeglib.h
include/jconfig.h
include/jmorecfg.h
include/jpegint.h
jcparam.c
jdsample.c
jerror.c
jdapistd.c
jcarith.c
jdcoefct.c
jmemmgr.c
jfdctfst.c
jdhuff.c
jerror.h
jutils.c
jdmerge.c
jinclude.h
jcprepct.c
jidctfst.c
jdatadst.c
jidctint.c
jversion.h
jccolor.c
jmemsys.h
jfdctint.c
jdmaster.c
jcdctmgr.c
jdct.h
jdinput.c
jdatasrc.c
jdpostct.c
jcsample.c
jchuff.c
jddctmgr.c
jdapimin.c
jcapimin.c
jdcolor.c
jcmainct.c
jfdctflt.c
jctrans.c
jquant1.c
jccoefct.c
jdmainct.c
jcinit.c
jidctflt.c
jdmarker.c
jdtrans.c
jdarith.c
jaricom.c
jcomapi.c
jcmarker.c
jmemnobs.c
jcmaster.c
jcapistd.c
jquant2.c)

# Let consumers get at our bundled library in the standard CMake way. These
# variables are not set in the cache, but instead shadow the variables in the
# cache. (These are the same variables exported by the standard CMake FindJPEG
# module).
set(JPEG_LIBRARIES bundled_libjpeg PARENT_SCOPE)
set(JPEG_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/lib/jpeg-8c/include/ PARENT_SCOPE)

mark_as_advanced(JPEG_LIBRARIES JPEG_INCLUDE_DIR)

# Build as position-independent code, since it will probably be linked into a
# dynamic library.
set_property(TARGET bundled_libjpeg PROPERTY POSITION_INDEPENDENT_CODE True)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 453b0f4

Please sign in to comment.