Skip to content
This repository was archived by the owner on Nov 20, 2020. It is now read-only.

Commit 04550fa

Browse files
committed
cmake import
1 parent 3c9a3b6 commit 04550fa

4 files changed

Lines changed: 410 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
2+
PROJECT(libjpeg C)
3+
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
4+
INCLUDE(dist.cmake)
5+
6+
# generating config.h file:
7+
MESSAGE("Configure: JPEG - generating jconfig.h:")
8+
INCLUDE(CheckIncludeFile)
9+
10+
CHECK_INCLUDE_FILE(stddef.h HAVE_STDDEF_H)
11+
CHECK_INCLUDE_FILE(stdlib.h HAVE_STDLIB_H)
12+
13+
IF(WIN32)
14+
# This is for jpeg binaries and is #defined in jconfig.h
15+
SET(TWO_FILE_COMMANDLINE true)
16+
ENDIF()
17+
18+
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/jconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h)
19+
20+
MESSAGE("Configure: JPEG - done.")
21+
# end of generating jconfig.h file:
22+
23+
24+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
25+
26+
IF(MSVC)
27+
SET(CMAKE_DEBUG_POSTFIX "D")
28+
ENDIF()
29+
30+
SET(JPEG_PUBLIC_HDRS
31+
jerror.h
32+
jmorecfg.h
33+
jpeglib.h
34+
${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
35+
)
36+
SET(JPEG_PRIVATE_HDRS
37+
cderror.h
38+
cdjpeg.h
39+
jdct.h
40+
jinclude.h
41+
jmemsys.h
42+
jpegint.h
43+
jversion.h
44+
transupp.h
45+
)
46+
47+
# memmgr back ends: compile only one of these into a working library
48+
# (For now, let's use the mode that requires the image fit into memory.
49+
# This is the recommended mode for Win32 anyway.)
50+
SET(JPEG_systemdependent_SRCS jmemnobs.c)
51+
52+
SET(JPEG_SRCS
53+
jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c
54+
jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c
55+
jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c
56+
jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c
57+
jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c
58+
jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c
59+
jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c
60+
jquant2.c jutils.c jmemmgr.c)
61+
62+
ADD_LIBRARY(jpeg SHARED ${JPEG_systemdependent_SRCS} ${JPEG_SRCS} ${JPEG_PUBLIC_HDRS} ${JPEG_PRIVATE_HDRS})
63+
#~ SET_TARGET_PROPERTIES(jpeg PROPERTIES VERSION 7.0.0)
64+
#~ SET_TARGET_PROPERTIES(jpeg PROPERTIES SOVERSION 7)
65+
66+
if(WIN32 AND BUILD_SHARED_LIBS)
67+
# We add JPEG_DLL only to building of this target because bad things
68+
# happen if it's enabled on all binary targets owing to the macros
69+
# defined in jmorecfg.h
70+
SET_TARGET_PROPERTIES(jpeg PROPERTIES COMPILE_FLAGS -DJPEG_DLL)
71+
ENDIF()
72+
73+
74+
#~ SET(JPEG_MANPAGES cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1)
75+
76+
ADD_EXECUTABLE(cjpeg cjpeg.c rdppm.c rdgif.c rdtarga.c rdrle.c rdbmp.c rdswitch.c cdjpeg.c)
77+
TARGET_LINK_LIBRARIES(cjpeg jpeg)
78+
79+
ADD_EXECUTABLE(djpeg djpeg.c wrppm.c wrgif.c wrtarga.c wrrle.c wrbmp.c rdcolmap.c cdjpeg.c)
80+
TARGET_LINK_LIBRARIES(djpeg jpeg)
81+
82+
ADD_EXECUTABLE(jpegtran jpegtran.c rdswitch.c cdjpeg.c transupp.c)
83+
TARGET_LINK_LIBRARIES(jpegtran jpeg)
84+
85+
ADD_EXECUTABLE(rdjpgcom rdjpgcom.c)
86+
ADD_EXECUTABLE(wrjpgcom wrjpgcom.c)
87+
88+
89+
INSTALL(TARGETS jpeg DESTINATION ${INSTALL_LIB})
90+
INSTALL(FILES ${JPEG_PUBLIC_HDRS} DESTINATION ${INSTALL_INC})
91+
INSTALL(TARGETS cjpeg djpeg jpegtran rdjpgcom wrjpgcom DESTINATION ${INSTALL_BIN})
92+
93+
INSTALL(FILES
94+
change.log
95+
coderules.txt
96+
filelist.txt
97+
libjpeg.txt
98+
structure.txt
99+
usage.txt
100+
wizard.txt
101+
README
102+
DESTINATION ${INSTALL_DOC})

dist.cmake

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# LuaDist CMake utility library.
2+
# Provides variables and utility functions common to LuaDist CMake builds.
3+
#
4+
# Copyright (C) 2007-2010 LuaDist.
5+
# by David Manura, Peter Drahos
6+
# Redistribution and use of this file is allowed according to the terms of the MIT license.
7+
# For details see the COPYRIGHT file distributed with LuaDist.
8+
# Please note that the package source code is licensed under its own license.
9+
10+
# Few convinence settings
11+
SET (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
12+
SET (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH})
13+
14+
# Where to install module parts:
15+
set(INSTALL_BIN bin CACHE PATH "Where to install binaries to.")
16+
set(INSTALL_LIB lib CACHE PATH "Where to install libraries to.")
17+
set(INSTALL_INC include CACHE PATH "Where to install headers to.")
18+
set(INSTALL_ETC etc CACHE PATH "Where to store configuration files")
19+
set(INSTALL_LMOD share/lua/lmod CACHE PATH "Directory to install Lua modules.")
20+
set(INSTALL_CMOD share/lua/cmod CACHE PATH "Directory to install Lua binary modules.")
21+
set(INSTALL_DATA share/${PROJECT_NAME} CACHE PATH "Directory the package can store documentation, tests or other data in.")
22+
set(INSTALL_DOC ${INSTALL_DATA}/doc CACHE PATH "Recommended directory to install documentation into.")
23+
set(INSTALL_EXAMPLE ${INSTALL_DATA}/example CACHE PATH "Recommended directory to install examples into.")
24+
set(INSTALL_TEST ${INSTALL_DATA}/test CACHE PATH "Recommended directory to install tests into.")
25+
set(INSTALL_FOO ${INSTALL_DATA}/etc CACHE PATH "Where to install additional files")
26+
27+
28+
# In MSVC, prevent warnings that can occur when using standard libraries.
29+
if(MSVC)
30+
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
31+
endif(MSVC)
32+
33+
# Adds Lua shared library module target `_target`.
34+
# Additional sources to build the module are listed after `_target`.
35+
macro(add_lua_module _target)
36+
find_package(Lua51 REQUIRED)
37+
include_directories(${LUA_INCLUDE_DIR}) #2DO: somehow apply only to _target?
38+
39+
add_library(${_target} MODULE ${ARGN})
40+
set_target_properties(${_target} PROPERTIES PREFIX "")
41+
target_link_libraries(${_target} ${LUA_LIBRARY})
42+
43+
IF(WIN32)
44+
set_target_properties(${_target} PROPERTIES LINK_FLAGS "-Wl,--enable-auto-import")
45+
ENDIF()
46+
47+
endmacro(add_lua_module)
48+
49+
# Runs Lua script `_testfile` under CTest tester.
50+
# Optional argument `_testcurrentdir` is current working directory to run test under
51+
# (defaults to ${CMAKE_CURRENT_BINARY_DIR}).
52+
# Both paths, if relative, are relative to ${CMAKE_CURRENT_SOURCE_DIR}.
53+
# Under LuaDist, set test=true in config.lua to enable testing.
54+
macro(add_lua_test _testfile)
55+
include(CTest)
56+
if(BUILD_TESTING)
57+
find_program(LUA NAMES lua lua.bat)
58+
get_filename_component(TESTFILEABS ${_testfile} ABSOLUTE)
59+
get_filename_component(TESTFILENAME ${_testfile} NAME)
60+
get_filename_component(TESTFILEBASE ${_testfile} NAME_WE)
61+
62+
# Write wrapper script.
63+
set(TESTWRAPPER ${CMAKE_CURRENT_BINARY_DIR}/${TESTFILENAME})
64+
set(TESTWRAPPERSOURCE
65+
"package.path = '${CMAKE_CURRENT_BINARY_DIR}/?.lua\;${CMAKE_CURRENT_SOURCE_DIR}/?.lua\;' .. package.path
66+
package.cpath = '${CMAKE_CURRENT_BINARY_DIR}/?.so\;${CMAKE_CURRENT_BINARY_DIR}/?.dll\;' .. package.cpath
67+
return dofile '${TESTFILEABS}'
68+
" )
69+
if(${ARGC} GREATER 1)
70+
set(_testcurrentdir ${ARGV1})
71+
get_filename_component(TESTCURRENTDIRABS ${_testcurrentdir} ABSOLUTE)
72+
set(TESTWRAPPERSOURCE
73+
"require 'lfs'
74+
lfs.chdir('${TESTCURRENTDIRABS}')
75+
${TESTWRAPPERSOURCE}")
76+
endif()
77+
FILE(WRITE ${TESTWRAPPER} ${TESTWRAPPERSOURCE})
78+
79+
add_test(${TESTFILEBASE} ${LUA} ${TESTWRAPPER})
80+
endif(BUILD_TESTING)
81+
82+
# see also http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/CMakeModules/UsePythonTest.cmake
83+
endmacro(add_lua_test)
84+
85+
# Converts Lua source file `_source` to binary string embedded in C source
86+
# file `_target`. Optionally compiles Lua source to byte code (not available
87+
# under LuaJIT2, which doesn't have a bytecode loader). Additionally, Lua
88+
# versions of bin2c [1] and luac [2] may be passed respectively as additional
89+
# arguments.
90+
#
91+
# [1] http://lua-users.org/wiki/BinToCee
92+
# [2] http://lua-users.org/wiki/LuaCompilerInLua
93+
function(add_lua_bin2c _target _source)
94+
find_program(LUA NAMES lua lua.bat)
95+
execute_process(COMMAND ${LUA} -e "string.dump(function()end)" RESULT_VARIABLE _LUA_DUMP_RESULT ERROR_QUIET)
96+
if (NOT ${_LUA_DUMP_RESULT})
97+
SET(HAVE_LUA_DUMP true)
98+
endif()
99+
message("-- string.dump=${HAVE_LUA_DUMP}")
100+
101+
if (ARGV2)
102+
get_filename_component(BIN2C ${ARGV2} ABSOLUTE)
103+
set(BIN2C ${LUA} ${BIN2C})
104+
else()
105+
find_program(BIN2C NAMES bin2c bin2c.bat)
106+
endif()
107+
if (HAVE_LUA_DUMP)
108+
if (ARGV3)
109+
get_filename_component(LUAC ${ARGV3} ABSOLUTE)
110+
set(LUAC ${LUA} ${LUAC})
111+
else()
112+
find_program(LUAC NAMES luac luac.bat)
113+
endif()
114+
endif (HAVE_LUA_DUMP)
115+
message("-- bin2c=${BIN2C}")
116+
message("-- luac=${LUAC}")
117+
118+
get_filename_component(SOURCEABS ${_source} ABSOLUTE)
119+
if (HAVE_LUA_DUMP)
120+
get_filename_component(SOURCEBASE ${_source} NAME_WE)
121+
add_custom_command(
122+
OUTPUT ${_target} DEPENDS ${_source}
123+
COMMAND ${LUAC} -o ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo ${SOURCEABS}
124+
COMMAND ${BIN2C} ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo ">${_target}" )
125+
else()
126+
add_custom_command(
127+
OUTPUT ${_target} DEPENDS ${SOURCEABS}
128+
COMMAND ${BIN2C} ${_source} ">${_target}" )
129+
endif()
130+
endfunction(add_lua_bin2c)

dist.info

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- This file is part of LuaDist project
2+
3+
name = "libjpeg"
4+
version = "8"
5+
6+
author = "Tom Lane, Guido Vollbeding, Philip Gladstone, Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Ge' Weijers, and other members of the Independent JPEG Group."
7+
desc = "Independent JPEG Group's JPEG software"
8+
license = "jpeg license"
9+
url = "http://www.ijg.org/"
10+
maintainer = "Peter Kapec"

0 commit comments

Comments
 (0)