Merge pull request #7970 from sergiobenrocha2/master

Improve detection of shared libs (zlib, libzip, libsnappy and glew)
This commit is contained in:
Henrik Rydgård 2015-09-16 09:27:08 +02:00
commit 17af86d4c3
14 changed files with 288 additions and 93 deletions

View File

@ -386,19 +386,29 @@ endif()
if(NOT USING_GLES2)
include_directories(${OPENGL_INCLUDE_DIR})
add_definitions(-DGLEW_STATIC)
add_library(glew STATIC
ext/native/ext/glew/GL/glew.h
ext/native/ext/glew/GL/glxew.h
ext/native/ext/glew/GL/wglew.h
ext/native/ext/glew/glew.c)
target_link_libraries(glew ${OPENGL_LIBRARIES})
include_directories(ext/native/ext/glew)
set(GLEW_LIBRARIES glew)
find_package(GLEW)
if(NOT GLEW_FOUND)
add_definitions(-DGLEW_STATIC)
add_library(glew STATIC
ext/native/ext/glew/GL/glew.h
ext/native/ext/glew/GL/glxew.h
ext/native/ext/glew/GL/wglew.h
ext/native/ext/glew/glew.c)
target_link_libraries(glew ${OPENGL_LIBRARIES})
include_directories(ext/native/ext/glew)
set(GLEW_LIBRARIES glew)
endif()
else()
find_package(X11)
endif()
find_package(Snappy)
if(SNAPPY_FOUND)
add_definitions(-DSHARED_SNAPPY)
else()
add_subdirectory(ext/snappy)
endif()
add_subdirectory(ext/snappy)
add_subdirectory(ext/udis86)
add_library(vjson STATIC
@ -575,6 +585,7 @@ endif()
find_package(ZLIB)
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIR})
add_definitions(-DSHARED_ZLIB)
else()
add_library(zlib STATIC
ext/zlib/adler32.c
@ -618,7 +629,9 @@ include_directories(ext/cityhash)
if (NOT MSVC)
# These can be fast even for debug.
set_target_properties(snappy PROPERTIES COMPILE_FLAGS "-O3")
if(NOT SNAPPY_FOUND)
set_target_properties(snappy PROPERTIES COMPILE_FLAGS "-O3")
endif()
set_target_properties(udis86 PROPERTIES COMPILE_FLAGS "-O3")
set_target_properties(cityhash PROPERTIES COMPILE_FLAGS "-O3")
if(NOT ZLIB_FOUND)
@ -627,65 +640,70 @@ if (NOT MSVC)
endif()
add_library(libzip STATIC
ext/native/ext/libzip/zip.h
ext/native/ext/libzip/mkstemp.c
ext/native/ext/libzip/zip_add.c
ext/native/ext/libzip/zip_add_dir.c
ext/native/ext/libzip/zip_close.c
ext/native/ext/libzip/zip_delete.c
ext/native/ext/libzip/zip_dirent.c
ext/native/ext/libzip/zip_entry_free.c
ext/native/ext/libzip/zip_entry_new.c
ext/native/ext/libzip/zip_err_str.c
ext/native/ext/libzip/zip_error.c
ext/native/ext/libzip/zip_error_clear.c
ext/native/ext/libzip/zip_error_get.c
ext/native/ext/libzip/zip_error_get_sys_type.c
ext/native/ext/libzip/zip_error_strerror.c
ext/native/ext/libzip/zip_error_to_str.c
ext/native/ext/libzip/zip_fclose.c
ext/native/ext/libzip/zip_file_error_clear.c
ext/native/ext/libzip/zip_file_error_get.c
ext/native/ext/libzip/zip_file_get_offset.c
ext/native/ext/libzip/zip_file_strerror.c
ext/native/ext/libzip/zip_filerange_crc.c
ext/native/ext/libzip/zip_fopen.c
ext/native/ext/libzip/zip_fopen_index.c
ext/native/ext/libzip/zip_fread.c
ext/native/ext/libzip/zip_free.c
ext/native/ext/libzip/zip_get_archive_comment.c
ext/native/ext/libzip/zip_get_archive_flag.c
ext/native/ext/libzip/zip_get_file_comment.c
ext/native/ext/libzip/zip_get_name.c
ext/native/ext/libzip/zip_get_num_files.c
ext/native/ext/libzip/zip_memdup.c
ext/native/ext/libzip/zip_name_locate.c
ext/native/ext/libzip/zip_new.c
ext/native/ext/libzip/zip_open.c
ext/native/ext/libzip/zip_rename.c
ext/native/ext/libzip/zip_replace.c
ext/native/ext/libzip/zip_set_archive_comment.c
ext/native/ext/libzip/zip_set_archive_flag.c
ext/native/ext/libzip/zip_set_file_comment.c
ext/native/ext/libzip/zip_set_name.c
ext/native/ext/libzip/zip_source_buffer.c
ext/native/ext/libzip/zip_source_file.c
ext/native/ext/libzip/zip_source_filep.c
ext/native/ext/libzip/zip_source_free.c
ext/native/ext/libzip/zip_source_function.c
ext/native/ext/libzip/zip_source_zip.c
ext/native/ext/libzip/zip_stat.c
ext/native/ext/libzip/zip_stat_index.c
ext/native/ext/libzip/zip_stat_init.c
ext/native/ext/libzip/zip_strerror.c
ext/native/ext/libzip/zip_unchange.c
ext/native/ext/libzip/zip_unchange_all.c
ext/native/ext/libzip/zip_unchange_archive.c
ext/native/ext/libzip/zip_unchange_data.c)
target_link_libraries(libzip ${ZLIB_LIBRARY})
include_directories(ext/native/ext/libzip)
set(LIBZIP_LIBRARY libzip)
find_package(LibZip)
if(LIBZIP_FOUND)
add_definitions(-DSHARED_LIBZIP)
else()
add_library(libzip STATIC
ext/native/ext/libzip/zip.h
ext/native/ext/libzip/mkstemp.c
ext/native/ext/libzip/zip_add.c
ext/native/ext/libzip/zip_add_dir.c
ext/native/ext/libzip/zip_close.c
ext/native/ext/libzip/zip_delete.c
ext/native/ext/libzip/zip_dirent.c
ext/native/ext/libzip/zip_entry_free.c
ext/native/ext/libzip/zip_entry_new.c
ext/native/ext/libzip/zip_err_str.c
ext/native/ext/libzip/zip_error.c
ext/native/ext/libzip/zip_error_clear.c
ext/native/ext/libzip/zip_error_get.c
ext/native/ext/libzip/zip_error_get_sys_type.c
ext/native/ext/libzip/zip_error_strerror.c
ext/native/ext/libzip/zip_error_to_str.c
ext/native/ext/libzip/zip_fclose.c
ext/native/ext/libzip/zip_file_error_clear.c
ext/native/ext/libzip/zip_file_error_get.c
ext/native/ext/libzip/zip_file_get_offset.c
ext/native/ext/libzip/zip_file_strerror.c
ext/native/ext/libzip/zip_filerange_crc.c
ext/native/ext/libzip/zip_fopen.c
ext/native/ext/libzip/zip_fopen_index.c
ext/native/ext/libzip/zip_fread.c
ext/native/ext/libzip/zip_free.c
ext/native/ext/libzip/zip_get_archive_comment.c
ext/native/ext/libzip/zip_get_archive_flag.c
ext/native/ext/libzip/zip_get_file_comment.c
ext/native/ext/libzip/zip_get_name.c
ext/native/ext/libzip/zip_get_num_files.c
ext/native/ext/libzip/zip_memdup.c
ext/native/ext/libzip/zip_name_locate.c
ext/native/ext/libzip/zip_new.c
ext/native/ext/libzip/zip_open.c
ext/native/ext/libzip/zip_rename.c
ext/native/ext/libzip/zip_replace.c
ext/native/ext/libzip/zip_set_archive_comment.c
ext/native/ext/libzip/zip_set_archive_flag.c
ext/native/ext/libzip/zip_set_file_comment.c
ext/native/ext/libzip/zip_set_name.c
ext/native/ext/libzip/zip_source_buffer.c
ext/native/ext/libzip/zip_source_file.c
ext/native/ext/libzip/zip_source_filep.c
ext/native/ext/libzip/zip_source_free.c
ext/native/ext/libzip/zip_source_function.c
ext/native/ext/libzip/zip_source_zip.c
ext/native/ext/libzip/zip_stat.c
ext/native/ext/libzip/zip_stat_index.c
ext/native/ext/libzip/zip_stat_init.c
ext/native/ext/libzip/zip_strerror.c
ext/native/ext/libzip/zip_unchange.c
ext/native/ext/libzip/zip_unchange_all.c
ext/native/ext/libzip/zip_unchange_archive.c
ext/native/ext/libzip/zip_unchange_data.c)
target_link_libraries(libzip)
include_directories(ext/native/ext/libzip)
set(LIBZIP_LIBRARY libzip)
endif()
# FindPNG does a few things we don't want. So do it ourselves. Fixed to libpng17
find_path(PNG_PNG_INCLUDE_DIR NAMES "libpng17/png.h")
@ -1019,7 +1037,7 @@ if (LINUX AND NOT ANDROID)
SET(RT_LIB rt)
endif()
target_link_libraries(native ${LIBZIP_LIBRARY} ${PNG_LIBRARY} rg_etc1 vjson stb_vorbis snappy udis86 ${RT_LIB} ${GLEW_LIBRARIES})
target_link_libraries(native ${LIBZIP_LIBRARY} ${ZLIB_LIBRARY} ${PNG_LIBRARY} rg_etc1 vjson stb_vorbis snappy udis86 ${RT_LIB} ${GLEW_LIBRARIES})
if(ANDROID)
target_link_libraries(native log EGL)

View File

@ -0,0 +1,74 @@
# https://code.google.com/p/osgearth-for-android/source/browse/trunk/CMakeModules/FindLibZip.cmake?r=4
# osgEarth - Dynamic map generation toolkit for OpenSceneGraph
# Copyright 2008-2010 Pelican Mapping
# http://osgearth.org
# git://github.com/gwaldron/osgearth
# osgEarth is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# Locate libzip
# This module defines
# LIBZIP_LIBRARY
# LIBZIP_FOUND, if false, do not try to link to libzip
# LIBZIP_INCLUDE_DIR, where to find the headers
#
FIND_PATH(LIBZIP_INCLUDE_DIR zip.h
$ENV{LIBZIP_DIR}/include
$ENV{LIBZIP_DIR}
$ENV{OSGDIR}/include
$ENV{OSGDIR}
$ENV{OSG_ROOT}/include
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
/usr/freeware/include
)
FIND_LIBRARY(LIBZIP_LIBRARY
NAMES libzip zip
PATHS
$ENV{LIBZIP_DIR}/lib
$ENV{LIBZIP_DIR}
$ENV{OSGDIR}/lib
$ENV{OSGDIR}
$ENV{OSG_ROOT}/lib
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
/usr/freeware/lib64
)
SET(LIBZIP_FOUND "NO")
IF(LIBZIP_LIBRARY AND LIBZIP_INCLUDE_DIR)
SET(LIBZIP_FOUND "YES")
ENDIF(LIBZIP_LIBRARY AND LIBZIP_INCLUDE_DIR)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBZIP DEFAULT_MSG LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR)

View File

@ -0,0 +1,59 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Tries to find Snappy headers and libraries.
#
# Usage of this module as follows:
#
# find_package(Snappy)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# SNAPPY_ROOT_DIR Set this variable to the root installation of
# Snappy if the module has problems finding
# the proper installation path.
#
# Variables defined by this module:
#
# SNAPPY_FOUND System has Snappy libs/headers
# SNAPPY_LIBRARIES The Snappy libraries
# SNAPPY_INCLUDE_DIR The location of Snappy headers
find_path(SNAPPY_INCLUDE_DIR
NAMES snappy.h
HINTS ${SNAPPY_ROOT_DIR}/include)
find_library(SNAPPY_LIBRARIES
NAMES snappy
HINTS ${SNAPPY_ROOT_DIR}/lib)
set(SNAPPY_FOUND "NO")
if(SNAPPY_LIBRARIES AND SNAPPY_INCLUDE_DIR)
set(SNAPPY_FOUND "YES")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Snappy DEFAULT_MSG
SNAPPY_LIBRARIES
SNAPPY_INCLUDE_DIR)
mark_as_advanced(
SNAPPY_ROOT_DIR
SNAPPY_LIBRARIES
SNAPPY_INCLUDE_DIR)

View File

@ -40,7 +40,11 @@
#include "Common.h"
#include "FileUtil.h"
#ifdef SHARED_SNAPPY
#include <snappy-c.h>
#else
#include "../ext/snappy/snappy-c.h"
#endif
#if defined(MACGNUSTD)
namespace std {

View File

@ -15,7 +15,11 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#ifdef SHARED_ZLIB
#include <zlib.h>
#else
#include "../ext/zlib/zlib.h"
#endif
#include "sceAdler.h"
#include "Common/Log.h"

View File

@ -20,7 +20,11 @@
#include <cstring>
#include "file/file_util.h"
#ifdef SHARED_LIBZIP
#include <zip.h>
#else
#include "ext/libzip/zip.h"
#endif
#include "thread/thread.h"
#include "util/text/utf8.h"

View File

@ -6,7 +6,9 @@ CONFIG += staticlib
include(Settings.pri)
INCLUDEPATH += $$P/ $$P/ext/native $$P/Core/MIPS $$P/ext/xbrz
!contains(DEFINES, USING_GLES2): INCLUDEPATH += $$P/ext/native/ext/glew
!exists( /usr/include/GL/glew.h ) {
!contains(DEFINES, USING_GLES2): INCLUDEPATH += $$P/ext/native/ext/glew
}
arm {
SOURCES += $$P/Core/MIPS/ARM/*.cpp #CoreARM

View File

@ -7,7 +7,9 @@ CONFIG += staticlib
include(Settings.pri)
INCLUDEPATH += $$P/ $$P/ext/native
!contains(DEFINES, USING_GLES2): INCLUDEPATH += $$P/ext/native/ext/glew
!exists( /usr/include/GL/glew.h ) {
!contains(DEFINES, USING_GLES2): INCLUDEPATH += $$P/ext/native/ext/glew
}
win32 {
SOURCES += $$P/Windows/OpenGLBase.cpp

View File

@ -11,10 +11,12 @@ linux-g++:system($$QMAKE_CXX --version | grep "4.6."): DEFINES+=override
INCLUDEPATH += $$P/ext/native
!contains(DEFINES,USING_GLES2) {
SOURCES += $$P/ext/native/ext/glew/glew.c
HEADERS += $$P/ext/native/ext/glew/GL/*.h
INCLUDEPATH += $$P/ext/native/ext/glew
!exists( /usr/include/GL/glew.h ) {
!contains(DEFINES,USING_GLES2) {
SOURCES += $$P/ext/native/ext/glew/glew.c
HEADERS += $$P/ext/native/ext/glew/GL/*.h
INCLUDEPATH += $$P/ext/native/ext/glew
}
}
# RG_ETC1
@ -41,10 +43,11 @@ HEADERS += $$P/ext/native/ext/stb_vorbis/stb_vorbis.h
INCLUDEPATH += $$P/ext/native/ext/stb_vorbis
# Snappy
SOURCES += $$P/ext/snappy/*.cpp
HEADERS += $$P/ext/snappy/*.h
INCLUDEPATH += $$P/ext/snappy
!exists( /usr/include/snappy-c.h ) {
SOURCES += $$P/ext/snappy/*.cpp
HEADERS += $$P/ext/snappy/*.h
INCLUDEPATH += $$P/ext/snappy
}
# udis86
@ -67,8 +70,10 @@ win32|contains(QT_CONFIG, no-zlib) {
}
# Libzip
SOURCES += $$P/ext/native/ext/libzip/*.c
HEADERS += $$P/ext/native/ext/libzip/*.h
!exists( /usr/include/zip.h ) {
SOURCES += $$P/ext/native/ext/libzip/*.c
HEADERS += $$P/ext/native/ext/libzip/*.h
}
# Native

View File

@ -49,6 +49,18 @@ macx|equals(PLATFORM_NAME, "linux") {
}
}
exists( /usr/include/GL/glew.h ) {
LIBS += -lGLEW
}
exists( /usr/include/snappy-c.h ) {
LIBS += -lsnappy
}
exists( /usr/include/zip.h ) {
LIBS += -lzip
}
unix:contains(QT_CONFIG, system-zlib) {
LIBS += -lz
}
@ -77,7 +89,10 @@ SOURCES += $$P/UI/*.cpp \
arm:android: SOURCES += $$P/android/jni/ArmEmitterTest.cpp
HEADERS += $$P/UI/*.h
INCLUDEPATH += $$P $$P/Common $$P/ext/native $$P/ext/native/ext $$P/ext/native/ext/glew
INCLUDEPATH += $$P $$P/Common $$P/ext/native $$P/ext/native/ext
!exists( /usr/include/GL/glew.h ) {
INCLUDEPATH += $$P/ext/native/ext/glew
}
mobile_platform {
!no_assets: RESOURCES += $$P/Qt/assets.qrc

View File

@ -1,6 +1,18 @@
VERSION = 1.0.1.0
DEFINES += USING_QT_UI USE_FFMPEG
exists( /usr/include/snappy-c.h ) {
DEFINES += SHARED_SNAPPY
}
unix:contains(QT_CONFIG, system-zlib) {
DEFINES += SHARED_ZLIB
}
exists( /usr/include/zip.h ) {
DEFINES += SHARED_LIBZIP
}
# Global specific
win32:CONFIG(release, debug|release): CONFIG_DIR = $$join(OUT_PWD,,,/release)
else:win32:CONFIG(debug, debug|release): CONFIG_DIR = $$join(OUT_PWD,,,/debug)

0
build_ppgeatlas.sh Normal file → Executable file
View File

View File

@ -27,12 +27,9 @@ include_directories(..)
include_directories(../ext)
include_directories(../math/lin)
include_directories(../image)
include_directories(../ext/libzip)
include_directories(../ext/rg_etc1)
include_directories(../ext/glew)
include_directories(/usr/local/include)
link_directories(/usr/X11R6/lib)
link_directories(/opt/local/lib)
# Horrible horrible hack
@ -47,14 +44,13 @@ add_subdirectory(../file file)
add_subdirectory(../image image)
add_subdirectory(../math math)
add_subdirectory(../util util)
add_subdirectory(../ext/libzip libzip)
add_subdirectory(../ext/rg_etc1 rg_etc1)
add_subdirectory(../ext/stb_image stb_image)
add_subdirectory(../ext/libpng17 png17)
add_executable(atlastool atlastool.cpp)
target_link_libraries(atlastool png17 freetype util image z stb_image rg_etc1 file zip base)
target_link_libraries(atlastool freetype util image png17 z stb_image rg_etc1 file base)
add_executable(zimtool zimtool.cpp)
target_link_libraries(zimtool png17 freetype image z stb_image rg_etc1 file zip base)
target_link_libraries(zimtool freetype image png17 z stb_image rg_etc1 file base)

View File

@ -18,7 +18,7 @@
// Hackery for our broken path structure
#include <ftbitmap.h>
#else
#include <freetype/ftbitmap.h>
#include <freetype2/ftbitmap.h>
#endif
#include <set>
#include <map>
@ -188,7 +188,7 @@ struct Image {
png_destroy_write_struct(&png_ptr, &info_ptr);
}
void SaveZIM(const char *zim_name, int zim_format) {
uint8 *image_data = new uint8[width() * height() * 4];
uint8_t *image_data = new uint8_t[width() * height() * 4];
for (int y = 0; y < height(); y++) {
memcpy(image_data + y * width() * 4, &dat[y][0], width() * 4);
}