Merge with default

This commit is contained in:
kaetemi 2013-09-07 16:25:45 +02:00
parent 8c40293f55
commit 8efbf91d78
35 changed files with 863 additions and 437 deletions

View file

@ -0,0 +1,149 @@
IF(DEFINED CMAKE_CROSSCOMPILING)
# subsequent toolchain loading is not really needed
RETURN()
ENDIF()
# Standard settings
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1) # TODO: determine target Linux version
SET(UNIX ON)
SET(LINUX ON)
SET(ANDROID ON)
IF(NOT NDK_ROOT)
SET(NDK_ROOT $ENV{NDK_ROOT})
IF(CMAKE_HOST_WIN32)
FILE(TO_CMAKE_PATH ${NDK_ROOT} NDK_ROOT)
ENDIF(CMAKE_HOST_WIN32)
ENDIF(NOT NDK_ROOT)
IF(NOT TARGET_CPU)
SET(TARGET_CPU "armv7")
ENDIF(NOT TARGET_CPU)
IF(TARGET_CPU STREQUAL "armv7")
SET(LIBRARY_ARCHITECTURE "armeabi-v7a")
SET(CMAKE_SYSTEM_PROCESSOR "armv7")
SET(TOOLCHAIN_ARCH "arm")
SET(TOOLCHAIN_PREFIX "arm-linux-androideabi")
SET(TOOLCHAIN_BIN_PREFIX "arm")
SET(MINIMUM_NDK_TARGET 4)
ELSEIF(TARGET_CPU STREQUAL "armv5")
SET(LIBRARY_ARCHITECTURE "armeabi")
SET(CMAKE_SYSTEM_PROCESSOR "armv5")
SET(TOOLCHAIN_ARCH "arm")
SET(TOOLCHAIN_PREFIX "arm-linux-androideabi")
SET(TOOLCHAIN_BIN_PREFIX "arm")
SET(MINIMUM_NDK_TARGET 4)
ELSEIF(TARGET_CPU STREQUAL "x86")
SET(LIBRARY_ARCHITECTURE "x86")
SET(CMAKE_SYSTEM_PROCESSOR "x86")
SET(TOOLCHAIN_ARCH "x86")
SET(TOOLCHAIN_PREFIX "x86")
SET(TOOLCHAIN_BIN_PREFIX "i686")
SET(MINIMUM_NDK_TARGET 9)
ELSEIF(TARGET_CPU STREQUAL "mips")
SET(LIBRARY_ARCHITECTURE "mips")
SET(CMAKE_SYSTEM_PROCESSOR "mips")
SET(TOOLCHAIN_ARCH "mips")
SET(TOOLCHAIN_PREFIX "mipsel-linux-android")
SET(TOOLCHAIN_BIN_PREFIX "mipsel")
SET(MINIMUM_NDK_TARGET 9)
ENDIF(TARGET_CPU STREQUAL "armv7")
IF(NOT NDK_TARGET)
SET(NDK_TARGET ${MINIMUM_NDK_TARGET})
ENDIF(NOT NDK_TARGET)
FILE(GLOB _TOOLCHAIN_VERSIONS "${NDK_ROOT}/toolchains/${TOOLCHAIN_PREFIX}-*")
IF(_TOOLCHAIN_VERSIONS)
LIST(SORT _TOOLCHAIN_VERSIONS)
LIST(REVERSE _TOOLCHAIN_VERSIONS)
FOREACH(_TOOLCHAIN_VERSION ${_TOOLCHAIN_VERSIONS})
STRING(REGEX REPLACE ".+${TOOLCHAIN_PREFIX}-([0-9.]+)" "\\1" _TOOLCHAIN_VERSION "${_TOOLCHAIN_VERSION}")
IF(_TOOLCHAIN_VERSION MATCHES "^([0-9.]+)$")
LIST(APPEND NDK_TOOLCHAIN_VERSIONS ${_TOOLCHAIN_VERSION})
ENDIF(_TOOLCHAIN_VERSION MATCHES "^([0-9.]+)$")
ENDFOREACH(_TOOLCHAIN_VERSION)
ENDIF(_TOOLCHAIN_VERSIONS)
IF(NOT NDK_TOOLCHAIN_VERSIONS)
MESSAGE(FATAL_ERROR "No Android toolchain found in default search path ${NDK_ROOT}/toolchains")
ENDIF(NOT NDK_TOOLCHAIN_VERSIONS)
IF(NDK_TOOLCHAIN_VERSION)
LIST(FIND NDK_TOOLCHAIN_VERSIONS "${NDK_TOOLCHAIN_VERSION}" _INDEX)
IF(_INDEX EQUAL -1)
LIST(GET NDK_TOOLCHAIN_VERSIONS 0 NDK_TOOLCHAIN_VERSION)
ENDIF(_INDEX EQUAL -1)
ELSE(NDK_TOOLCHAIN_VERSION)
LIST(GET NDK_TOOLCHAIN_VERSIONS 0 NDK_TOOLCHAIN_VERSION)
ENDIF(NDK_TOOLCHAIN_VERSION)
MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use GCC ${NDK_TOOLCHAIN_VERSION}")
IF(CMAKE_HOST_WIN32)
SET(TOOLCHAIN_HOST "windows")
SET(TOOLCHAIN_BIN_SUFFIX ".exe")
ELSEIF(CMAKE_HOST_APPLE)
SET(TOOLCHAIN_HOST "apple")
SET(TOOLCHAIN_BIN_SUFFIX "")
ELSEIF(CMAKE_HOST_UNIX)
SET(TOOLCHAIN_HOST "linux")
SET(TOOLCHAIN_BIN_SUFFIX "")
ENDIF(CMAKE_HOST_WIN32)
SET(TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${TOOLCHAIN_PREFIX}-${NDK_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}")
SET(PLATFORM_ROOT "${NDK_ROOT}/platforms/android-${NDK_TARGET}/arch-${TOOLCHAIN_ARCH}")
IF(NOT EXISTS "${TOOLCHAIN_ROOT}")
FILE(GLOB _TOOLCHAIN_PREFIXES "${TOOLCHAIN_ROOT}*")
IF(_TOOLCHAIN_PREFIXES)
LIST(GET _TOOLCHAIN_PREFIXES 0 TOOLCHAIN_ROOT)
ENDIF(_TOOLCHAIN_PREFIXES)
ENDIF(NOT EXISTS "${TOOLCHAIN_ROOT}")
MESSAGE(STATUS "Found Android toolchain in ${TOOLCHAIN_ROOT}")
MESSAGE(STATUS "Found Android platform in ${PLATFORM_ROOT}")
# include dirs
SET(PLATFORM_INCLUDE_DIR "${PLATFORM_ROOT}/usr/include")
SET(STL_DIR "${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++")
IF(EXISTS "${STL_DIR}/${NDK_TOOLCHAIN_VERSION}")
# NDK version >= 8b
SET(STL_DIR "${STL_DIR}/${NDK_TOOLCHAIN_VERSION}")
ENDIF(EXISTS "${STL_DIR}/${NDK_TOOLCHAIN_VERSION}")
# Determine bin prefix for toolchain
FILE(GLOB _TOOLCHAIN_BIN_PREFIXES "${TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-*-gcc${TOOLCHAIN_BIN_SUFFIX}")
IF(_TOOLCHAIN_BIN_PREFIXES)
LIST(GET _TOOLCHAIN_BIN_PREFIXES 0 _TOOLCHAIN_BIN_PREFIX)
STRING(REGEX REPLACE "${TOOLCHAIN_ROOT}/bin/([a-z0-9-]+)-gcc${TOOLCHAIN_BIN_SUFFIX}" "\\1" TOOLCHAIN_BIN_PREFIX "${_TOOLCHAIN_BIN_PREFIX}")
ENDIF(_TOOLCHAIN_BIN_PREFIXES)
SET(STL_INCLUDE_DIR "${STL_DIR}/include")
SET(STL_LIBRARY_DIR "${STL_DIR}/libs/${LIBRARY_ARCHITECTURE}")
SET(STL_INCLUDE_CPU_DIR "${STL_LIBRARY_DIR}/include")
SET(STL_LIBRARY "${STL_LIBRARY_DIR}/libgnustl_static.a")
SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_ROOT} ${PLATFORM_ROOT}/usr ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} $ENV{EXTERNAL_ANDROID_PATH} CACHE string "Android find search path root")
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
INCLUDE_DIRECTORIES(${STL_INCLUDE_DIR} ${STL_INCLUDE_CPU_DIR})
MACRO(SET_TOOLCHAIN_BINARY _NAME _BINARY)
SET(${_NAME} ${TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-${_BINARY}${TOOLCHAIN_BIN_SUFFIX})
ENDMACRO(SET_TOOLCHAIN_BINARY)
SET_TOOLCHAIN_BINARY(CMAKE_C_COMPILER gcc)
SET_TOOLCHAIN_BINARY(CMAKE_CXX_COMPILER g++)
# Force the compilers to GCC for Android
include (CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} GNU)
CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} GNU)

View file

@ -4,42 +4,35 @@
# MFC_LIBRARY_DIR, where to find libraries
# MFC_INCLUDE_DIR, where to find headers
# Try to find MFC using official module, MFC_FOUND is set
FIND_PACKAGE(MFC)
SET(CUSTOM_MFC_DIR FALSE)
# If using STLport and MFC have been found, remember its directory
IF(WITH_STLPORT AND MFC_FOUND AND VC_DIR)
SET(MFC_STANDARD_DIR "${VC_DIR}/atlmfc")
ENDIF(WITH_STLPORT AND MFC_FOUND AND VC_DIR)
# If using STLport or MFC haven't been found, search for afxwin.h
IF(WITH_STLPORT OR NOT MFC_FOUND)
FIND_PATH(MFC_DIR
include/afxwin.h
PATHS
${MFC_STANDARD_DIR}
)
IF(CustomMFC_FIND_REQUIRED)
SET(MFC_FIND_REQUIRED TRUE)
ENDIF(CustomMFC_FIND_REQUIRED)
# Try to find MFC using official module, MFC_FOUND is set
FIND_PACKAGE(MFC)
IF(NOT MFC_DIR)
# If MFC have been found, remember their directory
IF(MFC_FOUND AND VC_DIR)
SET(MFC_STANDARD_DIR "${VC_DIR}/atlmfc")
ENDIF(MFC_FOUND AND VC_DIR)
FIND_PATH(MFC_DIR
include/afxwin.h
HINTS
${MFC_STANDARD_DIR}
)
ENDIF(NOT MFC_DIR)
# Display an error message if MFC are not found, MFC_FOUND is updated
# User will be able to update MFC_DIR to the correct directory
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MFC DEFAULT_MSG MFC_DIR)
IF(MFC_FOUND)
SET(CUSTOM_MFC_DIR TRUE)
SET(MFC_INCLUDE_DIR "${MFC_DIR}/include")
INCLUDE_DIRECTORIES(${MFC_INCLUDE_DIR})
ENDIF(MFC_FOUND)
ENDIF(WITH_STLPORT OR NOT MFC_FOUND)
# Only if using a custom path
IF(CUSTOM_MFC_DIR)
# Using 32 or 64 bits libraries
IF(TARGET_X64)
SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib/amd64")
@ -49,9 +42,7 @@ IF(CUSTOM_MFC_DIR)
# Add MFC libraries directory to default library path
LINK_DIRECTORIES(${MFC_LIBRARY_DIR})
ENDIF(CUSTOM_MFC_DIR)
IF(MFC_FOUND)
# Set definitions for using MFC in DLL
SET(MFC_DEFINITIONS -D_AFXDLL)
ENDIF(MFC_FOUND)

View file

@ -1,38 +0,0 @@
# - Find DirectInput
# Find the DirectSound includes and libraries
#
# DINPUT_INCLUDE_DIR - where to find dinput.h
# DINPUT_LIBRARIES - List of libraries when using DirectInput.
# DINPUT_FOUND - True if DirectInput found.
if(DINPUT_INCLUDE_DIR)
# Already in cache, be silent
set(DINPUT_FIND_QUIETLY TRUE)
endif(DINPUT_INCLUDE_DIR)
find_path(DINPUT_INCLUDE_DIR dinput.h
"$ENV{DXSDK_DIR}"
"$ENV{DXSDK_DIR}/Include"
)
find_library(DINPUT_LIBRARY
NAMES dinput dinput8
PATHS
"$ENV{DXSDK_DIR}"
"$ENV{DXSDK_DIR}/Lib"
"$ENV{DXSDK_DIR}/Lib/x86"
)
# Handle the QUIETLY and REQUIRED arguments and set DINPUT_FOUND to TRUE if
# all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DINPUT DEFAULT_MSG
DINPUT_INCLUDE_DIR DINPUT_LIBRARY)
if(DINPUT_FOUND)
set(DINPUT_LIBRARIES ${DINPUT_LIBRARY})
else(DINPUT_FOUND)
set(DINPUT_LIBRARIES)
endif(DINPUT_FOUND)
mark_as_advanced(DINPUT_INCLUDE_DIR DINPUT_LIBRARY)

View file

@ -0,0 +1,76 @@
# - Find MS Visual C++
#
# VC_INCLUDE_DIR - where to find headers
# VC_INCLUDE_DIRS - where to find headers
# VC_LIBRARY_DIR - where to find libraries
# VC_FOUND - True if MSVC found.
MACRO(DETECT_VC_VERSION_HELPER _ROOT _VERSION)
# Software/Wow6432Node/...
GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;${_VERSION}]" ABSOLUTE)
IF(VC${_VERSION}_DIR AND VC${_VERSION}_DIR STREQUAL "/registry")
SET(VC${_VERSION}_DIR)
GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;${_VERSION}]" ABSOLUTE)
IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
SET(VC${_VERSION}_DIR "${VC${_VERSION}_DIR}VC/")
ENDIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
ENDIF(VC${_VERSION}_DIR AND VC${_VERSION}_DIR STREQUAL "/registry")
IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
SET(VC${_VERSION}_FOUND ON)
IF(NOT MSVC_FIND_QUIETLY)
MESSAGE(STATUS "Found Visual C++ ${_VERSION} in ${VC${_VERSION}_DIR}")
ENDIF(NOT MSVC_FIND_QUIETLY)
ELSEIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
SET(VC${_VERSION}_FOUND OFF)
SET(VC${_VERSION}_DIR "")
ENDIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
ENDMACRO(DETECT_VC_VERSION_HELPER)
MACRO(DETECT_VC_VERSION _VERSION)
SET(VC${_VERSION}_FOUND OFF)
DETECT_VC_VERSION_HELPER("HKEY_CURRENT_USER" ${_VERSION})
IF(NOT VC${_VERSION}_FOUND)
DETECT_VC_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION})
ENDIF(NOT VC${_VERSION}_FOUND)
IF(NOT VC${_VERSION}_FOUND)
SET(VC_FOUND ON)
SET(VC_DIR "${VC${_VERSION}_DIR}")
ENDIF(NOT VC${_VERSION}_FOUND)
ENDMACRO(DETECT_VC_VERSION)
IF(MSVC11)
DETECT_VC_VERSION("11.0")
IF(NOT MSVC11_REDIST_DIR)
# If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC11_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC11_REDIST_DIR)
ELSEIF(MSVC10)
DETECT_VC_VERSION("10.0")
IF(NOT MSVC10_REDIST_DIR)
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC10_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC10_REDIST_DIR)
ELSEIF(MSVC90)
DETECT_VC_VERSION("9.0")
ELSEIF(MSVC80)
DETECT_VC_VERSION("8.0")
ENDIF(MSVC11)
# If you plan to use VC++ compilers with WINE, set VC_DIR environment variable
IF(NOT VC_DIR)
SET(VC_DIR $ENV{VC_DIR})
ENDIF(NOT VC_DIR)
IF(NOT VC_DIR)
STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${CMAKE_CXX_COMPILER})
ENDIF(NOT VC_DIR)
SET(VC_INCLUDE_DIR "${VC_DIR}/include")
SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR})

View file

@ -48,7 +48,8 @@
# License text for the above reference.)
FIND_PROGRAM(Mercurial_HG_EXECUTABLE hg
DOC "mercurial command line client")
DOC "mercurial command line client"
HINTS /opt/local/bin)
MARK_AS_ADVANCED(Mercurial_HG_EXECUTABLE)
IF(Mercurial_HG_EXECUTABLE)

View file

@ -6,80 +6,163 @@
# WINSDK_LIBRARY_DIR - where to find libraries
# WINSDK_FOUND - True if Windows SDK found.
IF(WINSDK_INCLUDE_DIR)
# Already in cache, be silent
SET(WindowsSDK_FIND_QUIETLY TRUE)
ENDIF(WINSDK_INCLUDE_DIR)
IF(WINSDK_FOUND)
# If Windows SDK already found, skip it
RETURN()
ENDIF(WINSDK_FOUND)
# TODO: add the possibility to use a specific Windows SDK
SET(WINSDK_VERSION "CURRENT" CACHE STRING "Windows SDK version to prefer")
IF(MSVC11)
GET_FILENAME_COMPONENT(WINSDK8_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(WINSDK8_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;ProductVersion]" NAME)
MACRO(DETECT_WINSDK_VERSION_HELPER _ROOT _VERSION)
GET_FILENAME_COMPONENT(WINSDK${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v${_VERSION};InstallationFolder]" ABSOLUTE)
IF(WINSDK8_DIR)
IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry")
SET(WINSDK${_VERSION}_FOUND ON)
GET_FILENAME_COMPONENT(WINSDK${_VERSION}_VERSION_FULL "[${_ROOT}\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v${_VERSION};ProductVersion]" NAME)
IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDK8_VERSION} in ${WINSDK8_DIR}")
MESSAGE(STATUS "Found Windows SDK ${_VERSION} in ${WINSDK${_VERSION}_DIR}")
ENDIF(NOT WindowsSDK_FIND_QUIETLY)
ELSEIF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry")
SET(WINSDK${_VERSION}_DIR "")
ENDIF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry")
ENDMACRO(DETECT_WINSDK_VERSION_HELPER)
MACRO(DETECT_WINSDK_VERSION _VERSION)
SET(WINSDK${_VERSION}_FOUND OFF)
DETECT_WINSDK_VERSION_HELPER("HKEY_CURRENT_USER" ${_VERSION})
IF(NOT WINSDK${_VERSION}_FOUND)
DETECT_WINSDK_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION})
ENDIF(NOT WINSDK${_VERSION}_FOUND)
ENDMACRO(DETECT_WINSDK_VERSION)
SET(WINSDK_VERSIONS "8.0" "8.0A" "7.1" "7.0A" "6.1" "6.0" "6.0A")
# Search all supported Windows SDKs
FOREACH(_VERSION ${WINSDK_VERSIONS})
DETECT_WINSDK_VERSION(${_VERSION})
ENDFOREACH(_VERSION)
SET(WINSDK_SUFFIX)
IF(TARGET_ARM)
SET(WINSDK8_SUFFIX "arm")
ELSEIF(TARGET_X64)
SET(WINSDK8_SUFFIX "x64")
SET(WINSDK_SUFFIX "x64")
ELSEIF(TARGET_X86)
SET(WINSDK8_SUFFIX "x86")
ENDIF(TARGET_ARM)
ENDIF(WINSDK8_DIR)
ENDIF(MSVC11)
GET_FILENAME_COMPONENT(WINSDK71_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;InstallationFolder]" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(WINSDK71_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;ProductVersion]" NAME)
IF(WINSDK71_DIR)
IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDK71_VERSION} in ${WINSDK71_DIR}")
ENDIF(NOT WindowsSDK_FIND_QUIETLY)
ENDIF(WINSDK71_DIR)
GET_FILENAME_COMPONENT(WINSDKCURRENT_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(WINSDKCURRENT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentVersion]" NAME)
IF(WINSDKCURRENT_DIR)
IF(WINSDKCURRENT_VERSION AND NOT WINSDKCURRENT_VERSION STREQUAL "/registry")
IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDKCURRENT_VERSION} in ${WINSDKCURRENT_DIR}")
# MESSAGE(STATUS "Current version is ${WINSDKCURRENT_VERSION}")
ENDIF(NOT WindowsSDK_FIND_QUIETLY)
ENDIF(WINSDKCURRENT_DIR)
ENDIF(WINSDKCURRENT_VERSION AND NOT WINSDKCURRENT_VERSION STREQUAL "/registry")
SET(WINSDKENV_DIR $ENV{WINSDK_DIR})
MACRO(USE_CURRENT_WINSDK)
IF(WINSDKENV_DIR)
SET(WINSDK_VERSION "")
SET(WINSDK_VERSION_FULL "")
SET(WINSDK_DIR ${WINSDKENV_DIR})
FOREACH(_VERSION ${WINSDK_VERSIONS})
IF(WINSDK_DIR STREQUAL WINSDK${_VERSION}_DIR)
SET(WINSDK_VERSION ${_VERSION})
SET(WINSDK_VERSION_FULL "${WINSDK${_VERSION}_VERSION_FULL}")
BREAK()
ENDIF(WINSDK_DIR STREQUAL WINSDK${_VERSION}_DIR)
ENDFOREACH(_VERSION)
ELSE(WINSDKENV_DIR)
# Windows SDK 7.0A doesn't provide 64bits compilers, use SDK 7.1 for 64 bits
IF(WINSDKCURRENT_VERSION STREQUAL WINSDK7.0A_VERSION_FULL)
IF(TARGET_X64)
SET(WINSDK_VERSION "7.1")
SET(WINSDK_VERSION_FULL ${WINSDK7.1_VERSION_FULL})
SET(WINSDK_DIR ${WINSDK7.1_DIR})
ELSE(TARGET_X64)
SET(WINSDK_VERSION "7.0A")
SET(WINSDK_VERSION_FULL ${WINSDK7.0A_VERSION_FULL})
SET(WINSDK_DIR ${WINSDK7.0A_DIR})
ENDIF(TARGET_X64)
ELSE(WINSDKCURRENT_VERSION STREQUAL WINSDK7.0A_VERSION_FULL)
FOREACH(_VERSION ${WINSDK_VERSIONS})
IF(WINSDKCURRENT_VERSION STREQUAL WINSDK${_VERSION}_VERSION)
SET(WINSDK_VERSION ${_VERSION})
SET(WINSDK_VERSION_FULL "${WINSDK${_VERSION}_VERSION_FULL}")
SET(WINSDK_DIR "${WINSDK${_VERSION}_DIR}")
BREAK()
ENDIF(WINSDKCURRENT_VERSION STREQUAL WINSDK${_VERSION}_VERSION)
ENDFOREACH(_VERSION)
ENDIF(WINSDKCURRENT_VERSION STREQUAL WINSDK7.0A_VERSION_FULL)
ENDIF(WINSDKENV_DIR)
ENDMACRO(USE_CURRENT_WINSDK)
IF(WINSDK_VERSION STREQUAL "CURRENT")
USE_CURRENT_WINSDK()
ELSE(WINSDK_VERSION STREQUAL "CURRENT")
IF(WINSDK${WINSDK_VERSION}_FOUND)
SET(WINSDK_VERSION_FULL "${WINSDK${WINSDK_VERSION}_VERSION_FULL}")
SET(WINSDK_DIR "${WINSDK${WINSDK_VERSION}_DIR}")
ELSE(WINSDK${WINSDK_VERSION}_FOUND)
USE_CURRENT_WINSDK()
ENDIF(WINSDK${WINSDK_VERSION}_FOUND)
ENDIF(WINSDK_VERSION STREQUAL "CURRENT")
IF(WINSDK_DIR)
MESSAGE(STATUS "Using Windows SDK ${WINSDK_VERSION}")
ELSE(WINSDK_DIR)
MESSAGE(FATAL_ERROR "Unable to find Windows SDK!")
ENDIF(WINSDK_DIR)
# directory where Win32 headers are found
FIND_PATH(WINSDK_INCLUDE_DIR Windows.h
HINTS
${WINSDK8_DIR}/Include/um
${WINSDK71_DIR}/Include
${WINSDKCURRENT_DIR}/Include
${WINSDK_DIR}/Include/um
${WINSDK_DIR}/Include
)
# directory where DirectX headers are found
FIND_PATH(WINSDK_SHARED_INCLUDE_DIR d3d9.h
HINTS
${WINSDK8_DIR}/Include/shared
${WINSDK71_DIR}/Include
${WINSDKCURRENT_DIR}/Include
${WINSDK_DIR}/Include/shared
${WINSDK_DIR}/Include
)
# directory where all libraries are found
FIND_PATH(WINSDK_LIBRARY_DIR ComCtl32.lib
HINTS
${WINSDK8_DIR}/Lib/win8/um/${WINSDK8_SUFFIX}
${WINSDK71_DIR}/Lib
${WINSDKCURRENT_DIR}/Lib
${WINSDK_DIR}/Lib/win8/um/${WINSDK8_SUFFIX}
${WINSDK_DIR}/Lib/${WINSDK_SUFFIX}
)
# signtool is used to sign executables
FIND_PROGRAM(WINSDK_SIGNTOOL signtool
HINTS
${WINSDK8_DIR}/Bin/x86
${WINSDK71_DIR}/Bin
${WINSDKCURRENT_DIR}/Bin
${WINSDK_DIR}/Bin/x86
${WINSDK_DIR}/Bin
)
# midl is used to generate IDL interfaces
FIND_PROGRAM(WINSDK_MIDL midl
HINTS
${WINSDK_DIR}/Bin/x86
${WINSDK_DIR}/Bin
)
IF(WINSDK_INCLUDE_DIR)
SET(WINSDK_FOUND TRUE)
SET(WINSDK_FOUND ON)
SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIR} ${WINSDK_SHARED_INCLUDE_DIR})
SET(CMAKE_LIBRARY_PATH ${WINSDK_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH})
INCLUDE_DIRECTORIES(${WINSDK_INCLUDE_DIRS})
# Fix for using Windows SDK 7.1 with Visual C++ 2012
IF(WINSDK_VERSION STREQUAL "7.1" AND MSVC11)
ADD_DEFINITIONS(-D_USING_V110_SDK71_)
ENDIF(WINSDK_VERSION STREQUAL "7.1" AND MSVC11)
ELSE(WINSDK_INCLUDE_DIR)
IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Windows SDK!")

View file

@ -19,6 +19,7 @@ IF(SOURCE_DIR)
SET(SOURCE_DIR ${ROOT_DIR})
ENDIF(NOT SOURCE_DIR AND ROOT_DIR)
ELSE(SOURCE_DIR)
SET(SOURCE_DIR ${CMAKE_SOURCE_DIR})
SET(ROOT_DIR ${CMAKE_SOURCE_DIR})
ENDIF(SOURCE_DIR)
@ -57,6 +58,15 @@ IF(EXISTS "${ROOT_DIR}/.hg/")
ENDIF(MERCURIAL_FOUND)
ENDIF(EXISTS "${ROOT_DIR}/.hg/")
# if processing exported sources, use "revision" file if exists
IF(SOURCE_DIR AND NOT DEFINED REVISION)
SET(REVISION_FILE ${SOURCE_DIR}/revision)
IF(EXISTS ${REVISION_FILE})
FILE(STRINGS ${REVISION_FILE} REVISION LIMIT_COUNT 1)
MESSAGE(STATUS "Read revision ${REVISION} from file")
ENDIF(EXISTS ${REVISION_FILE})
ENDIF(SOURCE_DIR AND NOT DEFINED REVISION)
IF(SOURCE_DIR AND DEFINED REVISION)
IF(EXISTS ${SOURCE_DIR}/revision.h.in)
MESSAGE(STATUS "Revision: ${REVISION}")

View file

@ -10,7 +10,6 @@
IF(MSVC)
SET(PCHSupport_FOUND TRUE)
SET(_PCH_include_prefix "/I")
ELSE(MSVC)
IF(CMAKE_COMPILER_IS_GNUCXX)
EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
@ -26,44 +25,50 @@ ELSE(MSVC)
# TODO: make tests for other compilers than GCC
SET(PCHSupport_FOUND TRUE)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
SET(_PCH_include_prefix "-I")
ENDIF(MSVC)
# Set PCH_FLAGS for common flags, PCH_ARCH_XXX_FLAGS for specific archs flags and PCH_ARCHS for archs
MACRO(PCH_SET_COMPILE_FLAGS _target)
SET(PCH_FLAGS)
SET(PCH_ARCHS)
SET(_FLAGS)
SET(_FLAGS)
LIST(APPEND _FLAGS ${CMAKE_CXX_FLAGS})
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" _UPPER_BUILD)
LIST(APPEND _FLAGS " ${CMAKE_CXX_FLAGS_${_UPPER_BUILD}}")
IF(NOT MSVC)
GET_TARGET_PROPERTY(_targetType ${_target} TYPE)
IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
LIST(APPEND _FLAGS " -fPIC")
LIST(APPEND _FLAGS " ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")
ELSE(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
GET_TARGET_PROPERTY(_pic ${_target} POSITION_INDEPENDENT_CODE)
IF(_pic)
LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIE}")
ENDIF(_pic)
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
ENDIF(NOT MSVC)
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES)
FOREACH(item ${DIRINC})
LIST(APPEND _FLAGS " ${_PCH_include_prefix}\"${item}\"")
LIST(APPEND _FLAGS " -I\"${item}\"")
ENDFOREACH(item)
# Required for CMake 2.6
SET(GLOBAL_DEFINITIONS)
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS)
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item)
ENDIF(DEFINITIONS)
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item)
ENDIF(DEFINITIONS)
GET_TARGET_PROPERTY(oldProps ${_target} COMPILE_FLAGS)
IF(oldProps)
@ -75,6 +80,27 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
LIST(APPEND _FLAGS " ${oldPropsBuild}")
ENDIF(oldPropsBuild)
GET_TARGET_PROPERTY(DIRINC ${_target} INCLUDE_DIRECTORIES)
IF(DIRINC)
FOREACH(item ${DIRINC})
LIST(APPEND _FLAGS " -I\"${item}\"")
ENDFOREACH(item)
ENDIF(DIRINC)
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS)
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item)
ENDIF(DEFINITIONS)
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item)
ENDIF(DEFINITIONS)
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
LIST(APPEND _FLAGS " ${GLOBAL_DEFINITIONS}")
@ -90,7 +116,6 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
SEPARATE_ARGUMENTS(_FLAGS)
ENDIF(MSVC)
IF(CLANG)
# Determining all architectures and get common flags
SET(_ARCH_NEXT)

View file

@ -0,0 +1,183 @@
# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake
# files which are included with CMake 2.8.4
# It has been altered for iOS development
#
# Options:
#
# IOS_VERSION = last(default) or specific one (4.3, 5.0, 4.1)
# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
#
# IOS_PLATFORM = OS (default) or SIMULATOR or ALL
# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
#
# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
# By default this location is automatcially chosen based on the IOS_PLATFORM value above.
# If set manually, it will override the default location and force the user of a particular Developer Platform
#
# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value.
# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path.
# If set manually, this will force the use of a specific SDK version
IF(DEFINED CMAKE_CROSSCOMPILING)
# subsequent toolchain loading is not really needed
RETURN()
ENDIF()
# Standard settings
SET(CMAKE_SYSTEM_NAME Darwin)
SET(CMAKE_SYSTEM_VERSION 1) # TODO: determine target Darwin version
SET(UNIX ON)
SET(APPLE ON)
SET(IOS ON)
# Force the compilers to Clang for iOS
include (CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER (clang Clang)
CMAKE_FORCE_CXX_COMPILER (clang++ Clang)
# Setup iOS platform
if (NOT DEFINED IOS_PLATFORM)
set (IOS_PLATFORM "OS")
endif (NOT DEFINED IOS_PLATFORM)
set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
SET(IOS_PLATFORM_LOCATION "iPhoneOS.platform")
SET(IOS_SIMULATOR_PLATFORM_LOCATION "iPhoneSimulator.platform")
# Check the platform selection and setup for developer root
if (${IOS_PLATFORM} STREQUAL "OS")
# This causes the installers to properly locate the output libraries
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
# This causes the installers to properly locate the output libraries
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
elseif (${IOS_PLATFORM} STREQUAL "ALL")
# This causes the installers to properly locate the output libraries
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator;-iphoneos")
else (${IOS_PLATFORM} STREQUAL "OS")
message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR")
endif (${IOS_PLATFORM} STREQUAL "OS")
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS ${CMAKE_XCODE_EFFECTIVE_PLATFORMS} CACHE PATH "iOS Platform")
# Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT
# Note Xcode 4.3 changed the installation location, choose the most recent one available
SET(XCODE_POST_43_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms")
SET(XCODE_PRE_43_ROOT "/Developer/Platforms")
IF(NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
IF(EXISTS ${XCODE_POST_43_ROOT})
SET(CMAKE_XCODE_ROOT ${XCODE_POST_43_ROOT})
ELSEIF(EXISTS ${XCODE_PRE_43_ROOT})
SET(CMAKE_XCODE_ROOT ${XCODE_PRE_43_ROOT})
ENDIF(EXISTS ${XCODE_POST_43_ROOT})
IF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_PLATFORM_LOCATION}/Developer)
SET(CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_XCODE_ROOT}/${IOS_PLATFORM_LOCATION}/Developer)
ENDIF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_PLATFORM_LOCATION}/Developer)
IF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_SIMULATOR_PLATFORM_LOCATION}/Developer)
SET(CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT ${CMAKE_XCODE_ROOT}/${IOS_SIMULATOR_PLATFORM_LOCATION}/Developer)
ENDIF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_SIMULATOR_PLATFORM_LOCATION}/Developer)
ENDIF(NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
SET(CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform")
SET(CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT ${CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT} CACHE PATH "Location of iOS Simulator Platform")
MACRO(GET_AVAILABLE_SDK_VERSIONS ROOT VERSIONS)
FILE(GLOB _CMAKE_IOS_SDKS "${ROOT}/SDKs/iPhoneOS*")
IF(_CMAKE_IOS_SDKS)
LIST(SORT _CMAKE_IOS_SDKS)
LIST(REVERSE _CMAKE_IOS_SDKS)
FOREACH(_CMAKE_IOS_SDK ${_CMAKE_IOS_SDKS})
STRING(REGEX REPLACE ".+iPhoneOS([0-9.]+)\\.sdk" "\\1" _IOS_SDK "${_CMAKE_IOS_SDK}")
LIST(APPEND ${VERSIONS} ${_IOS_SDK})
ENDFOREACH(_CMAKE_IOS_SDK)
ENDIF(_CMAKE_IOS_SDKS)
ENDMACRO(GET_AVAILABLE_SDK_VERSIONS)
# Find and use the most recent iOS sdk
IF(NOT DEFINED CMAKE_IOS_SDK_ROOT)
# Search for a specific version of a SDK
GET_AVAILABLE_SDK_VERSIONS(${CMAKE_IOS_DEVELOPER_ROOT} IOS_VERSIONS)
IF(NOT IOS_VERSIONS)
MESSAGE(FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
ENDIF(NOT IOS_VERSIONS)
IF(IOS_VERSION)
LIST(FIND IOS_VERSIONS "${IOS_VERSION}" _INDEX)
IF(_INDEX EQUAL -1)
LIST(GET IOS_VERSIONS 0 IOS_SDK_VERSION)
ELSE(_INDEX EQUAL -1)
SET(IOS_SDK_VERSION ${IOS_VERSION})
ENDIF(_INDEX EQUAL -1)
ELSE(IOS_VERSION)
LIST(GET IOS_VERSIONS 0 IOS_VERSION)
SET(IOS_SDK_VERSION ${IOS_VERSION})
ENDIF(IOS_VERSION)
MESSAGE(STATUS "Target iOS ${IOS_VERSION} and use SDK ${IOS_SDK_VERSION}")
SET(CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/iPhoneOS${IOS_SDK_VERSION}.sdk)
SET(CMAKE_IOS_SIMULATOR_SDK_ROOT ${CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT}/SDKs/iPhoneSimulator${IOS_SDK_VERSION}.sdk)
endif (NOT DEFINED CMAKE_IOS_SDK_ROOT)
SET(CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
SET(CMAKE_IOS_SIMULATOR_SDK_ROOT ${CMAKE_IOS_SIMULATOR_SDK_ROOT} CACHE PATH "Location of the selected iOS Simulator SDK")
SET(IOS_VERSION ${IOS_VERSION} CACHE STRING "iOS target version")
# Set the sysroot default to the most recent SDK
SET(CMAKE_IOS_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
SET(CMAKE_IOS_SIMULATOR_SYSROOT ${CMAKE_IOS_SIMULATOR_SDK_ROOT} CACHE PATH "Sysroot used for iOS Simulator support")
IF(CMAKE_GENERATOR MATCHES Xcode)
SET(ARCHS "$(ARCHS_STANDARD_32_BIT)")
IF(${IOS_PLATFORM} STREQUAL "OS")
SET(CMAKE_SYSTEM_PROCESSOR "armv7")
ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR")
SET(CMAKE_SYSTEM_PROCESSOR "x86")
ELSEIF(${IOS_PLATFORM} STREQUAL "ALL")
SET(CMAKE_SYSTEM_PROCESSOR "armv7")
ENDIF(${IOS_PLATFORM} STREQUAL "OS")
ELSE(CMAKE_GENERATOR MATCHES Xcode)
IF(${IOS_PLATFORM} STREQUAL "OS")
SET(ARCHS "armv7")
SET(CMAKE_SYSTEM_PROCESSOR "armv7")
ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR")
# iPhone simulator targets i386
SET(ARCHS "i386")
SET(CMAKE_SYSTEM_PROCESSOR "x86")
ELSEIF(${IOS_PLATFORM} STREQUAL "ALL")
SET(ARCHS "armv7;i386")
SET(CMAKE_SYSTEM_PROCESSOR "armv7")
ENDIF(${IOS_PLATFORM} STREQUAL "OS")
ENDIF(CMAKE_GENERATOR MATCHES Xcode)
# set the architecture for iOS - using ARCHS_STANDARD_32_BIT sets armv7,armv7s and appears to be XCode's standard.
# The other value that works is ARCHS_UNIVERSAL_IPHONE_OS but that sets armv7 only
set (CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE string "Build architecture for iOS")
# Set the find root to the iOS developer roots and to user defined paths
set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} $ENV{EXTERNAL_IOS_PATH} CACHE string "iOS find search path root")
# default to searching for frameworks first
set (CMAKE_FIND_FRAMEWORK FIRST)
# set up the default search directories for frameworks
set (CMAKE_SYSTEM_FRAMEWORK_PATH
${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks
${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks
${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks
)
# only search the iOS sdks, not the remainder of the host filesystem
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
#SET(CMAKE_SYSTEM_INCLUDE_PATH /include /usr/include)
#SET(CMAKE_SYSTEM_LIBRARY_PATH /lib /usr/lib)
#SET(CMAKE_SYSTEM_PROGRAM_PATH /bin /usr/bin)

View file

@ -125,10 +125,6 @@ MACRO(NL_DEFAULT_PROPS name label)
COMPILE_FLAGS "/GA"
LINK_FLAGS "/VERSION:${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}")
ENDIF(${type} STREQUAL EXECUTABLE AND WIN32)
IF(WITH_STLPORT AND WIN32)
SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "/X")
ENDIF(WITH_STLPORT AND WIN32)
ENDMACRO(NL_DEFAULT_PROPS)
###
@ -389,11 +385,11 @@ MACRO(NL_SETUP_BUILD)
SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR})
IF(HOST_CPU MATCHES "amd64")
IF(HOST_CPU MATCHES "(amd|AMD)64")
SET(HOST_CPU "x86_64")
ELSEIF(HOST_CPU MATCHES "i.86")
SET(HOST_CPU "x86")
ENDIF(HOST_CPU MATCHES "amd64")
ENDIF(HOST_CPU MATCHES "(amd|AMD)64")
# Determine target CPU
@ -402,11 +398,11 @@ MACRO(NL_SETUP_BUILD)
SET(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR})
ENDIF(NOT TARGET_CPU)
IF(TARGET_CPU MATCHES "amd64")
IF(TARGET_CPU MATCHES "(amd|AMD)64")
SET(TARGET_CPU "x86_64")
ELSEIF(TARGET_CPU MATCHES "i.86")
SET(TARGET_CPU "x86")
ENDIF(TARGET_CPU MATCHES "amd64")
ENDIF(TARGET_CPU MATCHES "(amd|AMD)64")
IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
SET(CLANG ON)
@ -418,6 +414,11 @@ MACRO(NL_SETUP_BUILD)
MESSAGE(STATUS "Generating Xcode project")
ENDIF(CMAKE_GENERATOR MATCHES "Xcode")
IF(CMAKE_GENERATOR MATCHES "NMake")
SET(NMAKE ON)
MESSAGE(STATUS "Generating NMake project")
ENDIF(CMAKE_GENERATOR MATCHES "NMake")
# If target and host CPU are the same
IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING)
# x86-compatible CPU
@ -537,6 +538,9 @@ MACRO(NL_SETUP_BUILD)
SET(MSVC11 ON)
ENDIF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11)
# Ignore default include paths
ADD_PLATFORM_FLAGS("/X")
IF(MSVC11)
ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2010, but custom optimizations don't exist
@ -896,20 +900,23 @@ ENDMACRO(NL_SETUP_BUILD)
MACRO(NL_SETUP_BUILD_FLAGS)
SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_EXE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_MODULE_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS ${PLATFORM_LINKFLAGS} CACHE STRING "" FORCE)
## Debug
SET(CMAKE_C_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_CXX_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${PLATFORM_LINKFLAGS} ${NL_DEBUG_LINKFLAGS}" CACHE STRING "" FORCE)
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${PLATFORM_LINKFLAGS} ${NL_DEBUG_LINKFLAGS}" CACHE STRING "" FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${PLATFORM_LINKFLAGS} ${NL_DEBUG_LINKFLAGS}" CACHE STRING "" FORCE)
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG ${NL_DEBUG_LINKFLAGS} CACHE STRING "" FORCE)
## Release
SET(CMAKE_C_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_CXX_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${PLATFORM_LINKFLAGS} ${NL_RELEASE_LINKFLAGS}" CACHE STRING "" FORCE)
SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${PLATFORM_LINKFLAGS} ${NL_RELEASE_LINKFLAGS}" CACHE STRING "" FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${PLATFORM_LINKFLAGS} ${NL_RELEASE_LINKFLAGS}" CACHE STRING "" FORCE)
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE ${NL_RELEASE_LINKFLAGS} CACHE STRING "" FORCE)
ENDMACRO(NL_SETUP_BUILD_FLAGS)
# Macro to create x_ABSOLUTE_PREFIX from x_PREFIX
@ -1063,74 +1070,14 @@ MACRO(SETUP_EXTERNAL)
IF(WIN32)
FIND_PACKAGE(External REQUIRED)
IF(NOT VC_DIR)
SET(VC_DIR $ENV{VC_DIR})
ENDIF(NOT VC_DIR)
IF(MSVC11)
IF(NOT MSVC_REDIST_DIR)
# If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC_REDIST_DIR)
IF(NOT VC_DIR)
IF(NOT VC_ROOT_DIR)
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\11.0_Config;InstallDir]" ABSOLUTE)
# VC_ROOT_DIR is set to "registry" when a key is not found
IF(VC_ROOT_DIR MATCHES "registry")
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\WDExpress\\11.0_Config\\Setup\\VC;InstallDir]" ABSOLUTE)
IF(VC_ROOT_DIR MATCHES "registry")
SET(VS110COMNTOOLS $ENV{VS110COMNTOOLS})
IF(VS110COMNTOOLS)
FILE(TO_CMAKE_PATH ${VS110COMNTOOLS} VC_ROOT_DIR)
ENDIF(VS110COMNTOOLS)
IF(NOT VC_ROOT_DIR)
MESSAGE(FATAL_ERROR "Unable to find VC++ 2012 directory!")
ENDIF(NOT VC_ROOT_DIR)
ENDIF(VC_ROOT_DIR MATCHES "registry")
ENDIF(VC_ROOT_DIR MATCHES "registry")
ENDIF(NOT VC_ROOT_DIR)
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR})
ENDIF(NOT VC_DIR)
ELSEIF(MSVC10)
IF(NOT MSVC_REDIST_DIR)
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC_REDIST_DIR)
IF(NOT VC_DIR)
IF(NOT VC_ROOT_DIR)
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0_Config;InstallDir]" ABSOLUTE)
# VC_ROOT_DIR is set to "registry" when a key is not found
IF(VC_ROOT_DIR MATCHES "registry")
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VCExpress\\10.0_Config;InstallDir]" ABSOLUTE)
IF(VC_ROOT_DIR MATCHES "registry")
SET(VS100COMNTOOLS $ENV{VS100COMNTOOLS})
IF(VS100COMNTOOLS)
FILE(TO_CMAKE_PATH ${VS100COMNTOOLS} VC_ROOT_DIR)
ENDIF(VS100COMNTOOLS)
IF(NOT VC_ROOT_DIR)
MESSAGE(FATAL_ERROR "Unable to find VC++ 2010 directory!")
ENDIF(NOT VC_ROOT_DIR)
ENDIF(VC_ROOT_DIR MATCHES "registry")
ENDIF(VC_ROOT_DIR MATCHES "registry")
ENDIF(NOT VC_ROOT_DIR)
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR})
ENDIF(NOT VC_DIR)
ELSE(MSVC11)
IF(NOT VC_DIR)
IF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${CMAKE_MAKE_PROGRAM})
ELSE(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
# convert compiler fullpath to VC++ path
STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER})
ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
ENDIF(NOT VC_DIR)
ENDIF(MSVC11)
# If using custom boost, we need to define the right variables used by official boost CMake module
IF(DEFINED BOOST_DIR)
SET(BOOST_INCLUDEDIR ${BOOST_DIR}/include)
SET(BOOST_LIBRARYDIR ${BOOST_DIR}/lib)
ENDIF(DEFINED BOOST_DIR)
ELSE(WIN32)
FIND_PACKAGE(External QUIET)
IF(APPLE)
IF(WITH_STATIC_EXTERNAL)
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a)
@ -1146,15 +1093,22 @@ MACRO(SETUP_EXTERNAL)
ENDIF(APPLE)
ENDIF(WIN32)
# Android and iOS have pthread
IF(ANDROID OR IOS)
SET(CMAKE_USE_PTHREADS_INIT 1)
SET(Threads_FOUND TRUE)
ELSE(ANDROID OR IOS)
FIND_PACKAGE(Threads REQUIRED)
# TODO: replace all -l<lib> by absolute path to <lib> in CMAKE_THREAD_LIBS_INIT
ENDIF(ANDROID OR IOS)
IF(WITH_STLPORT)
FIND_PACKAGE(STLport REQUIRED)
INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR})
IF(MSVC)
SET(VC_INCLUDE_DIR "${VC_DIR}/include")
FIND_PACKAGE(WindowsSDK REQUIRED)
# use VC++ and Windows SDK include paths
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIRS})
ENDIF(MSVC)
ENDIF(WITH_STLPORT)
IF(MSVC)
FIND_PACKAGE(MSVC REQUIRED)
FIND_PACKAGE(WindowsSDK REQUIRED)
ENDIF(MSVC)
ENDMACRO(SETUP_EXTERNAL)

View file

@ -6,7 +6,7 @@ GraphicsDriver = "OpenGL";
SoundDriver = "OpenAL";
SoundDevice = "";
LanguageCode = "en";
QtStyle = "Cleanlooks";
QtStyle = "";
FontName = "andbasr.ttf";
FontShadow = 1;
BackgroundColor = {

View file

@ -247,8 +247,8 @@ void CComputedString::render2DClip (IDriver& driver, CRenderStringBuffer &rdrBuf
uint lastIndex = 0;
for(uint i=0;i<numVerts;i++)
{
if(count==4){
if(count==4)
{
if(!LetterColors.empty())
{
if(LetterColors.getIndex(lastIndex)==i/4)

View file

@ -354,6 +354,9 @@ namespace NLGUI
// start to draw at the reference corner
getTextureSizeFromId (nTxId, txw, txh);
// to avoid a division by zero crash later
if (txw < 0 || txh < 0) return;
if (rot > 3) rot = 3;
sint32 startX = x, startY = y;

View file

@ -19,6 +19,7 @@
#include "nel/misc/bitmap.h"
#include "nel/misc/stream.h"
#include "nel/misc/file.h"
#include "nel/misc/system_info.h"
// Define this to force all bitmap white (debug)
// #define NEL_ALL_BITMAP_WHITE

View file

@ -189,7 +189,8 @@ gint KeyIn(GtkWidget *Widget, GdkEventKey *Event, gpointer *Data)
}
break;
case GDK_Down :
if (CommandHistoryPos + 1 < CommandHistory.size()) {
if (CommandHistoryPos + 1 < CommandHistory.size())
{
CommandHistoryPos++;
gtk_entry_set_text (GTK_ENTRY(Widget), CommandHistory[CommandHistoryPos].c_str());
}
@ -374,7 +375,8 @@ gint updateInterf (gpointer data)
{
uint32 col = (*it).first;
GtkTextTag *tag = NULL;
if ((col>>24) == 0) {
if ((col>>24) == 0)
{
GdkColor color;
color.red = (col >> 8) & 0xFF00;
color.green = col & 0xFF00;

View file

@ -37,14 +37,13 @@ namespace NLMISC
return token;
}
uint i;
uint i, j;
CSString result;
// skip leading junk
for (i=0;i<size();++i)
{
// look for the next character in the 'separator' character list supplied
uint j;
for (j=0;separators[j] && (*this)[i]!=separators[j];++j)
{}
// if not found then we're at end of leading junk
@ -56,7 +55,6 @@ namespace NLMISC
for (;i<size();++i)
{
// look for the next character in the 'separator' character list supplied
uint j;
for (j=0;separators[j] && (*this)[i]!=separators[j];++j)
{}
// if not found then we're at end of text chunk
@ -69,7 +67,6 @@ namespace NLMISC
for (;i<size();++i)
{
// look for the next character in the 'separator' character list supplied
uint j;
for (j=0;separators[j] && (*this)[i]!=separators[j];++j)
{}
// if not found then we're at end of leading junk

View file

@ -17,8 +17,6 @@
#ifndef NL_STDMISC_H
#define NL_STDMISC_H
#include "nel/misc/types_nl.h"
#include <algorithm>
#include <cmath>
#include <csignal>
@ -44,16 +42,7 @@
#include <utility>
#include <vector>
#include "nel/misc/debug.h"
#include "nel/misc/common.h"
#include "nel/misc/fast_mem.h"
#include "nel/misc/system_info.h"
#include "nel/misc/mem_displayer.h"
#include "nel/misc/stream.h"
#include "nel/misc/path.h"
#include "nel/misc/string_common.h"
#ifdef NL_OS_WINDOWS
#ifdef _WIN32
#define NOMINMAX
#include <WinSock2.h>
#include <windows.h>

View file

@ -56,7 +56,8 @@ static void uuencode (const char *s, const char *store, const int length)
unsigned char *us = (unsigned char *)s;
/* Transform the 3x8 bits to 4x6 bits, as required by base64. */
for (i = 0; i < length; i += 3) {
for (i = 0; i < length; i += 3)
{
*p++ = tbl[us[0] >> 2];
*p++ = tbl[((us[0] & 3) << 4) + (us[1] >> 4)];
*p++ = tbl[((us[1] & 0xf) << 2) + (us[2] >> 6)];
@ -64,10 +65,12 @@ static void uuencode (const char *s, const char *store, const int length)
us += 3;
}
/* Pad the result if necessary... */
if (i == length + 1) {
if (i == length + 1)
{
*(p - 1) = tbl[64];
}
else if (i == length + 2) {
else if (i == length + 2)
{
*(p - 1) = *(p - 2) = tbl[64];
}
/* ...and zero-terminate it. */

View file

@ -217,7 +217,7 @@ LRESULT APIENTRY colorSwatchSubclassWndProc(
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK: {
HWND hPanel = GetParent(hwnd);
LONG mod = GetWindowLongPtr(hPanel,GWLP_USERDATA);
LONG_PTR mod = GetWindowLongPtr(hPanel,GWLP_USERDATA);
if (mod) {
((VertexPaint*)mod)->PaletteButton(hwnd);
}
@ -424,7 +424,8 @@ void VertexPaint::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev )
SendMessage(hParams, WM_POSTINIT, 0, 0);
}
else {
else
{
SetWindowLongPtr(hParams,GWLP_USERDATA,(LONG_PTR)this);
}

View file

@ -8,6 +8,12 @@ function getDbPropU(dbEntry)
return value
end
if string.find(_VERSION, "Lua 5.0") then
function math.fmod(a, b)
return math.mod(a, b)
end
end
------------------------------------------------------------------------------------------------------------
-- create the game namespace without reseting if already created in an other file.
if (game==nil) then

View file

@ -925,32 +925,27 @@ void CChatGroupWindow::saveFreeTeller(NLMISC::IStream &f)
{
f.serialVersion(2);
uint32 nNbFreeTellerSaved = 0;
// Save the free teller only if it is present in the friend list to avoid the only-growing situation
// because free tellers are never deleted in game if we save/load all the free tellers, we just create more
// and more container.
uint32 i, nNbFreeTellerSaved = 0;
for (i = 0; i < _FreeTellers.size(); ++i)
if (PeopleInterraction.FriendList.getIndexFromName(_FreeTellers[i]->getUCTitle()) != -1)
nNbFreeTellerSaved++;
f.serial(nNbFreeTellerSaved);
// Don't save the free tellers
//// Save the free teller only if it is present in the friend list to avoid the only-growing situation
//// because free tellers are never deleted in game if we save/load all the free tellers, we just create more
//// and more container.
//uint32 i, nNbFreeTellerSaved = 0;
//for (i = 0; i < _FreeTellers.size(); ++i)
// if (PeopleInterraction.FriendList.getIndexFromName(_FreeTellers[i]->getUCTitle()) != -1)
// nNbFreeTellerSaved++;
//f.serial(nNbFreeTellerSaved);
//for (i = 0; i < _FreeTellers.size(); ++i)
//{
// CGroupContainer *pGC = _FreeTellers[i];
// if (PeopleInterraction.FriendList.getIndexFromName(pGC->getUCTitle()) != -1)
// {
// ucstring sTitle = pGC->getUCTitle();
// f.serial(sTitle);
// }
//}
for (i = 0; i < _FreeTellers.size(); ++i)
{
CGroupContainer *pGC = _FreeTellers[i];
if (PeopleInterraction.FriendList.getIndexFromName(pGC->getUCTitle()) != -1)
{
ucstring sTitle = pGC->getUCTitle();
f.serial(sTitle);
}
}
}
//=================================================================================
@ -979,12 +974,11 @@ void CChatGroupWindow::loadFreeTeller(NLMISC::IStream &f)
ucstring sTitle;
f.serial(sTitle);
// Don't actually create the free teller
//CGroupContainer *pGC = createFreeTeller(sTitle, "");
CGroupContainer *pGC = createFreeTeller(sTitle, "");
//// With version 1 all tells are active because windows information have "title based" ids and no "sID based".
//if ((ver == 1) && (pGC != NULL))
// pGC->setActive(false);
// With version 1 all tells are active because windows information have "title based" ids and no "sID based".
if ((ver == 1) && (pGC != NULL))
pGC->setActive(false);
}
}

View file

@ -3552,12 +3552,13 @@ void CUserEntity::CSpeedFactor::update(ICDBNode *node) // virtual
//nlinfo("SpeedFactor changed to %f / %"NL_I64"u", _Value, leaf->getValue64());
// clamp the value (2.0 is the egg item or the level 6 speed up power up, nothing should be faster)
if(_Value > 2.0f)
{
// commented because ring editor speed is in fact faster
//if(_Value > 2.0f)
//{
//nlwarning("HACK: you try to change the speed factor to %f", _Value);
//nlstop;
//_Value = 2.0f;
}
//}
}// CSpeedFactor::update //

View file

@ -155,6 +155,11 @@ inline double CAIVectorMirror::distTo(const CAIPos &dest) const
return (dest-CAIVector(*this)).norm();
}
inline double CAIVectorMirror::distSqTo(const CAIPos &dest) const
{
return (dest-CAIVector(*this)).sqrnorm();
}
inline double CAIVectorMirror::quickDistTo(const CAIPos &dest) const
{
double dx=fabs((dest.x()-x()).asDouble()), dy=fabs((dest.y()-y()).asDouble());
@ -172,6 +177,11 @@ inline double CAIVectorMirror::distTo(const CAIVector &dest) const
return (dest-CAIVector(*this)).norm();
}
inline double CAIVectorMirror::distSqTo(const CAIVector &dest) const
{
return (dest-CAIVector(*this)).sqrnorm();
}
inline double CAIVectorMirror::quickDistTo(const CAIVector &dest) const
{
double dx=fabs((dest.x()-x()).asDouble()), dy=fabs((dest.y()-y()).asDouble());
@ -189,6 +199,11 @@ inline double CAIVectorMirror::distTo(const CAIVectorMirror &dest) const
return (dest-*this).norm();
}
inline double CAIVectorMirror::distSqTo(const CAIVectorMirror &dest) const
{
return (dest-*this).sqrnorm();
}
inline double CAIVectorMirror::quickDistTo(const CAIVectorMirror &dest) const
{
double dx=fabs((dest.x()-x()).asDouble()), dy=fabs((dest.y()-y()).asDouble()); return (dx>dy)? (dx+dy/2): (dy+dx/2);

View file

@ -310,9 +310,9 @@ void CWanderFaunaProfile::updateProfile(uint ticksSinceLastUpdate)
CFollowPathContext fpcWanderFaunaProfileUpdate("WanderFaunaProfileUpdate");
// calculate distance from bot position to magnet point (used in all the different processes)
_magnetDist=_Bot->pos().distTo(_Bot->spawnGrp().magnetPos());
if (_magnetDist>_Bot->spawnGrp().magnetRadiusFar())
_magnetDistSq=_Bot->pos().distSqTo(_Bot->spawnGrp().magnetPos());
double grpMagnetRadiusFar=_Bot->spawnGrp().magnetRadiusFar();
if (_magnetDistSq>(grpMagnetRadiusFar*grpMagnetRadiusFar))
{
_Bot->setMode( MBEHAV::NORMAL );
@ -405,11 +405,12 @@ void CGrazeFaunaProfile::updateProfile(uint ticksSinceLastUpdate)
CFollowPathContext fpcGrazeFaunaProfileUpdate("GrazeFaunaProfileUpdate");
// calculate distance from bot position to magnet point (used in all the different processes)
_magnetDist=_Bot->pos().distTo(_Bot->spawnGrp().magnetPos());
_magnetDistSq=_Bot->pos().distSqTo(_Bot->spawnGrp().magnetPos());
if (!_ArrivedInZone)
{
if (_magnetDist>_Bot->spawnGrp().magnetRadiusFar())
float grpMagnetRadiusFar=_Bot->spawnGrp().magnetRadiusFar();
if (_magnetDistSq>(grpMagnetRadiusFar*grpMagnetRadiusFar))
{
_Bot->setMode( MBEHAV::NORMAL );
@ -501,7 +502,8 @@ void CGrazeFaunaProfile::updateProfile(uint ticksSinceLastUpdate)
}
// && _state==0 ) // means wait in movementmagnet.
if ( _magnetDist<=_Bot->spawnGrp().magnetRadiusNear()
const float grpMagnetRadiusNear=_Bot->spawnGrp().magnetRadiusNear();
if ( _magnetDistSq<=(grpMagnetRadiusNear*grpMagnetRadiusNear)
&& _MovementMagnet->getMovementType()==CMovementMagnet::Movement_Anim)
{
if (_Bot->getPersistent().grp().getType()==AITYPES::FaunaTypePredator)
@ -564,11 +566,12 @@ void CRestFaunaProfile::updateProfile(uint ticksSinceLastUpdate)
CFollowPathContext fpcRestFaunaProfileUpdate("RestFaunaProfileUpdate");
// calculate distance from bot position to magnet point (used in all the different processes)
_magnetDist=_Bot->pos().distTo(_Bot->spawnGrp().magnetPos());
_magnetDistSq=_Bot->pos().distSqTo(_Bot->spawnGrp().magnetPos());
if (!_ArrivedInZone)
{
if (_magnetDist>_Bot->spawnGrp().magnetRadiusFar())
float grpMagnetRadiusFar=_Bot->spawnGrp().magnetRadiusFar();
if (_magnetDistSq>(grpMagnetRadiusFar*grpMagnetRadiusFar))
{
if (!_OutOfMagnet)
{
@ -656,7 +659,8 @@ void CRestFaunaProfile::updateProfile(uint ticksSinceLastUpdate)
break;
}
if ( _magnetDist<=_Bot->spawnGrp().magnetRadiusNear()
const float grpMagnetRadiusNear=_Bot->spawnGrp().magnetRadiusNear();
if ( _magnetDistSq<=(grpMagnetRadiusNear*grpMagnetRadiusNear)
&& _MovementMagnet->getMovementType()==CMovementMagnet::Movement_Anim)
{
_Bot->setMode(MBEHAV::REST);

View file

@ -137,7 +137,7 @@ public:
protected:
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
CSpawnBotFauna* _Bot;
double _magnetDist; ///< distance from bot to his magnet at last move
double _magnetDistSq; ///< square distance from bot to his magnet at last move
static CFaunaProfileFloodLogger _FloodLogger;
};
@ -166,7 +166,7 @@ private:
CAITimer _CycleTimer;
uint _CycleTimerBaseTime;
bool _ArrivedInZone;
double _magnetDist; ///< distance from bot to his magnet at last move
double _magnetDistSq; ///< square distance from bot to his magnet at last move
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
static CFaunaProfileFloodLogger _FloodLogger;
};
@ -196,7 +196,7 @@ private:
CAITimer _CycleTimer;
uint _CycleTimerBaseTime;
bool _ArrivedInZone;
double _magnetDist; // distance from bot to his magnet at last move
double _magnetDistSq; // square distance from bot to his magnet at last move
RYAI_MAP_CRUNCH::TAStarFlag _DenyFlags;
static CFaunaProfileFloodLogger _FloodLogger;
};

View file

@ -83,14 +83,17 @@ public: // Methods.
// a few handy utility methods
inline CAngle angleTo(const CAIPos &dest) const;
inline double distTo(const CAIPos &dest) const;
inline double distSqTo(const CAIPos &dest) const;
inline double quickDistTo(const CAIPos &dest) const;
inline CAngle angleTo(const CAIVector &dest) const;
inline double distTo(const CAIVector &dest) const;
inline double distSqTo(const CAIVector &dest) const;
inline double quickDistTo(const CAIVector &dest) const;
inline CAngle angleTo(const CAIVectorMirror &dest) const;
inline double distTo(const CAIVectorMirror &dest) const;
inline double distSqTo(const CAIVectorMirror &dest) const;
inline double quickDistTo(const CAIVectorMirror &dest) const;
protected:

View file

@ -1607,6 +1607,7 @@ Then user events are triggered on the group to inform it about what happens:
- user_event_3: triggered after the player has given the mission items to the npc.
Warning: this function can only be called after the event "player_target_npc".
Warning: only works on an R2 shard for R2 plot items.
Arguments: s(missionItems), s(missionText), c(groupToNotify) ->
@param[in] missionItems is the list of mission items, the string format is "item1:qty1;item2:qty2;...".
@ -1709,38 +1710,6 @@ void receiveMissionItems_ssc_(CStateInstance* entity, CScriptStack& stack)
DEBUG_STOP;
return;
}
// if LD use this the function outside a ring shard
if (IsRingShard)
{
// Here we destroy the item: so we do not want that a user create a scenario where we destroy
// other players precious items
static std::set<CSheetId> r2PlotItemSheetId; // :TODO: use R2Share::CRingAccess
// lazy intialisation
if (r2PlotItemSheetId.empty())
{
for (uint32 i = 0 ; i <= 184 ; ++i)
{
r2PlotItemSheetId.insert( CSheetId( NLMISC::toString("r2_plot_item_%d.sitem", i)));
}
}
// A npc give a mission to take an item given by another npc
// but the item instead of being a r2_plot_item is a normal item like system_mp or big armor
if ( r2PlotItemSheetId.find(sheetId) == r2PlotItemSheetId.end())
{
nlwarning("!!!!!!!!!!!!");
nlwarning("!!!!!!!!!!!! Someone is trying to hack us");
nlwarning("!!!!!!!!!!!!");
nlwarning("ERROR/HACK : an npc is trying to give to a player a item that is not a plot item SheetId='%s' sheetIdAsInt=%u",sheetId.toString().c_str(), sheetId.asInt());
nlwarning("His ai instanceId is %u, use log to know the sessionId and the user ", msg.InstanceId );
nlwarning("!!!!!!!!!!!!");
nlwarning("!!!!!!!!!!!!");
return ;
}
}
uint32 quantity;
NLMISC::fromString(itemAndQty[1], quantity);
@ -1774,6 +1743,7 @@ Then user events are triggered on the group to inform it about what happens:
- user_event_1: triggered after the player has received the mission items from the npc.
Warning: this function can only be called after the event "player_target_npc".
Warning: only works on an R2 shard for R2 plot items.
Arguments: s(missionItems), s(missionText), c(groupToNotify) ->
@param[in] missionItems is the list of mission items, the string format is "item1:qty1;item2:qty2;...".
@ -1877,37 +1847,6 @@ void giveMissionItems_ssc_(CStateInstance* entity, CScriptStack& stack)
return;
}
// if LD use this the function outside a ring shard
if (IsRingShard)
{
static std::set<CSheetId> r2PlotItemSheetId; // :TODO: use R2Share::CRingAccess
// lazy intialisation
if (r2PlotItemSheetId.empty())
{
for (uint32 i = 0 ; i <= 184 ; ++i)
{
r2PlotItemSheetId.insert( CSheetId( NLMISC::toString("r2_plot_item_%d.sitem", i)));
}
}
// A npc give a mission to give a item to another npc
// but the item instead of being a r2_plot_item is a normal item like system_mp or big armor
if ( r2PlotItemSheetId.find(sheetId) == r2PlotItemSheetId.end())
{
nlwarning("!!!!!!!!!!!!");
nlwarning("!!!!!!!!!!!! Someone is trying to hack us");
nlwarning("!!!!!!!!!!!!");
nlwarning("ERROR/HACK : an npc is trying to give to a player a item that is not a plot item SheetId='%s' sheetIdAsInt=%u",sheetId.toString().c_str(), sheetId.asInt());
nlwarning("His ai instanceId is %u, use log to know the sessionId and the user ", msg.InstanceId );
nlwarning("!!!!!!!!!!!!");
nlwarning("!!!!!!!!!!!!");
return ;
}
}
uint32 quantity;
NLMISC::fromString(itemAndQty[1], quantity);
if (quantity == 0)

View file

@ -130,6 +130,7 @@ public: // Methods.
template <class V> CAngle angleTo(const V &v) const { return CAngle(atan2((v.y()-y()).asDouble(),
(v.x()-x()).asDouble())); }
template <class V> double distTo(const V &v) const { return (*this-v).norm(); }
template <class V> double distSqTo(const V &v) const { return (*this-v).sqrnorm(); }
template <class V> double quickDistTo(const V &v) const { double dx=fabs((v.x()-x()).asDouble()),
dy=fabs((v.y()-y()).asDouble());
return (dx>dy)? (dx+dy/2): (dy+dx/2); }

View file

@ -26,6 +26,7 @@
#include "player_manager/player_manager.h"
#include "player_manager/character.h"
#include "server_share/log_item_gen.h"
#include "egs_sheets/egs_sheets.h"
using namespace std;
using namespace NLMISC;
@ -154,6 +155,17 @@ void CR2MissionItem::giveMissionItem(const NLMISC::CEntityId &eid, TSessionId se
{
std::vector< CGameItemPtr > itemDropToEgg;
for( uint32 j = 0; j < items.size(); ++j )
{
const CStaticItem* sitem = CSheets::getForm(items[j].SheetId);
if (sitem == NULL)
{
nlwarning("Attempted to give deprecated sitem sheet %s to player character %s in session %i", items[j].SheetId.toString().c_str(), c->getName().toUtf8().c_str(), sessionId.asInt());
}
else if (sitem->Family != ITEMFAMILY::SCROLL_R2)
{
nlwarning("Attempted hack to give non-R2 item %s to player character %s in session %i", items[j].SheetId.toString().c_str(), c->getName().toUtf8().c_str(), sessionId.asInt());
}
else
{
CGameItemPtr item = c->createItem(1, items[j].Quantity, items[j].SheetId);
@ -197,6 +209,7 @@ void CR2MissionItem::giveMissionItem(const NLMISC::CEntityId &eid, TSessionId se
nlwarning("CR2MissionItem::giveMissionItem: can't create item %s", items[j].SheetId.toString().c_str());
}
}
}
if(itemDropToEgg.size() != 0)
{
CR2EasterEgg::getInstance().dropMissionItem(itemDropToEgg, scenarioId, c->getInstanceNumber(), eid);
@ -273,6 +286,17 @@ void CR2MissionItem::destroyMissionItem(const NLMISC::CEntityId &eid, const std:
CSheetId itemSheetId = items[j].SheetId;
uint32 quantity = items[j].Quantity;
const CStaticItem* sitem = CSheets::getForm(items[j].SheetId);
if (sitem == NULL)
{
nlwarning("Attempted to take deprecated sitem sheet %s from player character %s", items[j].SheetId.toString().c_str(), c->getName().toUtf8().c_str());
}
else if (sitem->Family != ITEMFAMILY::SCROLL_R2)
{
nlwarning("Attempted hack to take non-R2 item %s from player character %s", items[j].SheetId.toString().c_str(), c->getName().toUtf8().c_str());
}
else
{
CInventoryPtr inv = c->getInventory(INVENTORIES::bag);
nlassert( inv != NULL );
_destroyMissionItem( inv, itemSheetId, quantity );
@ -294,6 +318,7 @@ void CR2MissionItem::destroyMissionItem(const NLMISC::CEntityId &eid, const std:
}
}
}
}
//----------------------------------------------------------------------------
void CR2MissionItem::_destroyMissionItem( CInventoryPtr inv, const NLMISC::CSheetId &itemSheetId, uint32 &quantity )

View file

@ -636,6 +636,18 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
{
if (session->WriteRight) // player must have the right to speak in the channel
{
// If universal channel check if player muted
if (session->getChan()->UniversalChannel)
{
if(_MutedUsers.find( eid ) != _MutedUsers.end())
{
nldebug("IOSCM: chat The player %s:%x is muted",
TheDataset.getEntityId(sender).toString().c_str(),
sender.getIndex());
return;
}
}
if (!session->getChan()->getDontBroadcastPlayerInputs())
{
// add msg to the historic

View file

@ -490,6 +490,8 @@ void COutputFile::generateOutput() const
outbuff+="/*\n";
outbuff+="\tFILE: ";
outbuff+=_FileName+"\n\n";
outbuff+="#ifndef RY_EGS_STATIC_BRICK_CPP_H\n";
outbuff+="#define RY_EGS_STATIC_BRICK_CPP_H\n\n";
outbuff+="\tWARNING: This file is autogenerated - any modifications will be lost at next regeneration\n\n";
outbuff+="*/\n\n";
@ -505,6 +507,8 @@ void COutputFile::generateOutput() const
_Structures[i].generateOutput(outbuff);
}
outbuff+="#endif\n\n";
// read in the previous version of the output file
char *inbuff=NULL;
FILE *inf=fopen(_FileName.c_str(),"rb");
@ -631,17 +635,11 @@ void COutputFile::CStruct::generateOutput(std::string &outbuff) const
for (i=0;i<_Params.size();++i)
{
outbuff+="\t\t";
outbuff+=_Params[i]._Name+"=";
if (_Params[i]._Type==COutputFile::INT) outbuff+="atoi(";
if (_Params[i]._Type==COutputFile::FLOAT) outbuff+="(float)atof(";
outbuff+="args[";
outbuff+="NLMISC::fromString(args[";
if (i>100) outbuff+=('0'+((i/100)%10));
if (i>10) outbuff+=('0'+((i/10)%10));
outbuff+=('0'+(i%10));
if (_Params[i]._Type==COutputFile::INT || _Params[i]._Type==COutputFile::FLOAT)
outbuff+="].c_str());\n";
else
outbuff+="].c_str();\n";
outbuff+="], "+_Params[i]._Name+");\n";
}
outbuff+="\n";
outbuff+="\t\treturn *this;\n";

View file

@ -32,8 +32,6 @@
#include <nel/misc/mem_stream.h>
#include <nel/misc/sheet_id.h>
//#include <nel/3d/u_driver.h>
#ifdef NL_OS_WINDOWS
#define NOMINMAX
#include <WinSock2.h>