Add option to shared libzip and libsnappy in CMakeLists.txt.

This commit is contained in:
sergiobenrocha2 2015-09-15 22:46:51 -03:00
parent 253ed9f584
commit c23f51480e
3 changed files with 218 additions and 72 deletions

View File

@ -386,19 +386,27 @@ 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(NOT SNAPPY_FOUND)
add_subdirectory(ext/snappy)
endif()
add_subdirectory(ext/snappy)
add_subdirectory(ext/udis86)
add_library(vjson STATIC
@ -618,7 +626,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 +637,68 @@ 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(NOT LIBZIP_FOUND)
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 +1032,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)