Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
4e4acf79
Commit
4e4acf79
authored
Mar 15, 2019
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make CMake build a test program to see if libjpeg is really available and not broken.
parent
7611b347
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
10 deletions
+103
-10
CMakeLists.txt
dlib/CMakeLists.txt
+2
-10
find_libjpeg.cmake
dlib/cmake_utils/find_libjpeg.cmake
+26
-0
CMakeLists.txt
dlib/cmake_utils/test_for_libjpeg/CMakeLists.txt
+11
-0
libjpeg_test.cpp
dlib/cmake_utils/test_for_libjpeg/libjpeg_test.cpp
+64
-0
No files found.
dlib/CMakeLists.txt
View file @
4e4acf79
...
...
@@ -493,16 +493,8 @@ if (NOT TARGET dlib)
endif
()
if
(
DLIB_JPEG_SUPPORT
)
# try to find libjpeg
find_package
(
JPEG QUIET
)
# Make sure there isn't something wrong with the version of libjpeg
# installed on this system. Also don't use the installed libjpeg
# if this is an APPLE system because apparently it's broken (as of 2015/01/01).
if
(
JPEG_FOUND AND
NOT
(
"
${
JPEG_INCLUDE_DIR
}
"
MATCHES
"(.*)(Ana|ana|mini)conda(.*)"
)
AND NOT BUILDING_PYTHON_IN_MSVC
)
set
(
CMAKE_REQUIRED_LIBRARIES
${
JPEG_LIBRARY
}
)
CHECK_FUNCTION_EXISTS
(
jpeg_read_header LIBJPEG_IS_GOOD
)
endif
()
if
(
JPEG_FOUND AND LIBJPEG_IS_GOOD AND NOT APPLE
)
include
(
cmake_utils/find_libjpeg.cmake
)
if
(
JPEG_FOUND
)
include_directories
(
${
JPEG_INCLUDE_DIR
}
)
set
(
dlib_needed_libraries
${
dlib_needed_libraries
}
${
JPEG_LIBRARY
}
)
else
()
...
...
dlib/cmake_utils/find_libjpeg.cmake
0 → 100644
View file @
4e4acf79
#This script just runs CMake's built in JPEG finding tool. But it also checks that the
#copy of libjpeg that cmake finds actually builds and links.
cmake_minimum_required
(
VERSION 2.8.12
)
# Don't rerun this script if its already been executed.
if
(
DEFINED JPEG_FOUND
)
return
()
endif
()
find_package
(
JPEG QUIET
)
if
(
JPEG_FOUND
)
try_compile
(
test_for_libjpeg_worked
${
PROJECT_BINARY_DIR
}
/test_for_libjpeg_build
${
CMAKE_CURRENT_LIST_DIR
}
/test_for_libjpeg
test_if_libjpeg_is_broken
)
message
(
STATUS
"Found system copy of libjpeg:
${
JPEG_LIBRARY
}
"
)
if
(
NOT test_for_libjpeg_worked
)
set
(
JPEG_FOUND 0
)
message
(
STATUS
"System copy of libjpeg is broken. Will build our own libjpeg and use that instead."
)
endif
()
endif
()
dlib/cmake_utils/test_for_libjpeg/CMakeLists.txt
0 → 100644
View file @
4e4acf79
cmake_minimum_required
(
VERSION 2.8.12
)
project
(
test_if_libjpeg_is_broken
)
find_package
(
JPEG
)
include_directories
(
${
JPEG_INCLUDE_DIR
}
)
add_executable
(
libjpeg_test libjpeg_test.cpp
)
target_link_libraries
(
libjpeg_test
${
JPEG_LIBRARY
}
)
dlib/cmake_utils/test_for_libjpeg/libjpeg_test.cpp
0 → 100644
View file @
4e4acf79
// Copyright (C) 2019 Davis E. King (davis@dlib.net), Nils Labugt
// License: Boost Software License See LICENSE.txt for the full license.
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <jpeglib.h>
#include <iostream>
struct
jpeg_loader_error_mgr
{
jpeg_error_mgr
pub
;
jmp_buf
setjmp_buffer
;
};
void
jpeg_loader_error_exit
(
j_common_ptr
cinfo
)
{
jpeg_loader_error_mgr
*
myerr
=
(
jpeg_loader_error_mgr
*
)
cinfo
->
err
;
longjmp
(
myerr
->
setjmp_buffer
,
1
);
}
// This code doesn't really make a lot of sense. It's just calling all the libjpeg functions to make
// sure they can be compiled and linked.
int
main
()
{
std
::
cerr
<<
"This program is just for build system testing. Don't actually run it."
<<
std
::
endl
;
abort
();
FILE
*
fp
=
fopen
(
"whatever.jpg"
,
"rb"
);
jpeg_decompress_struct
cinfo
;
jpeg_loader_error_mgr
jerr
;
cinfo
.
err
=
jpeg_std_error
(
&
jerr
.
pub
);
jerr
.
pub
.
error_exit
=
jpeg_loader_error_exit
;
setjmp
(
jerr
.
setjmp_buffer
);
jpeg_create_decompress
(
&
cinfo
);
jpeg_stdio_src
(
&
cinfo
,
fp
);
jpeg_read_header
(
&
cinfo
,
TRUE
);
jpeg_start_decompress
(
&
cinfo
);
unsigned
long
height_
=
cinfo
.
output_height
;
unsigned
long
width_
=
cinfo
.
output_width
;
unsigned
long
output_components_
=
cinfo
.
output_components
;
unsigned
char
*
rows
[
123
];
while
(
cinfo
.
output_scanline
<
cinfo
.
output_height
)
{
jpeg_read_scanlines
(
&
cinfo
,
&
rows
[
cinfo
.
output_scanline
],
100
);
}
jpeg_finish_decompress
(
&
cinfo
);
jpeg_destroy_decompress
(
&
cinfo
);
fclose
(
fp
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment