From 2c7f848c83b0611b77c9783df482b1822de02e46 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Aug 2013 10:30:40 +0200 Subject: [PATCH 01/31] Changed: Tabulations to spaces --- code/nel/tools/3d/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/tools/3d/CMakeLists.txt b/code/nel/tools/3d/CMakeLists.txt index 441a83800..7f4ed6b8c 100644 --- a/code/nel/tools/3d/CMakeLists.txt +++ b/code/nel/tools/3d/CMakeLists.txt @@ -24,7 +24,7 @@ IF(WITH_NEL_TOOLS) shapes_exporter tga_cut tga_resize - shape2obj + shape2obj zone_check_bind zone_dump zviewer) From c792c423dbf52efb160d571bf06f3cf52558e0c0 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Aug 2013 10:31:23 +0200 Subject: [PATCH 02/31] Fixed: X64 not detected with CMake 2.8.11 --- code/CMakeModules/nel.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 834a5da5b..c70d6acde 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -387,11 +387,11 @@ MACRO(NL_SETUP_BUILD) SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR}) - IF(HOST_CPU MATCHES "amd64") + IF(HOST_CPU MATCHES "amd64|AMD64") SET(HOST_CPU "x86_64") ELSEIF(HOST_CPU MATCHES "i.86") SET(HOST_CPU "x86") - ENDIF(HOST_CPU MATCHES "amd64") + ENDIF(HOST_CPU MATCHES "amd64|AMD64") # Determine target CPU @@ -400,11 +400,11 @@ MACRO(NL_SETUP_BUILD) SET(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR}) ENDIF(NOT TARGET_CPU) - IF(TARGET_CPU MATCHES "amd64") + IF(TARGET_CPU MATCHES "amd64|AMD64") SET(TARGET_CPU "x86_64") ELSEIF(TARGET_CPU MATCHES "i.86") SET(TARGET_CPU "x86") - ENDIF(TARGET_CPU MATCHES "amd64") + ENDIF(TARGET_CPU MATCHES "amd64|AMD64") IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") SET(CLANG ON) From a41ba055a5eb0d2dc584fe3046b4ed527b1cd934 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Aug 2013 10:32:17 +0200 Subject: [PATCH 03/31] Fixed: PCH with Qt 5 and CMake 2.8.11 --- code/CMakeModules/PCHSupport.cmake | 52 ++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index 042f6b0cc..bcca9d877 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -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,16 +25,14 @@ 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(PCH_ARCHS) + SET(_FLAGS) - LIST(APPEND _FLAGS ${CMAKE_CXX_FLAGS}) STRING(TOUPPER "${CMAKE_BUILD_TYPE}" _UPPER_BUILD) @@ -46,24 +43,33 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) LIST(APPEND _FLAGS " -fPIC") ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) + + GET_TARGET_PROPERTY(_pic ${_target} POSITION_INDEPENDENT_CODE) + IF(_pic) + LIST(APPEND _FLAGS " -fPIE") + ENDIF(_pic) 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) - FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") - ENDFOREACH(item) + IF(DEFINITIONS) + FOREACH(item ${DEFINITIONS}) + LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") + ENDFOREACH(item) + ENDIF(DEFINITIONS) GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD}) - FOREACH(item ${DEFINITIONS}) - LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") - ENDFOREACH(item) + 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 +81,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 +117,6 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) SEPARATE_ARGUMENTS(_FLAGS) ENDIF(MSVC) - IF(CLANG) # Determining all architectures and get common flags SET(_ARCH_NEXT) From f680e3943d0214ca7a3d07d83427964d750135d1 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 5 Aug 2013 10:34:38 +0200 Subject: [PATCH 04/31] Changed: Minor formatting --- code/CMakeModules/FindDirectXSDK.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/CMakeModules/FindDirectXSDK.cmake b/code/CMakeModules/FindDirectXSDK.cmake index 9947778db..dc6753a8b 100644 --- a/code/CMakeModules/FindDirectXSDK.cmake +++ b/code/CMakeModules/FindDirectXSDK.cmake @@ -6,8 +6,8 @@ # DXSDK_FOUND - True if MAX SDK found. IF(DXSDK_DIR) - # Already in cache, be silent - SET(DXSDK_FIND_QUIETLY TRUE) + # Already in cache, be silent + SET(DXSDK_FIND_QUIETLY TRUE) ENDIF(DXSDK_DIR) FIND_PATH(DXSDK_DIR @@ -26,10 +26,10 @@ FIND_PATH(DXSDK_DIR MACRO(FIND_DXSDK_LIBRARY MYLIBRARY MYLIBRARYNAME) FIND_LIBRARY(${MYLIBRARY} - NAMES ${MYLIBRARYNAME} - PATHS - "${DXSDK_LIBRARY_DIR}" - ) + NAMES ${MYLIBRARYNAME} + PATHS + "${DXSDK_LIBRARY_DIR}" + ) ENDMACRO(FIND_DXSDK_LIBRARY MYLIBRARY MYLIBRARYNAME) IF(DXSDK_DIR) From 881912fa341ec0055892c73487046a524d97062b Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 26 Aug 2013 12:33:26 +0200 Subject: [PATCH 05/31] Fixed: Crash when trying to display a missing texture --- code/nel/src/gui/view_renderer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/nel/src/gui/view_renderer.cpp b/code/nel/src/gui/view_renderer.cpp index c61d8fa51..6d3ef62e7 100644 --- a/code/nel/src/gui/view_renderer.cpp +++ b/code/nel/src/gui/view_renderer.cpp @@ -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; From 6d10e3189c1ef8b73048c84ff7102bfce04797e1 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 26 Aug 2013 12:34:04 +0200 Subject: [PATCH 06/31] Changed: Formatting --- code/nel/src/3d/computed_string.cpp | 4 ++-- code/nel/src/misc/gtk_displayer.cpp | 6 ++++-- code/nel/src/net/email.cpp | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/code/nel/src/3d/computed_string.cpp b/code/nel/src/3d/computed_string.cpp index 0c2cd48de..a4c400284 100644 --- a/code/nel/src/3d/computed_string.cpp +++ b/code/nel/src/3d/computed_string.cpp @@ -242,8 +242,8 @@ void CComputedString::render2DClip (IDriver& driver, CRenderStringBuffer &rdrBuf uint lastIndex = 0; for(uint i=0;i>24) == 0) { + if ((col>>24) == 0) + { GdkColor color; color.red = (col >> 8) & 0xFF00; color.green = col & 0xFF00; diff --git a/code/nel/src/net/email.cpp b/code/nel/src/net/email.cpp index 589e3aa8e..ae6f92477 100644 --- a/code/nel/src/net/email.cpp +++ b/code/nel/src/net/email.cpp @@ -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. */ From 3e4a567d6acb4237d577b5648ed0603a6c1d0794 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 08:43:44 +0200 Subject: [PATCH 07/31] Fixed: Don't use -fPIC and -fPIE together (this could occur in some cases) --- code/CMakeModules/PCHSupport.cmake | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index bcca9d877..9e858e3fe 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -38,17 +38,16 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) 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") - ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) + GET_TARGET_PROPERTY(_targetType ${_target} TYPE) + IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) + 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 " -fPIE") + LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIE}") ENDIF(_pic) - ENDIF(NOT MSVC) + ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES) FOREACH(item ${DIRINC}) From 26679e767e7673e3fd85ea4744123941e88d414f Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 08:44:57 +0200 Subject: [PATCH 08/31] Changed: Allow to put a "revision" file in root directory if .hg directory is not present --- code/CMakeModules/GetRevision.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/code/CMakeModules/GetRevision.cmake b/code/CMakeModules/GetRevision.cmake index 18e997af2..21b234f74 100644 --- a/code/CMakeModules/GetRevision.cmake +++ b/code/CMakeModules/GetRevision.cmake @@ -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}") From a52df4c7108a893b1f377b56c1a450759406a929 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 08:58:02 +0200 Subject: [PATCH 09/31] Changed: Factorized AMD/amd --- code/CMakeModules/nel.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index c70d6acde..7ed4a1c6c 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -387,11 +387,11 @@ MACRO(NL_SETUP_BUILD) SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR}) - IF(HOST_CPU MATCHES "amd64|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|AMD64") + ENDIF(HOST_CPU MATCHES "(amd|AMD)64") # Determine target CPU @@ -400,11 +400,11 @@ MACRO(NL_SETUP_BUILD) SET(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR}) ENDIF(NOT TARGET_CPU) - IF(TARGET_CPU MATCHES "amd64|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|AMD64") + ENDIF(TARGET_CPU MATCHES "(amd|AMD)64") IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") SET(CLANG ON) From 969d9a057de4ae00e0c2beb61a7c63402e25d237 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 08:58:36 +0200 Subject: [PATCH 10/31] Changed: Display a message when compiling with NMake and define NMAKE --- code/CMakeModules/nel.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 7ed4a1c6c..1f3d45766 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -416,6 +416,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 From a71f08274e083b7aa921cfdc1fed9b61bedc8af5 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 09:00:33 +0200 Subject: [PATCH 11/31] Changed: Use PLATFORM_LINKFLAGS in *_LINKER_FLAGS --- code/CMakeModules/nel.cmake | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 1f3d45766..82b9ca815 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -899,20 +899,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 From 651065e4edded6fc6365a8ea4a142fbf915d243d Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 09:01:42 +0200 Subject: [PATCH 12/31] Added: MSVC module to use later --- code/CMakeModules/FindMSVC.cmake | 76 ++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 code/CMakeModules/FindMSVC.cmake diff --git a/code/CMakeModules/FindMSVC.cmake b/code/CMakeModules/FindMSVC.cmake new file mode 100644 index 000000000..822e752dd --- /dev/null +++ b/code/CMakeModules/FindMSVC.cmake @@ -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}) From 4a4b9b5ab803ca8ae7fbb2c533167c355f369d43 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 09:02:48 +0200 Subject: [PATCH 13/31] Changed: Detect hg binary under Mac OS X if /opt/local/bin is not in PATH --- code/CMakeModules/FindMercurial.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/CMakeModules/FindMercurial.cmake b/code/CMakeModules/FindMercurial.cmake index a18e50c43..b0602cbdf 100644 --- a/code/CMakeModules/FindMercurial.cmake +++ b/code/CMakeModules/FindMercurial.cmake @@ -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) @@ -58,7 +59,7 @@ IF(Mercurial_HG_EXECUTABLE) STRING(REGEX REPLACE ".*version ([\\.0-9]+).*" "\\1" Mercurial_VERSION_HG "${Mercurial_VERSION_HG}") - + MACRO(Mercurial_WC_INFO dir prefix) EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} tip --template "{rev};{node};{tags};{author}" WORKING_DIRECTORY ${dir} From 3a7cee4aa7ecf6f6efff89542bee34e3a02ceabb Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 09:26:23 +0200 Subject: [PATCH 14/31] Changed: Improved MFC module --- code/CMakeModules/FindCustomMFC.cmake | 45 +++++++++++---------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/code/CMakeModules/FindCustomMFC.cmake b/code/CMakeModules/FindCustomMFC.cmake index 7dd87c15f..6f2f163d3 100644 --- a/code/CMakeModules/FindCustomMFC.cmake +++ b/code/CMakeModules/FindCustomMFC.cmake @@ -4,42 +4,35 @@ # MFC_LIBRARY_DIR, where to find libraries # MFC_INCLUDE_DIR, where to find headers +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) -SET(CUSTOM_MFC_DIR FALSE) +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) -# 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 + HINTS ${MFC_STANDARD_DIR} ) +ENDIF(NOT MFC_DIR) - IF(CustomMFC_FIND_REQUIRED) - SET(MFC_FIND_REQUIRED TRUE) - ENDIF(CustomMFC_FIND_REQUIRED) +# 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) - # 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(MFC_INCLUDE_DIR "${MFC_DIR}/include") + INCLUDE_DIRECTORIES(${MFC_INCLUDE_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) From 6ddf4786fff5dcd7e469da92ab2f71ad722c0a66 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 09:30:54 +0200 Subject: [PATCH 15/31] Changed: Use /X everytime with MSVC --- code/CMakeModules/nel.cmake | 102 +++++++++--------------------------- 1 file changed, 24 insertions(+), 78 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 82b9ca815..bcd32d052 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -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) ### @@ -540,6 +536,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 @@ -1069,74 +1068,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) @@ -1152,15 +1091,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 by absolute path to 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) From 3988120c55fcf0665857669594daf0a76780d184 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 13:35:43 +0200 Subject: [PATCH 16/31] Changed: Allows to choose a specific Windows SDK version with WINSDK_VERSION Changed: Look for all installed Windows SDKs --- code/CMakeModules/FindWindowsSDK.cmake | 166 ++++++++++++++++++------- 1 file changed, 123 insertions(+), 43 deletions(-) diff --git a/code/CMakeModules/FindWindowsSDK.cmake b/code/CMakeModules/FindWindowsSDK.cmake index 9d9b91777..8f6ed5772 100644 --- a/code/CMakeModules/FindWindowsSDK.cmake +++ b/code/CMakeModules/FindWindowsSDK.cmake @@ -6,80 +6,160 @@ # 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) - IF(TARGET_ARM) - SET(WINSDK8_SUFFIX "arm") - ELSEIF(TARGET_X64) - SET(WINSDK8_SUFFIX "x64") - ELSEIF(TARGET_X86) - SET(WINSDK8_SUFFIX "x86") - ENDIF(TARGET_ARM) - ENDIF(WINSDK8_DIR) -ENDIF(MSVC11) + 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) -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) +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) -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) +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) + +IF(TARGET_ARM) + SET(WINSDK8_SUFFIX "arm") +ELSEIF(TARGET_X64) + SET(WINSDK8_SUFFIX "x64") +ELSEIF(TARGET_X86) + SET(WINSDK8_SUFFIX "x86") +ENDIF(TARGET_ARM) -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 ) +# 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!") From f2bc8f3c8c4493b61ca94a94a25ca49e4f9a8e2e Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 13:38:19 +0200 Subject: [PATCH 17/31] Added: Toolchains for Android and iOS --- code/CMakeModules/AndroidToolChain.cmake | 149 ++++++++++++++++++ code/CMakeModules/iOSToolChain.cmake | 183 +++++++++++++++++++++++ 2 files changed, 332 insertions(+) create mode 100644 code/CMakeModules/AndroidToolChain.cmake create mode 100644 code/CMakeModules/iOSToolChain.cmake diff --git a/code/CMakeModules/AndroidToolChain.cmake b/code/CMakeModules/AndroidToolChain.cmake new file mode 100644 index 000000000..049c39adf --- /dev/null +++ b/code/CMakeModules/AndroidToolChain.cmake @@ -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) diff --git a/code/CMakeModules/iOSToolChain.cmake b/code/CMakeModules/iOSToolChain.cmake new file mode 100644 index 000000000..5b419778e --- /dev/null +++ b/code/CMakeModules/iOSToolChain.cmake @@ -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) From d196f05b7e99ee6ab006fb146244f580307264e2 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 14:44:03 +0200 Subject: [PATCH 18/31] Removed: DInput module because it's not used anymore --- code/CMakeModules/FindDInput.cmake | 38 ------------------------------ 1 file changed, 38 deletions(-) delete mode 100644 code/CMakeModules/FindDInput.cmake diff --git a/code/CMakeModules/FindDInput.cmake b/code/CMakeModules/FindDInput.cmake deleted file mode 100644 index 100650652..000000000 --- a/code/CMakeModules/FindDInput.cmake +++ /dev/null @@ -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) From a62b5068f718c8089fcfcff6a4f9e4a2c929c6f0 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 14:45:48 +0200 Subject: [PATCH 19/31] Changed: Replace atoi by NLMISC::fromString --- .../brick_param_extractor.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/code/ryzom/tools/server/brick_param_extractor/brick_param_extractor.cpp b/code/ryzom/tools/server/brick_param_extractor/brick_param_extractor.cpp index 0ff24e0f9..1a4257a99 100644 --- a/code/ryzom/tools/server/brick_param_extractor/brick_param_extractor.cpp +++ b/code/ryzom/tools/server/brick_param_extractor/brick_param_extractor.cpp @@ -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"; From 37fa1fa1ec35c9b8116a88f8670c3409d6994653 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 14:48:21 +0200 Subject: [PATCH 20/31] Fixed: Use 32 bits libraries from Windows SDK in 64 bits --- code/CMakeModules/FindWindowsSDK.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/CMakeModules/FindWindowsSDK.cmake b/code/CMakeModules/FindWindowsSDK.cmake index 8f6ed5772..1b2affb99 100644 --- a/code/CMakeModules/FindWindowsSDK.cmake +++ b/code/CMakeModules/FindWindowsSDK.cmake @@ -43,10 +43,13 @@ 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) @@ -133,7 +136,7 @@ FIND_PATH(WINSDK_SHARED_INCLUDE_DIR d3d9.h FIND_PATH(WINSDK_LIBRARY_DIR ComCtl32.lib HINTS ${WINSDK_DIR}/Lib/win8/um/${WINSDK8_SUFFIX} - ${WINSDK_DIR}/Lib + ${WINSDK_DIR}/Lib/${WINSDK_SUFFIX} ) # signtool is used to sign executables From ca9597e11e7a130ca7b5a8fad15c182b0344c37e Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 14:49:12 +0200 Subject: [PATCH 21/31] Changed: Cleanlooks doesn't exist anymore in Qt 5, so use default style --- code/nel/samples/3d/nel_qt/nel_qt.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/samples/3d/nel_qt/nel_qt.cfg b/code/nel/samples/3d/nel_qt/nel_qt.cfg index b2c141f89..b87b4767a 100644 --- a/code/nel/samples/3d/nel_qt/nel_qt.cfg +++ b/code/nel/samples/3d/nel_qt/nel_qt.cfg @@ -6,7 +6,7 @@ GraphicsDriver = "OpenGL"; SoundDriver = "OpenAL"; SoundDevice = ""; LanguageCode = "en"; -QtStyle = "Cleanlooks"; +QtStyle = ""; FontName = "andbasr.ttf"; FontShadow = 1; BackgroundColor = { From d03c795dd820bb95f7845f5aa3f26eeeb48e07b3 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 14:50:19 +0200 Subject: [PATCH 22/31] Changed: Don't use NLMISC includes in NLMISC PCH --- code/nel/src/misc/stdmisc.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/code/nel/src/misc/stdmisc.h b/code/nel/src/misc/stdmisc.h index 1c1cda1e5..432ec02b0 100644 --- a/code/nel/src/misc/stdmisc.h +++ b/code/nel/src/misc/stdmisc.h @@ -17,8 +17,6 @@ #ifndef NL_STDMISC_H #define NL_STDMISC_H -#include "nel/misc/types_nl.h" - #include #include #include @@ -44,16 +42,7 @@ #include #include -#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 #include From 86dfd0350b6e0efe5e5cf7f71ca27ded4a7c9b2e Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 14:51:21 +0200 Subject: [PATCH 23/31] Fixed: Integer 32 bits conversion to 64 bits pointer --- .../nel_vertex_tree_paint/vertex_tree_paint.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp index 9c82f5421..a2465ba4c 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp @@ -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,9 +424,10 @@ void VertexPaint::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev ) SendMessage(hParams, WM_POSTINIT, 0, 0); } - else { + else + { SetWindowLongPtr(hParams,GWLP_USERDATA,(LONG_PTR)this); - } + } iTint = SetupIntSpinner (hParams, IDC_TINT_SPIN, IDC_TINT, 0, 100, (int) (fTint*100.0f)); @@ -440,7 +441,7 @@ void VertexPaint::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev ) // Force an eval to update caches. NotifyDependents(FOREVER, PART_VERTCOLOR, REFMSG_CHANGE); - } +} void VertexPaint::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next) { From 3c37af1bbc474bb3f22cedf6b8eb43ef97540346 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 14:53:40 +0200 Subject: [PATCH 24/31] Fixed: Define math.fmod as a function for Lua 5.0 --- code/ryzom/client/data/gamedev/interfaces_v3/player.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/player.lua b/code/ryzom/client/data/gamedev/interfaces_v3/player.lua index 062f09690..3827593b1 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/player.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/player.lua @@ -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 From 980b7120c8a78f42213a5c2a46cca598083bb5cc Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 15:00:01 +0200 Subject: [PATCH 25/31] Changed: Merged code from official client --- .../client/src/interface_v3/chat_window.cpp | 56 +++++++++---------- .../src/input_output_service/chat_manager.cpp | 12 ++++ 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 24b1e15c6..e74392432 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -924,33 +924,28 @@ void CChatGroupWindow::removeAllFreeTellers() void CChatGroupWindow::saveFreeTeller(NLMISC::IStream &f) { f.serialVersion(2); - - uint32 nNbFreeTellerSaved = 0; - - 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); - // } - //} + // 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); + } + } } //================================================================================= @@ -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); } } diff --git a/code/ryzom/server/src/input_output_service/chat_manager.cpp b/code/ryzom/server/src/input_output_service/chat_manager.cpp index a4765c300..50c58fce6 100644 --- a/code/ryzom/server/src/input_output_service/chat_manager.cpp +++ b/code/ryzom/server/src/input_output_service/chat_manager.cpp @@ -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 From 89b945bb8cebfce49158da5afc51b80e16b2a287 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 6 Sep 2013 15:00:35 +0200 Subject: [PATCH 26/31] Changed: Minor changes --- code/nel/src/misc/sstring.cpp | 5 +--- .../client/client_config/display_dlg.cpp | 28 +++++++++---------- code/ryzom/tools/sheets_packer/stdpch.h | 2 -- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/code/nel/src/misc/sstring.cpp b/code/nel/src/misc/sstring.cpp index 492a00db1..fe9332328 100644 --- a/code/nel/src/misc/sstring.cpp +++ b/code/nel/src/misc/sstring.cpp @@ -37,14 +37,13 @@ namespace NLMISC return token; } - uint i; + uint i, j; CSString result; // skip leading junk for (i=0;i #include -//#include - #ifdef NL_OS_WINDOWS #define NOMINMAX #include From e99bf91b20877b9e0009172c9fdc93116e7c2e7a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 7 Sep 2013 15:51:30 +0200 Subject: [PATCH 27/31] Move r2 plot item security off the AIS to the EGS and remove hardcoded sheet ids --- .../server/src/ai_service/nf_grp_npc.cpp | 65 +-------- .../modules/r2_mission_item.cpp | 129 +++++++++++------- 2 files changed, 79 insertions(+), 115 deletions(-) diff --git a/code/ryzom/server/src/ai_service/nf_grp_npc.cpp b/code/ryzom/server/src/ai_service/nf_grp_npc.cpp index 0672269fc..25fd7e4e0 100644 --- a/code/ryzom/server/src/ai_service/nf_grp_npc.cpp +++ b/code/ryzom/server/src/ai_service/nf_grp_npc.cpp @@ -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 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 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) diff --git a/code/ryzom/server/src/entities_game_service/modules/r2_mission_item.cpp b/code/ryzom/server/src/entities_game_service/modules/r2_mission_item.cpp index d51682761..7feea7f00 100644 --- a/code/ryzom/server/src/entities_game_service/modules/r2_mission_item.cpp +++ b/code/ryzom/server/src/entities_game_service/modules/r2_mission_item.cpp @@ -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; @@ -155,46 +156,58 @@ void CR2MissionItem::giveMissionItem(const NLMISC::CEntityId &eid, TSessionId se std::vector< CGameItemPtr > itemDropToEgg; for( uint32 j = 0; j < items.size(); ++j ) { - CGameItemPtr item = c->createItem(1, items[j].Quantity, items[j].SheetId); - - if( item != NULL ) + const CStaticItem* sitem = CSheets::getForm(items[j].SheetId); + if (sitem == NULL) { - if( c->addItemToInventory(INVENTORIES::bag, item) ) - { -/* // check eid is registered as character have instantiated mission item for this scenario - TMissionItemInstanciatedOwner::iterator it = _OwnerOfInstanciatedItemFromScenario.find(scenarioId); - if( it == _OwnerOfInstanciatedItemFromScenario.end() ) - { - pair< TMissionItemInstanciatedOwner::iterator, bool > ret = _OwnerOfInstanciatedItemFromScenario.insert( make_pair( scenarioId, vector< CEntityId >() ) ); - if( ret.second ) - { - (*ret.first).second.push_back( eid ); - } - } - else - { - bool found = false; - for( uint32 i = 0; i < (*it).second.size(); ++ i ) - { - if( (*it).second[i] == eid ) - { - found = true; - break; - } - } - if ( ! found) { (*it).second.push_back(eid); } - } -*/ - keepR2ItemAssociation(eid, scenarioId); - } - else - { - itemDropToEgg.push_back(item); - } + 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 { - nlwarning("CR2MissionItem::giveMissionItem: can't create item %s", items[j].SheetId.toString().c_str()); + CGameItemPtr item = c->createItem(1, items[j].Quantity, items[j].SheetId); + + if( item != NULL ) + { + if( c->addItemToInventory(INVENTORIES::bag, item) ) + { + /* // check eid is registered as character have instantiated mission item for this scenario + TMissionItemInstanciatedOwner::iterator it = _OwnerOfInstanciatedItemFromScenario.find(scenarioId); + if( it == _OwnerOfInstanciatedItemFromScenario.end() ) + { + pair< TMissionItemInstanciatedOwner::iterator, bool > ret = _OwnerOfInstanciatedItemFromScenario.insert( make_pair( scenarioId, vector< CEntityId >() ) ); + if( ret.second ) + { + (*ret.first).second.push_back( eid ); + } + } + else + { + bool found = false; + for( uint32 i = 0; i < (*it).second.size(); ++ i ) + { + if( (*it).second[i] == eid ) + { + found = true; + break; + } + } + if ( ! found) { (*it).second.push_back(eid); } + } + */ + keepR2ItemAssociation(eid, scenarioId); + } + else + { + itemDropToEgg.push_back(item); + } + } + else + { + nlwarning("CR2MissionItem::giveMissionItem: can't create item %s", items[j].SheetId.toString().c_str()); + } } } if(itemDropToEgg.size() != 0) @@ -273,24 +286,36 @@ void CR2MissionItem::destroyMissionItem(const NLMISC::CEntityId &eid, const std: CSheetId itemSheetId = items[j].SheetId; uint32 quantity = items[j].Quantity; - CInventoryPtr inv = c->getInventory(INVENTORIES::bag); - nlassert( inv != NULL ); - _destroyMissionItem( inv, itemSheetId, quantity ); - if( quantity > 0) + const CStaticItem* sitem = CSheets::getForm(items[j].SheetId); + if (sitem == NULL) { - for( uint32 j = INVENTORIES::pet_animal; j < INVENTORIES::max_pet_animal; ++j ) - { - inv = c->getInventory((INVENTORIES::TInventory)j); - nlassert(inv != NULL); - _destroyMissionItem( inv, itemSheetId, quantity ); - if(quantity == 0) - break; - } + 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 ); + if( quantity > 0) + { + for( uint32 j = INVENTORIES::pet_animal; j < INVENTORIES::max_pet_animal; ++j ) + { + inv = c->getInventory((INVENTORIES::TInventory)j); + nlassert(inv != NULL); + _destroyMissionItem( inv, itemSheetId, quantity ); + if(quantity == 0) + break; + } + } + // TODO: if we can't found enough quantity of item to destroy, we need decide if we must manage that as an error + // if(quantity > 0) + // { + // } } - // TODO: if we can't found enough quantity of item to destroy, we need decide if we must manage that as an error -// if(quantity > 0) -// { -// } } } } From 9e1ca3d1d0b502752172f42aadd9bf0765255d14 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 7 Sep 2013 15:53:00 +0200 Subject: [PATCH 28/31] Comment if-check around commented unused client-side speed limiting code --- code/ryzom/client/src/user_entity.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/ryzom/client/src/user_entity.cpp b/code/ryzom/client/src/user_entity.cpp index 5f7fc3868..c8652fd43 100644 --- a/code/ryzom/client/src/user_entity.cpp +++ b/code/ryzom/client/src/user_entity.cpp @@ -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 // From 082ce825a5d2491622db453b3843fc15c27f7c62 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 7 Sep 2013 15:53:10 +0200 Subject: [PATCH 29/31] Add distSqTo to CAIVector --- .../server/src/ai_service/ai_pos_mirror_inline.h | 15 +++++++++++++++ .../server/src/ai_service/ai_vector_mirror.h | 3 +++ code/ryzom/server/src/ai_share/ai_vector.h | 1 + 3 files changed, 19 insertions(+) diff --git a/code/ryzom/server/src/ai_service/ai_pos_mirror_inline.h b/code/ryzom/server/src/ai_service/ai_pos_mirror_inline.h index b75c54f1a..4185adafa 100644 --- a/code/ryzom/server/src/ai_service/ai_pos_mirror_inline.h +++ b/code/ryzom/server/src/ai_service/ai_pos_mirror_inline.h @@ -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); diff --git a/code/ryzom/server/src/ai_service/ai_vector_mirror.h b/code/ryzom/server/src/ai_service/ai_vector_mirror.h index dc03305bc..0464de4fb 100644 --- a/code/ryzom/server/src/ai_service/ai_vector_mirror.h +++ b/code/ryzom/server/src/ai_service/ai_vector_mirror.h @@ -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: diff --git a/code/ryzom/server/src/ai_share/ai_vector.h b/code/ryzom/server/src/ai_share/ai_vector.h index 34a82bb82..8c818b70a 100644 --- a/code/ryzom/server/src/ai_share/ai_vector.h +++ b/code/ryzom/server/src/ai_share/ai_vector.h @@ -130,6 +130,7 @@ public: // Methods. template CAngle angleTo(const V &v) const { return CAngle(atan2((v.y()-y()).asDouble(), (v.x()-x()).asDouble())); } template double distTo(const V &v) const { return (*this-v).norm(); } + template double distSqTo(const V &v) const { return (*this-v).sqrnorm(); } template 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); } From 68f20a3369d86f46e3874d39b06ab1a8da3a6c63 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 7 Sep 2013 15:53:17 +0200 Subject: [PATCH 30/31] Use distSqTo instead of distTo --- .../src/ai_service/ai_profile_fauna.cpp | 22 +++++++++++-------- .../server/src/ai_service/ai_profile_fauna.h | 6 ++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/code/ryzom/server/src/ai_service/ai_profile_fauna.cpp b/code/ryzom/server/src/ai_service/ai_profile_fauna.cpp index 41b0504d9..354cccdfc 100644 --- a/code/ryzom/server/src/ai_service/ai_profile_fauna.cpp +++ b/code/ryzom/server/src/ai_service/ai_profile_fauna.cpp @@ -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); diff --git a/code/ryzom/server/src/ai_service/ai_profile_fauna.h b/code/ryzom/server/src/ai_service/ai_profile_fauna.h index 1c3499080..e85f2b709 100644 --- a/code/ryzom/server/src/ai_service/ai_profile_fauna.h +++ b/code/ryzom/server/src/ai_service/ai_profile_fauna.h @@ -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; }; From 361b7eab747df9aaa47e4ae16b53c1ece688e1ab Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 7 Sep 2013 16:05:28 +0200 Subject: [PATCH 31/31] Fix compile error --- code/nel/src/misc/bitmap.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index cfe8cab89..f32980508 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -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