A lot of cmake changes, fix compile on win32

This commit is contained in:
Eduardo Bart 2012-06-22 16:04:03 -03:00
parent 139f389d88
commit 4515e360e4
17 changed files with 123 additions and 171 deletions

View File

@ -7,7 +7,7 @@ INCLUDE(src/otclient/CMakeLists.txt)
# functions map for reading backtraces
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,-Map=otclient.map")
OPTION(PCH "Use precompiled header (speed up compile)" OFF)
OPTION(USE_PCH "Use precompiled header (speed up compile)" OFF)
SET(executable_SOURCES
src/main.cpp
@ -29,7 +29,7 @@ ADD_EXECUTABLE(otclient ${framework_SOURCES} ${otclient_SOURCES} ${executable_SO
# target link libraries
TARGET_LINK_LIBRARIES(otclient ${framework_LIBRARIES})
IF(PCH)
IF(USE_PCH)
include(cotire)
cotire(otclient)
MESSAGE(STATUS "Use precompiled header: ON")

View File

@ -8,6 +8,8 @@ SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}")
OPTION(CRASH_HANDLER "Generate crash reports" ON)
OPTION(LUAJIT "Use lua jit" OFF)
OPTION(USE_STATIC_LIBS "Don't use shared libraries (dlls)" ON)
SET(OPENGLES "OFF" CACHE "Use OpenGL ES 1.0 or 2.0 (for mobiles devices)" STRING)
SET(BUILD_REVISION "custom" CACHE "Git revision string (intended for releases)" STRING)
@ -26,12 +28,14 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNS_FLAGS} ${ARCH_
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -ggdb -fno-omit-frame-pointer")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
SET(CMAKE_CXX_FLAGS_PERFORMANCE "-Ofast -mmxx -msee -msee2")
SET(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -static-libgcc -static-libstdc++ -Wl,--as-needed")
IF(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,-s")
IF(USE_STATIC_LIBS)
SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++")
MESSAGE("Link to static libraries: ON")
ELSE()
MESSAGE("Link to static libraries: OFF")
ENDIF()
MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
@ -70,7 +74,7 @@ MESSAGE(STATUS "OpenGL ES: " ${OPENGLES})
IF(LUAJIT)
FIND_PACKAGE(LuaJIT REQUIRED)
SET(LUA_INCLUDE_DIR ${LUAJIT_INCLUDE_DIR})
SET(LUA_LIBRARIES ${LUAJIT_LIBRARIES})
SET(LUA_LIBRARY ${LUAJIT_LIBRARY})
ELSE()
FIND_PACKAGE(Lua REQUIRED)
ENDIF()
@ -94,7 +98,7 @@ ELSE()
ADD_DEFINITIONS(-DNDEBUG)
# strip all debug information
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -s")
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--as-needed -Wl,-s")
ENDIF()
IF(CRASH_HANDLER)
@ -140,7 +144,7 @@ INCLUDE_DIRECTORIES(
SET(framework_LIBRARIES
${Boost_LIBRARIES}
${LUA_LIBRARIES}
${LUA_LIBRARY}
${PHYSFS_LIBRARY}
${GMP_LIBRARY}
${ZLIB_LIBRARY}

View File

@ -4,7 +4,13 @@
# GLEW_LIBRARY - the GLEW library
FIND_PATH(GLEW_INCLUDE_DIR NAMES GL/glew.h)
FIND_LIBRARY(GLEW_LIBRARY NAMES libGLEW.a libglew32.a GLEW glew32)
SET(_GLEW_STATIC_LIBS libGLEW.a libglew32.a)
SET(_GLEW_SHARED_LIBS GLEW.dll glew32.dll GLEW glew32)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(GLEW_LIBRARY NAMES ${_GLEW_STATIC_LIBS} ${_GLEW_SHARED_LIBS})
ELSE()
FIND_LIBRARY(GLEW_LIBRARY NAMES ${_GLEW_SHARED_LIBS} ${_GLEW_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDE_DIR)
MARK_AS_ADVANCED(GLEW_LIBRARY GLEW_INCLUDE_DIR)

View File

@ -4,7 +4,13 @@
# GMP_LIBRARY - the GMP library
FIND_PATH(GMP_INCLUDE_DIR NAMES gmp.h)
FIND_LIBRARY(GMP_LIBRARY NAMES libgmp.a gmp)
SET(_GMP_STATIC_LIBS libgmp.a)
SET(_GMP_SHARED_LIBS gmp.dll gmp)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(GMP_LIBRARY NAMES ${_GMP_STATIC_LIBS} ${_GMP_SHARED_LIBS})
ELSE()
FIND_LIBRARY(GMP_LIBRARY NAMES ${_GMP_SHARED_LIBS} ${_GMP_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMP DEFAULT_MSG GMP_LIBRARY GMP_INCLUDE_DIR)
MARK_AS_ADVANCED(GMP_LIBRARY GMP_INCLUDE_DIR)

View File

@ -4,19 +4,15 @@
# LUA_LIBRARY - the lua library
# LUA_LIBRARIES - the lua library and it's dependencies
FIND_PATH(LUA_INCLUDE_DIR NAMES lua.h PATH_SUFFIXES lua51 lua5.1)
FIND_LIBRARY(LUA_LIBRARY NAMES liblua51.a liblua5.1.a liblua-5.1.a liblua.a lua51 lua5.1 lua-5.1 lua)
IF(LUA_LIBRARY)
IF(UNIX AND NOT APPLE)
FIND_LIBRARY(LUA_MATH_LIBRARY m)
SET(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}")
ELSE(UNIX AND NOT APPLE)
SET(LUA_LIBRARIES "${LUA_LIBRARY}")
ENDIF(UNIX AND NOT APPLE)
ENDIF(LUA_LIBRARY)
FIND_PATH(LUA_INCLUDE_DIR NAMES lua.h PATH_SUFFIXES lua51 lua5.1 lua)
FIND_LIBRARY(LUA_LIBRARY NAMES)
SET(_LUA_STATIC_LIBS liblua51.a liblua5.1.a liblua-5.1.a liblua.a )
SET(_LUA_SHARED_LIBS lua51.dll lua5.1.dll lua-5.1.dll lua.dll lua51 lua5.1 lua-5.1 lua)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(LUA_LIBRARY NAMES ${_LUA_STATIC_LIBS} ${_LUA_SHARED_LIBS})
ELSE()
FIND_LIBRARY(LUA_LIBRARY NAMES ${_LUA_SHARED_LIBS} ${_LUA_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR)
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua DEFAULT_MSG LUA_LIBRARY LUA_INCLUDE_DIR)
MARK_AS_ADVANCED(LUA_LIBRARY LUA_INCLUDE_DIR)

View File

@ -5,10 +5,13 @@
# LUAJIT_LIBRARIES - the lua library and it's dependencies
FIND_PATH(LUAJIT_INCLUDE_DIR NAMES lua.h PATH_SUFFIXES luajit-2.0)
FIND_LIBRARY(LUAJIT_LIBRARY NAMES libluajit51.a libluajit5.1.a libluajit-5.1.a libluajit.a luajit51 luajit5.1 luajit-5.1 luajit)
SET(LUAJIT_LIBRARIES "${LUAJIT_LIBRARY}")
SET(_LUAJIT_STATIC_LIBS libluajit51.a libluajit5.1.a libluajit-5.1.a libluajit.a)
SET(_LUAJIT_SHARED_LIBS luajit51 luajit5.1 luajit-5.1 luajit)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(LUAJIT_LIBRARY NAMES ${_LUAJIT_STATIC_LIBS} ${_LUAJIT_SHARED_LIBS})
ELSE()
FIND_LIBRARY(LUAJIT_LIBRARY NAMES ${_LUAJIT_SHARED_LIBS} ${_LUAJIT_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT DEFAULT_MSG LUAJIT_LIBRARIES LUAJIT_INCLUDE_DIR)
MARK_AS_ADVANCED(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARIES LUAJIT_LIBRARY)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT DEFAULT_MSG LUAJIT_LIBRARY LUAJIT_INCLUDE_DIR)
MARK_AS_ADVANCED(LUAJIT_LIBRARY LUAJIT_INCLUDE_DIR)

View File

@ -4,7 +4,13 @@
# OGG_LIBRARY - the OGG library
FIND_PATH(OGG_INCLUDE_DIR NAMES ogg/ogg.h)
FIND_LIBRARY(OGG_LIBRARY NAMES libogg.a ogg)
SET(_OGG_STATIC_LIBS libogg.a)
SET(_OGG_SHARED_LIBS ogg.dll ogg)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(OGG_LIBRARY NAMES ${_OGG_STATIC_LIBS} ${_OGG_SHARED_LIBS})
ELSE()
FIND_LIBRARY(OGG_LIBRARY NAMES ${_OGG_SHARED_LIBS} ${_OGG_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ogg DEFAULT_MSG OGG_LIBRARY OGG_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OGG DEFAULT_MSG OGG_LIBRARY OGG_INCLUDE_DIR)
MARK_AS_ADVANCED(OGG_LIBRARY OGG_INCLUDE_DIR)

View File

@ -1,102 +1,16 @@
# Locate OpenAL
# This module defines
# OPENAL_LIBRARY
# OPENAL_FOUND, if false, do not try to link to OpenAL
# OPENAL_INCLUDE_DIR, where to find the headers
#
# $OPENALDIR is an environment variable that would
# correspond to the ./configure --prefix=$OPENALDIR
# used in building OpenAL.
#
# Created by Eric Wing. This was influenced by the FindSDL.cmake module.
# Try to find the OPENAL library
# OPENAL_FOUND - system has OPENAL
# OPENAL_INCLUDE_DIR - the OPENAL include directory
# OPENAL_LIBRARY - the OPENAL library
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# This makes the presumption that you are include al.h like
# #include "al.h"
# and not
# #include <AL/al.h>
# The reason for this is that the latter is not entirely portable.
# Windows/Creative Labs does not by default put their headers in AL/ and
# OS X uses the convention <OpenAL/al.h>.
#
# For Windows, Creative Labs seems to have added a registry key for their
# OpenAL 1.1 installer. I have added that key to the list of search paths,
# however, the key looks like it could be a little fragile depending on
# if they decide to change the 1.00.0000 number for bug fix releases.
# Also, they seem to have laid down groundwork for multiple library platforms
# which puts the library in an extra subdirectory. Currently there is only
# Win32 and I have hardcoded that here. This may need to be adjusted as
# platforms are introduced.
# The OpenAL 1.0 installer doesn't seem to have a useful key I can use.
# I do not know if the Nvidia OpenAL SDK has a registry key.
#
# For OS X, remember that OpenAL was added by Apple in 10.4 (Tiger).
# To support the framework, I originally wrote special framework detection
# code in this module which I have now removed with CMake's introduction
# of native support for frameworks.
# In addition, OpenAL is open source, and it is possible to compile on Panther.
# Furthermore, due to bugs in the initial OpenAL release, and the
# transition to OpenAL 1.1, it is common to need to override the built-in
# framework.
# Per my request, CMake should search for frameworks first in
# the following order:
# ~/Library/Frameworks/OpenAL.framework/Headers
# /Library/Frameworks/OpenAL.framework/Headers
# /System/Library/Frameworks/OpenAL.framework/Headers
#
# On OS X, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of
# OPENAL_LIBRARY to override this selection or set the CMake environment
# CMAKE_INCLUDE_PATH to modify the search paths.
FIND_PATH(OPENAL_INCLUDE_DIR AL/al.h
HINTS
$ENV{OPENALDIR}
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
)
FIND_LIBRARY(OPENAL_LIBRARY
NAMES OpenAL al openal OpenAL32
HINTS
$ENV{OPENALDIR}
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
)
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
# all listed variables are TRUE
FIND_PATH(OPENAL_INCLUDE_DIR NAMES AL/al.h)
SET(_OPENAL_STATIC_LIBS OpenAL.a al.a openal.a OpenAL32.a)
SET(_OPENAL_SHARED_LIBS OpenAL.dll al.dll openal.dll OpenAL32.dll OpenAL al openal OpenAL32)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(OPENAL_LIBRARY NAMES ${_OPENAL_STATIC_LIBS} ${_OPENAL_SHARED_LIBS})
ELSE()
FIND_LIBRARY(OPENAL_LIBRARY NAMES ${_OPENAL_SHARED_LIBS} ${_OPENAL_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
MARK_AS_ADVANCED(OPENAL_LIBRARY OPENAL_INCLUDE_DIR)

View File

@ -1,4 +1,4 @@
# Try to find the OpenGLES2 librairy
# Try to find the OpenGLES2 library
# OPENGLES1_FOUND - system has OpenGL ES 1.0
# OPENGLES1_INCLUDE_DIR - the OpenGL ES 1.0 include directory
# OPENGLES1_LIBRARY - the OpenGL ES 1.0 library

View File

@ -1,4 +1,4 @@
# Try to find the OpenGLES2 librairy
# Try to find the OpenGLES2 library
# OPENGLES2_FOUND - system has OpenGL ES 2.0
# OPENGLES2_INCLUDE_DIR - the OpenGL ES 2.0 include directory
# OPENGLES2_LIBRARY - the OpenGL ES 2.0 library

View File

@ -1,10 +0,0 @@
# Try to find the PNG librairy
# PNG_FOUND - system has PNG
# PNG_INCLUDE_DIR - the PNG include directory
# PNG_LIBRARY - the PNG library
FIND_PATH(PNG_INCLUDE_DIR NAMES png.h PATH_SUFFIXES libpng15 libpng)
FIND_LIBRARY(PNG_LIBRARY NAMES libpng15.a libpng.a png15 png)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PNG DEFAULT_MSG PNG_LIBRARY PNG_INCLUDE_DIR)
MARK_AS_ADVANCED(PNG_LIBRARY PNG_INCLUDE_DIR)

View File

@ -1,10 +1,16 @@
# Try to find the physfs librairy
# PHYSFS_FOUND - system has physfs
# PHYSFS_INCLUDE_DIR - the physfs include directory
# PHYSFS_LIBRARY - the physfs library
# Try to find the PHYSFS library
# PHYSFS_FOUND - system has PHYSFS
# PHYSFS_INCLUDE_DIR - the PHYSFS include directory
# PHYSFS_LIBRARY - the PHYSFS library
FIND_PATH(PHYSFS_INCLUDE_DIR physfs.h PATH_SUFFIXES physfs)
FIND_LIBRARY(PHYSFS_LIBRARY NAMES libphysfs.a physfs)
SET(_PHYSFS_STATIC_LIBS libphysfs.a)
SET(_PHYSFS_SHARED_LIBS physfs.dll physfs)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(PHYSFS_LIBRARY NAMES ${_PHYSFS_STATIC_LIBS} ${_PHYSFS_SHARED_LIBS})
ELSE()
FIND_LIBRARY(PHYSFS_LIBRARY NAMES ${_PHYSFS_SHARED_LIBS} ${_PHYSFS_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PhysFS DEFAULT_MSG PHYSFS_LIBRARY PHYSFS_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PHYSFS DEFAULT_MSG PHYSFS_LIBRARY PHYSFS_INCLUDE_DIR)
MARK_AS_ADVANCED(PHYSFS_LIBRARY PHYSFS_INCLUDE_DIR)

View File

@ -4,7 +4,13 @@
# VORBIS_LIBRARY - the VORBIS library
FIND_PATH(VORBIS_INCLUDE_DIR NAMES vorbis/codec.h)
FIND_LIBRARY(VORBIS_LIBRARY NAMES libvorbis.a vorbis)
SET(_VORBIS_STATIC_LIBS libvorbis.a)
SET(_VORBIS_SHARED_LIBS vorbis.dll vorbis)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(VORBIS_LIBRARY NAMES ${_VORBIS_STATIC_LIBS} ${_VORBIS_SHARED_LIBS})
ELSE()
FIND_LIBRARY(VORBIS_LIBRARY NAMES ${_VORBIS_SHARED_LIBS} ${_VORBIS_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Vorbis DEFAULT_MSG VORBIS_LIBRARY VORBIS_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(VORBIS DEFAULT_MSG VORBIS_LIBRARY VORBIS_INCLUDE_DIR)
MARK_AS_ADVANCED(VORBIS_LIBRARY VORBIS_INCLUDE_DIR)

View File

@ -4,7 +4,13 @@
# VORBISFILE_LIBRARY - the VORBISFILE library
FIND_PATH(VORBISFILE_INCLUDE_DIR NAMES vorbis/vorbisfile.h)
FIND_LIBRARY(VORBISFILE_LIBRARY NAMES libvorbisfile.a vorbisfile)
SET(_VORBISFILE_STATIC_LIBS libvorbisfile.a)
SET(_VORBISFILE_SHARED_LIBS vorbisfile.dll vorbisfile)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(VORBISFILE_LIBRARY NAMES ${_VORBISFILE_STATIC_LIBS} ${_VORBISFILE_SHARED_LIBS})
ELSE()
FIND_LIBRARY(VORBISFILE_LIBRARY NAMES ${_VORBISFILE_SHARED_LIBS} ${_VORBISFILE_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(VorbisFile DEFAULT_MSG VORBISFILE_LIBRARY VORBISFILE_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(VORBISFILE DEFAULT_MSG VORBISFILE_LIBRARY VORBISFILE_INCLUDE_DIR)
MARK_AS_ADVANCED(VORBISFILE_LIBRARY VORBISFILE_INCLUDE_DIR)

View File

@ -1,11 +1,16 @@
# Try to find the zlib librairy
# ZLIB_FOUND - system has zlib
# ZLIB_INCLUDE_DIR - the zlib include directory
# ZLIB_LIBRARY - the zlib library
# Try to find the ZLIB library
# ZLIB_FOUND - system has ZLIB
# ZLIB_INCLUDE_DIR - the ZLIB include directory
# ZLIB_LIBRARY - the ZLIB library
FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h)
FIND_LIBRARY(ZLIB_LIBRARY NAMES libz.a libzlib.a zlib1.a z zlib zdll zlib1)
SET(_ZLIB_STATIC_LIBS libz.a libzlib.a zlib1.a)
SET(_ZLIB_SHARED_LIBS z.dll zlib.dll zdll.dll zlib1.dll z zlib zdll zlib1)
IF(USE_STATIC_LIBS)
FIND_LIBRARY(ZLIB_LIBRARY NAMES ${_ZLIB_STATIC_LIBS} ${_ZLIB_SHARED_LIBS})
ELSE()
FIND_LIBRARY(ZLIB_LIBRARY NAMES ${_ZLIB_SHARED_LIBS} ${_ZLIB_STATIC_LIBS})
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB DEFAULT_MSG ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)

View File

@ -205,12 +205,12 @@ std::string FileStream::getString()
char buffer[8192];
if(m_fileHandle) {
if(PHYSFS_read(m_fileHandle, buffer, 1, len) == 0)
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
throwError("read failed");
else
str = std::string(buffer, len);
} else {
if(m_pos+len > m_data.size()) {
g_logger.traceError(stdext::format("operation failed on '%s': reached file eof", m_name));
throwError("read failed");
return 0;
}
@ -249,7 +249,10 @@ void FileStream::addU64(uint8 v)
void FileStream::throwError(const std::string& message)
{
std::string completeMessage = stdext::format("in file '%s': %s", m_name, message);
if(m_fileHandle)
completeMessage += std::string(": ") + PHYSFS_getLastError();
if(m_fileHandle) {
const char *errorMessage = PHYSFS_getLastError();
if(errorMessage)
completeMessage += std::string(": ") + errorMessage;
}
stdext::throw_exception(completeMessage);
}

View File

@ -22,6 +22,7 @@
#include "protocol.h"
#include "connection.h"
#include <framework/application.h>
Protocol::Protocol()
{