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
0cf422d4
Commit
0cf422d4
authored
Mar 15, 2019
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have CMake build a little test program to see if the system copy of libpng really works.
parent
0268e274
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
10 deletions
+91
-10
CMakeLists.txt
dlib/CMakeLists.txt
+2
-10
find_libpng.cmake
dlib/cmake_utils/find_libpng.cmake
+25
-0
CMakeLists.txt
dlib/cmake_utils/test_for_libpng/CMakeLists.txt
+10
-0
libpng_test.cpp
dlib/cmake_utils/test_for_libpng/libpng_test.cpp
+54
-0
No files found.
dlib/CMakeLists.txt
View file @
0cf422d4
...
...
@@ -430,16 +430,8 @@ if (NOT TARGET dlib)
endif
()
if
(
DLIB_PNG_SUPPORT
)
# try to find libpng
find_package
(
PNG QUIET
)
# Make sure there isn't something wrong with the version of LIBPNG
# installed on this system. Also never link to anything from anaconda
# since it's probably broken.
if
(
PNG_FOUND AND
NOT
(
"
${
PNG_INCLUDE_DIR
}
"
MATCHES
"(.*)(Ana|ana|mini)conda(.*)"
)
AND NOT BUILDING_PYTHON_IN_MSVC
)
set
(
CMAKE_REQUIRED_LIBRARIES
${
PNG_LIBRARIES
}
)
CHECK_FUNCTION_EXISTS
(
png_create_read_struct LIBPNG_IS_GOOD
)
endif
()
if
(
PNG_FOUND AND LIBPNG_IS_GOOD
)
include
(
cmake_utils/find_libpng.cmake
)
if
(
PNG_FOUND
)
include_directories
(
${
PNG_INCLUDE_DIR
}
)
set
(
dlib_needed_libraries
${
dlib_needed_libraries
}
${
PNG_LIBRARIES
}
)
set
(
REQUIRES_LIBS
" libpng"
)
...
...
dlib/cmake_utils/find_libpng.cmake
0 → 100644
View file @
0cf422d4
#This script just runs CMake's built in PNG finding tool. But it also checks that the
#copy of libpng 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 PNG_FOUND
)
return
()
endif
()
find_package
(
PNG QUIET
)
if
(
PNG_FOUND
)
try_compile
(
test_for_libpng_worked
${
PROJECT_BINARY_DIR
}
/test_for_libpng_build
${
CMAKE_CURRENT_LIST_DIR
}
/test_for_libpng
test_if_libpng_is_broken
)
message
(
STATUS
"Found system copy of libpng:
${
PNG_LIBRARIES
}
"
)
if
(
NOT test_for_libpng_worked
)
set
(
PNG_FOUND 0
)
message
(
STATUS
"System copy of libpng is broken. Will build our own libpng and use that instead."
)
endif
()
endif
()
dlib/cmake_utils/test_for_libpng/CMakeLists.txt
0 → 100644
View file @
0cf422d4
cmake_minimum_required
(
VERSION 2.8.12
)
project
(
test_if_libpng_is_broken
)
find_package
(
PNG
)
add_executable
(
libpng_test libpng_test.cpp
)
target_link_libraries
(
libpng_test
${
PNG_LIBRARIES
}
)
dlib/cmake_utils/test_for_libpng/libpng_test.cpp
0 → 100644
View file @
0cf422d4
// Copyright (C) 2019 Davis E. King (davis@dlib.net), Nils Labugt
// License: Boost Software License See LICENSE.txt for the full license.
#include <png.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
void
png_loader_user_error_fn_silent
(
png_structp
png_struct
,
png_const_charp
)
{
longjmp
(
png_jmpbuf
(
png_struct
),
1
);
}
void
png_loader_user_warning_fn_silent
(
png_structp
,
png_const_charp
)
{
}
// This code doesn't really make a lot of sense. It's just calling all the libpng functions to make
// sure they can be compiled and linked.
int
main
()
{
png_bytep
*
row_pointers_
;
png_structp
png_ptr_
;
png_infop
info_ptr_
;
png_infop
end_info_
;
FILE
*
fp
=
fopen
(
"whatever.png"
,
"rb"
);
png_byte
sig
[
8
];
fread
(
sig
,
1
,
8
,
fp
);
png_sig_cmp
(
sig
,
0
,
8
);
png_ptr_
=
png_create_read_struct
(
PNG_LIBPNG_VER_STRING
,
NULL
,
&
png_loader_user_error_fn_silent
,
&
png_loader_user_warning_fn_silent
);
png_get_header_ver
(
NULL
);
info_ptr_
=
png_create_info_struct
(
png_ptr_
);
end_info_
=
png_create_info_struct
(
png_ptr_
);
setjmp
(
png_jmpbuf
(
png_ptr_
));
png_set_palette_to_rgb
(
png_ptr_
);
png_init_io
(
png_ptr_
,
fp
);
png_set_sig_bytes
(
png_ptr_
,
8
);
// flags force one byte per channel output
int
png_transforms
=
PNG_TRANSFORM_PACKING
;
png_read_png
(
png_ptr_
,
info_ptr_
,
png_transforms
,
NULL
);
png_get_image_height
(
png_ptr_
,
info_ptr_
);
png_get_image_width
(
png_ptr_
,
info_ptr_
);
png_get_bit_depth
(
png_ptr_
,
info_ptr_
);
png_get_color_type
(
png_ptr_
,
info_ptr_
);
png_get_rows
(
png_ptr_
,
info_ptr_
);
fclose
(
fp
);
png_destroy_read_struct
(
&
png_ptr_
,
&
info_ptr_
,
&
end_info_
);
std
::
cerr
<<
"This program is just for build system testing. Don't actually run it."
<<
std
::
endl
;
abort
();
}
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