Merge with develop

--HG--
branch : opengl3
hg/feature/opengl3
kaetemi 9 years ago
commit bbecb833b3

@ -0,0 +1,19 @@
; Top-most EditorConfig file
root = true
; 4-column tab indentation
[*.cpp]
indent_style = tab
indent_size = 4
[*.c]
indent_style = tab
indent_size = 4
[*.h]
indent_style = tab
indent_size = 4
[*.py]
indent_style = tab
indent_size = 4

265
.gitignore vendored

@ -0,0 +1,265 @@
syntax: glob
# Various build directories
bin
obj
Debug
Release
ReleaseDebug
DebugFast
ReleaseDebugStatic
DebugFastStatic
# Test and application directories
screenshots
release
test
Temp
# NeL cache
*.packed_sheets
# Ryzom save
save_shard
last_loaded_char.bin
*.binprim
*.string_cache
graphs_output
default_c
# Windows compile
*.exe
*.dll
*.lib
*.obj
# Linux compile
*.a
*.la
*.lo
*.Po
*.Plo
*.o
*.so
*.so.*
*_debug
*.pc
*.gch
# Mac OS X compile
*.dylib
# Log dump files
report_refused
report_failed
exception_catched
*.stat
*.log
log.txt
# Max plugin extensions
*.dlx
*.dlm
*.dlu
# makeall build
.mode_static
# cmake build files & directories
CMakeFiles
CMakeCache.txt
cmake_install.cmake
CTestTestfile.cmake
CPackConfig.cmake
CPackSourceConfig.cmake
.libs
# Linux garbage
Makefile*
aclocal.m4
config.guess
config.sub
configure
depcomp
config.h.in
nelconfig.h.in
install-sh
ltmain.sh
missing
ylwrap
*.mk
# Visual Studio garbage
*.opensdf
UpgradeLog*.XML
_UpgradeReport_Files
BuildLog.htm
mt.dep
ipch
*.suo
*.ncb
*.user
*.ilk
*.pdb
*.aps
*.exp
*.idb
*.sdf
# Mac OS X garbage
.DS_Store
# Ryzom server garbage
aes_alias_name.cfg
aes_nagios_report.txt
aes_state.txt
*.launch_ctrl
*.state
*.start_count
# Vim and kwrite cache
*~
# Kdevelop4 garbage
*.kdev4
.kdev4
# intellij project folder
.idea/
# Python cache
*.pyd
*.pyc
# Qt compiler
moc_*.cpp
*.moc
# Misc garbage
*.rej
*.orig
*.cachefile
*.cache
*.patch
*.7z
3rdParty
.svn
thumbs.db
Thumbs.db
*.tpl.php
.SyncID
.SyncIgnore
.SyncArchive
# build
code/nel/build/*
code/nelns/build/*
code/snowballs/build/*
code/ryzom/build/*
code/build/*
code/build-2010/*
build/*
install/*
build_vc*
code/nel/tools/build_gamedata/configuration/buildsite.py
# Linux nel compile
code/nel/build/nel-config
code/nel/config.status
code/nel/include/nelconfig.h
code/nel/include/stamp-h1
code/nel/libtool
code/nel/nel-config
code/nel/samples/3d/cluster_viewer/cluster_viewer
code/nel/samples/3d/font/font
code/nel/samples/georges/georges
code/nel/samples/misc/command/command
code/nel/samples/misc/configfile/configfile
code/nel/samples/misc/debug/debug
code/nel/samples/misc/i18n/i18n
code/nel/samples/misc/log/log
code/nel/samples/misc/strings/strings
code/nel/samples/net/chat/chatclient
code/nel/samples/net/chat/chatserver
code/nel/samples/net/login_system/nls_frontend_service
code/nel/samples/net/login_system/nls_login_client
code/nel/samples/net/udp/udp_bench_client
code/nel/samples/net/udp/udp_bench_service
code/nel/samples/pacs/pacs_sample
code/nel/tools/3d/build_coarse_mesh/build_coarse_mesh
code/nel/tools/3d/build_far_bank/build_far_bank
code/nel/tools/3d/build_smallbank/build_smallbank
code/nel/tools/3d/ig_lighter/ig_lighter
code/nel/tools/3d/zone_dependencies/zone_dependencies
code/nel/tools/3d/zone_ig_lighter/zone_ig_lighter
code/nel/tools/3d/zone_lighter/zone_lighter
code/nel/tools/3d/zone_welder/zone_welder
code/nel/tools/misc/bnp_make/bnp_make
code/nel/tools/misc/disp_sheet_id/disp_sheet_id
code/nel/tools/misc/make_sheet_id/make_sheet_id
code/nel/tools/misc/xml_packer/xml_packer
code/nel/tools/pacs/build_ig_boxes/build_ig_boxes
code/nel/tools/pacs/build_indoor_rbank/build_indoor_rbank
code/nel/tools/pacs/build_rbank/build_rbank
code/ryzom/common/data_leveldesign/leveldesign/game_element/xp_table/skills.skill_tree
code/ryzom/common/data_leveldesign/leveldesign/game_element/xp_table/xptable.xp_table
code/ryzom/tools/server/sql/ryzom_admin_default_data.sql
# Linux server compile
code/ryzom/server/src/entities_game_service/entities_game_service
code/ryzom/server/src/frontend_service/frontend_service
code/ryzom/server/src/gpm_service/gpm_service
code/ryzom/server/src/input_output_service/input_output_service
code/ryzom/server/src/mirror_service/mirror_service
code/ryzom/server/src/ryzom_admin_service/ryzom_admin_service
code/ryzom/server/src/ryzom_naming_service/ryzom_naming_service
code/ryzom/server/src/ryzom_welcome_service/ryzom_welcome_service
code/ryzom/server/src/tick_service/tick_service
# WebTT temp dir
code/ryzom/tools/server/www/webtt/app/tmp
# AMS ignore
code/web/public_php/ams/is_installed
code/web/docs/ams/html
code/web/public_php/ams/templates_c
code/ryzom/tools/server/ryzom_ams/drupal
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/autoload
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/configs
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/cron
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/img
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/plugins
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/smarty
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/translations
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/libinclude.php
code/ryzom/tools/server/ryzom_ams/old
#tools and external dir's
external
external_stlport
nel_tools*
ryzom_tools*
#Dumps
*.dmp
code/nel/tools/build_gamedata/processes/ai_wmap/ai_build_wmap.cfg
code/nel/tools/build_gamedata/processes/sheets/sheets_packer.cfg
code/nel/tools/build_gamedata/processes/rbank/build_rbank.cfg
code/nel/tools/build_gamedata/processes/zone/debug_zone_dependencies.cfg
code/web/public_php/config.php
code/web/public_php/is_installed
code/web/public_php/ams/files
code/web/public_php/db_version_lib
code/web/public_php/db_version_shard
code/web/public_php/db_version_tool
code/web/public_php/db_version_web
code/web/public_php/role_service
code/web/public_php/role_support
code/web/public_php/role_domain
code/web/public_php/db_version_ring
code/web/public_php/config_user.php
code/nel/tools/build_gamedata/processes/pz/build_world_packed_col.cfg
code/nel/tools/build_gamedata/processes/cartographer/island_screenshots.cfg

@ -124,6 +124,9 @@ aes_state.txt
*.kdev4 *.kdev4
.kdev4 .kdev4
# intellij project folder
.idea/
# Python cache # Python cache
*.pyd *.pyd
*.pyc *.pyc
@ -139,8 +142,6 @@ moc_*.cpp
*.cache *.cache
*.patch *.patch
*.7z *.7z
external
external_stlport
3rdParty 3rdParty
.svn .svn
thumbs.db thumbs.db

@ -7,3 +7,4 @@ edaa3624a56420b02ccc64c26059801a389927ee ryzomcore/v0.11.0
e3fe4855f22c3e75722e015dc33c091c340b3ad7 ryzomcore/v0.11.1 e3fe4855f22c3e75722e015dc33c091c340b3ad7 ryzomcore/v0.11.1
9e583b717fd63be0be9fd60b99087abf1691ea49 ryzomcore/v0.11.2 9e583b717fd63be0be9fd60b99087abf1691ea49 ryzomcore/v0.11.2
bfe5628e14a024ba7ea32e4b326ae433a07856b9 ryzomcore/v0.11.3 bfe5628e14a024ba7ea32e4b326ae433a07856b9 ryzomcore/v0.11.3
9a6120735daa97c96ac5d85ca35c7f21f607bd87 ryzomcore/v0.12.0

@ -0,0 +1,53 @@
sudo: false
language: cpp
compiler:
- gcc
os:
- linux
matrix:
fast_finish: true
env:
- CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS:BOOL=off -DWITH_LUA51:BOOL=on -DWITH_LUA52:BOOL=off -DWITH_LUA53:BOOL=off"
- CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS:BOOL=off -DWITH_LUA51:BOOL=off -DWITH_LUA52:BOOL=on -DWITH_LUA53:BOOL=off"
- CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS:BOOL=off -DWITH_LUA51:BOOL=off -DWITH_LUA52:BOOL=off -DWITH_LUA53:BOOL=on"
- CMAKE_CONFIGURE_OPTIONS="-DCPPTEST_LIBRARY_DEBUG:STRING=/usr/lib/libcpptest.so"
CMAKE_BUILD_OPTIONS="--target nel_unit_test -- -j 2"
RUN="build/bin/nel_unit_test"
addons:
apt:
packages:
- liblua5.1-0-dev
- liblua5.1-0-dbg
- liblua5.2-0-dev
- liblua5.2-0-dbg
- libluabind-dev
- libcpptest-dev
- libogg-dev
- libvorbis-dev
- libopenal-dev
- libgif-dev
- libfreetype6-dev
- libxml2-dev
before_script:
- mkdir build
- cmake --version
- cmake -Hcode -Bbuild $CMAKE_CONFIGURE_OPTIONS
- cat build/CMakeCache.txt
script:
- cmake --build build $CMAKE_BUILD_OPTIONS
- $RUN
notifications:
irc:
channels:
- $NOTIFICATION_IRC_CHANNEL
template:
- "%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}"
- "Description : %{commit_message}"
- "Change view : %{compare_url}"
- "Build details : %{build_url}"

@ -1,3 +1,5 @@
# Ryzom Core [![Build Status](https://travis-ci.org/ryzom/ryzomcore.svg)](https://travis-ci.org/ryzom/ryzomcore)
Ryzom Core is the open-source project related to Ryzom Game. Written in C++, Ryzom Core contains the whole code (client, server, tools) used to make the commercial MMORPG Ryzom. Ryzom Core is a toolkit for the development of massively multiplayer online universes. It provides the base technologies and a set of development methodologies for the development of both client and server code. Ryzom Core is the open-source project related to Ryzom Game. Written in C++, Ryzom Core contains the whole code (client, server, tools) used to make the commercial MMORPG Ryzom. Ryzom Core is a toolkit for the development of massively multiplayer online universes. It provides the base technologies and a set of development methodologies for the development of both client and server code.

@ -2,7 +2,7 @@
# #
# Ryzom Core # Ryzom Core
# Authors: Nevrax and the Ryzom Core Community # Authors: Nevrax and the Ryzom Core Community
# Version: 0.11.3 # Version: 0.12.0
# #
# Notes: # Notes:
# * Changing install location: add -DCMAKE_INSTALL_PREFIX:PATH=/my/new/path # * Changing install location: add -DCMAKE_INSTALL_PREFIX:PATH=/my/new/path
@ -31,11 +31,16 @@ IF(COMMAND cmake_policy)
# Works around warnings about escaped quotes in ADD_DEFINITIONS # Works around warnings about escaped quotes in ADD_DEFINITIONS
# statements # statements
cmake_policy(SET CMP0005 OLD) cmake_policy(SET CMP0005 OLD)
# allow to link to qtmain automatically under Windows
IF(POLICY CMP0020)
CMAKE_POLICY(SET CMP0020 NEW)
ENDIF()
ENDIF(COMMAND cmake_policy) ENDIF(COMMAND cmake_policy)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/nel.cmake) INCLUDE(nel)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/ConfigureChecks.cmake) INCLUDE(ConfigureChecks)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/CheckDepends.cmake) INCLUDE(CheckDepends)
INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL) INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
# Force out of source builds. # Force out of source builds.
@ -44,12 +49,19 @@ CHECK_OUT_OF_SOURCE()
# To be able to specify a different deployment target on Mac OS X : # To be able to specify a different deployment target on Mac OS X :
# export MACOSX_DEPLOYMENT_TARGET=10.6 # export MACOSX_DEPLOYMENT_TARGET=10.6
IF(CMAKE_VERSION VERSION_GREATER "2.8.10")
STRING(TIMESTAMP CURRENT_YEAR "%Y")
ELSE()
SET(CURRENT_YEAR "2016")
ENDIF()
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(RyzomCore CXX C) PROJECT(RyzomCore CXX C)
SET(NL_VERSION_MAJOR 0) SET(NL_VERSION_MAJOR 0)
SET(NL_VERSION_MINOR 11) SET(NL_VERSION_MINOR 12)
SET(NL_VERSION_PATCH 3) SET(NL_VERSION_PATCH 0)
SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}") SET(YEAR "2004-${CURRENT_YEAR}")
SET(AUTHOR "Winchgate and The Ryzom Core Community")
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Redirect output files # Redirect output files
@ -67,10 +79,6 @@ IF(WIN32)
IF(WITH_MFC) IF(WITH_MFC)
FIND_PACKAGE(MFC QUIET) FIND_PACKAGE(MFC QUIET)
ENDIF(WITH_MFC) ENDIF(WITH_MFC)
IF(NOT DEFINED ENV{QTDIR})
SET(ENV{QTDIR} "c:/qt/4.6.3")
ENDIF(NOT DEFINED ENV{QTDIR})
ENDIF(WIN32) ENDIF(WIN32)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@ -94,7 +102,6 @@ NL_SETUP_BUILD_FLAGS()
#Platform specifics #Platform specifics
SETUP_EXTERNAL() SETUP_EXTERNAL()
NL_GEN_REVISION_H()
IF(WIN32) IF(WIN32)
SET(WINSOCK2_LIB ws2_32.lib) SET(WINSOCK2_LIB ws2_32.lib)
@ -104,8 +111,11 @@ IF(WIN32)
ENDIF(WITH_MFC) ENDIF(WITH_MFC)
ENDIF(WIN32) ENDIF(WIN32)
FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(LibXml2 REQUIRED) FIND_PACKAGE(LibXml2 REQUIRED)
FIND_PACKAGE(PNG REQUIRED) FIND_PACKAGE(PNG REQUIRED)
FIND_PACKAGE(OpenSSL REQUIRED)
FIND_PACKAGE(GIF)
FIND_PACKAGE(Jpeg) FIND_PACKAGE(Jpeg)
IF(WITH_STATIC_LIBXML2) IF(WITH_STATIC_LIBXML2)
@ -120,13 +130,17 @@ ENDIF(WITH_LIBXML2_ICONV)
IF(WITH_STATIC) IF(WITH_STATIC)
# libxml2 could need winsock2 library # libxml2 could need winsock2 library
IF(WINSOCK2_LIB)
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB}) SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB})
ENDIF()
# on Mac OS X libxml2 requires iconv and liblzma IF(UNIX)
IF(APPLE) # under Linux and OS X, recent libxml2 versions are linked against liblzma
FIND_PACKAGE(LibLZMA REQUIRED) FIND_PACKAGE(LibLZMA)
IF(LIBLZMA_LIBRARIES)
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${LIBLZMA_LIBRARIES}) SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${LIBLZMA_LIBRARIES})
ENDIF(APPLE) ENDIF()
ENDIF()
ENDIF(WITH_STATIC) ENDIF(WITH_STATIC)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/PCHSupport.cmake) INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/PCHSupport.cmake)
@ -142,48 +156,284 @@ IF(WITH_SSE2)
ENDIF(WITH_SSE3) ENDIF(WITH_SSE3)
ENDIF(WITH_SSE2) ENDIF(WITH_SSE2)
IF(APPLE_CERTIFICATE)
# Find codesign_allocate
# Xcode 7.0 and later versions
SET(CODESIGN_ALLOCATE ${OSX_DEVELOPER_ROOT}/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate)
IF(NOT EXISTS "${CODESIGN_ALLOCATE}")
# Xcode 6.4 and previous versions
SET(CODESIGN_ALLOCATE ${CMAKE_OSX_SYSROOT}/usr/bin/codesign_allocate)
ENDIF()
IF(NOT EXISTS "${CODESIGN_ALLOCATE}")
# System path
SET(CODESIGN_ALLOCATE /usr/bin/codesign_allocate)
ENDIF()
IF(NOT EXISTS "${CODESIGN_ALLOCATE}")
MESSAGE(WARNING "Unable to find codesign_allocate in standard directories")
SET(CODESIGN_ALLOCATE)
ENDIF()
ENDIF()
MACRO(ADD_QT_LIBRARY _NAME)
IF(WIN32)
SET(_PREFIX "Qt5")
SET(_EXT "lib")
ELSE()
SET(_PREFIX "libQt5")
SET(_EXT "a")
ENDIF()
SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}.${_EXT}")
IF(EXISTS ${_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB})
ENDIF()
SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}")
IF(EXISTS ${_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB})
ENDIF()
ENDMACRO()
MACRO(ADD_QT_PLUGIN _TYPE _NAME)
IF(WIN32)
SET(_PREFIX "")
SET(_EXT "lib")
ELSE()
SET(_PREFIX "lib")
SET(_EXT "a")
ENDIF()
SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}.${_EXT}")
IF(EXISTS ${_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB})
ENDIF()
SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}")
IF(EXISTS ${_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB})
ENDIF()
ENDMACRO()
IF(WITH_QT5)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR)
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR})
FIND_PACKAGE(Qt5Core QUIET)
IF(Qt5Core_FOUND)
# Check if we are using Qt static or shared libraries
GET_TARGET_PROPERTY(_FILE Qt5::Core IMPORTED_LOCATION_RELEASE)
SET(QT_VERSION "${Qt5Core_VERSION_STRING}")
SET(_VERSION "${QT_VERSION}")
IF(_FILE MATCHES "\\.(lib|a)$")
SET(QT_STATIC ON)
SET(_VERSION "${_VERSION} static version")
ELSE()
SET(QT_STATIC OFF)
SET(_VERSION "${_VERSION} shared version")
ENDIF()
MESSAGE(STATUS "Found Qt ${_VERSION}")
# These variables are not defined with Qt5 CMake modules
SET(QT_BINARY_DIR "${_qt5Core_install_prefix}/bin")
SET(QT_LIBRARY_DIR "${_qt5Core_install_prefix}/lib")
SET(QT_PLUGINS_DIR "${_qt5Core_install_prefix}/plugins")
SET(QT_TRANSLATIONS_DIR "${_qt5Core_install_prefix}/translations")
# Fix wrong include directories with Qt 5 under Mac OS X
INCLUDE_DIRECTORIES("${_qt5Core_install_prefix}/include")
FIND_PACKAGE(Qt5Gui)
FIND_PACKAGE(Qt5Widgets)
FIND_PACKAGE(Qt5OpenGL)
FIND_PACKAGE(Qt5Xml)
FIND_PACKAGE(Qt5LinguistTools)
FIND_PACKAGE(Qt5Network)
IF(QT_STATIC)
ADD_DEFINITIONS(-DQT_STATICPLUGIN)
SET(QT_LIBRARIES Qt5::Widgets)
# Gui
SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Gui Qt5::OpenGL)
ADD_QT_LIBRARY(PrintSupport)
IF(WIN32)
SET(QT_LIBRARIES ${QT_LIBRARIES}
${WINSDK_LIBRARY_DIR}/Imm32.lib
${WINSDK_LIBRARY_DIR}/OpenGL32.lib
${WINSDK_LIBRARY_DIR}/WinMM.Lib)
ADD_QT_PLUGIN(platforms qwindows)
ADD_QT_LIBRARY(PlatformSupport)
ELSEIF(APPLE)
# Cups needs .dylib
SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib)
FIND_LIBRARY(CUPS_LIBRARY cups)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES})
FIND_LIBRARY(IOKIT_FRAMEWORK IOKit)
FIND_LIBRARY(COCOA_FRAMEWORK Cocoa)
FIND_LIBRARY(SYSTEMCONFIGURATION_FRAMEWORK SystemConfiguration)
FIND_LIBRARY(OPENGL_FRAMEWORK NAMES OpenGL)
SET(QT_LIBRARIES ${QT_LIBRARIES}
${CUPS_LIBRARY}
${COCOA_FRAMEWORK}
${SYSTEMCONFIGURATION_FRAMEWORK}
${IOKIT_FRAMEWORK}
${OPENGL_FRAMEWORK})
ADD_QT_PLUGIN(printsupport cocoaprintersupport)
ADD_QT_PLUGIN(platforms qcocoa)
ADD_QT_LIBRARY(PlatformSupport)
ELSE()
# order is very important there
ADD_QT_PLUGIN(platforms qxcb)
ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration)
ADD_QT_LIBRARY(XcbQpa)
ADD_QT_LIBRARY(PlatformSupport)
SET(QT_LIBRARIES ${QT_LIBRARIES} -lX11-xcb -lXi -lSM -lICE -lxcb -lGL)
IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a")
SET(QT_LIBRARIES ${QT_LIBRARIES} "${QT_LIBRARY_DIR}/libxcb-static.a")
ENDIF()
SET(QT_LIBRARIES ${QT_LIBRARIES} -lfontconfig)
ADD_QT_LIBRARY(DBus)
ENDIF()
ADD_QT_PLUGIN(imageformats qgif)
ADD_QT_PLUGIN(imageformats qicns)
ADD_QT_PLUGIN(imageformats qico)
ADD_QT_PLUGIN(imageformats qjpeg)
# harfbuzz is needed since Qt 5.3
IF(UNIX)
SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzzng.a")
ELSEIF(WIN32)
SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib")
ENDIF()
IF(EXISTS ${HB_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} ${HB_LIB})
ENDIF()
# freetype is needed since Qt 5.5
IF(UNIX)
SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a")
ELSEIF(WIN32)
SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib")
ENDIF()
IF(EXISTS ${FREETYPE_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIB})
ENDIF()
ADD_QT_PLUGIN(accessible qtaccessiblewidgets)
SET(QT_LIBRARIES ${QT_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARY})
# Network
SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Network Qt5::Xml)
SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES})
IF(WIN32)
SET(QT_LIBRARIES ${QT_LIBRARIES}
${WINSDK_LIBRARY_DIR}/Crypt32.lib
${WINSDK_LIBRARY_DIR}/WS2_32.Lib)
ENDIF()
# Core
SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Core)
# pcre is needed since Qt 5.5
IF(UNIX)
SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a")
ELSEIF(WIN32)
SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib")
ENDIF()
IF(EXISTS ${PCRE_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} ${PCRE_LIB})
ENDIF()
IF(APPLE)
FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre)
FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation)
FIND_LIBRARY(CARBON_FRAMEWORK Carbon)
FIND_LIBRARY(SECURITY_FRAMEWORK Security)
SET(QT_LIBRARIES ${QT_LIBRARIES}
${PCRE_LIBRARY}
${FOUNDATION_FRAMEWORK}
${CARBON_FRAMEWORK}
${SECURITY_FRAMEWORK})
ELSEIF(UNIX)
SET(QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -ldl -lrt)
ENDIF()
ELSE()
SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core)
ENDIF()
ELSE()
MESSAGE(WARNING "Unable to find Qt 5")
ENDIF()
ENDIF()
IF(WITH_QT) IF(WITH_QT)
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR})
# Use Qt 4
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtXml QtOpenGL REQUIRED) FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtXml QtOpenGL REQUIRED)
ENDIF(WITH_QT) ENDIF(WITH_QT)
IF(WITH_ASSIMP)
FIND_PACKAGE(assimp REQUIRED)
ENDIF(WITH_ASSIMP)
IF(WITH_NEL) IF(WITH_NEL)
IF(WITH_NEL_TESTS) IF(WITH_NEL_TESTS)
FIND_PACKAGE(CppTest) FIND_PACKAGE(CppTest)
ENDIF(WITH_NEL_TESTS) ENDIF(WITH_NEL_TESTS)
IF(WITH_GUI) IF(WITH_GUI)
FIND_PACKAGE(Libwww REQUIRED)
FIND_PACKAGE(Luabind REQUIRED) FIND_PACKAGE(Luabind REQUIRED)
FIND_PACKAGE(CURL REQUIRED) FIND_PACKAGE(CURL REQUIRED)
IF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL) IF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
SET(CURL_STATIC ON) SET(CURL_STATIC ON)
ELSE((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL) ELSE()
SET(CURL_STATIC OFF) SET(CURL_STATIC OFF)
ENDIF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL) ENDIF()
IF(CURL_STATIC) IF(CURL_STATIC)
SET(CURL_DEFINITIONS -DCURL_STATICLIB) SET(CURL_DEFINITIONS -DCURL_STATICLIB)
FIND_PACKAGE(OpenSSL QUIET)
IF(OPENSSL_FOUND)
SET(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) SET(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES})
ENDIF(OPENSSL_FOUND)
IF(UNIX)
# CURL depends on libidn
FIND_LIBRARY(IDN_LIBRARY idn)
IF(IDN_LIBRARY)
SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${IDN_LIBRARY})
ENDIF()
# CURL Macports version depends on libidn, libintl and libiconv too # CURL Macports version depends on libidn, libintl and libiconv too
IF(APPLE) IF(APPLE)
FIND_LIBRARY(IDN_LIBRARY idn)
FIND_LIBRARY(INTL_LIBRARY intl) FIND_LIBRARY(INTL_LIBRARY intl)
IF(INTL_LIBRARY)
SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${IDN_LIBRARY} ${INTL_LIBRARY}) SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${INTL_LIBRARY})
ENDIF(APPLE) ENDIF()
ENDIF(CURL_STATIC) ENDIF()
ENDIF(WITH_GUI) ENDIF()
ENDIF()
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include ${LIBXML2_INCLUDE_DIR}) ENDIF()
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include)
ADD_SUBDIRECTORY(nel) ADD_SUBDIRECTORY(nel)
ENDIF(WITH_NEL) ENDIF(WITH_NEL)
@ -201,7 +451,7 @@ ENDIF(WITH_SNOWBALLS)
IF(WITH_TOOLS) IF(WITH_TOOLS)
ADD_SUBDIRECTORY(tool) ADD_SUBDIRECTORY(tool)
ENDIF(WITH_TOOLS) ENDIF()
IF(WITH_STUDIO) IF(WITH_STUDIO)
ADD_SUBDIRECTORY(studio) ADD_SUBDIRECTORY(studio)

@ -15,48 +15,76 @@ IF(NOT NDK_ROOT)
IF(CMAKE_HOST_WIN32) IF(CMAKE_HOST_WIN32)
FILE(TO_CMAKE_PATH ${NDK_ROOT} NDK_ROOT) FILE(TO_CMAKE_PATH ${NDK_ROOT} NDK_ROOT)
ENDIF(CMAKE_HOST_WIN32) ENDIF()
ENDIF(NOT NDK_ROOT) ENDIF()
IF(NOT TARGET_CPU) IF(NOT TARGET_CPU)
SET(TARGET_CPU "armv7") SET(TARGET_CPU "armv7")
ENDIF(NOT TARGET_CPU) ENDIF()
SET(ARMV7_HARD_FLOAT OFF)
IF(TARGET_CPU STREQUAL "armv7") IF(TARGET_CPU STREQUAL "armv7")
SET(LIBRARY_ARCHITECTURE "armeabi-v7a") SET(LIBRARY_ARCHITECTURE "armeabi-v7a")
IF(ARMV7_HARD_FLOAT)
SET(LIBRARY_ARCHITECTURE "${LIBRARY_ARCHITECTURE}-hard")
ENDIF()
SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(CMAKE_SYSTEM_PROCESSOR "armv7")
SET(TOOLCHAIN_ARCH "arm") SET(TOOLCHAIN_ARCH "arm")
SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi") SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi")
SET(TOOLCHAIN_BIN_PREFIX "arm") SET(TOOLCHAIN_BIN_PREFIX "arm-linux-androideabi")
SET(MINIMUM_NDK_TARGET 4) SET(MINIMUM_NDK_TARGET 4)
ELSEIF(TARGET_CPU STREQUAL "armv5") ELSEIF(TARGET_CPU STREQUAL "armv5")
SET(LIBRARY_ARCHITECTURE "armeabi") SET(LIBRARY_ARCHITECTURE "armeabi")
SET(CMAKE_SYSTEM_PROCESSOR "armv5") SET(CMAKE_SYSTEM_PROCESSOR "armv5")
SET(TOOLCHAIN_ARCH "arm") SET(TOOLCHAIN_ARCH "arm")
SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi") SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi")
SET(TOOLCHAIN_BIN_PREFIX "arm") SET(TOOLCHAIN_BIN_PREFIX "arm-linux-androideabi")
SET(MINIMUM_NDK_TARGET 4) SET(MINIMUM_NDK_TARGET 4)
ELSEIF(TARGET_CPU STREQUAL "arm64")
SET(LIBRARY_ARCHITECTURE "arm64-v8a")
SET(CMAKE_SYSTEM_PROCESSOR "arm64")
SET(TOOLCHAIN_ARCH "arm64")
SET(GCC_TOOLCHAIN_PREFIX "aarch64-linux-android")
SET(TOOLCHAIN_BIN_PREFIX "aarch64-linux-android")
SET(MINIMUM_NDK_TARGET 21)
ELSEIF(TARGET_CPU STREQUAL "x86") ELSEIF(TARGET_CPU STREQUAL "x86")
SET(LIBRARY_ARCHITECTURE "x86") SET(LIBRARY_ARCHITECTURE "x86")
SET(CMAKE_SYSTEM_PROCESSOR "x86") SET(CMAKE_SYSTEM_PROCESSOR "x86")
SET(TOOLCHAIN_ARCH "x86") SET(TOOLCHAIN_ARCH "x86")
SET(GCC_TOOLCHAIN_PREFIX "x86") SET(GCC_TOOLCHAIN_PREFIX "x86")
SET(TOOLCHAIN_BIN_PREFIX "i686") SET(TOOLCHAIN_BIN_PREFIX "i686-linux-android")
SET(MINIMUM_NDK_TARGET 9) SET(MINIMUM_NDK_TARGET 9)
ELSEIF(TARGET_CPU STREQUAL "x86_64")
SET(LIBRARY_ARCHITECTURE "x86_64")
SET(CMAKE_SYSTEM_PROCESSOR "x86_64")
SET(TOOLCHAIN_ARCH "x86_64")
SET(GCC_TOOLCHAIN_PREFIX "x86_64")
SET(TOOLCHAIN_BIN_PREFIX "x86_64-linux-android")
SET(MINIMUM_NDK_TARGET 21)
ELSEIF(TARGET_CPU STREQUAL "mips") ELSEIF(TARGET_CPU STREQUAL "mips")
SET(LIBRARY_ARCHITECTURE "mips") SET(LIBRARY_ARCHITECTURE "mips")
SET(CMAKE_SYSTEM_PROCESSOR "mips") SET(CMAKE_SYSTEM_PROCESSOR "mips")
SET(TOOLCHAIN_ARCH "mips") SET(TOOLCHAIN_ARCH "mips")
SET(GCC_TOOLCHAIN_PREFIX "mipsel-linux-android") SET(GCC_TOOLCHAIN_PREFIX "mipsel-linux-android")
SET(TOOLCHAIN_BIN_PREFIX "mipsel") SET(TOOLCHAIN_BIN_PREFIX "mipsel-linux-android")
SET(MINIMUM_NDK_TARGET 9) SET(MINIMUM_NDK_TARGET 9)
ENDIF(TARGET_CPU STREQUAL "armv7") ELSEIF(TARGET_CPU STREQUAL "mips64")
SET(LIBRARY_ARCHITECTURE "mips64")
SET(CMAKE_SYSTEM_PROCESSOR "mips64")
SET(TOOLCHAIN_ARCH "mips64")
SET(GCC_TOOLCHAIN_PREFIX "mips64el-linux-android")
SET(TOOLCHAIN_BIN_PREFIX "mips64el-linux-android")
SET(MINIMUM_NDK_TARGET 21)
ELSE()
MESSAGE(FATAL_ERROR "Unable to process TARGET_CPU ${TARGET_CPU}")
ENDIF()
SET(CLANG_TOOLCHAIN_PREFIX "llvm")
SET(ANDROID_COMPILER "GCC") SET(ANDROID_COMPILER "GCC")
IF(NDK_TOOLCHAIN_VERSION STREQUAL "clang") IF(NDK_TOOLCHAIN_VERSION STREQUAL "clang")
SET(ANDROID_COMPILER "clang") SET(ANDROID_COMPILER "clang")
SET(CLANG_TOOLCHAIN_PREFIX "llvm")
SET(CLANG ON) SET(CLANG ON)
ELSE() ELSE()
SET(GCC_TOOLCHAIN_VERSION ${NDK_TOOLCHAIN_VERSION}) SET(GCC_TOOLCHAIN_VERSION ${NDK_TOOLCHAIN_VERSION})
@ -64,7 +92,11 @@ ENDIF()
IF(NOT NDK_TARGET) IF(NOT NDK_TARGET)
SET(NDK_TARGET ${MINIMUM_NDK_TARGET}) SET(NDK_TARGET ${MINIMUM_NDK_TARGET})
ENDIF(NOT NDK_TARGET) ELSE()
IF(NDK_TARGET LESS MINIMUM_NDK_TARGET)
SET(NDK_TARGET ${MINIMUM_NDK_TARGET})
ENDIF()
ENDIF()
IF(CMAKE_HOST_WIN32) IF(CMAKE_HOST_WIN32)
SET(TOOLCHAIN_HOST "windows") SET(TOOLCHAIN_HOST "windows")
@ -75,7 +107,7 @@ ELSEIF(CMAKE_HOST_APPLE)
ELSEIF(CMAKE_HOST_UNIX) ELSEIF(CMAKE_HOST_UNIX)
SET(TOOLCHAIN_HOST "linux") SET(TOOLCHAIN_HOST "linux")
SET(TOOLCHAIN_BIN_SUFFIX "") SET(TOOLCHAIN_BIN_SUFFIX "")
ENDIF(CMAKE_HOST_WIN32) ENDIF()
MACRO(SEARCH_TOOLCHAIN _COMPILER) MACRO(SEARCH_TOOLCHAIN _COMPILER)
SET(${_COMPILER}_TOOLCHAIN_VERSIONS) SET(${_COMPILER}_TOOLCHAIN_VERSIONS)
@ -110,7 +142,7 @@ MACRO(SEARCH_TOOLCHAIN _COMPILER)
FILE(GLOB _TOOLCHAIN_PREFIXES "${${_COMPILER}_TOOLCHAIN_ROOT}*") FILE(GLOB _TOOLCHAIN_PREFIXES "${${_COMPILER}_TOOLCHAIN_ROOT}*")
IF(_TOOLCHAIN_PREFIXES) IF(_TOOLCHAIN_PREFIXES)
LIST(GET _TOOLCHAIN_PREFIXES 0 ${_COMPILER}_TOOLCHAIN_ROOT) LIST(GET _TOOLCHAIN_PREFIXES 0 ${_COMPILER}_TOOLCHAIN_ROOT)
ENDIF(_TOOLCHAIN_PREFIXES) ENDIF()
ENDIF() ENDIF()
ENDMACRO() ENDMACRO()
@ -123,8 +155,14 @@ ENDIF()
SEARCH_TOOLCHAIN(GCC) SEARCH_TOOLCHAIN(GCC)
MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use GCC ${GCC_TOOLCHAIN_VERSION}") MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use GCC ${GCC_TOOLCHAIN_VERSION}")
IF(CLANG_TOOLCHAIN_ROOT)
MESSAGE(STATUS "Found Android LLVM toolchain in ${CLANG_TOOLCHAIN_ROOT}") MESSAGE(STATUS "Found Android LLVM toolchain in ${CLANG_TOOLCHAIN_ROOT}")
ENDIF()
IF(GCC_TOOLCHAIN_ROOT)
MESSAGE(STATUS "Found Android GCC toolchain in ${GCC_TOOLCHAIN_ROOT}") MESSAGE(STATUS "Found Android GCC toolchain in ${GCC_TOOLCHAIN_ROOT}")
ENDIF()
SET(PLATFORM_ROOT "${NDK_ROOT}/platforms/android-${NDK_TARGET}/arch-${TOOLCHAIN_ARCH}") SET(PLATFORM_ROOT "${NDK_ROOT}/platforms/android-${NDK_TARGET}/arch-${TOOLCHAIN_ARCH}")
@ -137,14 +175,7 @@ SET(STL_DIR "${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++")
IF(EXISTS "${STL_DIR}/${GCC_TOOLCHAIN_VERSION}") IF(EXISTS "${STL_DIR}/${GCC_TOOLCHAIN_VERSION}")
# NDK version >= 8b # NDK version >= 8b
SET(STL_DIR "${STL_DIR}/${GCC_TOOLCHAIN_VERSION}") SET(STL_DIR "${STL_DIR}/${GCC_TOOLCHAIN_VERSION}")
ENDIF(EXISTS "${STL_DIR}/${GCC_TOOLCHAIN_VERSION}") ENDIF()
# Determine bin prefix for toolchain
FILE(GLOB _TOOLCHAIN_BIN_PREFIXES "${GCC_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 "${GCC_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_INCLUDE_DIR "${STL_DIR}/include")
SET(STL_LIBRARY_DIR "${STL_DIR}/libs/${LIBRARY_ARCHITECTURE}") SET(STL_LIBRARY_DIR "${STL_DIR}/libs/${LIBRARY_ARCHITECTURE}")
@ -160,39 +191,45 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
MACRO(SET_TOOLCHAIN_BINARY _NAME _BINARY) MACRO(SET_TOOLCHAIN_BINARY_LLVM _NAME _BINARY)
IF("${_BINARY}" MATCHES "clang")
SET(${_NAME} ${CLANG_TOOLCHAIN_ROOT}/bin/${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE ) SET(${_NAME} ${CLANG_TOOLCHAIN_ROOT}/bin/${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE )
ELSE() ENDMACRO()
MACRO(SET_TOOLCHAIN_BINARY_GCC _NAME _BINARY)
SET(${_NAME} ${GCC_TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE) SET(${_NAME} ${GCC_TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE)
ENDIF() ENDMACRO()
ENDMACRO(SET_TOOLCHAIN_BINARY)
# Force the compilers to GCC for Android # Force the compilers to GCC for Android
include (CMakeForceCompiler) include (CMakeForceCompiler)
IF(CLANG) IF(CLANG)
SET_TOOLCHAIN_BINARY(CMAKE_C_COMPILER clang) MESSAGE(STATUS "Using clang compiler")
SET_TOOLCHAIN_BINARY(CMAKE_CXX_COMPILER clang++)
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_C_COMPILER clang)
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_CXX_COMPILER clang++)
CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} clang) CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} clang)
CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} clang) CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} clang)
MESSAGE(STATUS "Using clang compiler") SET_TOOLCHAIN_BINARY_LLVM(CMAKE_ASM_COMPILER llvm-as)
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_AR llvm-ar)
SET_TOOLCHAIN_BINARY_LLVM(CMAKE_LINKER clang++)
ELSE() ELSE()
SET_TOOLCHAIN_BINARY(CMAKE_C_COMPILER gcc) MESSAGE(STATUS "Using GCC compiler")
SET_TOOLCHAIN_BINARY(CMAKE_CXX_COMPILER g++)
SET_TOOLCHAIN_BINARY_GCC(CMAKE_C_COMPILER gcc)
SET_TOOLCHAIN_BINARY_GCC(CMAKE_CXX_COMPILER g++)
CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} GNU) CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} GNU)
CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} GNU) CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} GNU)
MESSAGE(STATUS "Using GCC compiler") SET_TOOLCHAIN_BINARY_GCC(CMAKE_ASM_COMPILER as)
SET_TOOLCHAIN_BINARY_GCC(CMAKE_AR ar)
SET_TOOLCHAIN_BINARY_GCC(CMAKE_LINKER ld)
ENDIF() ENDIF()
SET_TOOLCHAIN_BINARY(CMAKE_STRIP strip) SET_TOOLCHAIN_BINARY_GCC(CMAKE_STRIP strip)
SET_TOOLCHAIN_BINARY(CMAKE_AR ar) SET_TOOLCHAIN_BINARY_GCC(CMAKE_NM nm)
SET_TOOLCHAIN_BINARY(CMAKE_LINKER ld) SET_TOOLCHAIN_BINARY_GCC(CMAKE_OBJCOPY objcopy)
SET_TOOLCHAIN_BINARY(CMAKE_NM nm) SET_TOOLCHAIN_BINARY_GCC(CMAKE_OBJDUMP objdump)
SET_TOOLCHAIN_BINARY(CMAKE_OBJCOPY objcopy) SET_TOOLCHAIN_BINARY_GCC(CMAKE_RANLIB ranlib)
SET_TOOLCHAIN_BINARY(CMAKE_OBJDUMP objdump)
SET_TOOLCHAIN_BINARY(CMAKE_RANLIB ranlib)

@ -1,79 +1,56 @@
MACRO(NL_CONFIGURE_CHECKS) MACRO(NL_CONFIGURE_CHECKS)
INCLUDE(CheckIncludeFiles) INCLUDE(GetRevision)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckLibraryExists)
INCLUDE(CheckTypeSize)
CHECK_INCLUDE_FILES ("execinfo.h" HAVE_EXECINFO_H)
CHECK_INCLUDE_FILES ("stdint.h" HAVE_STDINT_H)
CHECK_INCLUDE_FILES ("sys/types.h" HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES ("inttypes.h" HAVE_INTTYPES_H)
CHECK_INCLUDE_FILES ("unistd.h" HAVE_UNISTD_H)
CHECK_INCLUDE_FILES ("utime.h" HAVE_UTIME_H)
CHECK_INCLUDE_FILES ("dl.h" HAVE_DL_H)
CHECK_INCLUDE_FILES ("limits.h" HAVE_LIMITS_H)
CHECK_INCLUDE_FILES ("malloc.h" HAVE_MALLOC_H)
CHECK_INCLUDE_FILES ("sys/param.h" HAVE_SYS_PARAM_H)
CHECK_INCLUDE_FILES ("sys/param.h;sys/mount.h" HAVE_SYS_MOUNT_H)
CHECK_INCLUDE_FILES ("sys/statvfs.h" HAVE_SYS_STATVFS_H)
CHECK_INCLUDE_FILES ("pthread.h" HAVE_PTHREAD)
CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
#if (NOT HAVE_SIZEOF_SIZE_T)
# MESSAGE(FATAL_ERROR "size_t is not present on this architecture - aborting")
#endif (NOT HAVE_SIZEOF_SIZE_T)
MESSAGE(STATUS "DEBUG size_t is ${SIZEOF_SIZE_T}")
CHECK_TYPE_SIZE("off_t" SIZEOF_OFF_T)
MESSAGE(STATUS "DEBUG off_t is ${SIZEOF_OFF_T}")
CHECK_FUNCTION_EXISTS("backtrace" HAVE_BACKTRACE)
CHECK_FUNCTION_EXISTS("getsockname" HAVE_GETSOCKNAME)
CHECK_FUNCTION_EXISTS("inet_ntoa" HAVE_INET_NTOA)
CHECK_FUNCTION_EXISTS("inet_ntop" HAVE_INET_NTOP)
CHECK_FUNCTION_EXISTS("inet_pton" HAVE_INET_PTON)
CHECK_FUNCTION_EXISTS("regcomp" HAVE_REGCOMP)
CHECK_FUNCTION_EXISTS("strerror" HAVE_STRERROR)
CHECK_FUNCTION_EXISTS("strlcat" HAVE_STRLCAT)
CHECK_FUNCTION_EXISTS("strptime" HAVE_STRPTIME)
CHECK_FUNCTION_EXISTS("strtok_r" HAVE_STRTOK_R)
CHECK_FUNCTION_EXISTS("strtoull" HAVE_STRTOULL)
CHECK_FUNCTION_EXISTS("statvfs" HAVE_STATVFS)
CHECK_FUNCTION_EXISTS("stat64" HAVE_STAT64)
# 3D drivers # 3D drivers
IF(WITH_DRIVER_OPENGL) IF(WITH_DRIVER_OPENGL)
SET(NL_OPENGL_AVAILABLE 1) SET(NL_OPENGL_AVAILABLE 1)
ENDIF(WITH_DRIVER_OPENGL) ENDIF()
IF(WITH_DRIVER_OPENGLES) IF(WITH_DRIVER_OPENGLES)
SET(NL_OPENGLES_AVAILABLE 1) SET(NL_OPENGLES_AVAILABLE 1)
ENDIF(WITH_DRIVER_OPENGLES) ENDIF()
IF(WITH_DRIVER_DIRECT3D) IF(WITH_DRIVER_DIRECT3D)
SET(NL_DIRECT3D_AVAILABLE 1) SET(NL_DIRECT3D_AVAILABLE 1)
ENDIF(WITH_DRIVER_DIRECT3D) ENDIF()
# sound drivers # sound drivers
IF(WITH_DRIVER_FMOD) IF(WITH_DRIVER_FMOD)
SET(NL_FMOD_AVAILABLE 1) SET(NL_FMOD_AVAILABLE 1)
ENDIF(WITH_DRIVER_FMOD) ENDIF()
IF(WITH_DRIVER_OPENAL) IF(WITH_DRIVER_OPENAL)
SET(NL_OPENAL_AVAILABLE 1) SET(NL_OPENAL_AVAILABLE 1)
ENDIF(WITH_DRIVER_OPENAL) ENDIF()
IF(WITH_DRIVER_DSOUND) IF(WITH_DRIVER_DSOUND)
SET(NL_DSOUND_AVAILABLE 1) SET(NL_DSOUND_AVAILABLE 1)
ENDIF(WITH_DRIVER_DSOUND) ENDIF()
IF(WITH_DRIVER_XAUDIO2) IF(WITH_DRIVER_XAUDIO2)
SET(NL_XAUDIO2_AVAILABLE 1) SET(NL_XAUDIO2_AVAILABLE 1)
ENDIF(WITH_DRIVER_XAUDIO2) ENDIF()
IF(NOT RYZOM_VERSION_MAJOR)
SET(RYZOM_VERSION_MAJOR ${NL_VERSION_MAJOR})
SET(RYZOM_VERSION_MINOR ${NL_VERSION_MINOR})
SET(RYZOM_VERSION_PATCH ${NL_VERSION_PATCH})
ENDIF()
SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}.${REVISION}")
SET(NL_VERSION_RC "${NL_VERSION_MAJOR},${NL_VERSION_MINOR},${NL_VERSION_PATCH},${REVISION}")
SET(RYZOM_VERSION "${RYZOM_VERSION_MAJOR}.${RYZOM_VERSION_MINOR}.${RYZOM_VERSION_PATCH}.${REVISION}")
SET(RYZOM_VERSION_RC "${RYZOM_VERSION_MAJOR},${RYZOM_VERSION_MINOR},${RYZOM_VERSION_PATCH},${REVISION}")
NOW(BUILD_DATE)
SET(COPYRIGHT "${YEAR} ${AUTHOR}")
IF(NOT RYZOM_CLIENT_ICON)
SET(RYZOM_CLIENT_ICON "ryzom_client")
ENDIF()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_DEFINITIONS(-DHAVE_CONFIG_H) ADD_DEFINITIONS(-DHAVE_CONFIG_H)
ENDMACRO(NL_CONFIGURE_CHECKS) ENDMACRO()

@ -9,7 +9,7 @@
if(MAXSDK_INCLUDE_DIR) if(MAXSDK_INCLUDE_DIR)
# Already in cache, be silent # Already in cache, be silent
SET(MAXSDK_FIND_QUIETLY TRUE) SET(MAXSDK_FIND_QUIETLY TRUE)
endif(MAXSDK_INCLUDE_DIR) endif()
FIND_PATH(MAXSDK_DIR FIND_PATH(MAXSDK_DIR
"include/maxversion.h" "include/maxversion.h"
@ -37,9 +37,9 @@ FIND_PATH(MAXSDK_CS_INCLUDE_DIR bipexp.h
IF(TARGET_X64) IF(TARGET_X64)
SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/x64/lib) SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/x64/lib)
ELSE(TARGET_X64) ELSE()
SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/lib) SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/lib)
ENDIF(TARGET_X64) ENDIF()
MACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME) MACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME)
FIND_LIBRARY(${MYLIBRARY} FIND_LIBRARY(${MYLIBRARY}
@ -47,7 +47,7 @@ MACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME)
HINTS HINTS
${MAXSDK_LIBRARY_DIRS} ${MAXSDK_LIBRARY_DIRS}
) )
ENDMACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME) ENDMACRO()
FIND_3DS_LIBRARY(MAXSDK_CORE_LIBRARY core) FIND_3DS_LIBRARY(MAXSDK_CORE_LIBRARY core)
FIND_3DS_LIBRARY(MAXSDK_GEOM_LIBRARY geom) FIND_3DS_LIBRARY(MAXSDK_GEOM_LIBRARY geom)

@ -45,6 +45,6 @@ IF(MFC_FOUND)
# Set CMake flag to use MFC DLL # Set CMake flag to use MFC DLL
SET(CMAKE_MFC_FLAG 2) SET(CMAKE_MFC_FLAG 2)
ENDIF(MFC_FOUND) ENDIF()
# TODO: create a macro which set MFC_DEFINITIONS, MFC_LIBRARY_DIR and MFC_INCLUDE_DIR for a project # TODO: create a macro which set MFC_DEFINITIONS, MFC_LIBRARY_DIR and MFC_INCLUDE_DIR for a project

@ -30,16 +30,16 @@ MACRO(FIND_DXSDK_LIBRARY MYLIBRARY MYLIBRARYNAME)
HINTS HINTS
"${DXSDK_LIBRARY_DIR}" "${DXSDK_LIBRARY_DIR}"
) )
ENDMACRO(FIND_DXSDK_LIBRARY MYLIBRARY MYLIBRARYNAME) ENDMACRO()
IF(DXSDK_DIR) IF(DXSDK_DIR)
SET(DXSDK_INCLUDE_DIR "${DXSDK_DIR}/Include") SET(DXSDK_INCLUDE_DIR "${DXSDK_DIR}/Include")
IF(TARGET_X64) IF(TARGET_X64)
SET(DXSDK_LIBRARY_DIRS ${DXSDK_DIR}/Lib/x64 ${DXSDK_DIR}/lib/amd64) SET(DXSDK_LIBRARY_DIRS ${DXSDK_DIR}/Lib/x64 ${DXSDK_DIR}/lib/amd64)
ELSE(TARGET_X64) ELSE()
SET(DXSDK_LIBRARY_DIRS ${DXSDK_DIR}/Lib/x86 ${DXSDK_DIR}/lib) SET(DXSDK_LIBRARY_DIRS ${DXSDK_DIR}/Lib/x86 ${DXSDK_DIR}/lib)
ENDIF(TARGET_X64) ENDIF()
FIND_PATH(DXSDK_LIBRARY_DIR FIND_PATH(DXSDK_LIBRARY_DIR
dxguid.lib dxguid.lib
@ -52,7 +52,7 @@ IF(DXSDK_DIR)
FIND_DXSDK_LIBRARY(DXSDK_XAUDIO_LIBRARY x3daudio) FIND_DXSDK_LIBRARY(DXSDK_XAUDIO_LIBRARY x3daudio)
FIND_DXSDK_LIBRARY(DXSDK_D3DX9_LIBRARY d3dx9) FIND_DXSDK_LIBRARY(DXSDK_D3DX9_LIBRARY d3dx9)
FIND_DXSDK_LIBRARY(DXSDK_D3D9_LIBRARY d3d9) FIND_DXSDK_LIBRARY(DXSDK_D3D9_LIBRARY d3d9)
ENDIF(DXSDK_DIR) ENDIF()
# Handle the QUIETLY and REQUIRED arguments and set DXSDK_FOUND to TRUE if # Handle the QUIETLY and REQUIRED arguments and set DXSDK_FOUND to TRUE if
# all listed variables are TRUE. # all listed variables are TRUE.

@ -8,7 +8,7 @@
# EXTERNAL_FOUND - True if the external libraries are available # EXTERNAL_FOUND - True if the external libraries are available
SET(EXTERNAL_TEMP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/../external ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty ${EXTERNAL_PATH}) SET(EXTERNAL_TEMP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/../external ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty ${EXTERNAL_PATH})
SET(EXTERNAL_TEMP_FILE "include/wwwconf.h") SET(EXTERNAL_TEMP_FILE "include/zlib.h")
SET(EXTERNAL_NAME "external") SET(EXTERNAL_NAME "external")
# If using STLport preprend external_stlport # If using STLport preprend external_stlport
@ -38,35 +38,35 @@ IF(EXTERNAL_PATH)
# Using 32 or 64 bits binaries # Using 32 or 64 bits binaries
IF(TARGET_X64 AND WIN32) IF(TARGET_X64 AND WIN32)
SET(EXTERNAL_BINARY_PATH "${EXTERNAL_PATH}/bin64") SET(EXTERNAL_BINARY_PATH "${EXTERNAL_PATH}/bin64")
ELSE(TARGET_X64 AND WIN32) ELSE()
SET(EXTERNAL_BINARY_PATH "${EXTERNAL_PATH}/bin") SET(EXTERNAL_BINARY_PATH "${EXTERNAL_PATH}/bin")
ENDIF(TARGET_X64 AND WIN32) ENDIF()
# Using 32 or 64 bits libraries # Using 32 or 64 bits libraries
IF(TARGET_X64 AND WIN32) IF(TARGET_X64 AND WIN32)
SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib64") SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib64")
ELSE(TARGET_X64 AND WIN32) ELSE()
SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib") SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib")
ENDIF(TARGET_X64 AND WIN32) ENDIF()
SET(CMAKE_INCLUDE_PATH "${EXTERNAL_INCLUDE_PATH};${CMAKE_INCLUDE_PATH}") SET(CMAKE_INCLUDE_PATH "${EXTERNAL_INCLUDE_PATH};${CMAKE_INCLUDE_PATH}")
# Stupid hack for FindOpenAL.cmake # Stupid hack for FindOpenAL.cmake
SET(CMAKE_INCLUDE_PATH "${EXTERNAL_PATH};${CMAKE_INCLUDE_PATH}") SET(CMAKE_INCLUDE_PATH "${EXTERNAL_PATH};${CMAKE_INCLUDE_PATH}")
SET(CMAKE_LIBRARY_PATH "${EXTERNAL_LIBRARY_PATH};${CMAKE_LIBRARY_PATH}") SET(CMAKE_LIBRARY_PATH "${EXTERNAL_LIBRARY_PATH};${CMAKE_LIBRARY_PATH}")
ENDIF(EXTERNAL_PATH) ENDIF()
IF(EXTERNAL_FOUND) IF(EXTERNAL_FOUND)
IF(NOT External_FIND_QUIETLY) IF(NOT External_FIND_QUIETLY)
MESSAGE(STATUS "Found ${EXTERNAL_NAME}: ${EXTERNAL_PATH}") MESSAGE(STATUS "Found ${EXTERNAL_NAME}: ${EXTERNAL_PATH}")
ENDIF(NOT External_FIND_QUIETLY) ENDIF()
ELSE(EXTERNAL_FOUND) ELSE()
IF(External_FIND_REQUIRED) IF(External_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Unable to find ${EXTERNAL_NAME}!") MESSAGE(FATAL_ERROR "Unable to find ${EXTERNAL_NAME}!")
ELSE(External_FIND_REQUIRED) ELSE()
IF(NOT External_FIND_QUIETLY) IF(NOT External_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find ${EXTERNAL_NAME}!") MESSAGE(STATUS "Warning: Unable to find ${EXTERNAL_NAME}!")
ENDIF(NOT External_FIND_QUIETLY) ENDIF()
ENDIF(External_FIND_REQUIRED) ENDIF()
ENDIF(EXTERNAL_FOUND) ENDIF()
MARK_AS_ADVANCED(EXTERNAL_INCLUDE_PATH EXTERNAL_BINARY_PATH EXTERNAL_LIBRARY_PATH) MARK_AS_ADVANCED(EXTERNAL_INCLUDE_PATH EXTERNAL_BINARY_PATH EXTERNAL_LIBRARY_PATH)

@ -58,6 +58,7 @@ IF(LIBOVR_LIBRARY AND LIBOVR_INCLUDE_DIR)
ENDIF(NOT LIBOVR_FIND_QUIETLY) ENDIF(NOT LIBOVR_FIND_QUIETLY)
SET(LIBOVR_FOUND "YES") SET(LIBOVR_FOUND "YES")
SET(LIBOVR_DEFINITIONS "-DHAVE_LIBOVR") SET(LIBOVR_DEFINITIONS "-DHAVE_LIBOVR")
SET(NL_STEREO_AVAILABLE ON)
IF(UNIX) IF(UNIX)
SET(LIBOVR_LIBRARIES ${LIBOVR_LIBRARY} X11 Xinerama udev pthread) SET(LIBOVR_LIBRARIES ${LIBOVR_LIBRARY} X11 Xinerama udev pthread)
ELSE(UNIX) ELSE(UNIX)

@ -25,6 +25,7 @@ IF(LIBVR_LIBRARY AND LIBVR_INCLUDE_DIR)
ENDIF(NOT LIBVR_FIND_QUIETLY) ENDIF(NOT LIBVR_FIND_QUIETLY)
SET(LIBVR_FOUND "YES") SET(LIBVR_FOUND "YES")
SET(LIBVR_DEFINITIONS "-DHAVE_LIBVR") SET(LIBVR_DEFINITIONS "-DHAVE_LIBVR")
SET(NL_STEREO_AVAILABLE ON)
ELSE(LIBVR_LIBRARY AND LIBVR_INCLUDE_DIR) ELSE(LIBVR_LIBRARY AND LIBVR_INCLUDE_DIR)
IF(NOT LIBVR_FIND_QUIETLY) IF(NOT LIBVR_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find LibVR!") MESSAGE(STATUS "Warning: Unable to find LibVR!")

@ -1,190 +0,0 @@
#
# Find the W3C libwww includes and library
#
# This module defines
# LIBWWW_INCLUDE_DIR, where to find tiff.h, etc.
# LIBWWW_LIBRARY, where to find the Libwww library.
# LIBWWW_FOUND, If false, do not try to use Libwww.
OPTION(WITH_LIBWWW_STATIC "Use only static libraries for libwww" OFF)
# also defined, but not for general use are
IF(LIBWWW_LIBRARIES AND LIBWWW_INCLUDE_DIR)
# in cache already
SET(Libwww_FIND_QUIETLY TRUE)
ENDIF(LIBWWW_LIBRARIES AND LIBWWW_INCLUDE_DIR)
FIND_PATH(LIBWWW_INCLUDE_DIR
WWWInit.h
PATHS
/usr/local/include
/usr/include
/sw/include
/opt/local/include
/opt/csw/include
/opt/include
PATH_SUFFIXES libwww w3c-libwww
)
# when installing libwww on mac os x using macports the file wwwconf.h resides
# in /opt/local/include and not in the real libwww include dir :/
FIND_PATH(LIBWWW_ADDITIONAL_INCLUDE_DIR
wwwconf.h
PATHS
/usr/local/include
/usr/include
/sw/include
/opt/local/include
/opt/csw/include
/opt/include
)
# combine both include directories into one variable
IF(LIBWWW_ADDITIONAL_INCLUDE_DIR)
SET(LIBWWW_INCLUDE_DIR ${LIBWWW_INCLUDE_DIR} ${LIBWWW_ADDITIONAL_INCLUDE_DIR})
ENDIF(LIBWWW_ADDITIONAL_INCLUDE_DIR)
# helper to find all the libwww sub libraries
MACRO(FIND_WWW_LIBRARY MYLIBRARY OPTION FILE)
IF(WITH_LIBWWW_STATIC AND UNIX AND NOT APPLE AND NOT WITH_STATIC_EXTERNAL)
SET(CMAKE_FIND_LIBRARY_SUFFIXES_OLD ${CMAKE_FIND_LIBRARY_SUFFIXES})
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
ENDIF(WITH_LIBWWW_STATIC AND UNIX AND NOT APPLE AND NOT WITH_STATIC_EXTERNAL)
FIND_LIBRARY(${MYLIBRARY}_RELEASE
NAMES ${FILE}
PATHS
/usr/local/lib
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
FIND_LIBRARY(${MYLIBRARY}_DEBUG
NAMES ${FILE}d
PATHS
/usr/local/lib
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
IF(CMAKE_FIND_LIBRARY_SUFFIXES_OLD)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_OLD})
ENDIF(CMAKE_FIND_LIBRARY_SUFFIXES_OLD)
IF(${MYLIBRARY}_RELEASE AND ${MYLIBRARY}_DEBUG)
IF(${OPTION} STREQUAL REQUIRED OR WITH_STATIC OR WITH_LIBWWW_STATIC)
SET(LIBWWW_LIBRARIES ${LIBWWW_LIBRARIES} optimized ${${MYLIBRARY}_RELEASE} debug ${${MYLIBRARY}_DEBUG})
ENDIF(${OPTION} STREQUAL REQUIRED OR WITH_STATIC OR WITH_LIBWWW_STATIC)
ELSEIF(${MYLIBRARY}_RELEASE)
IF(${OPTION} STREQUAL REQUIRED OR WITH_STATIC OR WITH_LIBWWW_STATIC)
SET(LIBWWW_LIBRARIES ${LIBWWW_LIBRARIES} ${${MYLIBRARY}_RELEASE})
ENDIF(${OPTION} STREQUAL REQUIRED OR WITH_STATIC OR WITH_LIBWWW_STATIC)
ELSEIF(${MYLIBRARY}_DEBUG)
IF(${OPTION} STREQUAL REQUIRED OR WITH_STATIC OR WITH_LIBWWW_STATIC)
SET(LIBWWW_LIBRARIES ${LIBWWW_LIBRARIES} ${${MYLIBRARY}_DEBUG})
ENDIF(${OPTION} STREQUAL REQUIRED OR WITH_STATIC OR WITH_LIBWWW_STATIC)
ELSE(${MYLIBRARY}_RELEASE AND ${MYLIBRARY}_DEBUG)
IF(NOT Libwww_FIND_QUIETLY AND NOT WIN32)
MESSAGE(STATUS "Warning: Libwww: Library not found: ${MYLIBRARY}")
ENDIF(NOT Libwww_FIND_QUIETLY AND NOT WIN32)
ENDIF(${MYLIBRARY}_RELEASE AND ${MYLIBRARY}_DEBUG)
MARK_AS_ADVANCED(${MYLIBRARY}_RELEASE ${MYLIBRARY}_DEBUG)
ENDMACRO(FIND_WWW_LIBRARY)
MACRO(LINK_WWW_LIBRARY MYLIBRARY OTHERLIBRARY SYMBOL)
IF(NOT WITH_LIBWWW_STATIC AND NOT WITH_STATIC_EXTERNAL)
LINK_DEPENDS(LIBWWW_LIBRARIES ${MYLIBRARY} ${OTHERLIBRARY} ${SYMBOL})
ENDIF(NOT WITH_LIBWWW_STATIC AND NOT WITH_STATIC_EXTERNAL)
ENDMACRO(LINK_WWW_LIBRARY)
# Find and link required libs for static or dynamic
FIND_WWW_LIBRARY(LIBWWWAPP_LIBRARY REQUIRED wwwapp) # cache core file ftp gopher html http mime news stream telnet trans utils zip xml xmlparse
FIND_WWW_LIBRARY(LIBWWWCORE_LIBRARY REQUIRED wwwcore) # utils
FIND_WWW_LIBRARY(LIBWWWFILE_LIBRARY REQUIRED wwwfile) # core trans utils html
FIND_WWW_LIBRARY(LIBWWWHTML_LIBRARY REQUIRED wwwhtml) # core utils
FIND_WWW_LIBRARY(LIBWWWHTTP_LIBRARY REQUIRED wwwhttp) # md5 core mime stream utils
FIND_WWW_LIBRARY(LIBWWWMIME_LIBRARY REQUIRED wwwmime) # core cache stream utils
# Required for static or if underlinking
FIND_WWW_LIBRARY(LIBWWWCACHE_LIBRARY OPTIONAL wwwcache) # core trans utils
FIND_WWW_LIBRARY(LIBWWWSTREAM_LIBRARY OPTIONAL wwwstream) # core file utils
FIND_WWW_LIBRARY(LIBWWWTRANS_LIBRARY REQUIRED wwwtrans) # core utils
FIND_WWW_LIBRARY(LIBWWWUTILS_LIBRARY REQUIRED wwwutils)
# Required only if underlinking
# Unused protocols
FIND_WWW_LIBRARY(LIBWWWFTP_LIBRARY OPTIONAL wwwftp) # core file utils
FIND_WWW_LIBRARY(LIBWWWGOPHER_LIBRARY OPTIONAL wwwgopher) # core html utils file
FIND_WWW_LIBRARY(LIBWWWNEWS_LIBRARY OPTIONAL wwwnews) # core html mime stream utils
FIND_WWW_LIBRARY(LIBWWWTELNET_LIBRARY OPTIONAL wwwtelnet) # core utils
# Other used by app
FIND_WWW_LIBRARY(LIBWWWDIR_LIBRARY OPTIONAL wwwdir) # file
FIND_WWW_LIBRARY(LIBWWWINIT_LIBRARY OPTIONAL wwwinit) # app cache core file html utils
FIND_WWW_LIBRARY(LIBWWWMUX_LIBRARY OPTIONAL wwwmux) # core stream trans utils
FIND_WWW_LIBRARY(LIBWWWXML_LIBRARY OPTIONAL wwwxml) # core utils xmlparse
FIND_WWW_LIBRARY(LIBWWWZIP_LIBRARY OPTIONAL wwwzip) # core utils
FIND_WWW_LIBRARY(LIBXMLPARSE_LIBRARY OPTIONAL xmlparse) # xmltok
# Other used by other
FIND_WWW_LIBRARY(LIBXMLTOK_LIBRARY OPTIONAL xmltok)
FIND_WWW_LIBRARY(LIBWWWSSL_LIBRARY OPTIONAL wwwssl)
FIND_WWW_LIBRARY(LIBMD5_LIBRARY OPTIONAL md5)
FIND_WWW_LIBRARY(LIBPICS_LIBRARY OPTIONAL pics)
# Other external libraries
FIND_PACKAGE(EXPAT QUIET)
FIND_PACKAGE(OpenSSL QUIET)
FIND_WWW_LIBRARY(LIBREGEX_LIBRARY OPTIONAL gnu_regex)
# Now link all libs together
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBWWWCACHE_LIBRARY HTLoadCache)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBWWWCACHE_LIBRARY HTCacheAppend)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBWWWFTP_LIBRARY HTLoadFTP)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBWWWGOPHER_LIBRARY HTLoadGopher)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBWWWNEWS_LIBRARY HTLoadNews)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBWWWTELNET_LIBRARY HTLoadTelnet)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBWWWSTREAM_LIBRARY HTStreamToChunk)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBWWWSTREAM_LIBRARY HTGuess_new)
LINK_WWW_LIBRARY(LIBWWWFILE_LIBRARY LIBWWWDIR_LIBRARY HTDir_new)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBWWWINIT_LIBRARY HTProtocolInit)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBWWWXML_LIBRARY HTXML_new)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBWWWZIP_LIBRARY HTZLib_inflate)
# libwwwxml can be linked to xmlparse or expat
LINK_WWW_LIBRARY(LIBWWWXML_LIBRARY LIBXMLPARSE_LIBRARY XML_ParserCreate)
IF(LIBXMLPARSE_LIBRARY_LINKED)
LINK_WWW_LIBRARY(LIBXMLPARSE_LIBRARY EXPAT_LIBRARY XmlInitEncoding)
ELSE(LIBXMLPARSE_LIBRARY_LINKED)
LINK_WWW_LIBRARY(LIBWWWXML_LIBRARY EXPAT_LIBRARY XML_ParserCreate)
ENDIF(LIBXMLPARSE_LIBRARY_LINKED)
LINK_WWW_LIBRARY(LIBWWWHTTP_LIBRARY LIBMD5_LIBRARY MD5Init)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY LIBREGEX_LIBRARY regexec)
LINK_WWW_LIBRARY(LIBWWWAPP_LIBRARY OPENSSL_LIBRARIES SSL_new)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libwww DEFAULT_MSG
LIBWWW_LIBRARIES
LIBWWW_INCLUDE_DIR
)

@ -0,0 +1,81 @@
# Locate Lua library
# This module defines
# LUA53_FOUND, if false, do not try to link to Lua
# LUA_LIBRARIES
# LUA_INCLUDE_DIR, where to find lua.h
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
#
# Note that the expected include convention is
# #include "lua.h"
# and not
# #include <lua/lua.h>
# This is because, the lua location is not standardized and may exist
# in locations other than lua/
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
find_path(LUA_INCLUDE_DIR lua.h
HINTS
ENV LUA_DIR
PATH_SUFFIXES include/lua53 include/lua5.3 include/lua-5.3 include/lua include
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
find_library(LUA_LIBRARY
NAMES lua53 lua5.3 lua-5.3 lua
HINTS
ENV LUA_DIR
PATH_SUFFIXES lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
)
if(LUA_LIBRARY)
# include the math library for Unix
if(UNIX AND NOT APPLE AND NOT BEOS)
find_library(LUA_MATH_LIBRARY m)
set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
# For Windows and Mac, don't need to explicitly include the math library
else()
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
endif()
endif()
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
unset(lua_version_str)
endif()
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua53
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUA_VERSION_STRING)
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)

@ -9,53 +9,81 @@ MACRO(FIND_CORRECT_LUA_VERSION)
IF(LUABIND_LIBRARY_RELEASE MATCHES "\\.so") IF(LUABIND_LIBRARY_RELEASE MATCHES "\\.so")
INCLUDE(CheckDepends) INCLUDE(CheckDepends)
SET(LUA52_LIBRARY "liblua5.2") # check for Lua 5.3
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE LUA52_LIBRARY LUALIB_FOUND) SET(LUA53_LIBRARIES liblua5.3 liblua-5.3 liblua.so.5.3)
FOREACH(_LIB ${LUA53_LIBRARIES})
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
IF(LUALIB_FOUND)
MESSAGE(STATUS "Luabind is using Lua 5.3")
FIND_PACKAGE(Lua53 REQUIRED)
BREAK()
ENDIF()
ENDFOREACH()
IF(NOT LUALIB_FOUND) IF(NOT LUALIB_FOUND)
# fedora (v20) # check for Lua 5.2
SET(LUA52_LIBRARY "liblua-5.2") SET(LUA52_LIBRARIES liblua5.2 liblua-5.2 liblua.so.5.2)
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE LUA52_LIBRARY LUALIB_FOUND)
ENDIF(NOT LUALIB_FOUND)
FOREACH(_LIB ${LUA52_LIBRARIES})
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
IF(LUALIB_FOUND) IF(LUALIB_FOUND)
MESSAGE(STATUS "Luabind is using Lua 5.2") MESSAGE(STATUS "Luabind is using Lua 5.2")
FIND_PACKAGE(Lua52 REQUIRED) FIND_PACKAGE(Lua52 REQUIRED)
ELSE(LUALIB_FOUND) BREAK()
SET(LUA51_LIBRARY "liblua5.1") ENDIF()
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE LUA51_LIBRARY LUALIB_FOUND) ENDFOREACH()
ENDIF()
IF(NOT LUALIB_FOUND)
# check for Lua 5.1
SET(LUA51_LIBRARIES liblua5.1 liblua-5.1 liblua.so.5.1)
FOREACH(_LIB ${LUA51_LIBRARIES})
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
IF(LUALIB_FOUND) IF(LUALIB_FOUND)
MESSAGE(STATUS "Luabind is using Lua 5.1") MESSAGE(STATUS "Luabind is using Lua 5.1")
FIND_PACKAGE(Lua51 REQUIRED) FIND_PACKAGE(Lua51 REQUIRED)
ELSE(LUALIB_FOUND) BREAK()
SET(LUA50_LIBRARY "liblua5.0") ENDIF()
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE LUA50_LIBRARY LUALIB_FOUND) ENDFOREACH()
ENDIF()
IF(NOT LUALIB_FOUND)
# check for Lua 5.0
SET(LUA50_LIBRARIES liblua5.0 liblua-5.0 liblua.so.5.0)
FOREACH(_LIB ${LUA50_LIBRARIES})
CHECK_LINKED_LIBRARY(LUABIND_LIBRARY_RELEASE _LIB LUALIB_FOUND)
IF(LUALIB_FOUND) IF(LUALIB_FOUND)
MESSAGE(STATUS "Luabind is using Lua 5.0") MESSAGE(STATUS "Luabind is using Lua 5.0")
FIND_PACKAGE(Lua50 REQUIRED) FIND_PACKAGE(Lua50 REQUIRED)
ELSE(LUALIB_FOUND) BREAK()
ENDIF()
ENDFOREACH()
ENDIF()
IF(NOT LUALIB_FOUND)
MESSAGE(FATAL_ERROR "Can't determine Lua version used by Luabind") MESSAGE(FATAL_ERROR "Can't determine Lua version used by Luabind")
ENDIF(LUALIB_FOUND) ENDIF()
ENDIF(LUALIB_FOUND) ELSE()
ENDIF(LUALIB_FOUND)
ELSE(LUABIND_LIBRARY_RELEASE MATCHES "\\.so")
# TODO: find a way to detect Lua version # TODO: find a way to detect Lua version
IF(WITH_LUA52) IF(WITH_LUA53)
FIND_PACKAGE(Lua53 REQUIRED)
ELSEIF(WITH_LUA52)
FIND_PACKAGE(Lua52 REQUIRED) FIND_PACKAGE(Lua52 REQUIRED)
ELSEIF(WITH_LUA51) ELSEIF(WITH_LUA51)
FIND_PACKAGE(Lua51 REQUIRED) FIND_PACKAGE(Lua51 REQUIRED)
ELSE(WITH_LUA52) ELSE()
FIND_PACKAGE(Lua50 REQUIRED) FIND_PACKAGE(Lua50 REQUIRED)
ENDIF(WITH_LUA52) ENDIF()
ENDIF(LUABIND_LIBRARY_RELEASE MATCHES "\\.so") ENDIF()
ENDMACRO(FIND_CORRECT_LUA_VERSION) ENDMACRO()
IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR) IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
# in cache already # in cache already
SET(Luabind_FIND_QUIETLY TRUE) SET(Luabind_FIND_QUIETLY TRUE)
ENDIF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR) ENDIF()
FIND_PATH(LUABIND_INCLUDE_DIR FIND_PATH(LUABIND_INCLUDE_DIR
luabind/luabind.hpp luabind/luabind.hpp
@ -72,11 +100,21 @@ FIND_PATH(LUABIND_INCLUDE_DIR
SET(LIBRARY_NAME_RELEASE) SET(LIBRARY_NAME_RELEASE)
SET(LIBRARY_NAME_DEBUG) SET(LIBRARY_NAME_DEBUG)
IF(WITH_LUA53)
IF(WITH_STLPORT)
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua53)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua53d)
ENDIF()
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua53)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua53d)
ENDIF()
IF(WITH_LUA52) IF(WITH_LUA52)
IF(WITH_STLPORT) IF(WITH_STLPORT)
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua52) LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua52)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua52d) LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua52d)
ENDIF(WITH_STLPORT) ENDIF()
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua52) LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua52)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua52d) LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua52d)

@ -14,8 +14,8 @@ MACRO(DETECT_VC_VERSION_HELPER _ROOT _VERSION)
GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;${_VERSION}]" ABSOLUTE) 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") IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
SET(VC${_VERSION}_DIR "${VC${_VERSION}_DIR}VC/") SET(VC${_VERSION}_DIR "${VC${_VERSION}_DIR}VC/")
ENDIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") ENDIF()
ENDIF(VC${_VERSION}_DIR AND VC${_VERSION}_DIR STREQUAL "/registry") ENDIF()
IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
SET(VC${_VERSION}_FOUND ON) SET(VC${_VERSION}_FOUND ON)
@ -24,14 +24,14 @@ MACRO(DETECT_VC_VERSION_HELPER _ROOT _VERSION)
SET(_VERSION_STR ${_VERSION}) SET(_VERSION_STR ${_VERSION})
IF(MSVC_EXPRESS) IF(MSVC_EXPRESS)
SET(_VERSION_STR "${_VERSION_STR} Express") SET(_VERSION_STR "${_VERSION_STR} Express")
ENDIF(MSVC_EXPRESS) ENDIF()
MESSAGE(STATUS "Found Visual C++ ${_VERSION_STR} in ${VC${_VERSION}_DIR}") MESSAGE(STATUS "Found Visual C++ ${_VERSION_STR} in ${VC${_VERSION}_DIR}")
ENDIF(NOT MSVC_FIND_QUIETLY) ENDIF()
ELSEIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") ELSEIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
SET(VC${_VERSION}_FOUND OFF) SET(VC${_VERSION}_FOUND OFF)
SET(VC${_VERSION}_DIR "") SET(VC${_VERSION}_DIR "")
ENDIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") ENDIF()
ENDMACRO(DETECT_VC_VERSION_HELPER) ENDMACRO()
MACRO(DETECT_VC_VERSION _VERSION) MACRO(DETECT_VC_VERSION _VERSION)
SET(VC${_VERSION}_FOUND OFF) SET(VC${_VERSION}_FOUND OFF)
@ -39,21 +39,21 @@ MACRO(DETECT_VC_VERSION _VERSION)
IF(NOT VC${_VERSION}_FOUND) IF(NOT VC${_VERSION}_FOUND)
DETECT_VC_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION}) DETECT_VC_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION})
ENDIF(NOT VC${_VERSION}_FOUND) ENDIF()
IF(VC${_VERSION}_FOUND) IF(VC${_VERSION}_FOUND)
SET(VC_FOUND ON) SET(VC_FOUND ON)
SET(VC_DIR "${VC${_VERSION}_DIR}") SET(VC_DIR "${VC${_VERSION}_DIR}")
ENDIF(VC${_VERSION}_FOUND) ENDIF()
ENDMACRO(DETECT_VC_VERSION) ENDMACRO()
MACRO(DETECT_EXPRESS_VERSION _VERSION) MACRO(DETECT_EXPRESS_VERSION _VERSION)
GET_FILENAME_COMPONENT(MSVC_EXPRESS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\${_VERSION}\\Setup\\VC;ProductDir]" ABSOLUTE) GET_FILENAME_COMPONENT(MSVC_EXPRESS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\${_VERSION}\\Setup\\VC;ProductDir]" ABSOLUTE)
IF(MSVC_EXPRESS AND NOT MSVC_EXPRESS STREQUAL "/registry") IF(MSVC_EXPRESS AND NOT MSVC_EXPRESS STREQUAL "/registry")
SET(MSVC_EXPRESS ON) SET(MSVC_EXPRESS ON)
ENDIF(MSVC_EXPRESS AND NOT MSVC_EXPRESS STREQUAL "/registry") ENDIF()
ENDMACRO(DETECT_EXPRESS_VERSION) ENDMACRO()
IF(MSVC12) IF(MSVC12)
DETECT_VC_VERSION("12.0") DETECT_VC_VERSION("12.0")
@ -62,7 +62,7 @@ IF(MSVC12)
IF(NOT MSVC12_REDIST_DIR) IF(NOT MSVC12_REDIST_DIR)
# If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist # If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC12_REDIST_DIR "${EXTERNAL_PATH}/redist") SET(MSVC12_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC12_REDIST_DIR) ENDIF()
ELSEIF(MSVC11) ELSEIF(MSVC11)
DETECT_VC_VERSION("11.0") DETECT_VC_VERSION("11.0")
SET(MSVC_TOOLSET "110") SET(MSVC_TOOLSET "110")
@ -70,7 +70,7 @@ ELSEIF(MSVC11)
IF(NOT MSVC11_REDIST_DIR) IF(NOT MSVC11_REDIST_DIR)
# If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist # If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC11_REDIST_DIR "${EXTERNAL_PATH}/redist") SET(MSVC11_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC11_REDIST_DIR) ENDIF()
ELSEIF(MSVC10) ELSEIF(MSVC10)
DETECT_VC_VERSION("10.0") DETECT_VC_VERSION("10.0")
SET(MSVC_TOOLSET "100") SET(MSVC_TOOLSET "100")
@ -78,23 +78,28 @@ ELSEIF(MSVC10)
IF(NOT MSVC10_REDIST_DIR) IF(NOT MSVC10_REDIST_DIR)
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist # If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC10_REDIST_DIR "${EXTERNAL_PATH}/redist") SET(MSVC10_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC10_REDIST_DIR) ENDIF()
ELSEIF(MSVC90) ELSEIF(MSVC90)
DETECT_VC_VERSION("9.0") DETECT_VC_VERSION("9.0")
SET(MSVC_TOOLSET "90") SET(MSVC_TOOLSET "90")
ELSEIF(MSVC80) ELSEIF(MSVC80)
DETECT_VC_VERSION("8.0") DETECT_VC_VERSION("8.0")
SET(MSVC_TOOLSET "80") SET(MSVC_TOOLSET "80")
ENDIF(MSVC12) ENDIF()
# If you plan to use VC++ compilers with WINE, set VC_DIR environment variable # If you plan to use VC++ compilers with WINE, set VC_DIR environment variable
IF(NOT VC_DIR) IF(NOT VC_DIR)
SET(VC_DIR $ENV{VC_DIR}) SET(VC_DIR $ENV{VC_DIR})
ENDIF(NOT VC_DIR) ENDIF()
IF(NOT VC_DIR) IF(NOT VC_DIR)
STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${CMAKE_CXX_COMPILER}) IF(CMAKE_CXX_COMPILER)
ENDIF(NOT VC_DIR) SET(_COMPILER ${CMAKE_CXX_COMPILER})
ELSE()
SET(_COMPILER ${CMAKE_C_COMPILER})
ENDIF()
STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${_COMPILER})
ENDIF()
SET(VC_INCLUDE_DIR "${VC_DIR}/include") SET(VC_INCLUDE_DIR "${VC_DIR}/include")
SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR}) SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR})

@ -31,7 +31,7 @@
# MESSAGE("Current revision is ${Project_WC_REVISION}") # MESSAGE("Current revision is ${Project_WC_REVISION}")
# Mercurial_WC_LOG(${PROJECT_SOURCE_DIR} Project) # Mercurial_WC_LOG(${PROJECT_SOURCE_DIR} Project)
# MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}") # MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}")
# ENDIF(MERCURIAL_FOUND) # ENDIF()
#============================================================================= #=============================================================================
# Copyright 2006-2009 Kitware, Inc. # Copyright 2006-2009 Kitware, Inc.
@ -74,22 +74,22 @@ IF(Mercurial_HG_EXECUTABLE)
IF(NOT ${Mercurial_hg_info_result} EQUAL 0) IF(NOT ${Mercurial_hg_info_result} EQUAL 0)
MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} tip\" failed with output:\n${Mercurial_hg_info_error}") MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} tip\" failed with output:\n${Mercurial_hg_info_error}")
ELSE(NOT ${Mercurial_hg_info_result} EQUAL 0) ELSE()
LIST(LENGTH ${prefix}_WC_INFO _COUNT) LIST(LENGTH ${prefix}_WC_INFO _COUNT)
IF(_COUNT EQUAL 4) IF(_COUNT EQUAL 4)
LIST(GET ${prefix}_WC_INFO 0 ${prefix}_WC_REVISION) LIST(GET ${prefix}_WC_INFO 0 ${prefix}_WC_REVISION)
LIST(GET ${prefix}_WC_INFO 1 ${prefix}_WC_CHANGESET) LIST(GET ${prefix}_WC_INFO 1 ${prefix}_WC_CHANGESET)
LIST(GET ${prefix}_WC_INFO 2 ${prefix}_WC_BRANCH) LIST(GET ${prefix}_WC_INFO 2 ${prefix}_WC_BRANCH)
LIST(GET ${prefix}_WC_INFO 3 ${prefix}_WC_LAST_CHANGED_AUTHOR) LIST(GET ${prefix}_WC_INFO 3 ${prefix}_WC_LAST_CHANGED_AUTHOR)
ELSE(_COUNT EQUAL 4) ELSE()
MESSAGE(STATUS "Bad output from HG") MESSAGE(STATUS "Bad output from HG")
SET(${prefix}_WC_REVISION "unknown") SET(${prefix}_WC_REVISION "unknown")
SET(${prefix}_WC_CHANGESET "unknown") SET(${prefix}_WC_CHANGESET "unknown")
SET(${prefix}_WC_BRANCH "unknown") SET(${prefix}_WC_BRANCH "unknown")
ENDIF(_COUNT EQUAL 4) ENDIF()
ENDIF(NOT ${Mercurial_hg_info_result} EQUAL 0) ENDIF()
ENDMACRO(Mercurial_WC_INFO) ENDMACRO()
MACRO(Mercurial_WC_LOG dir prefix) MACRO(Mercurial_WC_LOG dir prefix)
# This macro can block if the certificate is not signed: # This macro can block if the certificate is not signed:
@ -105,9 +105,9 @@ IF(Mercurial_HG_EXECUTABLE)
IF(NOT ${Mercurial_hg_log_result} EQUAL 0) IF(NOT ${Mercurial_hg_log_result} EQUAL 0)
MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} log -r BASE ${dir}\" failed with output:\n${Mercurial_hg_log_error}") MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} log -r BASE ${dir}\" failed with output:\n${Mercurial_hg_log_error}")
ENDIF(NOT ${Mercurial_hg_log_result} EQUAL 0) ENDIF()
ENDMACRO(Mercurial_WC_LOG) ENDMACRO()
ENDIF(Mercurial_HG_EXECUTABLE) ENDIF()
INCLUDE(FindPackageHandleStandardArgs) INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Mercurial DEFAULT_MSG Mercurial_HG_EXECUTABLE) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Mercurial DEFAULT_MSG Mercurial_HG_EXECUTABLE)

@ -17,9 +17,12 @@ ELSE()
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
PATHS
/usr/include/mysql /usr/include/mysql
/usr/local/include/mysql /usr/local/include/mysql
/opt/local/include/mysql5/mysql /opt/local/include/mysql5/mysql
/opt/local/include/mysql55/mysql
/opt/local/include/mysql51/mysql
$ENV{ProgramFiles}/MySQL/*/include $ENV{ProgramFiles}/MySQL/*/include
$ENV{SystemDrive}/MySQL/*/include) $ENV{SystemDrive}/MySQL/*/include)
@ -41,6 +44,8 @@ ELSE()
/usr/lib/mysql /usr/lib/mysql
/usr/local/lib/mysql /usr/local/lib/mysql
/opt/local/lib/mysql5/mysql /opt/local/lib/mysql5/mysql
/opt/local/lib/mysql55/mysql
/opt/local/lib/mysql51/mysql
) )
FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES mysqlclientd FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES mysqlclientd
@ -50,6 +55,8 @@ ELSE()
/usr/lib/mysql /usr/lib/mysql
/usr/local/lib/mysql /usr/local/lib/mysql
/opt/local/lib/mysql5/mysql /opt/local/lib/mysql5/mysql
/opt/local/lib/mysql55/mysql
/opt/local/lib/mysql51/mysql
) )
ENDIF() ENDIF()

@ -9,7 +9,7 @@
IF(WINSDK_FOUND) IF(WINSDK_FOUND)
# If Windows SDK already found, skip it # If Windows SDK already found, skip it
RETURN() RETURN()
ENDIF(WINSDK_FOUND) ENDIF()
# Values can be CURRENT or any existing versions 7.1, 8.0A, etc... # Values can be CURRENT or any existing versions 7.1, 8.0A, etc...
SET(WINSDK_VERSION "CURRENT" CACHE STRING "Windows SDK version to prefer") SET(WINSDK_VERSION "CURRENT" CACHE STRING "Windows SDK version to prefer")
@ -17,16 +17,31 @@ SET(WINSDK_VERSION "CURRENT" CACHE STRING "Windows SDK version to prefer")
MACRO(DETECT_WINSDK_VERSION_HELPER _ROOT _VERSION) MACRO(DETECT_WINSDK_VERSION_HELPER _ROOT _VERSION)
GET_FILENAME_COMPONENT(WINSDK${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v${_VERSION};InstallationFolder]" ABSOLUTE) GET_FILENAME_COMPONENT(WINSDK${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v${_VERSION};InstallationFolder]" ABSOLUTE)
IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry") IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry" AND EXISTS "${WINSDK${_VERSION}_DIR}/Include")
SET(WINSDK${_VERSION}_FOUND ON) SET(WINSDK${_VERSION}_FOUND ON)
GET_FILENAME_COMPONENT(WINSDK${_VERSION}_VERSION_FULL "[${_ROOT}\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v${_VERSION};ProductVersion]" NAME) GET_FILENAME_COMPONENT(WINSDK${_VERSION}_VERSION_FULL "[${_ROOT}\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v${_VERSION};ProductVersion]" NAME)
IF(NOT WindowsSDK_FIND_QUIETLY) IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${_VERSION} in ${WINSDK${_VERSION}_DIR}") MESSAGE(STATUS "Found Windows SDK ${_VERSION} in ${WINSDK${_VERSION}_DIR}")
ENDIF(NOT WindowsSDK_FIND_QUIETLY) ENDIF()
ELSE(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry") ELSE()
SET(WINSDK${_VERSION}_DIR "") SET(WINSDK${_VERSION}_DIR "")
ENDIF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry") ENDIF()
ENDMACRO(DETECT_WINSDK_VERSION_HELPER) ENDMACRO()
MACRO(DETECT_WINKIT_VERSION _VERSION _SUFFIX)
GET_FILENAME_COMPONENT(WINSDK${_VERSION}_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot${_SUFFIX}]" ABSOLUTE)
IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry")
SET(WINSDK${_VERSION}_FOUND ON)
SET(WINSDK${_VERSION}_VERSION_FULL "${_VERSION}")
IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${_VERSION} in ${WINSDK${_VERSION}_DIR}")
ENDIF()
LIST(APPEND WINSDK_DETECTED_VERSIONS ${_VERSION})
ELSE()
SET(WINSDK${_VERSION}_DIR "")
ENDIF()
ENDMACRO()
MACRO(DETECT_WINSDK_VERSION _VERSION) MACRO(DETECT_WINSDK_VERSION _VERSION)
SET(WINSDK${_VERSION}_FOUND OFF) SET(WINSDK${_VERSION}_FOUND OFF)
@ -34,43 +49,52 @@ MACRO(DETECT_WINSDK_VERSION _VERSION)
IF(NOT WINSDK${_VERSION}_FOUND) IF(NOT WINSDK${_VERSION}_FOUND)
DETECT_WINSDK_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION}) DETECT_WINSDK_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION})
ENDIF(NOT WINSDK${_VERSION}_FOUND) ENDIF()
ENDMACRO(DETECT_WINSDK_VERSION) ENDMACRO()
SET(WINSDK_VERSIONS "8.0" "8.0A" "7.1" "7.1A" "7.0" "7.0A" "6.1" "6.0" "6.0A")
SET(WINSDK_DETECTED_VERSIONS) SET(WINSDK_DETECTED_VERSIONS)
# Fixed versions for Windows Kits (VC++ from 2012)
DETECT_WINKIT_VERSION("10.0" "10")
DETECT_WINKIT_VERSION("8.1" "81")
DETECT_WINKIT_VERSION("8.0" "")
# For VC++ up to 2010
SET(WINSDK_VERSIONS "7.1" "7.1A" "7.0" "7.0A" "6.1" "6.0" "6.0A")
# Search all supported Windows SDKs # Search all supported Windows SDKs
FOREACH(_VERSION ${WINSDK_VERSIONS}) FOREACH(_VERSION ${WINSDK_VERSIONS})
DETECT_WINSDK_VERSION(${_VERSION}) DETECT_WINSDK_VERSION(${_VERSION})
IF(WINSDK${_VERSION}_FOUND) IF(WINSDK${_VERSION}_FOUND)
LIST(APPEND WINSDK_DETECTED_VERSIONS ${_VERSION}) LIST(APPEND WINSDK_DETECTED_VERSIONS ${_VERSION})
ENDIF(WINSDK${_VERSION}_FOUND) ENDIF()
ENDFOREACH(_VERSION) ENDFOREACH()
SET(WINSDK_SUFFIX) SET(WINSDK_SUFFIXES)
IF(TARGET_ARM) IF(TARGET_ARM64)
SET(WINSDK8_SUFFIX "arm64")
ELSEIF(TARGET_ARM)
SET(WINSDK8_SUFFIX "arm") SET(WINSDK8_SUFFIX "arm")
ELSEIF(TARGET_X64) ELSEIF(TARGET_X64)
SET(WINSDK8_SUFFIX "x64") SET(WINSDK8_SUFFIX "x64")
SET(WINSDK_SUFFIX "x64") SET(WINSDK_SUFFIXES "x64" "amd64")
ELSEIF(TARGET_X86) ELSEIF(TARGET_X86)
SET(WINSDK8_SUFFIX "x86") SET(WINSDK8_SUFFIX "x86")
ENDIF(TARGET_ARM) ENDIF()
SET(WINSDKCURRENT_VERSION_INCLUDE $ENV{INCLUDE}) SET(WINSDKCURRENT_VERSION_INCLUDE $ENV{INCLUDE})
IF(WINSDKCURRENT_VERSION_INCLUDE) IF(WINSDKCURRENT_VERSION_INCLUDE)
FILE(TO_CMAKE_PATH "${WINSDKCURRENT_VERSION_INCLUDE}" WINSDKCURRENT_VERSION_INCLUDE) FILE(TO_CMAKE_PATH "${WINSDKCURRENT_VERSION_INCLUDE}" WINSDKCURRENT_VERSION_INCLUDE)
ENDIF(WINSDKCURRENT_VERSION_INCLUDE) ENDIF()
SET(WINSDKENV_DIR $ENV{WINSDK_DIR}) SET(WINSDKENV_DIR $ENV{WINSDK_DIR})
IF(NOT WINSDKENV_DIR) IF(NOT WINSDKENV_DIR)
SET(WINSDKENV_DIR $ENV{WindowsSDKDir}) SET(WINSDKENV_DIR $ENV{WindowsSDKDir})
ENDIF(NOT WINSDKENV_DIR) ENDIF()
MACRO(FIND_WINSDK_VERSION_HEADERS) MACRO(FIND_WINSDK_VERSION_HEADERS)
IF(WINSDK_DIR AND NOT WINSDK_VERSION) IF(WINSDK_DIR AND NOT WINSDK_VERSION)
@ -82,12 +106,23 @@ MACRO(FIND_WINSDK_VERSION_HEADERS)
) )
IF(_MSI_FILE) IF(_MSI_FILE)
IF(NOT WINSDK_VERSION)
# Look for Windows SDK 8.1
FILE(STRINGS ${_MSI_FILE} _CONTENT REGEX "^#ifndef NTDDI_WINBLUE")
IF(_CONTENT)
SET(WINSDK_VERSION "8.1")
ENDIF()
ENDIF()
IF(NOT WINSDK_VERSION)
# Look for Windows SDK 8.0 # Look for Windows SDK 8.0
FILE(STRINGS ${_MSI_FILE} _CONTENT REGEX "^#ifndef NTDDI_WIN8") FILE(STRINGS ${_MSI_FILE} _CONTENT REGEX "^#ifndef NTDDI_WIN8")
IF(_CONTENT) IF(_CONTENT)
SET(WINSDK_VERSION "8.0") SET(WINSDK_VERSION "8.0")
ENDIF(_CONTENT) ENDIF()
ENDIF()
IF(NOT WINSDK_VERSION) IF(NOT WINSDK_VERSION)
# Look for Windows SDK 7.0 # Look for Windows SDK 7.0
@ -112,14 +147,14 @@ MACRO(FIND_WINSDK_VERSION_HEADERS)
SET(WINSDK_VERSION "7.1") SET(WINSDK_VERSION "7.1")
ELSEIF(_WINSDKVER STREQUAL "0601") ELSEIF(_WINSDKVER STREQUAL "0601")
SET(WINSDK_VERSION "7.0A") SET(WINSDK_VERSION "7.0A")
ELSE(_WINSDKVER STREQUAL "06010000") ELSE()
MESSAGE(FATAL_ERROR "Can't determine Windows SDK version with NTDDI_MAXVER 0x${_WINSDKVER}") MESSAGE(FATAL_ERROR "Can't determine Windows SDK version with NTDDI_MAXVER 0x${_WINSDKVER}")
ENDIF(_WINSDKVER STREQUAL "06010000") ENDIF()
ELSE(_WINSDKVER_FILE) ELSE()
SET(WINSDK_VERSION "7.0") SET(WINSDK_VERSION "7.0")
ENDIF(_WINSDKVER_FILE) ENDIF()
ENDIF(_CONTENT) ENDIF()
ENDIF(NOT WINSDK_VERSION) ENDIF()
IF(NOT WINSDK_VERSION) IF(NOT WINSDK_VERSION)
# Look for Windows SDK 6.0 # Look for Windows SDK 6.0
@ -127,8 +162,8 @@ MACRO(FIND_WINSDK_VERSION_HEADERS)
IF(_CONTENT) IF(_CONTENT)
SET(WINSDK_VERSION "6.0") SET(WINSDK_VERSION "6.0")
ENDIF(_CONTENT) ENDIF()
ENDIF(NOT WINSDK_VERSION) ENDIF()
IF(NOT WINSDK_VERSION) IF(NOT WINSDK_VERSION)
# Look for Windows SDK 5.2 # Look for Windows SDK 5.2
@ -136,8 +171,8 @@ MACRO(FIND_WINSDK_VERSION_HEADERS)
IF(_CONTENT) IF(_CONTENT)
SET(WINSDK_VERSION "5.2") SET(WINSDK_VERSION "5.2")
ENDIF(_CONTENT) ENDIF()
ENDIF(NOT WINSDK_VERSION) ENDIF()
IF(NOT WINSDK_VERSION) IF(NOT WINSDK_VERSION)
# Look for Windows SDK 5.1 # Look for Windows SDK 5.1
@ -145,8 +180,8 @@ MACRO(FIND_WINSDK_VERSION_HEADERS)
IF(_CONTENT) IF(_CONTENT)
SET(WINSDK_VERSION "5.1") SET(WINSDK_VERSION "5.1")
ENDIF(_CONTENT) ENDIF()
ENDIF(NOT WINSDK_VERSION) ENDIF()
IF(NOT WINSDK_VERSION) IF(NOT WINSDK_VERSION)
# Look for Windows SDK 5.0 # Look for Windows SDK 5.0
@ -154,13 +189,13 @@ MACRO(FIND_WINSDK_VERSION_HEADERS)
IF(_CONTENT) IF(_CONTENT)
SET(WINSDK_VERSION "5.0") SET(WINSDK_VERSION "5.0")
ENDIF(_CONTENT) ENDIF()
ENDIF(NOT WINSDK_VERSION) ENDIF()
ELSE(_MSI_FILE) ELSE()
MESSAGE(FATAL_ERROR "Unable to find Msi.h in ${WINSDK_DIR}") MESSAGE(FATAL_ERROR "Unable to find Msi.h in ${WINSDK_DIR}")
ENDIF(_MSI_FILE) ENDIF()
ENDIF(WINSDK_DIR AND NOT WINSDK_VERSION) ENDIF()
ENDMACRO(FIND_WINSDK_VERSION_HEADERS) ENDMACRO()
MACRO(USE_CURRENT_WINSDK) MACRO(USE_CURRENT_WINSDK)
SET(WINSDK_DIR "") SET(WINSDK_DIR "")
@ -174,7 +209,7 @@ MACRO(USE_CURRENT_WINSDK)
${WINSDKENV_DIR}/Include/um ${WINSDKENV_DIR}/Include/um
${WINSDKENV_DIR}/Include ${WINSDKENV_DIR}/Include
) )
ENDIF(WINSDKENV_DIR) ENDIF()
# Use INCLUDE environment variable # Use INCLUDE environment variable
IF(NOT WINSDK_DIR AND WINSDKCURRENT_VERSION_INCLUDE) IF(NOT WINSDK_DIR AND WINSDKCURRENT_VERSION_INCLUDE)
@ -186,9 +221,9 @@ MACRO(USE_CURRENT_WINSDK)
STRING(REGEX REPLACE "/(include|INCLUDE|Include)(.*)" "" WINSDK_DIR ${_INCLUDE}) STRING(REGEX REPLACE "/(include|INCLUDE|Include)(.*)" "" WINSDK_DIR ${_INCLUDE})
MESSAGE(STATUS "Found Windows SDK in INCLUDE environment variable: ${WINSDK_DIR}") MESSAGE(STATUS "Found Windows SDK in INCLUDE environment variable: ${WINSDK_DIR}")
BREAK() BREAK()
ENDIF(EXISTS ${_INCLUDE}/Windows.h) ENDIF()
ENDFOREACH(_INCLUDE) ENDFOREACH()
ENDIF(NOT WINSDK_DIR AND WINSDKCURRENT_VERSION_INCLUDE) ENDIF()
IF(WINSDK_DIR) IF(WINSDK_DIR)
# Compare WINSDK_DIR with registered Windows SDKs # Compare WINSDK_DIR with registered Windows SDKs
@ -197,38 +232,44 @@ MACRO(USE_CURRENT_WINSDK)
SET(WINSDK_VERSION ${_VERSION}) SET(WINSDK_VERSION ${_VERSION})
SET(WINSDK_VERSION_FULL "${WINSDK${WINSDK_VERSION}_VERSION_FULL}") SET(WINSDK_VERSION_FULL "${WINSDK${WINSDK_VERSION}_VERSION_FULL}")
BREAK() BREAK()
ENDIF(WINSDK_DIR STREQUAL "${WINSDK${_VERSION}_DIR}") ENDIF()
ENDFOREACH(_VERSION) ENDFOREACH()
FIND_WINSDK_VERSION_HEADERS() FIND_WINSDK_VERSION_HEADERS()
ENDIF(WINSDK_DIR) ENDIF()
IF(NOT WINSDK_DIR) IF(NOT WINSDK_DIR)
# Use Windows SDK versions installed with VC++ when possible # Use Windows SDK versions installed with VC++ when possible
IF(MSVC12) IF(MSVC14)
SET(WINSDK_VERSION "8.1A") SET(WINSDK_VERSION "8.1")
ELSEIF(MSVC12)
SET(WINSDK_VERSION "8.1")
ELSEIF(MSVC11) ELSEIF(MSVC11)
SET(WINSDK_VERSION "8.0A") SET(WINSDK_VERSION "8.0")
ELSEIF(MSVC10) ELSEIF(MSVC10)
IF(NOT TARGET_X64 OR NOT MSVC_EXPRESS) IF(NOT TARGET_X64 OR NOT MSVC_EXPRESS)
SET(WINSDK_VERSION "7.0A") SET(WINSDK_VERSION "7.0A")
ENDIF(NOT TARGET_X64 OR NOT MSVC_EXPRESS) ENDIF()
ELSEIF(MSVC90) ELSEIF(MSVC90)
IF(NOT MSVC_EXPRESS) IF(NOT MSVC_EXPRESS)
SET(WINSDK_VERSION "6.0A") SET(WINSDK_VERSION "6.0A")
ENDIF(NOT MSVC_EXPRESS) ENDIF()
ELSEIF(MSVC80) ELSEIF(MSVC80)
IF(NOT MSVC_EXPRESS) IF(NOT MSVC_EXPRESS)
# TODO: fix this version # TODO: fix this version
SET(WINSDK_VERSION "5.2A") SET(WINSDK_VERSION "5.2A")
ENDIF(NOT MSVC_EXPRESS) ENDIF()
ELSE(MSVC12) ELSE()
MESSAGE(FATAL_ERROR "Your compiler is either too old or too recent, please update this CMake module.") MESSAGE(FATAL_ERROR "Your compiler is either too old or too recent, please update this CMake module.")
ENDIF(MSVC12) ENDIF()
# Use installed Windows SDK # Use installed Windows SDK
IF(NOT WINSDK_VERSION) IF(NOT WINSDK_VERSION)
IF(WINSDK7.1_FOUND) IF(WINSDK8.1_FOUND)
SET(WINSDK_VERSION "8.1")
ELSEIF(WINSDK8.0_FOUND)
SET(WINSDK_VERSION "8.0")
ELSEIF(WINSDK7.1_FOUND)
SET(WINSDK_VERSION "7.1") SET(WINSDK_VERSION "7.1")
ELSEIF(WINSDK7.0_FOUND) ELSEIF(WINSDK7.0_FOUND)
SET(WINSDK_VERSION "7.0") SET(WINSDK_VERSION "7.0")
@ -236,10 +277,10 @@ MACRO(USE_CURRENT_WINSDK)
SET(WINSDK_VERSION "6.1") SET(WINSDK_VERSION "6.1")
ELSEIF(WINSDK6.0_FOUND) ELSEIF(WINSDK6.0_FOUND)
SET(WINSDK_VERSION "6.0") SET(WINSDK_VERSION "6.0")
ELSE(WINSDK7.1_FOUND) ELSE()
MESSAGE(FATAL_ERROR "You have no compatible Windows SDK installed.") MESSAGE(FATAL_ERROR "You have no compatible Windows SDK installed.")
ENDIF(WINSDK7.1_FOUND) ENDIF()
ENDIF(NOT WINSDK_VERSION) ENDIF()
# Look for correct registered Windows SDK version # Look for correct registered Windows SDK version
FOREACH(_VERSION ${WINSDK_DETECTED_VERSIONS}) FOREACH(_VERSION ${WINSDK_DETECTED_VERSIONS})
@ -247,27 +288,37 @@ MACRO(USE_CURRENT_WINSDK)
SET(WINSDK_VERSION_FULL "${WINSDK${WINSDK_VERSION}_VERSION_FULL}") SET(WINSDK_VERSION_FULL "${WINSDK${WINSDK_VERSION}_VERSION_FULL}")
SET(WINSDK_DIR "${WINSDK${WINSDK_VERSION}_DIR}") SET(WINSDK_DIR "${WINSDK${WINSDK_VERSION}_DIR}")
BREAK() BREAK()
ENDIF(WINSDK_VERSION STREQUAL _VERSION) ENDIF()
ENDFOREACH(_VERSION) ENDFOREACH()
ENDIF(NOT WINSDK_DIR) ENDIF()
ENDMACRO(USE_CURRENT_WINSDK) ENDMACRO()
IF(MSVC14)
# Under VC++ 2015, stdio.h, stdlib.h, etc... are part of UCRT
SET(WINSDK_UCRT_VERSION "10.0")
ENDIF()
# Look for correct UCRT
IF(WINSDK_UCRT_VERSION AND WINSDK${WINSDK_UCRT_VERSION}_FOUND)
SET(WINSDK_UCRT_DIR "${WINSDK${WINSDK_UCRT_VERSION}_DIR}")
ENDIF()
IF(WINSDK_VERSION STREQUAL "CURRENT") IF(WINSDK_VERSION STREQUAL "CURRENT")
USE_CURRENT_WINSDK() USE_CURRENT_WINSDK()
ELSE(WINSDK_VERSION STREQUAL "CURRENT") ELSE()
IF(WINSDK${WINSDK_VERSION}_FOUND) IF(WINSDK${WINSDK_VERSION}_FOUND)
SET(WINSDK_VERSION_FULL "${WINSDK${WINSDK_VERSION}_VERSION_FULL}") SET(WINSDK_VERSION_FULL "${WINSDK${WINSDK_VERSION}_VERSION_FULL}")
SET(WINSDK_DIR "${WINSDK${WINSDK_VERSION}_DIR}") SET(WINSDK_DIR "${WINSDK${WINSDK_VERSION}_DIR}")
ELSE(WINSDK${WINSDK_VERSION}_FOUND) ELSE()
USE_CURRENT_WINSDK() USE_CURRENT_WINSDK()
ENDIF(WINSDK${WINSDK_VERSION}_FOUND) ENDIF()
ENDIF(WINSDK_VERSION STREQUAL "CURRENT") ENDIF()
IF(WINSDK_DIR) IF(WINSDK_DIR)
MESSAGE(STATUS "Using Windows SDK ${WINSDK_VERSION}") MESSAGE(STATUS "Using Windows SDK ${WINSDK_VERSION}")
ELSE(WINSDK_DIR) ELSE()
MESSAGE(FATAL_ERROR "Unable to find Windows SDK!") MESSAGE(FATAL_ERROR "Unable to find Windows SDK!")
ENDIF(WINSDK_DIR) ENDIF()
# directory where Win32 headers are found # directory where Win32 headers are found
FIND_PATH(WINSDK_INCLUDE_DIR Windows.h FIND_PATH(WINSDK_INCLUDE_DIR Windows.h
@ -276,30 +327,64 @@ FIND_PATH(WINSDK_INCLUDE_DIR Windows.h
${WINSDK_DIR}/Include ${WINSDK_DIR}/Include
) )
# directory where WinRT headers are found
FIND_PATH(WINSDK_WINRT_INCLUDE_DIR winstring.h
HINTS
${WINSDK_DIR}/Include/winrt
)
# directory where DirectX headers are found # directory where DirectX headers are found
FIND_PATH(WINSDK_SHARED_INCLUDE_DIR d3d9.h FIND_PATH(WINSDK_SHARED_INCLUDE_DIR d3d9.h
HINTS HINTS
${WINSDK_DIR}/Include/shared ${WINSDK_DIR}/Include/shared
${WINSDK_DIR}/Include
) )
# directory where OpenGL headers are found # directory where OpenGL headers are found
FIND_PATH(WINSDK_OPENGL_INCLUDE_DIR GL.h FIND_PATH(WINSDK_OPENGL_INCLUDE_DIR GL.h
HINTS HINTS
${WINSDK_DIR}/Include/um/gl
${WINSDK_DIR}/Include/gl ${WINSDK_DIR}/Include/gl
${WINSDK_DIR}/Include
) )
SET(WINSDK_LIBRARY_DIRS
${WINSDK_DIR}/Lib/winv6.3/um/${WINSDK8_SUFFIX}
${WINSDK_DIR}/Lib/win8/um/${WINSDK8_SUFFIX}
)
IF(WINSDK_SUFFIXES)
FOREACH(_SUFFIX ${WINSDK_SUFFIXES})
SET(WINSDK_LIBRARY_DIRS ${WINSDK_LIBRARY_DIRS} ${WINSDK_DIR}/Lib/${_SUFFIX})
ENDFOREACH()
ELSE()
SET(WINSDK_LIBRARY_DIRS ${WINSDK_LIBRARY_DIRS} ${WINSDK_DIR}/Lib)
ENDIF()
# directory where all libraries are found # directory where all libraries are found
FIND_PATH(WINSDK_LIBRARY_DIR ComCtl32.lib FIND_PATH(WINSDK_LIBRARY_DIR ComCtl32.lib
HINTS HINTS
${WINSDK_DIR}/Lib/win8/um/${WINSDK8_SUFFIX} ${WINSDK_LIBRARY_DIRS}
${WINSDK_DIR}/Lib/${WINSDK_SUFFIX} )
IF(WINSDK_UCRT_DIR)
# directory where UCRT headers are found
FIND_PATH(WINSDK_UCRT_INCLUDE_DIR corecrt.h
HINTS
${WINSDK_UCRT_DIR}/Include/10.0.10056.0/ucrt
${WINSDK_UCRT_DIR}/Include/10.0.10150.0/ucrt
) )
# directory where UCRT libraries are found
FIND_PATH(WINSDK_UCRT_LIBRARY_DIR ucrt.lib
HINTS
${WINSDK_UCRT_DIR}/Lib/10.0.10056.0/ucrt/${WINSDK8_SUFFIX}
${WINSDK_UCRT_DIR}/Lib/10.0.10150.0/ucrt/${WINSDK8_SUFFIX}
)
ENDIF()
# signtool is used to sign executables # signtool is used to sign executables
FIND_PROGRAM(WINSDK_SIGNTOOL signtool FIND_PROGRAM(WINSDK_SIGNTOOL signtool
HINTS HINTS
${WINSDK_DIR}/Bin/${WINSDK8_SUFFIX}
${WINSDK_DIR}/Bin/x86 ${WINSDK_DIR}/Bin/x86
${WINSDK_DIR}/Bin ${WINSDK_DIR}/Bin
) )
@ -307,22 +392,46 @@ FIND_PROGRAM(WINSDK_SIGNTOOL signtool
# midl is used to generate IDL interfaces # midl is used to generate IDL interfaces
FIND_PROGRAM(WINSDK_MIDL midl FIND_PROGRAM(WINSDK_MIDL midl
HINTS HINTS
${WINSDK_DIR}/Bin/${WINSDK8_SUFFIX}
${WINSDK_DIR}/Bin/x86 ${WINSDK_DIR}/Bin/x86
${WINSDK_DIR}/Bin ${WINSDK_DIR}/Bin
) )
IF(WINSDK_INCLUDE_DIR) IF(WINSDK_INCLUDE_DIR)
SET(WINSDK_FOUND ON) SET(WINSDK_FOUND ON)
SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIR} ${WINSDK_SHARED_INCLUDE_DIR} ${WINSDK_OPENGL_INCLUDE_DIR})
IF(WINSDK_UCRT_INCLUDE_DIR)
SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIRS} ${WINSDK_UCRT_INCLUDE_DIR})
ENDIF()
IF(WINSDK_SHARED_INCLUDE_DIR)
SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIRS} ${WINSDK_SHARED_INCLUDE_DIR})
ENDIF()
SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIRS} ${WINSDK_INCLUDE_DIR})
IF(WINSDK_OPENGL_INCLUDE_DIR)
SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIRS} ${WINSDK_OPENGL_INCLUDE_DIR})
ENDIF()
IF(WINSDK_WINRT_INCLUDE_DIR)
SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIRS} ${WINSDK_WINRT_INCLUDE_DIR})
ENDIF()
INCLUDE_DIRECTORIES(${WINSDK_INCLUDE_DIRS}) # TODO: Move this after all other includes somehow...
IF(WINSDK_UCRT_LIBRARY_DIR)
SET(CMAKE_LIBRARY_PATH ${WINSDK_UCRT_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH})
ENDIF()
SET(CMAKE_LIBRARY_PATH ${WINSDK_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH}) 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 # Fix for using Windows SDK 7.1 with Visual C++ 2012
IF(WINSDK_VERSION STREQUAL "7.1" AND MSVC11) IF(WINSDK_VERSION STREQUAL "7.1" AND MSVC11)
ADD_DEFINITIONS(-D_USING_V110_SDK71_) ADD_DEFINITIONS(-D_USING_V110_SDK71_)
ENDIF(WINSDK_VERSION STREQUAL "7.1" AND MSVC11) ENDIF()
ELSE(WINSDK_INCLUDE_DIR) ELSE()
IF(NOT WindowsSDK_FIND_QUIETLY) IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Windows SDK!") MESSAGE(STATUS "Warning: Unable to find Windows SDK!")
ENDIF(NOT WindowsSDK_FIND_QUIETLY) ENDIF()
ENDIF(WINSDK_INCLUDE_DIR) ENDIF()

@ -0,0 +1,29 @@
FIND_PATH(
assimp_INCLUDE_DIRS
NAMES assimp/postprocess.h assimp/scene.h assimp/version.h assimp/config.h assimp/cimport.h
PATHS /usr/local/include/
)
FIND_LIBRARY(
assimp_LIBRARIES
NAMES assimp
PATHS /usr/local/lib/
)
IF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
SET(assimp_FOUND TRUE)
FIND_PACKAGE(ZLIB)
IF(ZLIB_FOUND)
SET(assimp_LIBRARIES ${assimp_LIBRARIES} ${ZLIB_LIBRARIES})
ENDIF()
ENDIF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
IF (assimp_FOUND)
IF (NOT assimp_FIND_QUIETLY)
MESSAGE(STATUS "Found asset importer library: ${assimp_LIBRARIES}")
ENDIF (NOT assimp_FIND_QUIETLY)
ELSE (assimp_FOUND)
IF (assimp_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find asset importer library")
ENDIF (assimp_FIND_REQUIRED)
ENDIF (assimp_FOUND)

@ -2,12 +2,13 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3)
# ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory) # ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory)
# SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt) # SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt)
# BINARY_DIR should be set to root of your build directory
IF(SOURCE_DIR) IF(SOURCE_DIR)
# Replace spaces by semi-columns # Replace spaces by semi-columns
IF(CMAKE_MODULE_PATH) IF(CMAKE_MODULE_PATH)
STRING(REPLACE " " ";" CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) STRING(REPLACE " " ";" CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
ENDIF(CMAKE_MODULE_PATH) ENDIF()
SET(CMAKE_MODULE_PATH ${SOURCE_DIR}/CMakeModules ${CMAKE_MODULE_PATH}) SET(CMAKE_MODULE_PATH ${SOURCE_DIR}/CMakeModules ${CMAKE_MODULE_PATH})
@ -20,10 +21,16 @@ IF(SOURCE_DIR)
ENDIF() ENDIF()
ELSE() ELSE()
SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}) SET(SOURCE_DIR ${CMAKE_SOURCE_DIR})
SET(ROOT_DIR ${CMAKE_SOURCE_DIR}) SET(ROOT_DIR ${CMAKE_SOURCE_DIR}/..)
# convert ROOT_DIR to absolute path
GET_FILENAME_COMPONENT(ROOT_DIR ${ROOT_DIR} ABSOLUTE)
ENDIF() ENDIF()
MACRO(NOW RESULT) MACRO(NOW RESULT)
IF(CMAKE_VERSION VERSION_GREATER "2.8.10")
STRING(TIMESTAMP ${RESULT} "%Y-%m-%d %H:%M:%S")
ELSE()
IF(WIN32) IF(WIN32)
EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME) EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME)
IF(NOT DATETIME MATCHES "ERROR") IF(NOT DATETIME MATCHES "ERROR")
@ -36,7 +43,8 @@ MACRO(NOW RESULT)
MESSAGE(SEND_ERROR "date not implemented") MESSAGE(SEND_ERROR "date not implemented")
SET(${RESULT} "0000-00-00 00:00:00") SET(${RESULT} "0000-00-00 00:00:00")
ENDIF() ENDIF()
ENDMACRO(NOW) ENDIF()
ENDMACRO()
IF(EXISTS "${ROOT_DIR}/.svn/") IF(EXISTS "${ROOT_DIR}/.svn/")
FIND_PACKAGE(Subversion QUIET) FIND_PACKAGE(Subversion QUIET)
@ -44,14 +52,14 @@ IF(EXISTS "${ROOT_DIR}/.svn/")
IF(SUBVERSION_FOUND) IF(SUBVERSION_FOUND)
Subversion_WC_INFO(${ROOT_DIR} ER) Subversion_WC_INFO(${ROOT_DIR} ER)
SET(REVISION ${ER_WC_REVISION}) SET(REVISION ${ER_WC_REVISION})
ENDIF(SUBVERSION_FOUND) ENDIF()
FIND_PACKAGE(TortoiseSVN QUIET) FIND_PACKAGE(TortoiseSVN QUIET)
IF(TORTOISESVN_FOUND) IF(TORTOISESVN_FOUND)
TORTOISESVN_GET_REVISION(${ROOT_DIR} REVISION) TORTOISESVN_GET_REVISION(${ROOT_DIR} REVISION)
ENDIF(TORTOISESVN_FOUND) ENDIF()
ENDIF(EXISTS "${ROOT_DIR}/.svn/") ENDIF()
IF(EXISTS "${ROOT_DIR}/.hg/") IF(EXISTS "${ROOT_DIR}/.hg/")
FIND_PACKAGE(Mercurial) FIND_PACKAGE(Mercurial)
@ -73,11 +81,6 @@ IF(SOURCE_DIR AND NOT DEFINED REVISION)
ENDIF() ENDIF()
ENDIF() ENDIF()
IF(SOURCE_DIR AND DEFINED REVISION) IF(DEFINED REVISION)
IF(EXISTS ${SOURCE_DIR}/revision.h.in) MESSAGE(STATUS "Found revision ${REVISION}")
MESSAGE(STATUS "Revision: ${REVISION}")
NOW(BUILD_DATE)
CONFIGURE_FILE(${SOURCE_DIR}/revision.h.in revision.h.txt)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy revision.h.txt revision.h) # copy_if_different
ENDIF()
ENDIF() ENDIF()

@ -10,22 +10,22 @@
IF(MSVC) IF(MSVC)
SET(PCHSupport_FOUND TRUE) SET(PCHSupport_FOUND TRUE)
ELSE(MSVC) ELSE()
IF(CMAKE_COMPILER_IS_GNUCXX) IF(CMAKE_COMPILER_IS_GNUCXX)
EXEC_PROGRAM(${CMAKE_CXX_COMPILER} EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE gcc_compiler_version) OUTPUT_VARIABLE gcc_compiler_version)
IF(gcc_compiler_version MATCHES "^4\\.1(\\.[0-9]+)?") IF(gcc_compiler_version VERSION_LESS "4.2")
SET(PCHSupport_FOUND FALSE) SET(PCHSupport_FOUND FALSE)
ELSEIF(gcc_compiler_version MATCHES "^4\\.[0-9]+(\\.[0-9]+)?") ELSE()
SET(PCHSupport_FOUND TRUE) SET(PCHSupport_FOUND TRUE)
ENDIF(gcc_compiler_version MATCHES "^4\\.1(\\.[0-9]+)?") ENDIF()
ELSE(CMAKE_COMPILER_IS_GNUCXX) ELSE()
# TODO: make tests for other compilers than GCC # TODO: make tests for other compilers than GCC
SET(PCHSupport_FOUND TRUE) SET(PCHSupport_FOUND TRUE)
ENDIF(CMAKE_COMPILER_IS_GNUCXX) ENDIF()
ENDIF(MSVC) ENDIF()
# Set PCH_FLAGS for common flags, PCH_ARCH_XXX_FLAGS for specific archs flags and PCH_ARCHS for archs # 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) MACRO(PCH_SET_COMPILE_FLAGS _target)
@ -40,19 +40,21 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
GET_TARGET_PROPERTY(_targetType ${_target} TYPE) GET_TARGET_PROPERTY(_targetType ${_target} TYPE)
IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) SET(_USE_PIC OFF)
IF(${_targetType} STREQUAL "SHARED_LIBRARY" OR ${_targetType} STREQUAL "MODULE_LIBRARY")
LIST(APPEND _FLAGS " ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}") LIST(APPEND _FLAGS " ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")
ELSE(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) ELSE()
GET_TARGET_PROPERTY(_pic ${_target} POSITION_INDEPENDENT_CODE) GET_TARGET_PROPERTY(_pic ${_target} POSITION_INDEPENDENT_CODE)
IF(_pic) IF(_pic)
LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIE}") SET(_USE_PIC ON)
ENDIF(_pic) ENDIF()
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) ENDIF()
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES) GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES)
FOREACH(item ${DIRINC}) FOREACH(item ${DIRINC})
LIST(APPEND _FLAGS " -I\"${item}\"") LIST(APPEND _FLAGS " -I\"${item}\"")
ENDFOREACH(item) ENDFOREACH()
# Required for CMake 2.6 # Required for CMake 2.6
SET(GLOBAL_DEFINITIONS) SET(GLOBAL_DEFINITIONS)
@ -60,61 +62,123 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item) ENDFOREACH()
ENDIF(DEFINITIONS) ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD}) GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item) ENDFOREACH()
ENDIF(DEFINITIONS) ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS)
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH()
ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH()
ENDIF()
GET_TARGET_PROPERTY(oldProps ${_target} COMPILE_FLAGS) GET_TARGET_PROPERTY(oldProps ${_target} COMPILE_FLAGS)
IF(oldProps) IF(oldProps)
LIST(APPEND _FLAGS " ${oldProps}") LIST(APPEND _FLAGS " ${oldProps}")
ENDIF(oldProps) ENDIF()
GET_TARGET_PROPERTY(oldPropsBuild ${_target} COMPILE_FLAGS_${_UPPER_BUILD}) GET_TARGET_PROPERTY(oldPropsBuild ${_target} COMPILE_FLAGS_${_UPPER_BUILD})
IF(oldPropsBuild) IF(oldPropsBuild)
LIST(APPEND _FLAGS " ${oldPropsBuild}") LIST(APPEND _FLAGS " ${oldPropsBuild}")
ENDIF(oldPropsBuild) ENDIF()
GET_TARGET_PROPERTY(DIRINC ${_target} INCLUDE_DIRECTORIES) GET_TARGET_PROPERTY(DIRINC ${_target} INCLUDE_DIRECTORIES)
IF(DIRINC) IF(DIRINC)
FOREACH(item ${DIRINC}) FOREACH(item ${DIRINC})
LIST(APPEND _FLAGS " -I\"${item}\"") LIST(APPEND _FLAGS " -I\"${item}\"")
ENDFOREACH(item) ENDFOREACH()
ENDIF(DIRINC) ENDIF()
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS) GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS)
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item) ENDFOREACH()
ENDIF(DEFINITIONS) ENDIF()
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS_${_UPPER_BUILD}) GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}") LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item) ENDFOREACH()
ENDIF(DEFINITIONS) ENDIF()
GET_TARGET_PROPERTY(_LIBS ${_target} INTERFACE_LINK_LIBRARIES)
IF(_LIBS)
FOREACH(_LIB ${_LIBS})
IF(TARGET "${_LIB}")
# use same include directories
GET_TARGET_PROPERTY(_DIRS ${_LIB} INTERFACE_INCLUDE_DIRECTORIES)
IF(_DIRS)
FOREACH(item ${_DIRS})
LIST(APPEND GLOBAL_DEFINITIONS " -I\"${item}\"")
ENDFOREACH()
ENDIF()
# use same compile definitions
GET_TARGET_PROPERTY(_DEFINITIONS ${_LIB} INTERFACE_COMPILE_DEFINITIONS)
IF(_DEFINITIONS)
FOREACH(item ${_DEFINITIONS})
# don't use dynamic expressions
IF(NOT item MATCHES "\\$<")
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDIF()
ENDFOREACH()
ENDIF()
ENDIF()
ENDFOREACH()
ENDIF()
# Special Qt 5 cases
IF(GLOBAL_DEFINITIONS MATCHES "QT_CORE_LIB")
# Hack to define missing QT_NO_DEBUG with Qt 5.2
IF(_UPPER_BUILD STREQUAL "RELEASE")
LIST(APPEND GLOBAL_DEFINITIONS " -DQT_NO_DEBUG")
ENDIF()
# Qt5_POSITION_INDEPENDENT_CODE should be true if Qt was compiled with PIC
IF(Qt5_POSITION_INDEPENDENT_CODE)
SET(_USE_PIC ON)
ENDIF()
IF(_USE_PIC)
LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIC}")
ENDIF()
ENDIF()
LIST(APPEND _FLAGS " ${GLOBAL_DEFINITIONS}")
IF(CMAKE_VERSION VERSION_LESS "3.3.0")
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS) GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS) GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
LIST(APPEND _FLAGS " ${GLOBAL_DEFINITIONS}")
LIST(APPEND _FLAGS " ${_directory_flags}") LIST(APPEND _FLAGS " ${_directory_flags}")
LIST(APPEND _FLAGS " ${_directory_definitions}") LIST(APPEND _FLAGS " ${_directory_definitions}")
ENDIF()
# Format definitions # Format definitions
IF(MSVC) IF(MSVC)
# Fix path with space # Fix path with space
SEPARATE_ARGUMENTS(_FLAGS UNIX_COMMAND "${_FLAGS}") SEPARATE_ARGUMENTS(_FLAGS UNIX_COMMAND "${_FLAGS}")
ELSE(MSVC) ELSE()
STRING(REGEX REPLACE " +" " " _FLAGS ${_FLAGS}) STRING(REGEX REPLACE " +" " " _FLAGS ${_FLAGS})
SEPARATE_ARGUMENTS(_FLAGS) SEPARATE_ARGUMENTS(_FLAGS)
ENDIF(MSVC) ENDIF()
IF(CLANG) IF(CLANG)
# Determining all architectures and get common flags # Determining all architectures and get common flags
@ -127,11 +191,11 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
LIST(APPEND PCH_ARCHS ${item}) LIST(APPEND PCH_ARCHS ${item})
STRING(TOUPPER "${item}" _UPPER_ARCH) STRING(TOUPPER "${item}" _UPPER_ARCH)
SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item}) SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item})
ENDIF(ITEM_FOUND EQUAL -1) ENDIF()
SET(_ARCH_NEXT OFF) SET(_ARCH_NEXT OFF)
ELSEIF(_XARCH_NEXT) ELSEIF(_XARCH_NEXT)
SET(_XARCH_NEXT OFF) SET(_XARCH_NEXT OFF)
ELSE(_ARCH_NEXT) ELSE()
IF(item MATCHES "^-arch") IF(item MATCHES "^-arch")
SET(_ARCH_NEXT ON) SET(_ARCH_NEXT ON)
ELSEIF(item MATCHES "^-Xarch_") ELSEIF(item MATCHES "^-Xarch_")
@ -141,13 +205,13 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
LIST(APPEND PCH_ARCHS ${item}) LIST(APPEND PCH_ARCHS ${item})
STRING(TOUPPER "${item}" _UPPER_ARCH) STRING(TOUPPER "${item}" _UPPER_ARCH)
SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item}) SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item})
ENDIF(ITEM_FOUND EQUAL -1) ENDIF()
SET(_XARCH_NEXT ON) SET(_XARCH_NEXT ON)
ELSE(item MATCHES "^-arch") ELSE()
LIST(APPEND PCH_FLAGS ${item}) LIST(APPEND PCH_FLAGS ${item})
ENDIF(item MATCHES "^-arch") ENDIF()
ENDIF(_ARCH_NEXT) ENDIF()
ENDFOREACH(item) ENDFOREACH()
# Get architcture specific flags # Get architcture specific flags
SET(_XARCH_NEXT) SET(_XARCH_NEXT)
@ -156,25 +220,25 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
STRING(TOUPPER "${_XARCH_NEXT}" _UPPER_XARCH) STRING(TOUPPER "${_XARCH_NEXT}" _UPPER_XARCH)
LIST(APPEND PCH_ARCH_${_UPPER_XARCH}_FLAGS ${item}) LIST(APPEND PCH_ARCH_${_UPPER_XARCH}_FLAGS ${item})
SET(_XARCH_NEXT OFF) SET(_XARCH_NEXT OFF)
ELSE(_XARCH_NEXT) ELSE()
IF(item MATCHES "^-Xarch_") IF(item MATCHES "^-Xarch_")
STRING(SUBSTRING "${item}" 7 -1 _XARCH_NEXT) STRING(SUBSTRING "${item}" 7 -1 _XARCH_NEXT)
ENDIF(item MATCHES "^-Xarch_") ENDIF()
ENDIF(_XARCH_NEXT) ENDIF()
ENDFOREACH(item) ENDFOREACH()
# Remove duplicated architectures # Remove duplicated architectures
IF(_ARCHS AND PCH_ARCHS) IF(_ARCHS AND PCH_ARCHS)
LIST(REMOVE_DUPLICATES PCH_ARCHS) LIST(REMOVE_DUPLICATES PCH_ARCHS)
ENDIF(_ARCHS AND PCH_ARCHS) ENDIF()
ELSE(CLANG) ELSE()
SET(PCH_FLAGS ${_FLAGS}) SET(PCH_FLAGS ${_FLAGS})
ENDIF(CLANG) ENDIF()
IF(PCH_FLAGS) IF(PCH_FLAGS)
LIST(REMOVE_DUPLICATES PCH_FLAGS) LIST(REMOVE_DUPLICATES PCH_FLAGS)
ENDIF(PCH_FLAGS) ENDIF()
ENDMACRO(PCH_SET_COMPILE_FLAGS) ENDMACRO()
MACRO(GET_PDB_FILENAME _out_filename _target) MACRO(GET_PDB_FILENAME _out_filename _target)
# determine output directory based on target type # determine output directory based on target type
@ -201,9 +265,9 @@ MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS)
IF(CMAKE_CXX_COMPILER_ARG1) IF(CMAKE_CXX_COMPILER_ARG1)
# remove leading space in compiler argument # remove leading space in compiler argument
STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1}) STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
ELSE(CMAKE_CXX_COMPILER_ARG1) ELSE()
SET(pchsupport_compiler_cxx_arg1 "") SET(pchsupport_compiler_cxx_arg1 "")
ENDIF(CMAKE_CXX_COMPILER_ARG1) ENDIF()
IF(MSVC) IF(MSVC)
GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target}) GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target})
@ -211,16 +275,16 @@ MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS)
# Ninja PCH Support # Ninja PCH Support
# http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html # http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html
SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES OBJECT_OUTPUTS "${PCH_OUTPUT}.obj") SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES OBJECT_OUTPUTS "${PCH_OUTPUT}.obj")
ELSE(MSVC) ELSE()
SET(HEADER_FORMAT "c++-header") SET(HEADER_FORMAT "c++-header")
SET(_FLAGS "") SET(_FLAGS "")
IF(APPLE) IF(APPLE)
SET(HEADER_FORMAT "objective-${HEADER_FORMAT}") SET(HEADER_FORMAT "objective-${HEADER_FORMAT}")
SET(_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch) SET(_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch)
ENDIF(APPLE) ENDIF()
SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} ${_FLAGS} -x ${HEADER_FORMAT} -o ${PCH_OUTPUT} -c ${PCH_INPUT}) SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} ${_FLAGS} -x ${HEADER_FORMAT} -o ${PCH_OUTPUT} -c ${PCH_INPUT})
ENDIF(MSVC) ENDIF()
ENDMACRO(PCH_SET_COMPILE_COMMAND) ENDMACRO()
MACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT _targetName _input _arch _language) MACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT _targetName _input _arch _language)
SET(_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch") SET(_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch")
@ -230,14 +294,14 @@ MACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT _targetName _input _arch _language)
GET_FILENAME_COMPONENT(_name ${_input} NAME_WE) GET_FILENAME_COMPONENT(_name ${_input} NAME_WE)
SET(PCH_INPUT ${_input}) SET(PCH_INPUT ${_input})
SET(PCH_OUTPUT "${_OUTPUT_DIR}/${_name}.pch") SET(PCH_OUTPUT "${_OUTPUT_DIR}/${_name}.pch")
ELSE(MSVC) ELSE()
IF(NOT "${_arch}" STREQUAL "") IF(NOT "${_arch}" STREQUAL "")
SET(_OUTPUT_DIR "${_OUTPUT_DIR}_${_arch}") SET(_OUTPUT_DIR "${_OUTPUT_DIR}_${_arch}")
ENDIF(NOT "${_arch}" STREQUAL "") ENDIF()
IF(NOT "${_language}" STREQUAL "") IF(NOT "${_language}" STREQUAL "")
SET(_OUTPUT_DIR "${_OUTPUT_DIR}_${_language}") SET(_OUTPUT_DIR "${_OUTPUT_DIR}_${_language}")
ENDIF(NOT "${_language}" STREQUAL "") ENDIF()
GET_FILENAME_COMPONENT(_name ${_input} NAME) GET_FILENAME_COMPONENT(_name ${_input} NAME)
@ -251,14 +315,14 @@ MACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT _targetName _input _arch _language)
IF(CLANG) IF(CLANG)
SET(PCH_EXT "pth") SET(PCH_EXT "pth")
ELSE(CLANG) ELSE()
SET(PCH_EXT "gch") SET(PCH_EXT "gch")
ENDIF(CLANG) ENDIF()
# For GCC and Clang, PCH needs to be in the same directory as .h # For GCC and Clang, PCH needs to be in the same directory as .h
SET(PCH_OUTPUT "${_OUTPUT_DIR}/${_name}.${PCH_EXT}") SET(PCH_OUTPUT "${_OUTPUT_DIR}/${_name}.${PCH_EXT}")
ENDIF(MSVC) ENDIF()
ENDMACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT) ENDMACRO()
# Add common flags # Add common flags
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName) MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName)
@ -266,7 +330,7 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName)
IF(${oldProps} MATCHES NOTFOUND) IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "") SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND) ENDIF()
IF(MSVC) IF(MSVC)
SET(_target_cflags "${oldProps} /Yu\"${PCH_INPUT}\" /FI\"${PCH_INPUT}\" /Fp\"${PCH_OUTPUT}\"") SET(_target_cflags "${oldProps} /Yu\"${PCH_INPUT}\" /FI\"${PCH_INPUT}\" /Fp\"${PCH_OUTPUT}\"")
@ -279,17 +343,17 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName)
GET_TARGET_PROPERTY(_STATIC_LIBRARY_FLAGS ${_targetName} STATIC_LIBRARY_FLAGS) GET_TARGET_PROPERTY(_STATIC_LIBRARY_FLAGS ${_targetName} STATIC_LIBRARY_FLAGS)
IF(NOT _STATIC_LIBRARY_FLAGS) IF(NOT _STATIC_LIBRARY_FLAGS)
SET(_STATIC_LIBRARY_FLAGS) SET(_STATIC_LIBRARY_FLAGS)
ENDIF(NOT _STATIC_LIBRARY_FLAGS) ENDIF()
SET(_STATIC_LIBRARY_FLAGS "${PCH_OUTPUT}.obj ${_STATIC_LIBRARY_FLAGS}") SET(_STATIC_LIBRARY_FLAGS "${PCH_OUTPUT}.obj ${_STATIC_LIBRARY_FLAGS}")
GET_TARGET_PROPERTY(_LINK_FLAGS ${_targetName} LINK_FLAGS) GET_TARGET_PROPERTY(_LINK_FLAGS ${_targetName} LINK_FLAGS)
IF(NOT _LINK_FLAGS) IF(NOT _LINK_FLAGS)
SET(_LINK_FLAGS) SET(_LINK_FLAGS)
ENDIF(NOT _LINK_FLAGS) ENDIF()
SET(_LINK_FLAGS "${PCH_OUTPUT}.obj ${_LINK_FLAGS}") SET(_LINK_FLAGS "${PCH_OUTPUT}.obj ${_LINK_FLAGS}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES STATIC_LIBRARY_FLAGS ${_STATIC_LIBRARY_FLAGS} LINK_FLAGS ${_LINK_FLAGS}) SET_TARGET_PROPERTIES(${_targetName} PROPERTIES STATIC_LIBRARY_FLAGS ${_STATIC_LIBRARY_FLAGS} LINK_FLAGS ${_LINK_FLAGS})
ELSE(MSVC) ELSE()
# for use with distcc and gcc >4.0.1 if preprocessed files are accessible # for use with distcc and gcc >4.0.1 if preprocessed files are accessible
# on all remote machines set # on all remote machines set
# PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess # PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess
@ -299,21 +363,21 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName)
# If no arch is specified, create common flags # If no arch is specified, create common flags
IF(PCH_ARCHS_COUNT LESS 2) IF(PCH_ARCHS_COUNT LESS 2)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-include ${PCH_INPUT} ${PCH_ADDITIONAL_COMPILER_FLAGS}") SET(PCH_ADDITIONAL_COMPILER_FLAGS "-include ${PCH_INPUT} ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(PCH_ARCHS_COUNT LESS 2) ENDIF()
IF(APPLE) IF(APPLE)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-fobjc-abi-version=2 -fobjc-legacy-dispatch -x objective-c++ ${PCH_ADDITIONAL_COMPILER_FLAGS}") SET(PCH_ADDITIONAL_COMPILER_FLAGS "-fobjc-abi-version=2 -fobjc-legacy-dispatch -x objective-c++ ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(APPLE) ENDIF()
IF(WITH_PCH_DEBUG) IF(WITH_PCH_DEBUG)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-H ${PCH_ADDITIONAL_COMPILER_FLAGS}") SET(PCH_ADDITIONAL_COMPILER_FLAGS "-H ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(WITH_PCH_DEBUG) ENDIF()
SET(_target_cflags "${oldProps} ${PCH_ADDITIONAL_COMPILER_FLAGS} -Winvalid-pch") SET(_target_cflags "${oldProps} ${PCH_ADDITIONAL_COMPILER_FLAGS} -Winvalid-pch")
ENDIF(MSVC) ENDIF()
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_target_cflags}) SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_target_cflags})
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET) ENDMACRO()
# Add specific flags for an arch # Add specific flags for an arch
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH _targetName _arch) MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH _targetName _arch)
@ -324,19 +388,19 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH _targetName _arch)
IF(${_FLAGS} MATCHES NOTFOUND) IF(${_FLAGS} MATCHES NOTFOUND)
SET(_FLAGS "") SET(_FLAGS "")
ENDIF(${_FLAGS} MATCHES NOTFOUND) ENDIF()
SET(_FLAGS "${_FLAGS} -Xarch_${_arch} -include${PCH_INPUT}") SET(_FLAGS "${_FLAGS} -Xarch_${_arch} -include${PCH_INPUT}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_FLAGS}) SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_FLAGS})
ENDIF(PCH_ARCHS_COUNT GREATER 1) ENDIF()
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH) ENDMACRO()
MACRO(PCH_CREATE_TARGET _targetName _targetNamePCH) MACRO(PCH_CREATE_TARGET _targetName _targetNamePCH)
ADD_CUSTOM_COMMAND(OUTPUT ${PCH_OUTPUT} COMMAND ${PCH_COMMAND} COMMENT "Generating ${_targetNamePCH}" DEPENDS ${PCH_INPUT}) ADD_CUSTOM_COMMAND(OUTPUT ${PCH_OUTPUT} COMMAND ${PCH_COMMAND} COMMENT "Generating ${_targetNamePCH}" DEPENDS ${PCH_INPUT})
ADD_CUSTOM_TARGET(${_targetNamePCH} DEPENDS ${PCH_INPUT} ${PCH_OUTPUT}) ADD_CUSTOM_TARGET(${_targetNamePCH} DEPENDS ${PCH_INPUT} ${PCH_OUTPUT})
ADD_DEPENDENCIES(${_targetName} ${_targetNamePCH}) ADD_DEPENDENCIES(${_targetName} ${_targetNamePCH})
ENDMACRO(PCH_CREATE_TARGET _targetName _inputh _inputcpp) ENDMACRO()
MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp) MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
SET(_PCH_current_target ${_targetName}) SET(_PCH_current_target ${_targetName})
@ -346,7 +410,7 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
"This is the ADD_PRECOMPILED_HEADER macro. " "This is the ADD_PRECOMPILED_HEADER macro. "
"You must set CMAKE_BUILD_TYPE!" "You must set CMAKE_BUILD_TYPE!"
) )
ENDIF(NOT CMAKE_BUILD_TYPE) ENDIF()
PCH_SET_COMPILE_FLAGS(${_targetName}) PCH_SET_COMPILE_FLAGS(${_targetName})
@ -362,26 +426,22 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch_${_ARCH}) PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch_${_ARCH})
ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH(${_targetName} ${_ARCH}) ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH(${_targetName} ${_ARCH})
ENDFOREACH(_ARCH) ENDFOREACH()
ELSE(PCH_ARCHS) ELSE()
PCH_SET_PRECOMPILED_HEADER_OUTPUT(${_targetName} ${_inputh} "" "") PCH_SET_PRECOMPILED_HEADER_OUTPUT(${_targetName} ${_inputh} "" "")
LIST(APPEND PCH_OUTPUTS ${PCH_OUTPUT}) LIST(APPEND PCH_OUTPUTS ${PCH_OUTPUT})
PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_FLAGS}") PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_FLAGS}")
PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch) PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch)
ENDIF(PCH_ARCHS) ENDIF()
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName}) ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName})
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PCH_OUTPUTS}") SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PCH_OUTPUTS}")
ENDMACRO(ADD_PRECOMPILED_HEADER) ENDMACRO()
MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp) MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
IF(NOT PCHSupport_FOUND) IF(PCHSupport_FOUND)
MESSAGE(STATUS "PCH disabled because compiler doesn't support them")
RETURN()
ENDIF(NOT PCHSupport_FOUND)
# 0 => creating a new target for PCH, works for all makefiles # 0 => creating a new target for PCH, works for all makefiles
# 1 => setting PCH for VC++ project, works for VC++ projects # 1 => setting PCH for VC++ project, works for VC++ projects
# 2 => setting PCH for XCode project, works for XCode projects # 2 => setting PCH for XCode project, works for XCode projects
@ -389,9 +449,9 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
SET(PCH_METHOD 1) SET(PCH_METHOD 1)
ELSEIF(CMAKE_GENERATOR MATCHES "Xcode") ELSEIF(CMAKE_GENERATOR MATCHES "Xcode")
SET(PCH_METHOD 2) SET(PCH_METHOD 2)
ELSE(CMAKE_GENERATOR MATCHES "Visual Studio") ELSE()
SET(PCH_METHOD 0) SET(PCH_METHOD 0)
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio") ENDIF()
IF(PCH_METHOD EQUAL 1) IF(PCH_METHOD EQUAL 1)
# Auto include the precompile (useful for moc processing, since the use of # Auto include the precompile (useful for moc processing, since the use of
@ -401,7 +461,7 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS) GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
IF(${oldProps} MATCHES NOTFOUND) IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "") SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND) ENDIF()
SET(newProperties "${oldProps} /Yu\"${_inputh}\" /FI\"${_inputh}\"") SET(newProperties "${oldProps} /Yu\"${_inputh}\" /FI\"${_inputh}\"")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}") SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
@ -418,12 +478,15 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}") SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES") SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
ELSE(PCH_METHOD EQUAL 1) ELSE()
#Fallback to the "old" precompiled suppport #Fallback to the "old" precompiled suppport
ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp}) ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp})
ENDIF(PCH_METHOD EQUAL 1) ENDIF()
IF(TARGET ${_targetName}_static) IF(TARGET ${_targetName}_static)
ADD_NATIVE_PRECOMPILED_HEADER(${_targetName}_static ${_inputh} ${_inputcpp}) ADD_NATIVE_PRECOMPILED_HEADER(${_targetName}_static ${_inputh} ${_inputcpp})
ENDIF(TARGET ${_targetName}_static) ENDIF()
ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER) ELSE()
MESSAGE(STATUS "PCH disabled because compiler doesn't support them")
ENDIF()
ENDMACRO()

@ -40,11 +40,24 @@ include (CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER (clang Clang) CMAKE_FORCE_C_COMPILER (clang Clang)
CMAKE_FORCE_CXX_COMPILER (clang++ Clang) CMAKE_FORCE_CXX_COMPILER (clang++ Clang)
IF(CMAKE_CXX_COMPILER)
EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} --version
OUTPUT_VARIABLE CLANG_VERSION_RAW
OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING(REGEX REPLACE "Apple LLVM version ([\\.0-9]+).*"
"\\1" CMAKE_CXX_COMPILER_VERSION "${CLANG_VERSION_RAW}")
SET(CMAKE_C_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
SET(CMAKE_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
ENDIF()
# Setup iOS platform # Setup iOS platform
if (NOT DEFINED IOS_PLATFORM) IF(NOT DEFINED IOS_PLATFORM)
set (IOS_PLATFORM "OS") SET(IOS_PLATFORM "OS")
endif (NOT DEFINED IOS_PLATFORM) ENDIF()
set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
SET(IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
SET(IOS_PLATFORM_LOCATION "iPhoneOS.platform") SET(IOS_PLATFORM_LOCATION "iPhoneOS.platform")
SET(IOS_SIMULATOR_PLATFORM_LOCATION "iPhoneSimulator.platform") SET(IOS_SIMULATOR_PLATFORM_LOCATION "iPhoneSimulator.platform")
@ -59,29 +72,35 @@ elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
elseif(${IOS_PLATFORM} STREQUAL "ALL") elseif(${IOS_PLATFORM} STREQUAL "ALL")
# This causes the installers to properly locate the output libraries # This causes the installers to properly locate the output libraries
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator;-iphoneos") set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator;-iphoneos")
else (${IOS_PLATFORM} STREQUAL "OS") else()
message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR") message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR")
endif (${IOS_PLATFORM} STREQUAL "OS") endif()
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS ${CMAKE_XCODE_EFFECTIVE_PLATFORMS} CACHE PATH "iOS Platform") 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 # 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 # 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_DEFAULT_ROOT "/Applications/Xcode.app/Contents")
SET(XCODE_PRE_43_ROOT "/Developer/Platforms")
IF(NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) IF(NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
IF(EXISTS ${XCODE_POST_43_ROOT}) IF(NOT DEFINED CMAKE_XCODE_ROOT)
SET(CMAKE_XCODE_ROOT ${XCODE_POST_43_ROOT}) IF(EXISTS ${XCODE_DEFAULT_ROOT})
ELSEIF(EXISTS ${XCODE_PRE_43_ROOT}) SET(CMAKE_XCODE_ROOT ${XCODE_DEFAULT_ROOT} CACHE STRING "Xcode root")
SET(CMAKE_XCODE_ROOT ${XCODE_PRE_43_ROOT}) ELSE()
ENDIF(EXISTS ${XCODE_POST_43_ROOT}) MESSAGE(FATAL_ERROR "Xcode directory ${XCODE_DEFAULT_ROOT} doesn't exist")
IF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_PLATFORM_LOCATION}/Developer) ENDIF()
SET(CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_XCODE_ROOT}/${IOS_PLATFORM_LOCATION}/Developer) ENDIF()
ENDIF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_PLATFORM_LOCATION}/Developer) SET(TMP ${CMAKE_XCODE_ROOT}/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer)
IF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_SIMULATOR_PLATFORM_LOCATION}/Developer) IF(EXISTS ${TMP})
SET(CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT ${CMAKE_XCODE_ROOT}/${IOS_SIMULATOR_PLATFORM_LOCATION}/Developer) SET(CMAKE_IOS_DEVELOPER_ROOT ${TMP})
ENDIF(EXISTS ${CMAKE_XCODE_ROOT}/${IOS_SIMULATOR_PLATFORM_LOCATION}/Developer) MESSAGE(STATUS "Use iOS developer root: ${CMAKE_IOS_DEVELOPER_ROOT}")
ENDIF(NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT) ENDIF()
SET(TMP ${CMAKE_XCODE_ROOT}/Developer/Platforms/${IOS_SIMULATOR_PLATFORM_LOCATION}/Developer)
IF(EXISTS ${TMP})
SET(CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT ${TMP})
MESSAGE(STATUS "Use iOS simulator developer root: ${CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT}")
ENDIF()
ENDIF()
SET(CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform") 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") SET(CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT ${CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT} CACHE PATH "Location of iOS Simulator Platform")
@ -93,9 +112,9 @@ MACRO(GET_AVAILABLE_SDK_VERSIONS ROOT VERSIONS)
FOREACH(_CMAKE_IOS_SDK ${_CMAKE_IOS_SDKS}) FOREACH(_CMAKE_IOS_SDK ${_CMAKE_IOS_SDKS})
STRING(REGEX REPLACE ".+iPhoneOS([0-9.]+)\\.sdk" "\\1" _IOS_SDK "${_CMAKE_IOS_SDK}") STRING(REGEX REPLACE ".+iPhoneOS([0-9.]+)\\.sdk" "\\1" _IOS_SDK "${_CMAKE_IOS_SDK}")
LIST(APPEND ${VERSIONS} ${_IOS_SDK}) LIST(APPEND ${VERSIONS} ${_IOS_SDK})
ENDFOREACH(_CMAKE_IOS_SDK) ENDFOREACH()
ENDIF(_CMAKE_IOS_SDKS) ENDIF()
ENDMACRO(GET_AVAILABLE_SDK_VERSIONS) ENDMACRO()
# Find and use the most recent iOS sdk # Find and use the most recent iOS sdk
IF(NOT DEFINED CMAKE_IOS_SDK_ROOT) IF(NOT DEFINED CMAKE_IOS_SDK_ROOT)
@ -104,25 +123,25 @@ IF(NOT DEFINED CMAKE_IOS_SDK_ROOT)
IF(NOT 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.") 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) ENDIF()
IF(IOS_VERSION) IF(IOS_VERSION)
LIST(FIND IOS_VERSIONS "${IOS_VERSION}" _INDEX) LIST(FIND IOS_VERSIONS "${IOS_VERSION}" _INDEX)
IF(_INDEX EQUAL -1) IF(_INDEX EQUAL -1)
LIST(GET IOS_VERSIONS 0 IOS_SDK_VERSION) LIST(GET IOS_VERSIONS 0 IOS_SDK_VERSION)
ELSE(_INDEX EQUAL -1) ELSE()
SET(IOS_SDK_VERSION ${IOS_VERSION}) SET(IOS_SDK_VERSION ${IOS_VERSION})
ENDIF(_INDEX EQUAL -1) ENDIF()
ELSE(IOS_VERSION) ELSE()
LIST(GET IOS_VERSIONS 0 IOS_VERSION) LIST(GET IOS_VERSIONS 0 IOS_VERSION)
SET(IOS_SDK_VERSION ${IOS_VERSION}) SET(IOS_SDK_VERSION ${IOS_VERSION})
ENDIF(IOS_VERSION) ENDIF()
MESSAGE(STATUS "Target iOS ${IOS_VERSION} and use SDK ${IOS_SDK_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_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) SET(CMAKE_IOS_SIMULATOR_SDK_ROOT ${CMAKE_IOS_SIMULATOR_DEVELOPER_ROOT}/SDKs/iPhoneSimulator${IOS_SDK_VERSION}.sdk)
endif (NOT DEFINED CMAKE_IOS_SDK_ROOT) endif()
SET(CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK") 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(CMAKE_IOS_SIMULATOR_SDK_ROOT ${CMAKE_IOS_SIMULATOR_SDK_ROOT} CACHE PATH "Location of the selected iOS Simulator SDK")
@ -134,31 +153,32 @@ SET(CMAKE_IOS_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS sup
SET(CMAKE_IOS_SIMULATOR_SYSROOT ${CMAKE_IOS_SIMULATOR_SDK_ROOT} CACHE PATH "Sysroot used for iOS Simulator support") SET(CMAKE_IOS_SIMULATOR_SYSROOT ${CMAKE_IOS_SIMULATOR_SDK_ROOT} CACHE PATH "Sysroot used for iOS Simulator support")
IF(CMAKE_GENERATOR MATCHES Xcode) IF(CMAKE_GENERATOR MATCHES Xcode)
SET(ARCHS "$(ARCHS_STANDARD_32_BIT)")
IF(${IOS_PLATFORM} STREQUAL "OS") IF(${IOS_PLATFORM} STREQUAL "OS")
SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(CMAKE_SYSTEM_PROCESSOR "armv7")
ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR") ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR")
SET(CMAKE_SYSTEM_PROCESSOR "x86") SET(CMAKE_SYSTEM_PROCESSOR "x86")
ELSEIF(${IOS_PLATFORM} STREQUAL "ALL") ELSEIF(${IOS_PLATFORM} STREQUAL "ALL")
SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(CMAKE_SYSTEM_PROCESSOR "armv7")
ENDIF(${IOS_PLATFORM} STREQUAL "OS") ENDIF()
ELSE(CMAKE_GENERATOR MATCHES Xcode) ELSE()
IF(${IOS_PLATFORM} STREQUAL "OS") IF(${IOS_PLATFORM} STREQUAL "OS")
SET(ARCHS "armv7") SET(ARCHS "armv7;arm64")
SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(CMAKE_SYSTEM_PROCESSOR "armv7")
ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR") ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR")
# iPhone simulator targets i386 # iPhone simulator targets i386
SET(ARCHS "i386") SET(ARCHS "i386")
SET(CMAKE_SYSTEM_PROCESSOR "x86") SET(CMAKE_SYSTEM_PROCESSOR "x86")
ELSEIF(${IOS_PLATFORM} STREQUAL "ALL") ELSEIF(${IOS_PLATFORM} STREQUAL "ALL")
SET(ARCHS "armv7;i386") SET(ARCHS "armv7;arm64;i386;x86_64")
SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(CMAKE_SYSTEM_PROCESSOR "armv7")
ENDIF(${IOS_PLATFORM} STREQUAL "OS") ENDIF()
ENDIF(CMAKE_GENERATOR MATCHES Xcode) ENDIF()
# set the architecture for iOS - using ARCHS_STANDARD_32_BIT sets armv7,armv7s and appears to be XCode's standard. # 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 # 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") IF(ARCHS)
SET(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE string "Build architecture for iOS")
ENDIF()
# Set the find root to the iOS developer roots and to user defined paths # 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") 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")
@ -174,10 +194,9 @@ set (CMAKE_SYSTEM_FRAMEWORK_PATH
) )
# only search the iOS sdks, not the remainder of the host filesystem # 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_PROGRAM BOTH)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
#SET(CMAKE_SYSTEM_INCLUDE_PATH /include /usr/include) # determinate location for bin utils based on CMAKE_FIND_ROOT_PATH
#SET(CMAKE_SYSTEM_LIBRARY_PATH /lib /usr/lib) include(CMakeFindBinUtils)
#SET(CMAKE_SYSTEM_PROGRAM_PATH /bin /usr/bin)

@ -20,60 +20,6 @@ MACRO(NL_GEN_PC name)
ENDIF(NOT WIN32 AND WITH_INSTALL_LIBRARIES) ENDIF(NOT WIN32 AND WITH_INSTALL_LIBRARIES)
ENDMACRO(NL_GEN_PC) ENDMACRO(NL_GEN_PC)
###
# Helper macro that generates revision.h from revision.h.in
###
MACRO(NL_GEN_REVISION_H)
IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
SET(TOOL_FOUND OFF)
IF(EXISTS "${CMAKE_SOURCE_DIR}/../.svn/")
FIND_PACKAGE(Subversion)
IF(SUBVERSION_FOUND)
SET(TOOL_FOUND ON)
ENDIF(SUBVERSION_FOUND)
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/../.svn/")
IF(EXISTS "${CMAKE_SOURCE_DIR}/../.hg/")
FIND_PACKAGE(Mercurial)
IF(MERCURIAL_FOUND)
SET(TOOL_FOUND ON)
ENDIF(MERCURIAL_FOUND)
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/../.hg/")
# if already generated
IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h)
# copy it
MESSAGE(STATUS "Copying provided revision.h...")
FILE(COPY ${CMAKE_SOURCE_DIR}/revision.h DESTINATION ${CMAKE_BINARY_DIR})
SET(HAVE_REVISION_H ON)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h)
IF(TOOL_FOUND)
# a custom target that is always built
ADD_CUSTOM_TARGET(revision ALL
COMMAND ${CMAKE_COMMAND}
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
-DROOT_DIR=${CMAKE_SOURCE_DIR}/..
-DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/CMakeModules
-P ${CMAKE_SOURCE_DIR}/CMakeModules/GetRevision.cmake)
# revision.h is a generated file
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/revision.h
PROPERTIES GENERATED TRUE
HEADER_FILE_ONLY TRUE)
SET(HAVE_REVISION_H ON)
ENDIF(TOOL_FOUND)
IF(HAVE_REVISION_H)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_DEFINITIONS(-DHAVE_REVISION_H)
ENDIF(HAVE_REVISION_H)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
ENDMACRO(NL_GEN_REVISION_H)
### ###
# #
### ###
@ -102,10 +48,10 @@ ENDMACRO(NL_TARGET_DRIVER)
# Argument: # Argument:
### ###
MACRO(NL_DEFAULT_PROPS name label) MACRO(NL_DEFAULT_PROPS name label)
IF(HAVE_REVISION_H) IF(TARGET revision)
# explicitly say that the target depends on revision.h # explicitly say that the target depends on revision.h
ADD_DEPENDENCIES(${name} revision) ADD_DEPENDENCIES(${name} revision)
ENDIF(HAVE_REVISION_H) ENDIF()
# Note: This is just a workaround for a CMake bug generating VS10 files with a colon in the project name. # Note: This is just a workaround for a CMake bug generating VS10 files with a colon in the project name.
# CMake Bug ID: http://www.cmake.org/Bug/view.php?id=11819 # CMake Bug ID: http://www.cmake.org/Bug/view.php?id=11819
@ -250,6 +196,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
OPTION(WITH_LOGGING "With Logging" ON ) OPTION(WITH_LOGGING "With Logging" ON )
OPTION(WITH_COVERAGE "With Code Coverage Support" OFF) OPTION(WITH_COVERAGE "With Code Coverage Support" OFF)
OPTION(WITH_PCH "With Precompiled Headers" ON ) OPTION(WITH_PCH "With Precompiled Headers" ON )
OPTION(WITH_LOW_MEMORY "With low memory (use the least of RAM)" OFF)
OPTION(FINAL_VERSION "Build in Final Version mode" ON ) OPTION(FINAL_VERSION "Build in Final Version mode" ON )
# Default to static building on Windows. # Default to static building on Windows.
@ -280,13 +227,21 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
OPTION(WITH_EXTERNAL "With provided external." OFF) OPTION(WITH_EXTERNAL "With provided external." OFF)
ENDIF(WIN32) ENDIF(WIN32)
OPTION(WITH_STATIC_EXTERNAL "With static external libraries" OFF) OPTION(WITH_STATIC_EXTERNAL "With static external libraries" OFF)
IF(UNIX AND NOT APPLE)
OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" ON )
ELSE()
OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" OFF)
ENDIF()
OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON ) OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON )
OPTION(WITH_ASSIMP "Use assimp exporter" OFF)
### ###
# GUI toolkits # GUI toolkits
### ###
OPTION(WITH_GTK "With GTK Support" OFF) OPTION(WITH_GTK "With GTK Support" OFF)
OPTION(WITH_QT "With QT Support" OFF) OPTION(WITH_QT "With Qt 4 Support" OFF)
OPTION(WITH_QT5 "With Qt 5 Support" OFF)
IF(WIN32 AND MFC_FOUND) IF(WIN32 AND MFC_FOUND)
OPTION(WITH_MFC "With MFC Support" ON ) OPTION(WITH_MFC "With MFC Support" ON )
@ -311,6 +266,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
OPTION(WITH_NELNS "Build NeL Network Services." OFF) OPTION(WITH_NELNS "Build NeL Network Services." OFF)
OPTION(WITH_RYZOM "Build Ryzom Core." ON ) OPTION(WITH_RYZOM "Build Ryzom Core." ON )
OPTION(WITH_SNOWBALLS "Build Snowballs." OFF) OPTION(WITH_SNOWBALLS "Build Snowballs." OFF)
OPTION(WITH_TOOLS "Build Tools" OFF)
ENDMACRO(NL_SETUP_DEFAULT_OPTIONS) ENDMACRO(NL_SETUP_DEFAULT_OPTIONS)
MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
@ -375,14 +331,16 @@ MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
OPTION(WITH_RYZOM_TOOLS "Build Ryzom Core Tools" ON ) OPTION(WITH_RYZOM_TOOLS "Build Ryzom Core Tools" ON )
OPTION(WITH_RYZOM_SERVER "Build Ryzom Core Services" ON ) OPTION(WITH_RYZOM_SERVER "Build Ryzom Core Services" ON )
OPTION(WITH_RYZOM_SOUND "Enable Ryzom Core Sound" ON ) OPTION(WITH_RYZOM_SOUND "Enable Ryzom Core Sound" ON )
OPTION(WITH_RYZOM_PATCH "Enable Ryzom in-game patch support" OFF)
### ###
# Optional support # Optional support
### ###
OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON ) OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON )
OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF) OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF)
OPTION(WITH_LUA53 "Build Ryzom Core using Lua 5.3" OFF)
OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF) OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF)
OPTION(WITH_RYZOM_PATCH "Enable Ryzom in-game patch support" OFF)
OPTION(WITH_RYZOM_CUSTOM_PATCH_SERVER "Only use patch server from CFG file" OFF)
ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS) MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
@ -577,7 +535,13 @@ MACRO(NL_SETUP_BUILD)
# Ignore default include paths # Ignore default include paths
ADD_PLATFORM_FLAGS("/X") ADD_PLATFORM_FLAGS("/X")
IF(MSVC12) IF(MSVC14)
ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2015, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC12)
ADD_PLATFORM_FLAGS("/Gy- /MP") ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2013, but custom optimizations don't exist # /Ox is working with VC++ 2013, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
@ -609,7 +573,7 @@ MACRO(NL_SETUP_BUILD)
SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}") SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}")
ELSE(MSVC12) ELSE(MSVC12)
MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
ENDIF(MSVC12) ENDIF(MSVC14)
ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250") ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250")
@ -861,7 +825,11 @@ MACRO(NL_SETUP_BUILD)
ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64") ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
ENDIF(APPLE) ENDIF(APPLE)
ADD_PLATFORM_FLAGS("-D_REENTRANT -pipe -fno-strict-aliasing") ADD_PLATFORM_FLAGS("-D_REENTRANT -fno-strict-aliasing")
IF(NOT WITH_LOW_MEMORY)
ADD_PLATFORM_FLAGS("-pipe")
ENDIF()
IF(WITH_COVERAGE) IF(WITH_COVERAGE)
ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage") ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage")
@ -869,11 +837,6 @@ MACRO(NL_SETUP_BUILD)
IF(WITH_WARNINGS) IF(WITH_WARNINGS)
ADD_PLATFORM_FLAGS("-Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused") ADD_PLATFORM_FLAGS("-Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused")
IF(CLANG)
ADD_PLATFORM_FLAGS("-std=gnu99")
ELSE(CLANG)
ADD_PLATFORM_FLAGS("-ansi")
ENDIF(CLANG)
ENDIF(WITH_WARNINGS) ENDIF(WITH_WARNINGS)
IF(ANDROID) IF(ANDROID)
@ -972,141 +935,140 @@ ENDMACRO(NL_SETUP_BUILD_FLAGS)
MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE) MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE)
IF(IS_ABSOLUTE "${${NAME_RELATIVE}}") IF(IS_ABSOLUTE "${${NAME_RELATIVE}}")
SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}}) SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})
ELSE(IS_ABSOLUTE "${${NAME_RELATIVE}}") ELSE()
IF(WIN32) IF(WITH_UNIX_STRUCTURE)
SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})
ELSE(WIN32)
SET(${NAME_ABSOLUTE} ${CMAKE_INSTALL_PREFIX}/${${NAME_RELATIVE}}) SET(${NAME_ABSOLUTE} ${CMAKE_INSTALL_PREFIX}/${${NAME_RELATIVE}})
ENDIF(WIN32) ELSE()
SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})
ENDIF()
ENDIF(IS_ABSOLUTE "${${NAME_RELATIVE}}") ENDIF(IS_ABSOLUTE "${${NAME_RELATIVE}}")
ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX) ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX)
MACRO(NL_SETUP_PREFIX_PATHS) MACRO(NL_SETUP_PREFIX_PATHS)
## Allow override of install_prefix/etc path. ## Allow override of install_prefix/etc path.
IF(NOT NL_ETC_PREFIX) IF(NOT NL_ETC_PREFIX)
IF(WIN32) IF(WITH_UNIX_STRUCTURE)
SET(NL_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
ELSE(WIN32)
SET(NL_ETC_PREFIX "etc/nel" CACHE PATH "Installation path for configurations") SET(NL_ETC_PREFIX "etc/nel" CACHE PATH "Installation path for configurations")
ENDIF(WIN32) ELSE()
ENDIF(NOT NL_ETC_PREFIX) SET(NL_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
ENDIF()
ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(NL_ETC_PREFIX NL_ETC_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(NL_ETC_PREFIX NL_ETC_ABSOLUTE_PREFIX)
## Allow override of install_prefix/share path. ## Allow override of install_prefix/share path.
IF(NOT NL_SHARE_PREFIX) IF(NOT NL_SHARE_PREFIX)
IF(WIN32) IF(WITH_UNIX_STRUCTURE)
SET(NL_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
ELSE(WIN32)
SET(NL_SHARE_PREFIX "share/nel" CACHE PATH "Installation path for data.") SET(NL_SHARE_PREFIX "share/nel" CACHE PATH "Installation path for data.")
ENDIF(WIN32) ELSE()
ENDIF(NOT NL_SHARE_PREFIX) SET(NL_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
ENDIF()
ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(NL_SHARE_PREFIX NL_SHARE_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(NL_SHARE_PREFIX NL_SHARE_ABSOLUTE_PREFIX)
## Allow override of install_prefix/sbin path. ## Allow override of install_prefix/sbin path.
IF(NOT NL_SBIN_PREFIX) IF(NOT NL_SBIN_PREFIX)
IF(WIN32) IF(WITH_UNIX_STRUCTURE)
SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
ELSE(WIN32)
SET(NL_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") SET(NL_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.")
ENDIF(WIN32) ELSE()
ENDIF(NOT NL_SBIN_PREFIX) SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
ENDIF()
ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(NL_SBIN_PREFIX NL_SBIN_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(NL_SBIN_PREFIX NL_SBIN_ABSOLUTE_PREFIX)
## Allow override of install_prefix/bin path. ## Allow override of install_prefix/bin path.
IF(NOT NL_BIN_PREFIX) IF(NOT NL_BIN_PREFIX)
IF(WIN32) IF(WITH_UNIX_STRUCTURE)
SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ELSE(WIN32)
SET(NL_BIN_PREFIX "bin" CACHE PATH "Installation path for tools and applications.") SET(NL_BIN_PREFIX "bin" CACHE PATH "Installation path for tools and applications.")
ENDIF(WIN32) ELSE()
ENDIF(NOT NL_BIN_PREFIX) SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ENDIF()
ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(NL_BIN_PREFIX NL_BIN_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(NL_BIN_PREFIX NL_BIN_ABSOLUTE_PREFIX)
## Allow override of install_prefix/lib path. ## Allow override of install_prefix/lib path.
IF(NOT NL_LIB_PREFIX) IF(NOT NL_LIB_PREFIX)
IF(LIBRARY_ARCHITECTURE) IF(LIBRARY_ARCHITECTURE)
SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.")
ELSE(LIBRARY_ARCHITECTURE) ELSE()
SET(NL_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") SET(NL_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.")
ENDIF(LIBRARY_ARCHITECTURE) ENDIF()
ENDIF(NOT NL_LIB_PREFIX) ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX)
## Allow override of install_prefix/lib path. ## Allow override of install_prefix/lib path.
IF(NOT NL_DRIVER_PREFIX) IF(NOT NL_DRIVER_PREFIX)
IF(WIN32) IF(WITH_UNIX_STRUCTURE)
SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.")
ELSE(WIN32)
IF(LIBRARY_ARCHITECTURE) IF(LIBRARY_ARCHITECTURE)
SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.") SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.")
ELSE(LIBRARY_ARCHITECTURE) ELSE()
SET(NL_DRIVER_PREFIX "lib/nel" CACHE PATH "Installation path for drivers.") SET(NL_DRIVER_PREFIX "lib/nel" CACHE PATH "Installation path for drivers.")
ENDIF(LIBRARY_ARCHITECTURE) ENDIF()
ENDIF(WIN32) ELSE()
ENDIF(NOT NL_DRIVER_PREFIX) SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.")
ENDIF()
ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(NL_DRIVER_PREFIX NL_DRIVER_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(NL_DRIVER_PREFIX NL_DRIVER_ABSOLUTE_PREFIX)
ENDMACRO(NL_SETUP_PREFIX_PATHS) ENDMACRO(NL_SETUP_PREFIX_PATHS)
MACRO(RYZOM_SETUP_PREFIX_PATHS) MACRO(RYZOM_SETUP_PREFIX_PATHS)
## Allow override of install_prefix/etc path. ## Allow override of install_prefix/etc path.
IF(NOT RYZOM_ETC_PREFIX) IF(NOT RYZOM_ETC_PREFIX)
IF(WIN32) IF(WITH_UNIX_STRUCTURE)
SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
ELSE(WIN32)
SET(RYZOM_ETC_PREFIX "etc/ryzom" CACHE PATH "Installation path for configurations") SET(RYZOM_ETC_PREFIX "etc/ryzom" CACHE PATH "Installation path for configurations")
ENDIF(WIN32) ELSE()
SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
ENDIF()
ENDIF(NOT RYZOM_ETC_PREFIX) ENDIF(NOT RYZOM_ETC_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_ETC_PREFIX RYZOM_ETC_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(RYZOM_ETC_PREFIX RYZOM_ETC_ABSOLUTE_PREFIX)
## Allow override of install_prefix/share path. ## Allow override of install_prefix/share path.
IF(NOT RYZOM_SHARE_PREFIX) IF(NOT RYZOM_SHARE_PREFIX)
IF(WIN32) IF(WITH_UNIX_STRUCTURE)
SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
ELSE(WIN32)
SET(RYZOM_SHARE_PREFIX "share/ryzom" CACHE PATH "Installation path for data.") SET(RYZOM_SHARE_PREFIX "share/ryzom" CACHE PATH "Installation path for data.")
ENDIF(WIN32) ELSE()
ENDIF(NOT RYZOM_SHARE_PREFIX) SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
ENDIF()
ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SHARE_PREFIX RYZOM_SHARE_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SHARE_PREFIX RYZOM_SHARE_ABSOLUTE_PREFIX)
## Allow override of install_prefix/sbin path. ## Allow override of install_prefix/sbin path.
IF(NOT RYZOM_SBIN_PREFIX) IF(NOT RYZOM_SBIN_PREFIX)
IF(WIN32) IF(WITH_UNIX_STRUCTURE)
SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
ELSE(WIN32)
SET(RYZOM_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") SET(RYZOM_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.")
ENDIF(WIN32) ELSE()
ENDIF(NOT RYZOM_SBIN_PREFIX) SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
ENDIF()
ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SBIN_PREFIX RYZOM_SBIN_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SBIN_PREFIX RYZOM_SBIN_ABSOLUTE_PREFIX)
## Allow override of install_prefix/bin path. ## Allow override of install_prefix/bin path.
IF(NOT RYZOM_BIN_PREFIX) IF(NOT RYZOM_BIN_PREFIX)
IF(WIN32) IF(WITH_UNIX_STRUCTURE)
SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ELSE(WIN32)
SET(RYZOM_BIN_PREFIX "bin" CACHE PATH "Installation path for tools.") SET(RYZOM_BIN_PREFIX "bin" CACHE PATH "Installation path for tools.")
ENDIF(WIN32) ELSE()
ENDIF(NOT RYZOM_BIN_PREFIX) SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ENDIF()
ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_BIN_PREFIX RYZOM_BIN_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(RYZOM_BIN_PREFIX RYZOM_BIN_ABSOLUTE_PREFIX)
## Allow override of install_prefix/lib path. ## Allow override of install_prefix/lib path.
IF(NOT RYZOM_LIB_PREFIX) IF(NOT RYZOM_LIB_PREFIX)
IF(LIBRARY_ARCHITECTURE) IF(LIBRARY_ARCHITECTURE)
SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.")
ELSE(LIBRARY_ARCHITECTURE) ELSE()
SET(RYZOM_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") SET(RYZOM_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.")
ENDIF(LIBRARY_ARCHITECTURE) ENDIF()
ENDIF(NOT RYZOM_LIB_PREFIX) ENDIF(NOT RYZOM_LIB_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX)
## Allow override of install_prefix/games path. ## Allow override of install_prefix/games path.
IF(NOT RYZOM_GAMES_PREFIX) IF(NOT RYZOM_GAMES_PREFIX)
IF(WIN32) IF(WITH_UNIX_STRUCTURE)
SET(RYZOM_GAMES_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ELSE(WIN32)
SET(RYZOM_GAMES_PREFIX "games" CACHE PATH "Installation path for client.") SET(RYZOM_GAMES_PREFIX "games" CACHE PATH "Installation path for client.")
ENDIF(WIN32) ELSE()
ENDIF(NOT RYZOM_GAMES_PREFIX) SET(RYZOM_GAMES_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ENDIF()
ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_GAMES_PREFIX RYZOM_GAMES_ABSOLUTE_PREFIX) NL_MAKE_ABSOLUTE_PREFIX(RYZOM_GAMES_PREFIX RYZOM_GAMES_ABSOLUTE_PREFIX)
ENDMACRO(RYZOM_SETUP_PREFIX_PATHS) ENDMACRO(RYZOM_SETUP_PREFIX_PATHS)
@ -1130,15 +1092,15 @@ MACRO(SETUP_EXTERNAL)
IF(APPLE) IF(APPLE)
IF(WITH_STATIC_EXTERNAL) IF(WITH_STATIC_EXTERNAL)
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a)
ELSE(WITH_STATIC_EXTERNAL) ELSE()
SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so .a) SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib .so .a)
ENDIF(WITH_STATIC_EXTERNAL) ENDIF()
ELSE(APPLE) ELSE(APPLE)
IF(WITH_STATIC_EXTERNAL) IF(WITH_STATIC_EXTERNAL)
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a .so)
ELSE(WITH_STATIC_EXTERNAL) ELSE()
SET(CMAKE_FIND_LIBRARY_SUFFIXES .so .a) SET(CMAKE_FIND_LIBRARY_SUFFIXES .so .a)
ENDIF(WITH_STATIC_EXTERNAL) ENDIF()
ENDIF(APPLE) ENDIF(APPLE)
ENDIF(WIN32) ENDIF(WIN32)
@ -1156,6 +1118,14 @@ MACRO(SETUP_EXTERNAL)
INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR})
ENDIF(WITH_STLPORT) ENDIF(WITH_STLPORT)
IF(WIN32)
# Must include DXSDK before WINSDK
FIND_PACKAGE(DirectXSDK REQUIRED)
# IF(DXSDK_INCLUDE_DIR)
# INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR})
# ENDIF()
ENDIF(WIN32)
IF(MSVC) IF(MSVC)
FIND_PACKAGE(MSVC REQUIRED) FIND_PACKAGE(MSVC REQUIRED)
FIND_PACKAGE(WindowsSDK REQUIRED) FIND_PACKAGE(WindowsSDK REQUIRED)

@ -1,39 +1,6 @@
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H
#cmakedefine HAVE_DL_H 1
#cmakedefine HAVE_EXECINFO_H 1
#cmakedefine HAVE_ICONV 1
#cmakedefine HAVE_INTTYPES_H 1
#cmakedefine HAVE_LANGINFO_CODESET 1
#cmakedefine HAVE_LIMITS_H 1
#cmakedefine HAVE_MALLOC_H 1
#cmakedefine HAVE_PAM_MISC_H 1
#cmakedefine HAVE_PAM_PAM_APPL_H 1
#cmakedefine HAVE_PTHREAD 1
#cmakedefine HAVE_SECURITY_PAM_APPL_H 1
#cmakedefine HAVE_SECURITY_PAM_MISC_H 1
#cmakedefine HAVE_STDINT_H 1
#cmakedefine HAVE_SYS_MOUNT_H 1
#cmakedefine HAVE_SYS_PARAM_H 1
#cmakedefine HAVE_SYS_STATVFS_H 1
#cmakedefine HAVE_SYS_TYPES_H 1
#cmakedefine HAVE_UNISTD_H 1
#cmakedefine HAVE_UTIME_H 1
#cmakedefine HAVE_WCHAR_H 1
#cmakedefine HAVE_BACKTRACE 1
#cmakedefine HAVE_INET_NTOA 1
#cmakedefine HAVE_INET_NTOP 1
#cmakedefine HAVE_INET_PTON 1
#cmakedefine HAVE_STRERROR 1
#cmakedefine HAVE_STRLCAT 1
#cmakedefine HAVE_STRPTIME 1
#cmakedefine HAVE_STRTOK_R 1
#cmakedefine HAVE_STRTOULL 1
#cmakedefine HAVE_STATVFS 1
#cmakedefine HAVE_STAT64 1
#cmakedefine NL_OPENGL_AVAILABLE ${NL_OPENGL_AVAILABLE} #cmakedefine NL_OPENGL_AVAILABLE ${NL_OPENGL_AVAILABLE}
#cmakedefine NL_OPENGLES_AVAILABLE ${NL_OPENGLES_AVAILABLE} #cmakedefine NL_OPENGLES_AVAILABLE ${NL_OPENGLES_AVAILABLE}
#cmakedefine NL_DIRECT3D_AVAILABLE ${NL_DIRECT3D_AVAILABLE} #cmakedefine NL_DIRECT3D_AVAILABLE ${NL_DIRECT3D_AVAILABLE}
@ -43,6 +10,8 @@
#cmakedefine NL_DSOUND_AVAILABLE ${NL_DSOUND_AVAILABLE} #cmakedefine NL_DSOUND_AVAILABLE ${NL_DSOUND_AVAILABLE}
#cmakedefine NL_XAUDIO2_AVAILABLE ${NL_XAUDIO2_AVAILABLE} #cmakedefine NL_XAUDIO2_AVAILABLE ${NL_XAUDIO2_AVAILABLE}
#cmakedefine NL_STEREO_AVAILABLE ${NL_STEREO_AVAILABLE}
#cmakedefine NL_BIN_PREFIX "${NL_BIN_ABSOLUTE_PREFIX}" #cmakedefine NL_BIN_PREFIX "${NL_BIN_ABSOLUTE_PREFIX}"
#cmakedefine NL_ETC_PREFIX "${NL_ETC_ABSOLUTE_PREFIX}" #cmakedefine NL_ETC_PREFIX "${NL_ETC_ABSOLUTE_PREFIX}"
#cmakedefine NL_SHARE_PREFIX "${NL_SHARE_ABSOLUTE_PREFIX}" #cmakedefine NL_SHARE_PREFIX "${NL_SHARE_ABSOLUTE_PREFIX}"
@ -53,4 +22,18 @@
#cmakedefine RYZOM_ETC_PREFIX "${RYZOM_ETC_ABSOLUTE_PREFIX}" #cmakedefine RYZOM_ETC_PREFIX "${RYZOM_ETC_ABSOLUTE_PREFIX}"
#cmakedefine RYZOM_SHARE_PREFIX "${RYZOM_SHARE_ABSOLUTE_PREFIX}" #cmakedefine RYZOM_SHARE_PREFIX "${RYZOM_SHARE_ABSOLUTE_PREFIX}"
#cmakedefine REVISION "${REVISION}"
#cmakedefine BUILD_DATE "${BUILD_DATE}"
#cmakedefine NL_VERSION "${NL_VERSION}"
#cmakedefine NL_VERSION_RC ${NL_VERSION_RC}
#cmakedefine RYZOM_VERSION "${RYZOM_VERSION}"
#cmakedefine RYZOM_VERSION_RC ${RYZOM_VERSION_RC}
#cmakedefine AUTHOR "${AUTHOR}"
#cmakedefine YEAR "${YEAR}"
#cmakedefine COPYRIGHT "${COPYRIGHT}"
#cmakedefine RYZOM_CLIENT_ICON "${RYZOM_CLIENT_ICON}"
#endif // CONFIG_H #endif // CONFIG_H

@ -4,11 +4,7 @@ IF(WITH_STATIC_DRIVERS)
ADD_DEFINITIONS(-DNL_STATIC) ADD_DEFINITIONS(-DNL_STATIC)
ENDIF(WITH_STATIC_DRIVERS) ENDIF(WITH_STATIC_DRIVERS)
# On Windows we need to find DirectInput for NLMISC.
# This is how we get events.
IF(WIN32) IF(WIN32)
FIND_PACKAGE(DirectXSDK REQUIRED)
# On Win32 we can also build the MAX plugins. # On Win32 we can also build the MAX plugins.
IF(WITH_NEL_MAXPLUGIN) IF(WITH_NEL_MAXPLUGIN)
FIND_PACKAGE(3dsMaxSDK) FIND_PACKAGE(3dsMaxSDK)
@ -68,18 +64,12 @@ IF(WITH_INSTALL_LIBRARIES)
ENDIF(UNIX) ENDIF(UNIX)
ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(include)
ENDIF(WITH_INSTALL_LIBRARIES) ENDIF()
ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(src)
IF(WITH_NEL_SAMPLES) IF(WITH_NEL_SAMPLES)
ADD_SUBDIRECTORY(samples) ADD_SUBDIRECTORY(samples)
ENDIF(WITH_NEL_SAMPLES) ENDIF()
# Allow to compile only max plugins without other tools.
IF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN)
IF(WITH_NEL_TOOLS)
FIND_PACKAGE(Squish)
ENDIF(WITH_NEL_TOOLS)
ADD_SUBDIRECTORY(tools) ADD_SUBDIRECTORY(tools)
ENDIF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN)

@ -415,6 +415,16 @@ public:
*/ */
virtual void setAnisotropicFilter(sint filter) = 0; virtual void setAnisotropicFilter(sint filter) = 0;
/**
* Get current anisotropic filter value
*/
virtual uint getAnisotropicFilter() const = 0;
/**
* Get maximum anisotropic filter value
*/
virtual uint getAnisotropicFilterMaximum() const = 0;
/** if !=1, force mostly all the textures (but TextureFonts lightmaps, interfaces etc..) /** if !=1, force mostly all the textures (but TextureFonts lightmaps, interfaces etc..)
* to be divided by Divisor (2, 4, 8...) * to be divided by Divisor (2, 4, 8...)
* Default is 1. * Default is 1.
@ -855,6 +865,12 @@ public:
* get the official name of the driver * get the official name of the driver
*/ */
virtual const char *getVideocardInformation () = 0; virtual const char *getVideocardInformation () = 0;
/**
* Get total video memory.
* get the amount of video memory of current adapter, result is in KiB, -1 if unable to determine
*/
virtual sint getTotalVideoMemory () const = 0;
// @} // @}
@ -1332,6 +1348,7 @@ public:
uint32 DeviceId; uint32 DeviceId;
uint32 SubSysId; uint32 SubSysId;
uint32 Revision; uint32 Revision;
sint32 VideoMemory; // video memory in KiB, -1 if unable to determine
}; };
// Get the number of hardware renderer available on the client platform. // Get the number of hardware renderer available on the client platform.

@ -412,6 +412,7 @@ public:
virtual uint32 getImplementationVersion () const; virtual uint32 getImplementationVersion () const;
virtual const char* getDriverInformation (); virtual const char* getDriverInformation ();
virtual const char* getVideocardInformation (); virtual const char* getVideocardInformation ();
virtual sint getTotalVideoMemory () const;
virtual uint getNbTextureStages(); virtual uint getNbTextureStages();
virtual void getWindowSize (uint32 &width, uint32 &height); virtual void getWindowSize (uint32 &width, uint32 &height);
virtual uint getWindowWidth (); virtual uint getWindowWidth ();
@ -474,6 +475,8 @@ public:
virtual TPolygonMode getPolygonMode (); virtual TPolygonMode getPolygonMode ();
virtual void forceDXTCCompression(bool dxtcComp); virtual void forceDXTCCompression(bool dxtcComp);
virtual void setAnisotropicFilter(sint filter); virtual void setAnisotropicFilter(sint filter);
virtual uint getAnisotropicFilter() const;
virtual uint getAnisotropicFilterMaximum() const;
virtual void forceTextureResize(uint divisor); virtual void forceTextureResize(uint divisor);
virtual bool setMonitorColorProperties (const CMonitorColorProperties &properties); virtual bool setMonitorColorProperties (const CMonitorColorProperties &properties);
// @} // @}

@ -54,11 +54,13 @@ public:
/** generate and return a bitmap /** generate and return a bitmap
* \param c the unicode char * \param c the unicode char
* \param size size of the generated font in ??? format * \param size size of the generated font in ??? format
* \param embolden set embolden style (bold)
* \param oblique set oblique style (slanted, italic)
* \param width width of the generated bitmap, this value is set by this function * \param width width of the generated bitmap, this value is set by this function
* \param height height of the generated bitmap, this value is set by this function * \param height height of the generated bitmap, this value is set by this function
* \param pitch pitch of the generated bitmap (+ or - the number of bytes per row), this value is set by this function * \param pitch pitch of the generated bitmap (+ or - the number of bytes per row), this value is set by this function
*/ */
uint8 *getBitmap (ucchar c, uint32 size, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex); uint8 *getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex);
/** returns the width and height of a character using a specific size and /** returns the width and height of a character using a specific size and
* *

@ -102,6 +102,8 @@ public:
* \param fontGen font generator * \param fontGen font generator
* \param color primitive blocks color * \param color primitive blocks color
* \param fontSize font size * \param fontSize font size
* \param embolden font style bold
* \param oblique font style slanted (italic)
* \param desc display descriptor (screen size, font ratio) * \param desc display descriptor (screen size, font ratio)
* \param output computed string * \param output computed string
* \param keep800x600Ratio true if you want that CFontManager look at Driver window size, and resize fontSize so it keeps same size... * \param keep800x600Ratio true if you want that CFontManager look at Driver window size, and resize fontSize so it keeps same size...
@ -110,6 +112,8 @@ public:
CFontGenerator *fontGen, CFontGenerator *fontGen,
const NLMISC::CRGBA &color, const NLMISC::CRGBA &color,
uint32 fontSize, uint32 fontSize,
bool embolden,
bool oblique,
IDriver *driver, IDriver *driver,
CComputedString& output, CComputedString& output,
bool keep800x600Ratio= true); bool keep800x600Ratio= true);
@ -121,6 +125,8 @@ public:
CFontGenerator *fontGen, CFontGenerator *fontGen,
const NLMISC::CRGBA &color, const NLMISC::CRGBA &color,
uint32 fontSize, uint32 fontSize,
bool embolden,
bool oblique,
IDriver *driver, IDriver *driver,
CComputedString &output, CComputedString &output,
bool keep800x600Ratio= true); bool keep800x600Ratio= true);
@ -132,6 +138,8 @@ public:
CFontGenerator *fontGen, CFontGenerator *fontGen,
const NLMISC::CRGBA &color, const NLMISC::CRGBA &color,
uint32 fontSize, uint32 fontSize,
bool embolden,
bool oblique,
IDriver *driver, IDriver *driver,
CComputedString &output, CComputedString &output,
bool keep800x600Ratio= true); bool keep800x600Ratio= true);

@ -429,7 +429,7 @@ private:
void resetTouchFlags() {_InternalFlags &= (uint16)(~TouchedAll);} void resetTouchFlags() {_InternalFlags &= (uint16)(~TouchedAll);}
// Force non resident memory // Force non resident memory
void restaureNonResidentMemory(); void restoreNonResidentMemory();
// Convert current index to a serializable vector // Convert current index to a serializable vector
void buildSerialVector(std::vector<uint32> &dest) const; void buildSerialVector(std::vector<uint32> &dest) const;

@ -74,6 +74,10 @@ public:
void setFontSize (uint32 fontSize) { _FontSize = fontSize; } void setFontSize (uint32 fontSize) { _FontSize = fontSize; }
void setEmbolden (bool b) { _Embolden = b; }
void setOblique (bool b) { _Oblique = b; }
void setHotSpot (CComputedString::THotSpot hotSpot) { _HotSpot = hotSpot; } void setHotSpot (CComputedString::THotSpot hotSpot) { _HotSpot = hotSpot; }
void setScaleX (float scaleX) { _ScaleX = scaleX; } void setScaleX (float scaleX) { _ScaleX = scaleX; }
@ -101,6 +105,10 @@ public:
uint32 getFontSize () const { return _FontSize; } uint32 getFontSize () const { return _FontSize; }
bool getEmbolden () const { return _Embolden; }
bool getOblique () const { return _Oblique; }
CComputedString::THotSpot getHotSpot() const { return _HotSpot; } CComputedString::THotSpot getHotSpot() const { return _HotSpot; }
float getScaleX() const { return _ScaleX; } float getScaleX() const { return _ScaleX; }
@ -240,7 +248,7 @@ public:
nlassert(_FontGen); nlassert(_FontGen);
// compute the string just one time // compute the string just one time
_FontManager->computeString (ucstr, _FontGen, _Color, _FontSize, _Driver, _TempString, _Keep800x600Ratio); _FontManager->computeString (ucstr, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, _TempString, _Keep800x600Ratio);
// draw shaded // draw shaded
if (_Shaded) if (_Shaded)
@ -279,7 +287,7 @@ public:
// compute the string just one time // compute the string just one time
char *str; char *str;
NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize); NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize);
_FontManager->computeString (str, _FontGen, _Color, _FontSize, _Driver, _TempString, _Keep800x600Ratio); _FontManager->computeString (str, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, _TempString, _Keep800x600Ratio);
// draw shaded // draw shaded
if (_Shaded) if (_Shaded)
@ -334,7 +342,7 @@ public:
*/ */
void computeString (const std::string& s, CComputedString& output) void computeString (const std::string& s, CComputedString& output)
{ {
_FontManager->computeString (s, _FontGen, _Color, _FontSize, _Driver, output, _Keep800x600Ratio); _FontManager->computeString (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
} }
/** /**
@ -345,12 +353,12 @@ public:
*/ */
void computeString (const ucstring& s, CComputedString& output) void computeString (const ucstring& s, CComputedString& output)
{ {
_FontManager->computeString (s, _FontGen, _Color, _FontSize, _Driver, output, _Keep800x600Ratio); _FontManager->computeString (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
} }
void computeStringInfo (const ucstring& s, CComputedString& output) void computeStringInfo (const ucstring& s, CComputedString& output)
{ {
_FontManager->computeStringInfo (s, _FontGen, _Color, _FontSize, _Driver, output, _Keep800x600Ratio); _FontManager->computeStringInfo (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
} }
/// Debug : write to the disk the texture cache /// Debug : write to the disk the texture cache
@ -381,6 +389,10 @@ private:
/// Font size; /// Font size;
uint32 _FontSize; uint32 _FontSize;
bool _Embolden;
bool _Oblique;
/// Current text color /// Current text color
NLMISC::CRGBA _Color; NLMISC::CRGBA _Color;

@ -66,6 +66,10 @@ public:
void setColor(NLMISC::CRGBA color); void setColor(NLMISC::CRGBA color);
void setFontSize(uint32 fontSize); void setFontSize(uint32 fontSize);
uint32 getFontSize() const; uint32 getFontSize() const;
void setEmbolden(bool b);
bool getEmbolden() const;
void setOblique(bool b);
bool getOblique() const;
void setHotSpot(THotSpot hotSpot); void setHotSpot(THotSpot hotSpot);
THotSpot getHotSpot() const; THotSpot getHotSpot() const;
void setScaleX(float scaleX); void setScaleX(float scaleX);

@ -43,6 +43,8 @@ public:
ucchar Char; ucchar Char;
CFontGenerator *FontGenerator; CFontGenerator *FontGenerator;
sint Size; sint Size;
bool Embolden;
bool Oblique;
// The less recently used infos // The less recently used infos
@ -66,6 +68,8 @@ public:
ucchar Char; ucchar Char;
CFontGenerator *FontGenerator; CFontGenerator *FontGenerator;
sint Size; sint Size;
bool Embolden;
bool Oblique;
uint32 getVal(); uint32 getVal();
//bool operator < (const SLetterKey&k) const; //bool operator < (const SLetterKey&k) const;

@ -20,6 +20,7 @@
#include "nel/misc/debug.h" #include "nel/misc/debug.h"
#include "nel/misc/stream.h" #include "nel/misc/stream.h"
#include "nel/misc/rgba.h" #include "nel/misc/rgba.h"
#include "nel/misc/path.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <string> #include <string>
@ -82,8 +83,8 @@ public:
// not free // not free
_Flags&=~NL3D_CTILE_FREE_FLAG; _Flags&=~NL3D_CTILE_FREE_FLAG;
// set filename // set filename, replacing \\ by / if needed
_BitmapName[bitmapType]=name; _BitmapName[bitmapType] = NLMISC::CPath::standardizePath(name, false);
} }
std::string getFileName (TBitmap bitmapType) const std::string getFileName (TBitmap bitmapType) const

@ -505,6 +505,12 @@ public:
*/ */
virtual const char* getVideocardInformation () = 0; virtual const char* getVideocardInformation () = 0;
/**
* Get total video memory.
* get the amount of video memory of current adapter, result is in KiB, -1 if unable to determine
*/
virtual sint getTotalVideoMemory () const = 0;
/// Get the number of texture stage available, for multitexturing (Normal material shaders). Valid only after setDisplay(). /// Get the number of texture stage available, for multitexturing (Normal material shaders). Valid only after setDisplay().
virtual uint getNbTextureStages() = 0; virtual uint getNbTextureStages() = 0;
@ -646,6 +652,16 @@ public:
*/ */
virtual void setAnisotropicFilter(sint filter)=0; virtual void setAnisotropicFilter(sint filter)=0;
/**
* Get current anisotropic filter value
*/
virtual uint getAnisotropicFilter() const = 0;
/**
* Get maximum anisotropic filter value
*/
virtual uint getAnisotropicFilterMaximum() const = 0;
/** if !=1, force mostly all the textures (but TextureFonts lightmaps, interfaces etc..) /** if !=1, force mostly all the textures (but TextureFonts lightmaps, interfaces etc..)
* to be divided by Divisor (2, 4, 8...) * to be divided by Divisor (2, 4, 8...)
* Default is 1. * Default is 1.

@ -137,6 +137,24 @@ public:
* \return the font size * \return the font size
*/ */
virtual uint32 getFontSize () const = 0; virtual uint32 getFontSize () const = 0;
/**
* set embolden (bold) state
* \param embolden the embbolden state
*/
virtual void setEmbolden (bool b) = 0;
/**
* \return the embolden state
*/
virtual bool getEmbolden () const = 0;
/**
* set oblique (italic) state
* \param oblique the oblique state
*/
virtual void setOblique (bool b) = 0;
/**
* \return the oblique state
*/
virtual bool getOblique () const = 0;
/** /**
* set the hot spot * set the hot spot
* \param fonSize the font size * \param fonSize the font size

@ -653,7 +653,7 @@ private:
void resetTouchFlags() {_InternalFlags &= (uint16)(~TouchedAll);} void resetTouchFlags() {_InternalFlags &= (uint16)(~TouchedAll);}
// Force non resident memory // Force non resident memory
void restaureNonResidentMemory(); void restoreNonResidentMemory();
private: private:

@ -19,8 +19,12 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
// Include from libxml2 // Forward declarations for libxml2
#include <libxml/parser.h> typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
typedef struct _xmlDoc xmlDoc;
typedef xmlDoc *xmlDocPtr;
namespace NLGEORGES namespace NLGEORGES
{ {

@ -17,13 +17,16 @@
#ifndef NL_ACTION_HANDLER_H #ifndef NL_ACTION_HANDLER_H
#define NL_ACTION_HANDLER_H #define NL_ACTION_HANDLER_H
#include "nel/misc/types_nl.h"
#include <libxml/parser.h>
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/misc/debug.h" #include "nel/misc/debug.h"
#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/xml_auto_ptr.h"
#include <map> #include <map>
// Forward declarations for libxml2
typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
namespace NLGUI namespace NLGUI
{ {

@ -151,8 +151,12 @@ namespace NLGUI
// called when keyboard capture has been lost // called when keyboard capture has been lost
virtual void onKeyboardCaptureLost() {} virtual void onKeyboardCaptureLost() {}
// 'tooltip' property expects string to be ucstring or latin1 which is not possible from html page
int luaSetTooltipUtf8(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlBase, CViewBase) REFLECT_EXPORT_START(CCtrlBase, CViewBase)
REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp); REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp);
REFLECT_LUA_METHOD("setTooltipUtf8", luaSetTooltipUtf8);
REFLECT_EXPORT_END REFLECT_EXPORT_END
// special for mouse over : return true and fill the name of the cursor to display // special for mouse over : return true and fill the name of the cursor to display

@ -147,7 +147,7 @@ namespace NLGUI
sint32 _Aligned; // 0-Top 1-Bottom 2-Left 3-Right sint32 _Aligned; // 0-Top 1-Bottom 2-Left 3-Right
sint32 _TrackDispPos; sint32 _TrackDispPos;
sint32 _TrackPos; float _TrackPos;
sint32 _TrackSize; sint32 _TrackSize;
sint32 _TrackSizeMin; sint32 _TrackSizeMin;

@ -63,6 +63,8 @@ namespace NLGUI
uint getTextId(uint i) const; uint getTextId(uint i) const;
uint getTextPos(uint nId) const; uint getTextPos(uint nId) const;
const ucstring &getTexture(uint i) const; const ucstring &getTexture(uint i) const;
void setGrayed(uint i, bool g);
const bool getGrayed(uint i) const;
void removeText(uint nPos); void removeText(uint nPos);
uint getNumTexts() const {return (uint)_Texts.size();} uint getNumTexts() const {return (uint)_Texts.size();}
void sortText(); void sortText();
@ -132,6 +134,7 @@ namespace NLGUI
sint32 _NotLinkedToDBSelection; sint32 _NotLinkedToDBSelection;
std::vector<std::pair<uint, ucstring> > _Texts; std::vector<std::pair<uint, ucstring> > _Texts;
std::vector<ucstring> _Textures; std::vector<ucstring> _Textures;
std::vector<bool> _Grayed;
// Action Handler called on combo click // Action Handler called on combo click
std::string _AHOnSelectStart; std::string _AHOnSelectStart;

@ -86,7 +86,7 @@ namespace NLGUI
uint8 getCurrentContentAlpha() const { return _CurrentContentAlpha; } uint8 getCurrentContentAlpha() const { return _CurrentContentAlpha; }
virtual bool isGrayed() const { return false; } virtual bool isGrayed() const { return false; }
virtual bool getTouchFlag(bool clearFlag) const{ return false; } virtual bool getTouchFlag(bool /* clearFlag */) const { return false; }
virtual void backupPosition() {} virtual void backupPosition() {}
virtual void restorePosition() {} virtual void restorePosition() {}

@ -25,23 +25,21 @@
#include "nel/gui/group_tree.h" #include "nel/gui/group_tree.h"
#include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_button.h"
#include "nel/gui/group_table.h" #include "nel/gui/group_table.h"
#include "nel/gui/libwww_types.h"
typedef std::map<std::string, std::string> TStyle; typedef std::map<std::string, std::string> TStyle;
extern "C"
{
#include "WWWInit.h"
}
namespace NLGUI namespace NLGUI
{ {
class CCtrlButton; class CCtrlButton;
class CCtrlScroll; class CCtrlScroll;
class CGroupList; class CGroupList;
class CGroupMenu;
class CDBGroupComboBox; class CDBGroupComboBox;
class CGroupParagraph; class CGroupParagraph;
extern std::string CurrentCookie;
extern std::string HTTPCurrentDomain;
// HTML group // HTML group
/** /**
@ -55,15 +53,6 @@ namespace NLGUI
public: public:
DECLARE_UI_CLASS( CGroupHTML ) DECLARE_UI_CLASS( CGroupHTML )
friend void TextAdd (struct _HText *me, const char * buf, int len);
friend void TextBeginElement (_HText *me, int element_number, const BOOL *present, const char ** value);
friend void TextEndElement (_HText *me, int element_number);
friend void TextLink (struct _HText *me, int element_number, int attribute_number, struct _HTChildAnchor *anchor, const BOOL *present, const char **value);
friend void TextBuild (HText * me, HTextStatus status);
friend void TextBeginUnparsedElement(HText *me, const char *buffer, int length);
friend void TextEndUnparsedElement(HText *me, const char *buffer, int length);
friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status);
/// Web browser options for CGroupHTML /// Web browser options for CGroupHTML
struct SWebOptions struct SWebOptions
{ {
@ -76,14 +65,43 @@ namespace NLGUI
std::string languageCode; std::string languageCode;
/// List of domains the widget can consider secure. /// List of domains the widget can consider secure.
std::vector< std::string > trustedDomains; std::vector< std::string > trustedDomains;
/// Maximum concurrent MultiCurl connections per CGroupHTML instance
sint32 curlMaxConnections;
SWebOptions() SWebOptions(): curlMaxConnections(2)
{ {
} }
}; };
static SWebOptions options; static SWebOptions options;
class CStyleParams
{
public:
CStyleParams () : TextColor(255,255,255,255)
{
FontSize=10;
FontWeight=400;
FontOblique=false;
Underlined=false;
StrikeThrough=false;
Width=-1;
Height=-1;
MaxWidth=-1;
MaxHeight=-1;
}
uint FontSize;
uint FontWeight;
bool FontOblique;
NLMISC::CRGBA TextColor;
bool Underlined;
bool StrikeThrough;
sint32 Width;
sint32 Height;
sint32 MaxWidth;
sint32 MaxHeight;
};
// Constructor // Constructor
CGroupHTML(const TCtorParam &param); CGroupHTML(const TCtorParam &param);
~CGroupHTML(); ~CGroupHTML();
@ -102,6 +120,9 @@ namespace NLGUI
// Browse // Browse
virtual void browse (const char *url); virtual void browse (const char *url);
// parse html string using libxml2 parser
virtual bool parseHtml(std::string htmlString);
// Refresh // Refresh
void refresh(); void refresh();
@ -169,12 +190,44 @@ namespace NLGUI
std::string DefaultFormTextGroup; std::string DefaultFormTextGroup;
std::string DefaultFormTextAreaGroup; std::string DefaultFormTextAreaGroup;
std::string DefaultFormSelectGroup; std::string DefaultFormSelectGroup;
std::string DefaultFormSelectBoxMenuGroup;
std::string DefaultCheckBoxBitmapNormal; std::string DefaultCheckBoxBitmapNormal;
std::string DefaultCheckBoxBitmapPushed; std::string DefaultCheckBoxBitmapPushed;
std::string DefaultCheckBoxBitmapOver; std::string DefaultCheckBoxBitmapOver;
std::string DefaultRadioButtonBitmapNormal;
std::string DefaultRadioButtonBitmapPushed;
std::string DefaultRadioButtonBitmapOver;
std::string DefaultBackgroundBitmapView; std::string DefaultBackgroundBitmapView;
std::string CurrentLinkTitle; std::string CurrentLinkTitle;
struct TFormField {
public:
TFormField(const std::string &k, const std::string &v)
:name(k),value(v)
{}
std::string name;
std::string value;
};
struct SFormFields {
public:
SFormFields()
{
}
void clear()
{
Values.clear();
}
void add(const std::string &key, const std::string &value)
{
Values.push_back(TFormField(key, value));
}
std::vector<TFormField> Values;
};
// Browser home // Browser home
std::string Home; std::string Home;
@ -199,6 +252,7 @@ namespace NLGUI
int luaBeginElement(CLuaState &ls); int luaBeginElement(CLuaState &ls);
int luaEndElement(CLuaState &ls); int luaEndElement(CLuaState &ls);
int luaShowDiv(CLuaState &ls); int luaShowDiv(CLuaState &ls);
int luaParseHtml(CLuaState &ls);
REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText) REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText)
REFLECT_LUA_METHOD("browse", luaBrowse) REFLECT_LUA_METHOD("browse", luaBrowse)
@ -210,6 +264,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("beginElement", luaBeginElement) REFLECT_LUA_METHOD("beginElement", luaBeginElement)
REFLECT_LUA_METHOD("endElement", luaEndElement) REFLECT_LUA_METHOD("endElement", luaEndElement)
REFLECT_LUA_METHOD("showDiv", luaShowDiv) REFLECT_LUA_METHOD("showDiv", luaShowDiv)
REFLECT_LUA_METHOD("parseHtml", luaParseHtml)
REFLECT_STRING("url", getURL, setURL) REFLECT_STRING("url", getURL, setURL)
REFLECT_FLOAT("timeout", getTimeout, setTimeout) REFLECT_FLOAT("timeout", getTimeout, setTimeout)
REFLECT_EXPORT_END REFLECT_EXPORT_END
@ -228,10 +283,10 @@ namespace NLGUI
virtual void addText (const char * buf, int len); virtual void addText (const char * buf, int len);
// A link has been parsed // A link has been parsed
virtual void addLink (uint element_number, uint attribute_number, HTChildAnchor *anchor, const BOOL *present, const char **value); virtual void addLink (uint element_number, const std::vector<bool> &present, const std::vector<const char *> &value);
// A new begin HTML element has been parsed (<IMG> for exemple) // A new begin HTML element has been parsed (<IMG> for exemple)
virtual void beginElement (uint element_number, const BOOL *present, const char **value); virtual void beginElement (uint element_number, const std::vector<bool> &present, const std::vector<const char *> &value);
// A new end HTML element has been parsed (</IMG> for exemple) // A new end HTML element has been parsed (</IMG> for exemple)
virtual void endElement (uint element_number); virtual void endElement (uint element_number);
@ -246,10 +301,14 @@ namespace NLGUI
virtual void addHTTPGetParams (std::string &url, bool trustedDomain); virtual void addHTTPGetParams (std::string &url, bool trustedDomain);
// Add POST params to the libwww list // Add POST params to the libwww list
virtual void addHTTPPostParams (HTAssocList *formfields, bool trustedDomain); virtual void addHTTPPostParams (SFormFields &formfields, bool trustedDomain);
// the current request is terminated // the current request is terminated
virtual void requestTerminated(HTRequest *request); virtual void requestTerminated();
// libxml2 html parser functions
void htmlElement(xmlNode *node, int element_number);
void htmlWalkDOM(xmlNode *a_node);
// Get Home URL // Get Home URL
virtual std::string home(); virtual std::string home();
@ -281,17 +340,19 @@ namespace NLGUI
void addString(const ucstring &str); void addString(const ucstring &str);
// Add an image in the current paragraph // Add an image in the current paragraph
void addImage(const char *image, bool globalColor, bool reloadImg=false); void addImage(const char *image, bool globalColor, bool reloadImg=false, const CStyleParams &style = CStyleParams());
// Add a text area in the current paragraph // Add a text area in the current paragraph
CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength); CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength);
// Add a combo box in the current paragraph // Add a combo box in the current paragraph
CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name); CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name);
CGroupMenu *addSelectBox(const std::string &templateName, const char *name);
// Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL. // Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL.
CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap, CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap,
const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, const char *tooltip); const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, const char *tooltip,
const CStyleParams &style = CStyleParams());
// Set the background color // Set the background color
void setBackgroundColor (const NLMISC::CRGBA &bgcolor); void setBackgroundColor (const NLMISC::CRGBA &bgcolor);
@ -311,8 +372,20 @@ namespace NLGUI
// Delete page content and prepare next page // Delete page content and prepare next page
void removeContent (); void removeContent ();
// Current URL // Current URL for relative links in page
std::string _URL; std::string _URL;
// Current URL
std::string _DocumentUrl;
// Valid base href was found
bool _IgnoreBaseUrlTag;
// Fragment from loading url
std::string _UrlFragment;
std::map<std::string,NLGUI::CInterfaceElement *> _Anchors;
std::vector<std::string> _AnchorName;
// Parser context
bool _ReadingHeadTag;
bool _IgnoreHeadTag;
// Current DOMAIN // Current DOMAIN
bool _TrustedDomain; bool _TrustedDomain;
@ -338,6 +411,11 @@ namespace NLGUI
bool _Connecting; bool _Connecting;
double _TimeoutValue; // the timeout in seconds double _TimeoutValue; // the timeout in seconds
double _ConnectingTimeout; double _ConnectingTimeout;
sint _RedirectsRemaining;
// Automatic page refresh
double _LastRefreshTime;
double _NextRefreshTime;
std::string _RefreshUrl;
// minimal embeded lua script support // minimal embeded lua script support
// Note : any embeded script is executed immediately after the closing // Note : any embeded script is executed immediately after the closing
@ -347,15 +425,13 @@ namespace NLGUI
bool _IgnoreText; bool _IgnoreText;
// the script to execute // the script to execute
std::string _LuaScript; std::string _LuaScript;
bool _LuaHrefHack;
bool _Object; bool _Object;
std::string _ObjectScript; std::string _ObjectScript;
// Someone is conecting. We got problem with libwww : 2 connection requests can deadlock the client. // Data container for active curl transfer
static CGroupHTML *_ConnectingLock; class CCurlWWWData * _CurlWWW;
// LibWWW data
class CLibWWWData *_LibWWW;
// Current paragraph // Current paragraph
std::string _DivName; std::string _DivName;
@ -377,14 +453,33 @@ namespace NLGUI
return _PRE.back(); return _PRE.back();
} }
// UL mode // DL list
std::vector<bool> _UL; class HTMLDListElement {
inline bool getUL() const public:
{ HTMLDListElement()
if (_UL.empty()) : DT(false), DD(false)
return false; { }
return _UL.back();
} public:
bool DT;
bool DD;
};
std::vector<HTMLDListElement> _DL;
// OL and UL
class HTMLOListElement {
public:
HTMLOListElement(int start, std::string type)
: Value(start),Type(type), First(true)
{ }
std::string getListMarkerText() const;
public:
sint32 Value;
std::string Type;
bool First;
};
std::vector<HTMLOListElement> _UL;
// A mode // A mode
std::vector<bool> _A; std::vector<bool> _A;
@ -424,6 +519,44 @@ namespace NLGUI
return TextFontSize; return TextFontSize;
return _FontSize.back(); return _FontSize.back();
} }
inline uint getFontSizeSmaller() const
{
if (getFontSize() < 5)
return 3;
return getFontSize()-2;
}
std::vector<uint> _FontWeight;
inline uint getFontWeight() const
{
if (_FontWeight.empty())
return 400;
return _FontWeight.back();
}
std::vector<bool> _FontOblique;
inline bool getFontOblique() const
{
if (_FontOblique.empty())
return false;
return _FontOblique.back();
}
std::vector<bool> _FontUnderlined;
inline bool getFontUnderlined() const
{
if (_FontUnderlined.empty())
return false;
return _FontUnderlined.back();
}
std::vector<bool> _FontStrikeThrough;
inline bool getFontStrikeThrough() const
{
if (_FontStrikeThrough.empty())
return false;
return _FontStrikeThrough.back();
}
// Current link // Current link
std::vector<std::string> _Link; std::vector<std::string> _Link;
@ -449,6 +582,14 @@ namespace NLGUI
return _LinkClass.back().c_str(); return _LinkClass.back().c_str();
} }
std::vector<bool> _BlockLevelElement;
inline bool isBlockLevelElement() const
{
if (_BlockLevelElement.empty())
return false;
return _BlockLevelElement.back();
}
// Divs (i.e. interface group) // Divs (i.e. interface group)
std::vector<class CInterfaceGroup*> _Divs; std::vector<class CInterfaceGroup*> _Divs;
inline CInterfaceGroup *getDiv() const inline CInterfaceGroup *getDiv() const
@ -492,6 +633,10 @@ namespace NLGUI
TextArea = NULL; TextArea = NULL;
Checkbox = NULL; Checkbox = NULL;
ComboBox = NULL; ComboBox = NULL;
SelectBox = NULL;
sbRBRef = NULL;
sbMultiple = false;
sbOptionDisabled = -1;
InitialSelection = 0; InitialSelection = 0;
} }
@ -510,6 +655,19 @@ namespace NLGUI
// Combobox group // Combobox group
CDBGroupComboBox *ComboBox; CDBGroupComboBox *ComboBox;
// Combobox with multiple selection or display size >= 2
CGroupMenu *SelectBox;
// Single or multiple selections for SelectBox
bool sbMultiple;
// Marks OPTION element as disabled
// Only valid when parsing html
sint sbOptionDisabled;
// First radio button in SelectBox if single selection
CCtrlBaseButton *sbRBRef;
// select values (for the <select> tag) // select values (for the <select> tag)
std::vector<std::string> SelectValues; std::vector<std::string> SelectValues;
sint InitialSelection; // initial selection for the combo box sint InitialSelection; // initial selection for the combo box
@ -593,6 +751,8 @@ namespace NLGUI
// search if the action / params match the url. look recurs into procedures // search if the action / params match the url. look recurs into procedures
bool actionLaunchUrlRecurs(const std::string &ah, const std::string &params, const std::string &url); bool actionLaunchUrlRecurs(const std::string &ah, const std::string &params, const std::string &url);
void registerAnchor(CInterfaceElement* elm);
// Browse undo and redo // Browse undo and redo
enum {MaxUrlUndoRedo= 256}; enum {MaxUrlUndoRedo= 256};
std::string _BrowseUndoButton; std::string _BrowseUndoButton;
@ -603,7 +763,8 @@ namespace NLGUI
std::deque<std::string> _BrowseUndo; std::deque<std::string> _BrowseUndo;
std::deque<std::string> _BrowseRedo; std::deque<std::string> _BrowseRedo;
void pushUrlUndoRedo(const std::string &url); void pushUrlUndoRedo(const std::string &url);
void doBrowse(const char *url); void doBrowse(const char *url, bool force = false);
void doBrowseAnchor(const std::string &anchor);
void updateUndoRedoButtons(); void updateUndoRedoButtons();
void updateRefreshButton(); void updateRefreshButton();
@ -613,28 +774,57 @@ namespace NLGUI
typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap; typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap;
static TGroupHtmlByUIDMap _GroupHtmlByUID; static TGroupHtmlByUIDMap _GroupHtmlByUID;
private: // read style attribute
void getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit = true);
void applyCssMinMax(sint32 &width, sint32 &height, sint32 minw=0, sint32 minh=0, sint32 maxw=0, sint32 maxh=0);
// load and render local html file (from bnp for example)
void doBrowseLocalFile(const std::string &filename);
// load remote content using either GET or POST
void doBrowseRemoteUrl(const std::string &url, const std::string &referer, bool doPost = false, const SFormFields &formfields = SFormFields());
// render html string as new browser page
bool renderHtmlString(const std::string &html);
// initialize formfields list from form elements on page
void buildHTTPPostParams (SFormFields &formfields);
private:
// decode all HTML entities // decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str); static ucstring decodeHTMLEntities(const ucstring &str);
// ImageDownload system // ImageDownload system
enum TDataType {ImgType= 0, BnpType}; enum TDataType {ImgType= 0, BnpType};
struct CDataImageDownload
{
public:
CDataImageDownload(CViewBase *img, CStyleParams style): Image(img), Style(style)
{
}
public:
CViewBase * Image;
CStyleParams Style;
};
struct CDataDownload struct CDataDownload
{ {
CDataDownload(CURL *c, const std::string &u, FILE *f, TDataType t, CViewBase *i, const std::string &s, const std::string &m) : curl(c), url(u), luaScript(s), md5sum(m), type(t), fp(f) public:
CDataDownload(CURL *c, const std::string &u, const std::string &d, FILE *f, TDataType t, CViewBase *i, const std::string &s, const std::string &m, const CStyleParams &style = CStyleParams()) : curl(c), url(u), dest(d), luaScript(s), md5sum(m), type(t), fp(f)
{ {
if (t == ImgType) imgs.push_back(i); if (t == ImgType) imgs.push_back(CDataImageDownload(i, style));
} }
public:
CURL *curl; CURL *curl;
std::string url; std::string url;
std::string dest;
std::string luaScript; std::string luaScript;
std::string md5sum; std::string md5sum;
TDataType type; TDataType type;
FILE *fp; FILE *fp;
std::vector<CViewBase *> imgs; std::vector<CDataImageDownload> imgs;
}; };
std::vector<CDataDownload> Curls; std::vector<CDataDownload> Curls;
@ -643,11 +833,13 @@ namespace NLGUI
void initImageDownload(); void initImageDownload();
void checkImageDownload(); void checkImageDownload();
void addImageDownload(const std::string &url, CViewBase *img); void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams());
std::string localImageName(const std::string &url); std::string localImageName(const std::string &url);
std::string getAbsoluteUrl(const std::string &url);
bool isTrustedDomain(const std::string &domain); bool isTrustedDomain(const std::string &domain);
void setImage(CViewBase *view, const std::string &file); void setImage(CViewBase *view, const std::string &file);
void setImageSize(CViewBase *view, const CStyleParams &style = CStyleParams());
// BnpDownload system // BnpDownload system
void initBnpDownload(); void initBnpDownload();
@ -658,6 +850,13 @@ namespace NLGUI
void releaseDownloads(); void releaseDownloads();
void checkDownloads(); void checkDownloads();
// HtmlType download finished
void htmlDownloadFinished(const std::string &content, const std::string &type, long code);
// cURL transfer callbacks
static size_t curlHeaderCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData);
static size_t curlDataCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData);
static size_t curlProgressCallback(void *pCCurlWWWData, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
}; };
// adapter group that store y offset for inputs inside an html form // adapter group that store y offset for inputs inside an html form
@ -671,7 +870,6 @@ namespace NLGUI
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
}; };
} }
#endif #endif

@ -346,6 +346,7 @@ namespace NLGUI
// set the minW of the RootMenu. // set the minW of the RootMenu.
void setMinW(sint32 minW); void setMinW(sint32 minW);
void setMinH(sint32 minH);
// Gray a line on the RootMenu // Gray a line on the RootMenu
void setGrayedLine(uint line, bool g); void setGrayedLine(uint line, bool g);

@ -66,6 +66,8 @@ namespace NLGUI
// from CCtrlBase // from CCtrlBase
virtual void elementCaptured(CCtrlBase *capturedElement); virtual void elementCaptured(CCtrlBase *capturedElement);
// setup vertical scrolling event
void smoothScrollY (sint32 dy);
REFLECT_EXPORT_START(CGroupScrollText, CInterfaceGroup) REFLECT_EXPORT_START(CGroupScrollText, CInterfaceGroup)
REFLECT_EXPORT_END REFLECT_EXPORT_END
@ -78,6 +80,9 @@ namespace NLGUI
bool _Settuped; bool _Settuped;
bool _InvertScrollBar; bool _InvertScrollBar;
sint32 _ListHeight; sint32 _ListHeight;
bool _Scrolling;
float _ScrollDistance;
bool _ClockMsgEventRegistered;
protected: protected:
void setup(); void setup();
void updateScrollBar(); void updateScrollBar();

@ -76,7 +76,7 @@ namespace NLGUI
public: public:
IDeletionWatcher() {} IDeletionWatcher() {}
virtual ~IDeletionWatcher() {} virtual ~IDeletionWatcher() {}
virtual void onDeleted( const std::string &name ){} virtual void onDeleted( const std::string &/* name */) {}
}; };
enum EStrech enum EStrech

@ -22,9 +22,12 @@
#include "nel/misc/debug.h" #include "nel/misc/debug.h"
#include "nel/misc/smart_ptr.h" #include "nel/misc/smart_ptr.h"
#include "nel/misc/rgba.h" #include "nel/misc/rgba.h"
#include "libxml/globals.h"
#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/xml_auto_ptr.h"
// Forward declarations for libxml2
typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
namespace NL3D namespace NL3D
{ {
class UAnimationSet; class UAnimationSet;

@ -20,12 +20,10 @@
#ifndef CL_LIB_WWW_H #ifndef CL_LIB_WWW_H
#define CL_LIB_WWW_H #define CL_LIB_WWW_H
extern "C" #include <curl/curl.h>
{
#include "WWWInit.h"
}
#include "nel/misc/rgba.h" #include "nel/misc/rgba.h"
#include "nel/gui/libwww_types.h"
namespace NLGUI namespace NLGUI
{ {
@ -35,14 +33,12 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
// Legacy function from libwww
SGML_dtd * HTML_dtd (void);
// Init the libwww // Init the libwww
void initLibWWW(); void initLibWWW();
// Get an url and setup a local domain
const std::string &setCurrentDomain(const std::string &url);
extern std::string CurrentCookie;
// *************************************************************************** // ***************************************************************************
// Some DTD table // Some DTD table
@ -218,49 +214,58 @@ namespace NLGUI
HTML_ATTR(DIV,STYLE), HTML_ATTR(DIV,STYLE),
}; };
enum
#undef HTML_ATTR
// ***************************************************************************
// A smart ptr for LibWWW strings
class C3WSmartPtr
{
public:
C3WSmartPtr ()
{ {
_Ptr = NULL; HTML_ATTR(SPAN,CLASS) = 0,
} HTML_ATTR(SPAN,ID),
C3WSmartPtr (const char *ptr) HTML_ATTR(SPAN,STYLE),
};
enum
{ {
_Ptr = ptr; HTML_ATTR(H1,CLASS) = 0,
} HTML_ATTR(H1,ID),
~C3WSmartPtr () HTML_ATTR(H1,STYLE),
};
enum
{ {
clear(); HTML_ATTR(H2,CLASS) = 0,
} HTML_ATTR(H2,ID),
void operator=(const char *str) HTML_ATTR(H2,STYLE),
};
enum
{ {
clear (); HTML_ATTR(H3,CLASS) = 0,
_Ptr = str; HTML_ATTR(H3,ID),
} HTML_ATTR(H3,STYLE),
operator const char *() const };
enum
{ {
return _Ptr; HTML_ATTR(H4,CLASS) = 0,
} HTML_ATTR(H4,ID),
void clear() HTML_ATTR(H4,STYLE),
};
enum
{ {
if (_Ptr) HTML_ATTR(H5,CLASS) = 0,
HTML_ATTR(H5,ID),
HTML_ATTR(H5,STYLE),
};
enum
{ {
void *ptr = (void*)_Ptr; HTML_ATTR(H6,CLASS) = 0,
HT_FREE(ptr); HTML_ATTR(H6,ID),
} HTML_ATTR(H6,STYLE),
_Ptr = NULL;
}
private:
const char *_Ptr;
}; };
#undef HTML_ATTR
// *************************************************************************** // ***************************************************************************
// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false // Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false
@ -273,15 +278,10 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void _VerifyLibWWW(const char *function, bool ok, const char *file, int line); const std::string &setCurrentDomain(const std::string &uri);
#define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__) void receiveCookies (CURL *curl, const std::string &domain, bool trusted);
void sendCookies(CURL *curl, const std::string &domain, bool trusted);
// ***************************************************************************
// Standard request terminator
int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status) ;
// ***************************************************************************
} }
#endif #endif

File diff suppressed because it is too large Load Diff

@ -239,6 +239,7 @@ namespace NLGUI
bool isNil(int index = -1); bool isNil(int index = -1);
bool isBoolean(int index = -1); bool isBoolean(int index = -1);
bool isNumber(int index = -1); bool isNumber(int index = -1);
bool isInteger(int index = -1);
bool isString(int index = -1); bool isString(int index = -1);
bool isTable(int index = -1); bool isTable(int index = -1);
bool isFunction(int index = -1); bool isFunction(int index = -1);
@ -248,6 +249,7 @@ namespace NLGUI
// converting then getting a value from the stack // converting then getting a value from the stack
bool toBoolean(int index = -1); bool toBoolean(int index = -1);
lua_Number toNumber(int index = -1); lua_Number toNumber(int index = -1);
lua_Integer toInteger(int index = -1);
const char *toString(int index = -1); const char *toString(int index = -1);
void toString(int index, std::string &str); // convert to a std::string, with a NULL check. void toString(int index, std::string &str); // convert to a std::string, with a NULL check.
size_t strlen(int index = -1); size_t strlen(int index = -1);
@ -259,11 +261,21 @@ namespace NLGUI
* If conversion fails then an exception is thrown (with optional msg) * If conversion fails then an exception is thrown (with optional msg)
*/ */
bool getTableBooleanValue(const char *name, bool defaultValue= false); bool getTableBooleanValue(const char *name, bool defaultValue= false);
double getTableNumberValue(const char *name, double defaultValue= 0); double getTableNumberValue(const char *name, double defaultValue= 0.0);
sint64 getTableIntegerValue(const char *name, sint64 defaultValue= 0);
const char *getTableStringValue(const char *name, const char *defaultValue= NULL); const char *getTableStringValue(const char *name, const char *defaultValue= NULL);
// pushing value onto the stack // pushing value onto the stack
void push(bool value); void push(bool value);
void push(lua_Number value); void push(float value);
void push(double value);
void push(uint8 value);
void push(uint16 value);
void push(uint32 value);
void push(uint64 value);
void push(sint8 value);
void push(sint16 value);
void push(sint32 value);
void push(sint64 value);
void push(const char *str); void push(const char *str);
void push(const char *str, int length); void push(const char *str, int length);
void push(const std::string &str); void push(const std::string &str);

@ -172,6 +172,18 @@ inline bool CLuaState::isNumber(int index)
return lua_isnumber(_State, index) != 0; return lua_isnumber(_State, index) != 0;
} }
//================================================================================
inline bool CLuaState::isInteger(int index)
{
//H_AUTO(Lua_CLuaState_isInteger)
checkIndex(index);
#if LUA_VERSION_NUM >= 503
return lua_isinteger(_State, index) != 0;
#else
return lua_isnumber(_State, index) != 0;
#endif
}
//================================================================================ //================================================================================
inline bool CLuaState::isString(int index) inline bool CLuaState::isString(int index)
{ {
@ -236,6 +248,27 @@ inline lua_Number CLuaState::toNumber(int index)
return lua_tonumber(_State, index); return lua_tonumber(_State, index);
} }
//================================================================================
inline lua_Integer CLuaState::toInteger(int index)
{
//H_AUTO(Lua_CLuaState_toInteger)
checkIndex(index);
#if LUA_VERSION_NUM >= 503
sint isnum = 0;
// lua_tointeger fails with decimal numbers under Lua 5.3
lua_Integer res = lua_tointegerx(_State, index, &isnum);
if (!isnum)
{
lua_Number d = lua_tonumber(_State, index);
nlwarning("Lua: Unable to convert Lua number %lf to integer", d);
res = (lua_Integer)d;
}
return res;
#else
return lua_tointeger(_State, index);
#endif
}
//================================================================================ //================================================================================
inline const char *CLuaState::toString(int index) inline const char *CLuaState::toString(int index)
{ {
@ -302,11 +335,83 @@ inline void CLuaState::push(bool value)
} }
//================================================================================ //================================================================================
inline void CLuaState::push(lua_Number value) inline void CLuaState::push(float value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushnumber(_State, (lua_Number)value);
}
//================================================================================
inline void CLuaState::push(double value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushnumber(_State, (lua_Number)value);
}
//================================================================================
inline void CLuaState::push(uint8 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(uint16 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(uint32 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(uint64 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(sint8 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(sint16 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(sint32 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(sint64 value)
{ {
//H_AUTO(Lua_CLuaState_push) //H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) ); nlverify( lua_checkstack(_State, 1) );
lua_pushnumber(_State, value); lua_pushinteger(_State, (lua_Integer)value);
} }
//================================================================================ //================================================================================

@ -31,8 +31,8 @@ namespace NLGUI
class CLuaManager class CLuaManager
{ {
public: public:
~CLuaManager();
/// Get or create singleton
static CLuaManager& getInstance() static CLuaManager& getInstance()
{ {
if( instance == NULL ) if( instance == NULL )
@ -42,6 +42,9 @@ namespace NLGUI
return *instance; return *instance;
} }
/// Release singleton
static void releaseInstance();
/// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup. /// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup.
static void enableLuaDebugging(){ debugLua = true; } static void enableLuaDebugging(){ debugLua = true; }
@ -65,6 +68,7 @@ namespace NLGUI
private: private:
CLuaManager(); CLuaManager();
~CLuaManager();
static CLuaManager *instance; static CLuaManager *instance;
static bool debugLua; static bool debugLua;

@ -80,6 +80,7 @@ namespace NLGUI
const char *getTypename() const; const char *getTypename() const;
bool isNil() const; bool isNil() const;
bool isNumber() const; bool isNumber() const;
bool isInteger() const;
bool isBoolean() const; bool isBoolean() const;
bool isString() const; bool isString() const;
bool isFunction() const; bool isFunction() const;
@ -94,6 +95,7 @@ namespace NLGUI
NLMISC::CRGBA toRGBA() const; // default to black if not a crgba NLMISC::CRGBA toRGBA() const; // default to black if not a crgba
bool toBoolean() const; bool toBoolean() const;
lua_Number toNumber() const; lua_Number toNumber() const;
lua_Integer toInteger() const;
std::string toString() const; std::string toString() const;
lua_CFunction toCFunction() const; lua_CFunction toCFunction() const;
void *toUserData() const; void *toUserData() const;
@ -102,6 +104,8 @@ namespace NLGUI
operator bool() const; operator bool() const;
operator float() const; operator float() const;
operator double() const; operator double() const;
operator sint32() const;
operator sint64() const;
operator std::string() const; operator std::string() const;
/** create a sub table for this object, with a string as a key /** create a sub table for this object, with a string as a key
* This object must be a table or an exception if thrown * This object must be a table or an exception if thrown
@ -121,6 +125,9 @@ namespace NLGUI
void setValue(const char *key, bool value) throw(ELuaNotATable); void setValue(const char *key, bool value) throw(ELuaNotATable);
void setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable); void setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable);
void setValue(const char *key, double value) throw(ELuaNotATable); void setValue(const char *key, double value) throw(ELuaNotATable);
void setValue(const char *key, uint32 value) throw(ELuaNotATable);
void setValue(const char *key, sint32 value) throw(ELuaNotATable);
void setValue(const char *key, sint64 value) throw(ELuaNotATable);
void setValue(const std::string &key, const std::string &value) throw(ELuaNotATable) { setValue(key.c_str(), value); } void setValue(const std::string &key, const std::string &value) throw(ELuaNotATable) { setValue(key.c_str(), value); }
void setNil(const char *key) throw(ELuaNotATable); void setNil(const char *key) throw(ELuaNotATable);
void setNil(const std::string &key) throw(ELuaNotATable) { setNil(key.c_str()); } void setNil(const std::string &key) throw(ELuaNotATable) { setNil(key.c_str()); }

@ -0,0 +1,63 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_URL_PARSER_H
#define CL_URL_PARSER_H
#include <string>
namespace NLGUI
{
/**
* Simple URL parser
* \author Meelis Mägi
* \date 2015
*/
class CUrlParser
{
public:
CUrlParser(){}
// parse uri to components
CUrlParser(const std::string &url);
// parse uri to components
void parse(std::string uri);
// serialize URL back to string
std::string toString() const;
// inherit scheme, domain, path from given url
void inherit(const std::string &url);
// if current parts can compose absolute url or not
bool isAbsolute() const;
// resolve relative path like './a/../b' to absolute path '/a/b'
static void resolveRelativePath(std::string &path);
public:
std::string scheme;
std::string domain;
std::string path;
std::string query;
std::string hash;
};
}// namespace
#endif // CL_URL_PARSER_H

@ -81,6 +81,8 @@ namespace NLGUI
void setText (const ucstring &text); void setText (const ucstring &text);
void setFontSize (sint nFontSize); void setFontSize (sint nFontSize);
void setEmbolden (bool nEmbolden);
void setOblique (bool nOblique);
void setColor (const NLMISC::CRGBA &color); void setColor (const NLMISC::CRGBA &color);
void setShadow (bool bShadow); void setShadow (bool bShadow);
void setShadowOutline (bool bShadowOutline); void setShadowOutline (bool bShadowOutline);
@ -101,6 +103,8 @@ namespace NLGUI
ucstring getText() const { return _Text; } ucstring getText() const { return _Text; }
sint getFontSize() const; sint getFontSize() const;
bool getEmbolden() { return _Embolden; }
bool getOblique() { return _Oblique; }
NLMISC::CRGBA getColor() { return _Color; } NLMISC::CRGBA getColor() { return _Color; }
bool getShadow() { return _Shadow; } bool getShadow() { return _Shadow; }
bool getShadowOutline() { return _ShadowOutline; } bool getShadowOutline() { return _ShadowOutline; }
@ -125,6 +129,8 @@ namespace NLGUI
uint getLastLineW () const; uint getLastLineW () const;
void setUnderlined (bool underlined) { _Underlined = underlined; } void setUnderlined (bool underlined) { _Underlined = underlined; }
bool getUnderlined () const { return _Underlined; } bool getUnderlined () const { return _Underlined; }
void setStrikeThrough (bool linethrough) { _StrikeThrough = linethrough; }
bool getStrikeThrough () const { return _StrikeThrough; }
// true if the viewText is a single line clamped. // true if the viewText is a single line clamped.
bool isSingleLineTextClamped() const {return _SingleLineTextClamped;} bool isSingleLineTextClamped() const {return _SingleLineTextClamped;}
@ -220,6 +226,8 @@ namespace NLGUI
NL3D::UTextContext::CStringInfo _Info; NL3D::UTextContext::CStringInfo _Info;
/// the font size /// the font size
sint _FontSize; sint _FontSize;
bool _Embolden;
bool _Oblique;
// width of the font in pixel. Just a Hint for tabing format (computed with '_') // width of the font in pixel. Just a Hint for tabing format (computed with '_')
uint _FontWidth; uint _FontWidth;
// height of the font in pixel. // height of the font in pixel.
@ -374,6 +382,7 @@ namespace NLGUI
bool _TextSelection : 1; bool _TextSelection : 1;
bool _InvalidTextContext : 1; bool _InvalidTextContext : 1;
bool _Underlined : 1; bool _Underlined : 1;
bool _StrikeThrough : 1;
bool _ContinuousUpdate : 1; bool _ContinuousUpdate : 1;
bool _Setuped : 1; bool _Setuped : 1;

@ -335,7 +335,7 @@ namespace NLGUI
sint32 newW, sint32 newH) const; sint32 newW, sint32 newH) const;
// move windows according to new screen size // move windows according to new screen size
void moveAllWindowsToNewScreenSize(sint32 newScreenW, sint32 newScreenH, bool fixCurrentUI ); void moveAllWindowsToNewScreenSize(uint32 newScreenW, uint32 newScreenH, bool fixCurrentUI );
void updateAllLocalisedElements(); void updateAllLocalisedElements();
@ -481,7 +481,7 @@ namespace NLGUI
void setIngame( bool i ){ inGame = i; } void setIngame( bool i ){ inGame = i; }
bool isIngame() const{ return inGame; } bool isIngame() const{ return inGame; }
void setScreenWH( uint32 w, uint32 h ){ screenW = w; screenH = h; } void setScreenWH(uint32 w, uint32 h){ _ScreenW = w; _ScreenH = h; }
void registerNewScreenSizeHandler( INewScreenSizeHandler *handler ); void registerNewScreenSizeHandler( INewScreenSizeHandler *handler );
void removeNewScreenSizeHandler( INewScreenSizeHandler *handler ); void removeNewScreenSizeHandler( INewScreenSizeHandler *handler );
@ -569,7 +569,7 @@ namespace NLGUI
std::vector< CInterfaceGroup* > _GroupsUnderPointer; std::vector< CInterfaceGroup* > _GroupsUnderPointer;
// view that should be notified from clock msg // view that should be notified from clock msg
std::vector<CCtrlBase*> _ClockMsgTargets; std::list<CCtrlBase*> _ClockMsgTargets;
NLMISC::CRGBA _GlobalColor; NLMISC::CRGBA _GlobalColor;
NLMISC::CRGBA _GlobalColorForContent; NLMISC::CRGBA _GlobalColorForContent;
@ -612,8 +612,8 @@ namespace NLGUI
CEventDescriptorKey lastKeyEvent; CEventDescriptorKey lastKeyEvent;
uint32 screenH; uint32 _ScreenH;
uint32 screenW; uint32 _ScreenW;
std::vector< CInterfaceAnim* > activeAnims; std::vector< CInterfaceAnim* > activeAnims;

@ -20,8 +20,13 @@
#include "nel/misc/vector.h" #include "nel/misc/vector.h"
#include "nel/misc/rgba.h" #include "nel/misc/rgba.h"
// Include from libxml2 // Forward declarations for libxml2
#include <libxml/parser.h> typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
typedef struct _xmlDoc xmlDoc;
typedef xmlDoc *xmlDocPtr;
#include <vector> #include <vector>

@ -22,8 +22,9 @@
#include <map> #include <map>
#include <set> #include <set>
// Include from libxml2 // Forward declarations for libxml2
#include <libxml/parser.h> typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
namespace NLLIGO namespace NLLIGO
{ {

@ -21,8 +21,9 @@
#include "nel/misc/rgba.h" #include "nel/misc/rgba.h"
#include <vector> #include <vector>
// Include from libxml2 // Forward declarations for libxml2
#include <libxml/parser.h> typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
namespace NLLIGO namespace NLLIGO
{ {

@ -20,7 +20,7 @@
#include "types_nl.h" #include "types_nl.h"
#include "tds.h" #include "tds.h"
#include "singleton.h" #include "singleton.h"
#include "callback.h"
namespace NLMISC { namespace NLMISC {
@ -86,6 +86,66 @@ public:
// Used for CPath only for the moment ! // Used for CPath only for the moment !
char *getFileNamePtr(const std::string &sFileName, const std::string &sBigFileName); char *getFileNamePtr(const std::string &sFileName, const std::string &sBigFileName);
typedef CCallback<bool /* continue */, const std::string &/* filename */, uint32 /* currentSize */, uint32 /* totalSize */> TUnpackProgressCallback;
// Unpack all files in sBigFileName to sDestDir and send progress notifications to optional callback
static bool unpack(const std::string &sBigFileName, const std::string &sDestDir, TUnpackProgressCallback *callback = NULL);
// A BNPFile header (filename is a char* pointing on FileNames and is always lowercase)
struct BNPFile
{
BNPFile() : Name(NULL), Size(0), Pos(0) { }
char* Name;
uint32 Size;
uint32 Pos;
};
// A SBNPFile header (filename is a std::string and keeps the original case)
struct SBNPFile
{
SBNPFile() : Size(0), Pos(0) { }
std::string Name;
uint32 Size;
uint32 Pos;
};
// A BNP structure
struct BNP
{
BNP() : FileNames(NULL), ThreadFileId(0), CacheFileOnOpen(false), AlwaysOpened(false), InternalUse(false), OffsetFromBeginning(0) { }
// FileName of the BNP. important to open it in getFile() (for other threads or if not always opened).
std::string BigFileName;
// map of files in the BNP.
char *FileNames;
std::vector<BNPFile> Files;
std::vector<SBNPFile> SFiles;
// Since many seek may be done on a FILE*, each thread should have its own FILE opened.
uint32 ThreadFileId;
bool CacheFileOnOpen;
bool AlwaysOpened;
bool InternalUse;
// Offset written in BNP header
uint32 OffsetFromBeginning;
// Read BNP header from FILE* and init member variables
bool readHeader(FILE* file);
// Read BNP header from BigFileName and init member variables
bool readHeader();
// Append BNP header to the big file BigFileName (to use after appendFile calls)
bool appendHeader();
// Append a file to BigFileName
bool appendFile(const std::string &filename);
// Unpack BigFileName to sDestDir and send progress notifications to optional callback
bool unpack(const std::string &sDestDir, TUnpackProgressCallback *callback = NULL);
};
// *************** // ***************
private: private:
class CThreadFileArray; class CThreadFileArray;
@ -118,38 +178,6 @@ private:
uint32 _CurrentId; uint32 _CurrentId;
}; };
// A BNPFile header
struct BNPFile
{
BNPFile() : Name(NULL), Size(0), Pos(0) { }
char *Name;
uint32 Size;
uint32 Pos;
};
struct CBNPFileComp
{
bool operator()(const BNPFile &f, const BNPFile &s )
{
return strcmp( f.Name, s.Name ) < 0;
}
};
// A BNP structure
struct BNP
{
BNP() : FileNames(NULL) { }
// FileName of the BNP. important to open it in getFile() (for other threads or if not always opened).
std::string BigFileName;
// map of files in the BNP.
char *FileNames;
std::vector<BNPFile> Files;
// Since many seek may be done on a FILE*, each thread should have its own FILE opened.
uint32 ThreadFileId;
bool CacheFileOnOpen;
bool AlwaysOpened;
};
private: private:
// CBigFile(); // Singleton mode -> access it with the getInstance function // CBigFile(); // Singleton mode -> access it with the getInstance function

@ -44,6 +44,7 @@ const uint32 DDS_HEADER = NL_MAKEFOURCC('D', 'D', 'S', ' ');
const uint32 DXT_HEADER = NL_MAKEFOURCC('D', 'X', 'T', '\0'); const uint32 DXT_HEADER = NL_MAKEFOURCC('D', 'X', 'T', '\0');
const uint32 PNG_HEADER = NL_MAKEFOURCC(0x89, 'P', 'N', 'G'); const uint32 PNG_HEADER = NL_MAKEFOURCC(0x89, 'P', 'N', 'G');
const uint32 JPG_HEADER = NL_MAKEFOURCC(0xff, 0xd8, 0xff, 0xe0); const uint32 JPG_HEADER = NL_MAKEFOURCC(0xff, 0xd8, 0xff, 0xe0);
const uint32 GIF_HEADER = NL_MAKEFOURCC('G', 'I', 'F', '8');
// dwLinearSize is valid // dwLinearSize is valid
@ -132,6 +133,15 @@ private :
uint8 readJPG( NLMISC::IStream &f ); uint8 readJPG( NLMISC::IStream &f );
/**
* Read a GIF from an IStream.
* GIF pictures are all converted to 32bit
* \param f IStream (must be a reading stream)
* \return image depth if succeed, 0 else
*/
uint8 readGIF( NLMISC::IStream &f );
/** /**
* Change bitmap format * Change bitmap format
* *
@ -226,6 +236,34 @@ private :
sint32 nDestWidth, sint32 nDestHeight); sint32 nDestWidth, sint32 nDestHeight);
/**
* The grayscale resample function
* \param pSrc grayscale 8-bits array
* \param pDest grayscale 8-bits array for storing resampled texture
* \param nSrcWidth original width
* \param nSrcHeight original height
* \param nDestWidth width after resample
* \param nDestHeight height after resample
*/
void resamplePicture8 (const uint8 *pSrc, uint8 *pDest,
sint32 nSrcWidth, sint32 nSrcHeight,
sint32 nDestWidth, sint32 nDestHeight);
/**
* The FAST resample function : works only when reducing the size by two
* and when the image is square
* \param pSrc grayscale 8-bits array
* \param pDest grayscale 8-bits array for storing resampled texture
* \param nSrcWidth original width
* \param nSrcHeight original height
* \param nDestWidth width after resample
* \param nDestHeight height after resample
*/
void resamplePicture8Fast (const uint8 *pSrc, uint8 *pDest,
sint32 nSrcWidth, sint32 nSrcHeight,
sint32 nDestWidth, sint32 nDestHeight);
/** /**
* Quadratic interpolator * Quadratic interpolator
* \return the interpolation in (x,y) of the values (xy**) * \return the interpolation in (x,y) of the values (xy**)
@ -282,16 +320,8 @@ public:
// don't forget to update operator=() and swap() if adding a data member // don't forget to update operator=() and swap() if adding a data member
CBitmap() CBitmap();
{ virtual ~CBitmap();
_MipMapCount = 1;
_Width = 0;
_Height = 0;
PixelFormat = RGBA;
_LoadGrayscaleAsAlpha = true;
}
virtual ~CBitmap() { }
// swap 2 bitmaps contents // swap 2 bitmaps contents
void swap(CBitmap &other); void swap(CBitmap &other);
@ -338,6 +368,27 @@ public:
*/ */
void makeNonPowerOf2Dummy(); void makeNonPowerOf2Dummy();
/**
* Make a bitmap fully opaque (set alpha to 255).
*/
void makeOpaque();
/**
* Return if the bitmap has uniform alpha values for all pixels.
* \param alpha return the uniform value if return is true
* \return uniform or not
*/
bool isAlphaUniform(uint8 *alpha = NULL) const;
/**
* Return if the bitmap is a real grayscale.
* \return grayscale or not
*/
bool isGrayscale() const;
/** /**
* Return the pixels buffer of the image, or of one of its mipmap. * Return the pixels buffer of the image, or of one of its mipmap.
* Return a reference of an array in pixel format get with getPixelFormat(). * Return a reference of an array in pixel format get with getPixelFormat().

@ -25,7 +25,9 @@
#include "string_mapper.h" #include "string_mapper.h"
#include "sstring.h" #include "sstring.h"
#include <libxml/parser.h> // Forward declarations for libxml2
typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
namespace NLMISC namespace NLMISC
{ {

@ -61,7 +61,7 @@ public:
class CClassIdHashMapTraits class CClassIdHashMapTraits
{ {
public: public:
enum { bucket_size = 4, min_buckets = 8, }; enum { bucket_size = 4, min_buckets = 8 };
inline size_t operator() ( const CClassId& classId ) const inline size_t operator() ( const CClassId& classId ) const
{ {
return ((((uint64)classId >> 32)|0xFFFFFFFF) ^ (((uint64)classId|0xFFFFFFFF) & 0xFFFFFFFF)); return ((((uint64)classId >> 32)|0xFFFFFFFF) ^ (((uint64)classId|0xFFFFFFFF) & 0xFFFFFFFF));

@ -31,36 +31,111 @@ namespace NLMISC
class CCmdArgs class CCmdArgs
{ {
public: public:
/// Sets the command line and init _Args variable. You must call this before calling main() CCmdArgs();
void setArgs (int argc, const char **argv);
/// Sets the command line and init _Args variable. You must call this before calling main() struct TArg
void setArgs (const char *args); {
std::string shortName; // short argument. Eg: o for -o
std::string longName; // long argument. Eg: output for --output
std::string helpName; // name of argument in help. Eg: <output directory>
std::string helpDescription; // description of argument in help. Eg: Specifies the directory where to write generated files
bool onlyOnce; // only one argument of this type is used, if several are provided, only the last one is kept
bool required; // at least one argument of this type must be provided
bool found; // all values for this argument
std::vector<std::string> values; // all values for this argument
};
typedef std::vector<TArg> TArgs;
/// Add a TArg structure to arguments list.
void addArg(const TArg &arg);
/// Add an full argument to arguments list.
/// shortName is "p" of the argument is -p
/// longName is "print" of the argument is --print
/// helpName is the name that will be displayed in help if it's a required argument
/// helpDescription is the description of the argument that will be displayed in help
/// onlyOnce can be set to false, if we allows to use this argument more than once
void addArg(const std::string &shortName, const std::string &longName, const std::string &helpName, const std::string &helpDescription, bool onlyOnce = true);
/// Add a additional argument to arguments list.
/// helpName is the name that will be displayed in help if it's a required argument
/// helpDescription is the description of the argument that will be displayed in help
/// onlyOnce can be set to false, if we allows to use this argument more than once
/// required can be set to false, if this argument is required
void addAdditionalArg(const std::string &name, const std::string &helpDescription, bool onlyOnce = true, bool required = true);
/// Parse the command line from main() parameters argc and argv and process default arguments.
bool parse(int argc, char **argv);
/// Parse the command line from a std::string and process default arguments.
bool parse(const std::string &args);
/// Parse the command linefrom a std::vector<std::string> and process default arguments.
bool parse(const std::vector<std::string> &args);
/// Returns arguments of the program pass from the user to the program using parameters (ie: "myprog param1 param2") /// Returns arguments of the program pass from the user to the program using parameters (ie: "myprog param1 param2")
const NLMISC::CVectorSString &getArgs () const { return _Args; } const TArgs& getArgs() const { return _Args; }
/// Returns true if the argument if present in the command line (ie: haveArg('p') will return true if -p is in the command line) /// Returns true if the argument if present in the command line (ie: haveArg("p") will return true if -p is in the command line)
bool haveArg (char argName) const; bool haveArg(const std::string &argName) const;
/** Returns the parameter linked to an option /** Returns the parameters linked to an option
* getArg('p') will return toto if -ptoto is in the command line * getArg("p") will return toto if -ptoto is in the command line
* getArg('p') will return C:\Documents and Settings\toto.tmp if -p"C:\Documents and Settings\toto.tmp" is in the command line * getArg("p") will return C:\Documents and Settings\toto.tmp if -p"C:\Documents and Settings\toto.tmp" is in the command line
* It'll thrown an Exception if the argName is not found
*/ */
std::string getArg (char argName) const; std::vector<std::string> getArg(const std::string &argName) const;
/// return true if named long arg is present on the commandline /// return true if named long arg is present on the commandline
/// eg haveLongArg("toto") returns true if "--toto" or "--toto=xxx" can be found on commandline /// eg haveLongArg("toto") returns true if "--toto" or "--toto=xxx" can be found on commandline
bool haveLongArg (const char* argName) const; bool haveLongArg(const std::string &argName) const;
/// returns the value associated with the given named argument /// returns values associated with the given named argument
/// both "--toto=xxx" and "--toto xxx" are acceptable /// both "--toto=xxx" and "--toto xxx" are acceptable
/// quotes round arguments are stripped /// quotes round arguments are stripped
std::string getLongArg (const char* argName) const; std::vector<std::string> getLongArg(const std::string &argName) const;
/// return true if there are arguments that are required
bool needAdditionalArg() const;
/// return true if any additional args are present on the commandline
bool haveAdditionalArg() const;
/// return true if a specific additional arg is present on the commandline
bool haveAdditionalArg(const std::string &name) const;
/// Returns values of a specific additional arg
std::vector<std::string> getAdditionalArg(const std::string &name) const;
/// Display help of the program.
void displayHelp();
/// Display version of the program.
void displayVersion();
/// Returns program name or path passed as first parameter to parse() method
std::string getProgramName() const { return _ProgramName; }
std::string getProgramPath() const { return _ProgramPath; }
std::string getStartupPath() const { return _StartupPath; }
/// Set or get description to display in help
void setDescription(const std::string &description) { _Description = description; }
std::string getDescription() const { return _Description; }
/// Set or get version to display in -v
void setVersion(const std::string &version) { _Version = version; }
std::string getVersion() const { return _Version; }
protected: protected:
std::string _ProgramName; // filename of the program
std::string _ProgramPath; // full path of the program
std::string _StartupPath; // initial startup path
std::string _Description; // description of the program
std::string _Version; // version of the program
/// Array of arguments pass from the command line /// Array of arguments pass from the command line
NLMISC::CVectorSString _Args; TArgs _Args;
}; // class CCmdArgs }; // class CCmdArgs
}; // NAMESPACE NLMISC }; // NAMESPACE NLMISC

@ -28,8 +28,8 @@ namespace NLMISC
# define NL_WIN_CALLBACK # define NL_WIN_CALLBACK
#endif #endif
// Default to 8KB stack for tasks // Default to 1MiB stack for tasks
const unsigned int NL_TASK_STACK_SIZE = 8*1024; const uint NL_TASK_STACK_SIZE = 1024*1024;
// forward def for platform specific data // forward def for platform specific data
struct TCoTaskData; struct TCoTaskData;

@ -38,6 +38,10 @@
# include <sys/types.h> # include <sys/types.h>
#endif #endif
#if defined(NL_CPU_INTEL) && defined(NL_COMP_GCC)
#include <x86intrin.h>
#endif
#include "string_common.h" #include "string_common.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
@ -65,20 +69,20 @@ namespace NLMISC
inline uint64 rdtsc() inline uint64 rdtsc()
{ {
uint64 ticks; #if defined(NL_COMP_GCC) && !defined(CLANG_VERSION) && (GCC_VERSION <= 40405)
# ifdef NL_OS_WINDOWS // for GCC versions that don't implement __rdtsc()
# ifdef NL_NO_ASM #ifdef NL_CPU_X86_64
ticks = uint64(__rdtsc()); uint64 low, high;
# else __asm__ volatile("rdtsc" : "=a" (low), "=d" (high));
// We should use the intrinsic code now. ticks = uint64(__rdtsc()); return low | (high << 32);
__asm rdtsc
__asm mov DWORD PTR [ticks], eax
__asm mov DWORD PTR [ticks + 4], edx
# endif // NL_NO_ASM
#else #else
__asm__ volatile(".byte 0x0f, 0x31" : "=a" (ticks.low), "=d" (ticks.high)); uint64 ticks;
# endif // NL_OS_WINDOWS __asm__ volatile("rdtsc" : "=A" (ticks));
return ticks; return ticks;
#endif
#else
return uint64(__rdtsc());
#endif
} }
#endif // NL_CPU_INTEL #endif // NL_CPU_INTEL
@ -278,6 +282,13 @@ inline sint nlstricmp(const std::string &lhs, const std::string &rhs) { return s
inline sint nlstricmp(const std::string &lhs, const char *rhs) { return stricmp(lhs.c_str(),rhs); } inline sint nlstricmp(const std::string &lhs, const char *rhs) { return stricmp(lhs.c_str(),rhs); }
inline sint nlstricmp(const char *lhs, const std::string &rhs) { return stricmp(lhs,rhs.c_str()); } inline sint nlstricmp(const char *lhs, const std::string &rhs) { return stricmp(lhs,rhs.c_str()); }
// macros helper to convert UTF-8 std::string and wchar_t*
#define wideToUtf8(str) (ucstring((ucchar*)str).toUtf8())
#define utf8ToWide(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str())
// wrapper for fopen to be able to open files with an UTF-8 filename
FILE* nlfopen(const std::string &filename, const std::string &mode);
/** Signed 64 bit fseek. Same interface as fseek /** Signed 64 bit fseek. Same interface as fseek
*/ */
int nlfseek64( FILE *stream, sint64 offset, int origin ); int nlfseek64( FILE *stream, sint64 offset, int origin );
@ -332,12 +343,18 @@ void itoaInt64 (sint64 number, char *str, sint64 base = 10);
std::string bytesToHumanReadable (const std::string &bytes); std::string bytesToHumanReadable (const std::string &bytes);
std::string bytesToHumanReadable (uint64 bytes); std::string bytesToHumanReadable (uint64 bytes);
/// Convert a number in bytes into a string that is easily readable by an human, for example 105123 -> "102kb"
/// Using units array as string: 0 => B, 1 => KiB, 2 => MiB, 3 => GiB, etc...
std::string bytesToHumanReadableUnits (uint64 bytes, const std::vector<std::string> &units);
/// Convert a human readable into a bytes, for example "102kb" -> 105123 /// Convert a human readable into a bytes, for example "102kb" -> 105123
uint32 humanReadableToBytes (const std::string &str); uint32 humanReadableToBytes (const std::string &str);
/// Convert a time into a string that is easily readable by an human, for example 3600 -> "1h" /// Convert a time into a string that is easily readable by an human, for example 3600 -> "1h"
std::string secondsToHumanReadable (uint32 time); std::string secondsToHumanReadable (uint32 time);
/// Convert a UNIX timestamp to a formatted date in ISO format
std::string timestampToHumanReadable(uint32 timestamp);
/// Get a bytes or time in string format and convert it in seconds or bytes /// Get a bytes or time in string format and convert it in seconds or bytes
uint32 fromHumanReadable (const std::string &str); uint32 fromHumanReadable (const std::string &str);
@ -349,6 +366,25 @@ std::string formatThousands(const std::string& s);
/// The program will be launched in the current directory /// The program will be launched in the current directory
bool launchProgram (const std::string &programName, const std::string &arguments, bool log = true); bool launchProgram (const std::string &programName, const std::string &arguments, bool log = true);
/// Same but with an array of strings for arguments
bool launchProgramArray (const std::string &programName, const std::vector<std::string> &arguments, bool log = true);
/// This function executes a program and wait for result (used for example for crash report).
/// The program will be launched in the current directory
sint launchProgramAndWaitForResult (const std::string &programName, const std::string &arguments, bool log = true);
/// This function executes a program and returns output as a string
std::string getCommandOutput(const std::string &command);
/// This function replace all environment variables in a string by their content.
/// Environment variables names can use both Windows (%NAME%) and UNIX syntax ($NAME)
/// Authorized characters in names are A-Z, a-z, 0-9 and _
std::string expandEnvironmentVariables(const std::string &s);
/// Functions to convert a string with arguments to array or array to string (will espace strings with spaces)
bool explodeArguments(const std::string &str, std::vector<std::string> &args);
std::string joinArguments(const std::vector<std::string> &args);
/// This function kills a program using his pid (on unix, it uses the kill() POSIX function) /// This function kills a program using his pid (on unix, it uses the kill() POSIX function)
bool killProgram(uint32 pid); bool killProgram(uint32 pid);

@ -229,7 +229,7 @@ void setCrashAlreadyReported(bool state);
*\code *\code
void function(char *filename) void function(char *filename)
{ {
FILE *fp = fopen (filename, "r"); FILE *fp = nlfopen (filename, "r");
if (fp==NULL) if (fp==NULL)
{ {
nlerror("file not found"); nlerror("file not found");

@ -26,13 +26,13 @@
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
#endif #endif
#ifndef _WIN32_WINDOWS #ifndef _WIN32_WINDOWS
# define _WIN32_WINDOWS 0x0410 # define _WIN32_WINDOWS 0x0500
#endif #endif
#ifndef _WIN32_WINNT #ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400 # define _WIN32_WINNT 0x0500
#endif #endif
#ifndef WINVER #ifndef WINVER
# define WINVER 0x0400 # define WINVER 0x0500
#endif #endif
#ifndef NOMINMAX #ifndef NOMINMAX
# define NOMINMAX # define NOMINMAX

@ -174,7 +174,8 @@ public:
/** Build a NeL standard library name according to platform and compilation mode setting. /** Build a NeL standard library name according to platform and compilation mode setting.
* aka : adding decoration one base lib name. * aka : adding decoration one base lib name.
* e.g : 'mylib' become 'mylib_rd.dll' on Windows ReleaseDebug mode or * e.g : 'mylib' become 'mylib_rd.dll' on Windows ReleaseDebug mode,
* 'libmylib.dylib' under OS X or
* 'libmylib.so' on unix system. * 'libmylib.so' on unix system.
*/ */
static std::string makeLibName(const std::string &baseName); static std::string makeLibName(const std::string &baseName);

@ -575,12 +575,12 @@ public:
// Traits for hash_map using CEntityId // Traits for hash_map using CEntityId
struct CEntityIdHashMapTraits struct CEntityIdHashMapTraits
{ {
enum { bucket_size = 4, min_buckets = 8, }; enum { bucket_size = 4, min_buckets = 8 };
CEntityIdHashMapTraits() { } CEntityIdHashMapTraits() { }
size_t operator() (const NLMISC::CEntityId &id ) const size_t operator() (const NLMISC::CEntityId &id ) const
{ {
uint64 hash64 = id.getUniqueId(); uint64 hash64 = id.getUniqueId();
#if (HAVE_X86_64) #ifdef HAVE_X86_64
return (size_t)hash64; return (size_t)hash64;
#else #else
return (size_t)hash64 ^ (size_t)(hash64 >> 32); return (size_t)hash64 ^ (size_t)(hash64 >> 32);

@ -212,6 +212,11 @@ enum TKey
KeyRCONTROL =0xA3, KeyRCONTROL =0xA3,
KeyLMENU =0xA4, KeyLMENU =0xA4,
KeyRMENU =0xA5, KeyRMENU =0xA5,
KeyMUTE =0xAD,
KeyPLAYPAUSE =0xB3,
KeyVOLUMEDOWN =0xB4,
KeyVOLUMEUP =0xB5,
KeyCALC =0xB7,
KeySEMICOLON =0xBA, KeySEMICOLON =0xBA,
KeyEQUALS =0xBB, KeyEQUALS =0xBB,
KeyCOMMA =0xBC, KeyCOMMA =0xBC,

@ -104,6 +104,11 @@ public:
*/ */
static const std::vector<std::string> &getLanguageCodes(); static const std::vector<std::string> &getLanguageCodes();
/** Check if a language code is supported.
* Code are ISO 639-2 compliant.
*/
static bool isLanguageCodeSupported(const std::string &lang);
/// Load a language file depending of the language code("en", "fr", ...). Code are ISO 639-2 compliant. /// Load a language file depending of the language code("en", "fr", ...). Code are ISO 639-2 compliant.
static void load (const std::string &languageCode, const std::string &fallbackLanguageCode=""); static void load (const std::string &languageCode, const std::string &fallbackLanguageCode="");
@ -119,6 +124,9 @@ public:
/// Returns the code of the language ("fr", "en", ...) /// Returns the code of the language ("fr", "en", ...)
static std::string getCurrentLanguageCode (); static std::string getCurrentLanguageCode ();
/// Returns the code of the language ("fr", "en", ...) defined on system
static std::string getSystemLanguageCode ();
/// Find a string in the selected language and return his association. /// Find a string in the selected language and return his association.
static const ucstring &get (const std::string &label); static const ucstring &get (const std::string &label);

@ -25,8 +25,12 @@
#include "types_nl.h" #include "types_nl.h"
#include "stream.h" #include "stream.h"
// Include from libxml2 // Forward declarations for libxml2
#include <libxml/parser.h> typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
typedef struct _xmlParserCtxt xmlParserCtxt;
typedef xmlParserCtxt *xmlParserCtxtPtr;
namespace NLMISC { namespace NLMISC {
@ -124,11 +128,11 @@ public:
/** Get the first child node pointer of type. NULL if no node of type. /** Get the first child node pointer of type. NULL if no node of type.
*/ */
static xmlNodePtr getFirstChildNode (xmlNodePtr parent, xmlElementType type); static xmlNodePtr getFirstChildNode (xmlNodePtr parent, sint /* xmlElementType */ type);
/** Get the next child node pointer of type. NULL if no node of type. /** Get the next child node pointer of type. NULL if no node of type.
*/ */
static xmlNodePtr getNextChildNode (xmlNodePtr last, xmlElementType type); static xmlNodePtr getNextChildNode (xmlNodePtr last, sint /* xmlElementType */ type);
/** Count number of sub node named with a given name for a given node. /** Count number of sub node named with a given name for a given node.
*/ */
@ -136,7 +140,7 @@ public:
/** Count number of sub node of type for a given node. /** Count number of sub node of type for a given node.
*/ */
static uint countChildren (xmlNodePtr node, xmlElementType type); static uint countChildren (xmlNodePtr node, sint /* xmlElementType */ type);
/** /**
* Read a property string * Read a property string

@ -31,13 +31,13 @@
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
#endif #endif
#ifndef _WIN32_WINDOWS #ifndef _WIN32_WINDOWS
# define _WIN32_WINDOWS 0x0410 # define _WIN32_WINDOWS 0x0500
#endif #endif
#ifndef _WIN32_WINNT #ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400 # define _WIN32_WINNT 0x0500
#endif #endif
#ifndef WINVER #ifndef WINVER
# define WINVER 0x0400 # define WINVER 0x0500
#endif #endif
#ifndef NOMINMAX #ifndef NOMINMAX
# define NOMINMAX # define NOMINMAX

@ -293,12 +293,7 @@ public:
if (!atomic_swap (&_Lock)) if (!atomic_swap (&_Lock))
break; break;
#ifdef NL_OS_WINDOWS
nlSleep (wait_time); nlSleep (wait_time);
#else
//std::cout << "Sleeping i=" << i << std::endl;
usleep( wait_time*1000 );
#endif
} }
} }
} }
@ -401,12 +396,7 @@ public:
if (!CFastMutex::atomic_swap (&_Lock)) if (!CFastMutex::atomic_swap (&_Lock))
break; break;
#ifdef NL_OS_WINDOWS
nlSleep (wait_time); nlSleep (wait_time);
#else
//std::cout << "Sleeping i=" << i << std::endl;
usleep( wait_time*1000 );
#endif
} }
} }
} }

@ -25,9 +25,12 @@
#include "types_nl.h" #include "types_nl.h"
#include "stream.h" #include "stream.h"
// Include from libxml2 // Forward declarations for libxml2
#include <libxml/parser.h> typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
typedef struct _xmlDoc xmlDoc;
typedef xmlDoc *xmlDocPtr;
namespace NLMISC { namespace NLMISC {

@ -230,7 +230,7 @@ public:
/** Get application directory. /** Get application directory.
* \return directory where applications should write files. * \return directory where applications should write files.
*/ */
std::string getApplicationDirectory(const std::string &appName = ""); std::string getApplicationDirectory(const std::string &appName = "", bool local = false);
/** Get a temporary directory. /** Get a temporary directory.
* \return temporary directory where applications should write files. * \return temporary directory where applications should write files.
@ -510,9 +510,16 @@ public:
/** Make path absolute /** Make path absolute
* \param relativePath - The relative path * \param relativePath - The relative path
* \param directory - the directory to which the path is relative to * \param directory - the directory to which the path is relative to
* \param simplify - if we should simplify or not the path (convert . and .. in path)
* returns the absolute path, or empty if something went wrong. * returns the absolute path, or empty if something went wrong.
*/ */
static std::string makePathAbsolute (const std::string &relativePath, const std::string &directory ); static std::string makePathAbsolute (const std::string &relativePath, const std::string &directory, bool simplify = false );
/** Return if a path is absolute or not.
* \param path - The path
* returns true if path is absolute or false if relative.
*/
static bool isAbsolutePath (const std::string &path);
/** If File in this list is added more than one in an addSearchPath, it doesn't launch a warning. /** If File in this list is added more than one in an addSearchPath, it doesn't launch a warning.
*/ */
@ -533,7 +540,7 @@ public:
/** Get application directory. /** Get application directory.
* \return directory where applications should write files. * \return directory where applications should write files.
*/ */
static std::string getApplicationDirectory(const std::string &appName = ""); static std::string getApplicationDirectory(const std::string &appName = "", bool local = false);
/** Get a temporary directory. /** Get a temporary directory.
* \return temporary directory where applications should write files. * \return temporary directory where applications should write files.
@ -612,7 +619,7 @@ struct CFile
* Return the position between [begin,end[ of the last separator between path and filename ('/' or '\'). * Return the position between [begin,end[ of the last separator between path and filename ('/' or '\').
* If there's no separator, it returns string::npos. * If there's no separator, it returns string::npos.
*/ */
static int getLastSeparator (const std::string &filename); static std::string::size_type getLastSeparator (const std::string &filename);
static std::string getFilenameWithoutExtension (const std::string &filename); static std::string getFilenameWithoutExtension (const std::string &filename);
static std::string getExtension (const std::string &filename); static std::string getExtension (const std::string &filename);
@ -701,7 +708,7 @@ struct CFile
/** Move a file /** Move a file
* NB this keeps file attributes * NB this keeps file attributes
*/ */
static bool moveFile(const char *dest, const char *src); static bool moveFile(const std::string &dest, const std::string &src);
/** Create a directory /** Create a directory
* \return true if success * \return true if success
@ -715,7 +722,6 @@ struct CFile
/** Try to set the file access to read/write if not already set. /** Try to set the file access to read/write if not already set.
* return true if the file doesn't exist or if the file already have RW access. * return true if the file doesn't exist or if the file already have RW access.
* Work actually only on Windows and returns always true on other platforms.
* \return true if RW access is granted * \return true if RW access is granted
*/ */
static bool setRWAccess(const std::string &filename); static bool setRWAccess(const std::string &filename);

@ -146,6 +146,14 @@ public:
*/ */
uint8 toGray() const; uint8 toGray() const;
/**
* Color is gray
*/
bool isGray() const
{
return R == G && G == B;
}
/** /**
* Get a 16 bits 565 pixel. * Get a 16 bits 565 pixel.
*/ */
@ -169,6 +177,17 @@ public:
B= (B<<3) + (B>>2); B= (B<<3) + (B>>2);
} }
/**
* Set the RGBA fields with a 32 bits 8888 pixel.
*/
void set8888(uint32 col)
{
R = col & 255;
G = (col >> 8) & 255;
B = (col >> 16) & 255;
A = (col >> 24) & 255;
}
/** /**
* Compute in this the average of 2 RGBA. * Compute in this the average of 2 RGBA.

@ -248,7 +248,7 @@ private :
class CSheetIdHashMapTraits class CSheetIdHashMapTraits
{ {
public: public:
enum { bucket_size = 4, min_buckets = 8, }; enum { bucket_size = 4, min_buckets = 8 };
inline size_t operator() ( const CSheetId& sheetId ) const inline size_t operator() ( const CSheetId& sheetId ) const
{ {
return sheetId.asInt() >> 5; return sheetId.asInt() >> 5;

@ -352,7 +352,7 @@ public:
} }
}; };
#if defined(NL_COMP_VC) && NL_COMP_VC_VERSION >= 80 #if defined(NL_COMP_VC) && NL_COMP_VC_VERSION >= 80 && NL_COMP_VC_VERSION < 140
// This operator only purpose is to compare with NULL value // This operator only purpose is to compare with NULL value
template <class T> template <class T>

@ -945,14 +945,6 @@ inline CSString operator+(const char* s0,const CSString& s1)
return CSString(s0) + s1.c_str(); return CSString(s0) + s1.c_str();
} }
#if !defined(NL_COMP_VC) || (NL_COMP_VC_VERSION <= 100)
// TODO: check if it can be disabled for other compilers too
inline CSString operator+(const std::string& s0,const CSString& s1)
{
return s0+static_cast<const std::string&>(s1);
}
#endif
} // NLMISC } // NLMISC
// *** The following was commented out by Sadge because there were strange compilation/ link issues *** // *** The following was commented out by Sadge because there were strange compilation/ link issues ***

@ -195,9 +195,11 @@ inline std::string toString(const sint64 &val) { return toString("%"NL_I64"d", v
// error fix for size_t? gcc 4.1.2 requested this type instead of size_t ... // error fix for size_t? gcc 4.1.2 requested this type instead of size_t ...
inline std::string toString(const long unsigned int &val) inline std::string toString(const long unsigned int &val)
{ {
if (sizeof(long unsigned int) == 8) #ifdef _LP64
return toString((uint64)val); return toString((uint64)val);
#else
return toString((uint32)val); return toString((uint32)val);
#endif
} }
# endif # endif
@ -210,9 +212,10 @@ inline std::string toString(const size_t &val) { return toString("%"NL_I64"u", v
inline std::string toString(const size_t &val) { return toString("%u", val); } inline std::string toString(const size_t &val) { return toString("%u", val); }
#endif #endif
#endif #endif
inline std::string toString(const float &val) { return toString("%f", val); } inline std::string toString(const float &val) { return toString("%f", val); }
inline std::string toString(const double &val) { return toString("%lf", val); } inline std::string toString(const double &val) { return toString("%lf", val); }
inline std::string toString(const bool &val) { return toString("%u", val?1:0); } inline std::string toString(const bool &val) { return val ? "1":"0"; }
inline std::string toString(const std::string &val) { return val; } inline std::string toString(const std::string &val) { return val; }
// stl vectors of bool use bit reference and not real bools, so define the operator for bit reference // stl vectors of bool use bit reference and not real bools, so define the operator for bit reference
@ -243,61 +246,50 @@ inline bool fromString(const std::string &str, bool &val)
{ {
if (str.length() == 1) if (str.length() == 1)
{ {
if( str[ 0 ] == '1' ) const char c = str[0];
val = true;
else
if( str[ 0 ] == '0' )
val = false;
else
return false;
}
else
{
if( str == "true" )
val = true;
else
if( str == "false" )
val = false;
else
return false;
}
return true;
}
inline bool fromString(const char *str, uint32 &val) { if (strstr(str, "-") != NULL) { val = 0; return false; } char *end; unsigned long v; errno = 0; v = strtoul(str, &end, 10); if (errno || v > UINT_MAX || end == str) { val = 0; return false; } else { val = (uint32)v; return true; } } switch(c)
inline bool fromString(const char *str, sint32 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > INT_MAX || v < INT_MIN || end == str) { val = 0; return false; } else { val = (sint32)v; return true; } }
inline bool fromString(const char *str, uint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > UCHAR_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint8)v; return true; } }
inline bool fromString(const char *str, sint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SCHAR_MAX || v < SCHAR_MIN || end == str) { val = 0; return false; } else { val = (sint8)v; return true; } }
inline bool fromString(const char *str, uint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > USHRT_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint16)v; return true; } }
inline bool fromString(const char *str, sint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SHRT_MAX || v < SHRT_MIN || end == str) { val = 0; return false; } else { val = (sint16)v; return true; } }
inline bool fromString(const char *str, uint64 &val) { bool ret = sscanf(str, "%"NL_I64"u", &val) == 1; if (!ret) val = 0; return ret; }
inline bool fromString(const char *str, sint64 &val) { bool ret = sscanf(str, "%"NL_I64"d", &val) == 1; if (!ret) val = 0; return ret; }
inline bool fromString(const char *str, float &val) { bool ret = sscanf(str, "%f", &val) == 1; if (!ret) val = 0.0f; return ret; }
inline bool fromString(const char *str, double &val) { bool ret = sscanf(str, "%lf", &val) == 1; if (!ret) val = 0.0; return ret; }
inline bool fromString(const char *str, bool &val)
{
switch (str[0])
{ {
case '1': case '1':
case 't': case 't':
case 'y':
case 'T': case 'T':
case 'y':
case 'Y': case 'Y':
val = true; val = true;
return true; break;
case '0': case '0':
case 'f': case 'f':
case 'n':
case 'F': case 'F':
case 'n':
case 'N': case 'N':
val = false; val = false;
return true; break;
}
default:
val = false;
return false;
}
}
else
{
if (str == "true" || str == "yes")
{
val = true;
}
else if (str == "false" || str == "no")
{
val = false;
}
else
{
val = false;
return false; return false;
} }
}
return true;
}
inline bool fromString(const std::string &str, std::string &val) { val = str; return true; } inline bool fromString(const std::string &str, std::string &val) { val = str; return true; }

@ -39,7 +39,7 @@ typedef const std::string *TStringId;
// Traits for hash_map using CStringId // Traits for hash_map using CStringId
struct CStringIdHashMapTraits struct CStringIdHashMapTraits
{ {
enum { bucket_size = 4, min_buckets = 8, }; enum { bucket_size = 4, min_buckets = 8 };
CStringIdHashMapTraits() { } CStringIdHashMapTraits() { }
size_t operator() (const NLMISC::TStringId &stringId) const size_t operator() (const NLMISC::TStringId &stringId) const
{ {

@ -72,9 +72,9 @@ public:
*/ */
static bool isNT(); static bool isNT();
/** Returns the space left on the hard drive that contains the filename /** Returns the space left on the hard drive that contains the filename in bytes
*/ */
static std::string availableHDSpace (const std::string &filename); static uint64 availableHDSpace (const std::string &filename);
/** Returns all the physical memory available on the computer (in bytes) /** Returns all the physical memory available on the computer (in bytes)
*/ */

@ -81,6 +81,7 @@ public:
/// Detect whether the current process is a windowed application. Return true if definitely yes, false if unknown /// Detect whether the current process is a windowed application. Return true if definitely yes, false if unknown
static bool detectWindowedApplication(); static bool detectWindowedApplication();
static sint getTotalVideoMemory();
}; };
} // NLMISC } // NLMISC

@ -43,17 +43,34 @@
// This way we know about _HAS_TR1 and _STLPORT_VERSION // This way we know about _HAS_TR1 and _STLPORT_VERSION
#include <string> #include <string>
#if defined(HAVE_X86_64)
# define NL_CPU_INTEL
# define NL_CPU_X86_64
// x86_64 CPU always have SSE2 instructions
# ifndef NL_HAS_SSE2
# define NL_HAS_SSE2
# endif
#elif defined(HAVE_X86)
# define NL_CPU_INTEL
# define NL_CPU_X86
#endif
// Operating systems definition // Operating systems definition
#ifdef _WIN32 #ifdef _WIN32
# define NL_OS_WINDOWS # define NL_OS_WINDOWS
# define NL_LITTLE_ENDIAN # define NL_LITTLE_ENDIAN
# ifndef NL_CPU_INTEL
# define NL_CPU_INTEL # define NL_CPU_INTEL
# endif
# ifndef _WIN32_WINNT # ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0500 // Minimal OS = Windows 2000 (NeL is not supported on Windows 95/98) # define _WIN32_WINNT 0x0500 // Minimal OS = Windows 2000 (NeL is not supported on Windows 95/98)
# endif # endif
# ifdef _MSC_VER # ifdef _MSC_VER
# define NL_COMP_VC # define NL_COMP_VC
# if _MSC_VER >= 1800 # if _MSC_VER >= 1900
# define NL_COMP_VC14
# define NL_COMP_VC_VERSION 140
# elif _MSC_VER >= 1800
# define NL_COMP_VC12 # define NL_COMP_VC12
# define NL_COMP_VC_VERSION 120 # define NL_COMP_VC_VERSION 120
# elif _MSC_VER >= 1700 # elif _MSC_VER >= 1700
@ -177,6 +194,10 @@
# define NL_ISO_STDTR1_HEADER(header) <header> # define NL_ISO_STDTR1_HEADER(header) <header>
# define NL_ISO_STDTR1_NAMESPACE std # define NL_ISO_STDTR1_NAMESPACE std
# endif # endif
# endif
// clang define GCC version for compatibility
# ifdef __clang__
# define CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
# endif # endif
#endif #endif
@ -368,8 +389,9 @@ typedef unsigned int uint; // at least 32bits (depend of processor)
inline void *aligned_malloc(size_t size, size_t alignment) { return _aligned_malloc(size, alignment); } inline void *aligned_malloc(size_t size, size_t alignment) { return _aligned_malloc(size, alignment); }
inline void aligned_free(void *ptr) { _aligned_free(ptr); } inline void aligned_free(void *ptr) { _aligned_free(ptr); }
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)
#include <stdlib.h>
// under Mac OS X, malloc is already aligned for SSE and Altivec (16 bytes alignment) // under Mac OS X, malloc is already aligned for SSE and Altivec (16 bytes alignment)
inline void *aligned_malloc(size_t size, size_t alignment) { return malloc(size); } inline void *aligned_malloc(size_t size, size_t /* alignment */) { return malloc(size); }
inline void aligned_free(void *ptr) { free(ptr); } inline void aligned_free(void *ptr) { free(ptr); }
#else #else
#include <malloc.h> #include <malloc.h>
@ -383,10 +405,13 @@ inline void aligned_free(void *ptr) { free(ptr); }
#define NL_DEFAULT_MEMORY_ALIGNMENT 16 #define NL_DEFAULT_MEMORY_ALIGNMENT 16
#define NL_ALIGN_SSE2 NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT) #define NL_ALIGN_SSE2 NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT)
#ifndef NL_CPU_X86_64
// on x86_64, new and delete are already aligned on 16 bytes
extern void *operator new(size_t size) throw(std::bad_alloc); extern void *operator new(size_t size) throw(std::bad_alloc);
extern void *operator new[](size_t size) throw(std::bad_alloc); extern void *operator new[](size_t size) throw(std::bad_alloc);
extern void operator delete(void *p) throw(); extern void operator delete(void *p) throw();
extern void operator delete[](void *p) throw(); extern void operator delete[](void *p) throw();
#endif
#else /* NL_HAS_SSE2 */ #else /* NL_HAS_SSE2 */
@ -463,7 +488,7 @@ typedef uint16 ucchar;
// To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234) // To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234)
#ifdef NL_COMP_VC #ifdef NL_COMP_VC
# if (NL_COMP_VC_VERSION >= 120) # if (NL_COMP_VC_VERSION >= 100)
# define INT64_CONSTANT(c) (c##LL) # define INT64_CONSTANT(c) (c##LL)
# define SINT64_CONSTANT(c) (c##LL) # define SINT64_CONSTANT(c) (c##LL)
# define UINT64_CONSTANT(c) (c##ULL) # define UINT64_CONSTANT(c) (c##ULL)

@ -355,7 +355,7 @@ namespace NLMISC
// Traits for hash_map using CEntityId // Traits for hash_map using CEntityId
struct CUCStringHashMapTraits struct CUCStringHashMapTraits
{ {
enum { bucket_size = 4, min_buckets = 8, }; enum { bucket_size = 4, min_buckets = 8 };
CUCStringHashMapTraits() { } CUCStringHashMapTraits() { }
size_t operator() (const ucstring &id ) const size_t operator() (const ucstring &id ) const
{ {

@ -242,8 +242,6 @@ public:
{ {
T v; T v;
bool ret = NLMISC::fromString(val, v); bool ret = NLMISC::fromString(val, v);
// std::stringstream ss (val);
// ss >> v;
set (v); set (v);
return ret; return ret;
} }
@ -251,9 +249,6 @@ public:
virtual std::string toString (bool /* human */) const virtual std::string toString (bool /* human */) const
{ {
return NLMISC::toString(_Value); return NLMISC::toString(_Value);
// std::stringstream ss;
// ss << _Value;
// return ss.str();
} }
CVariable<T> &operator= (const T &val) CVariable<T> &operator= (const T &val)

@ -45,7 +45,7 @@ inline uint64 wangHash64Inv(uint64 key)
key = key^tmp >> 28; key = key^tmp >> 28;
// Invert key *= 21 // Invert key *= 21
key *= 14933078535860113213u; key *= UINT64_CONSTANT(14933078535860113213);
// Invert key = key ^ (key >> 14) // Invert key = key ^ (key >> 14)
tmp = key^key >> 14; tmp = key^key >> 14;
@ -54,7 +54,7 @@ inline uint64 wangHash64Inv(uint64 key)
key = key^tmp >> 14; key = key^tmp >> 14;
// Invert key *= 265 // Invert key *= 265
key *= 15244667743933553977u; key *= UINT64_CONSTANT(15244667743933553977);
// Invert key = key ^ (key >> 24) // Invert key = key ^ (key >> 24)
tmp = key^key >> 24; tmp = key^key >> 24;

@ -25,13 +25,13 @@
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
#endif #endif
#ifndef _WIN32_WINDOWS #ifndef _WIN32_WINDOWS
# define _WIN32_WINDOWS 0x0410 # define _WIN32_WINDOWS 0x0500
#endif #endif
#ifndef _WIN32_WINNT #ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400 # define _WIN32_WINNT 0x0500
#endif #endif
#ifndef WINVER #ifndef WINVER
# define WINVER 0x0400 # define WINVER 0x0500
#endif #endif
#ifndef NOMINMAX #ifndef NOMINMAX
# define NOMINMAX # define NOMINMAX

@ -64,6 +64,8 @@ public:
virtual void getWindowPos (uint32 &x, uint32 &y, uint32 &w, uint32 &h) { x=y=w=h=0; } virtual void getWindowPos (uint32 &x, uint32 &y, uint32 &w, uint32 &h) { x=y=w=h=0; }
static std::string stringifyMessage(const NLMISC::CLog::TDisplayInfo &args, const char *message, bool needSlashR = false);
protected: protected:
// display a string (MT) // display a string (MT)

@ -19,6 +19,9 @@
#ifndef XML_AUTO_PTR_H #ifndef XML_AUTO_PTR_H
#define XML_AUTO_PTR_H #define XML_AUTO_PTR_H
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#include <string> #include <string>
/** Simple auto pointer for xml pointers /** Simple auto pointer for xml pointers
@ -28,7 +31,7 @@ class CXMLAutoPtr
public: public:
CXMLAutoPtr(const char *value = NULL) : _Value(value) {} CXMLAutoPtr(const char *value = NULL) : _Value(value) {}
CXMLAutoPtr(const unsigned char *value) : _Value((const char *) value) {} CXMLAutoPtr(const unsigned char *value) : _Value((const char *) value) {}
~CXMLAutoPtr() { destroy(); } ~CXMLAutoPtr();
operator const char *() const { return _Value; } operator const char *() const { return _Value; }
operator bool() const { return _Value != NULL; } operator bool() const { return _Value != NULL; }
inline std::string str() const { return _Value; } inline std::string str() const { return _Value; }
@ -36,13 +39,7 @@ public:
operator const unsigned char *() const { return (const unsigned char *) _Value; } operator const unsigned char *() const { return (const unsigned char *) _Value; }
char operator * () const { nlassert(_Value); return *_Value; } char operator * () const { nlassert(_Value); return *_Value; }
/// NB : This remove previous owned pointer with xmlFree /// NB : This remove previous owned pointer with xmlFree
CXMLAutoPtr &operator = (const char *other) CXMLAutoPtr &operator = (const char *other);
{
if (other == _Value) return *this;
destroy();
_Value = other;
return *this;
}
CXMLAutoPtr &operator = (const unsigned char *other) CXMLAutoPtr &operator = (const unsigned char *other)
{ {
@ -54,14 +51,7 @@ public:
private: private:
const char *_Value; const char *_Value;
private: private:
void destroy() void destroy();
{
if (_Value)
{
xmlFree(const_cast<char *>(_Value));
_Value = NULL;
}
}
// We'd rather avoid problems // We'd rather avoid problems
CXMLAutoPtr(const CXMLAutoPtr &/* other */) CXMLAutoPtr(const CXMLAutoPtr &/* other */)

@ -24,7 +24,9 @@
struct sockaddr_in; struct sockaddr_in;
struct sockaddr_in6;
struct in_addr; struct in_addr;
struct in6_addr;
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
@ -89,17 +91,25 @@ public:
/// Sets hostname and port (ex: www.nevrax.com:80) /// Sets hostname and port (ex: www.nevrax.com:80)
void setNameAndPort( const std::string& hostNameAndPort ); void setNameAndPort( const std::string& hostNameAndPort );
/** Sets internal socket address directly (contents is copied). /** Sets internal IPv4 socket address directly (contents is copied).
* It also retrieves the host name if CInetAddress::RetrieveNames is true. * It also retrieves the host name if CInetAddress::RetrieveNames is true.
*/ */
void setSockAddr( const sockaddr_in* saddr ); void setSockAddr( const sockaddr_in* saddr );
/** Sets internal IPv6 socket address directly (contents is copied).
* It also retrieves the host name if CInetAddress::RetrieveNames is true.
*/
void setSockAddr6( const sockaddr_in6* saddr6 );
/// Returns if object (address and port) is valid /// Returns if object (address and port) is valid
bool isValid() const; bool isValid() const;
/// Returns internal socket address (read only) /// Returns internal IPv4 socket address (read only)
const sockaddr_in *sockAddr() const; const sockaddr_in *sockAddr() const;
/// Returns internal IPv6 socket address (read only)
const sockaddr_in6 *sockAddr6() const;
/// Returns internal IP address /// Returns internal IP address
uint32 internalIPAddress() const; uint32 internalIPAddress() const;
@ -140,9 +150,12 @@ public:
protected: protected:
/// Constructor with ip address, port=0 /// Constructor with IPv4 address, port=0
CInetAddress( const in_addr *ip, const char *hostname = 0); CInetAddress( const in_addr *ip, const char *hostname = 0);
/// Constructor with IPv6 address, port=0
CInetAddress( const in6_addr *ip, const char *hostname = 0);
/// Update _HostName from _SockAddr /// Update _HostName from _SockAddr
void updateHostName(); void updateHostName();
@ -153,6 +166,7 @@ private:
std::string _HostName; std::string _HostName;
sockaddr_in *_SockAddr; sockaddr_in *_SockAddr;
sockaddr_in6 *_SockAddr6;
bool _Valid; bool _Valid;
}; };

@ -70,7 +70,7 @@ namespace NLNET
* *
* The library name is the base name that will be 'decorated' * The library name is the base name that will be 'decorated'
* with the nel naming standard according to compilation mode * with the nel naming standard according to compilation mode
* and platform specific file extension (.dll or .so). * and platform specific file extension (.dll, .dylib or .so).
* *
* A module library can only be loaded once. If the library * A module library can only be loaded once. If the library
* is already loaded, the call is ingored. * is already loaded, the call is ingored.

@ -0,0 +1,62 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2015 Winch Gate Property Limited
// Author: Jan Boon <jan.boon@kaetemi.be>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <nel/misc/types_nl.h>
namespace NLMISC {
class CConfigFile;
}
#ifdef NL_OS_WINDOWS
#include <nel/misc/sstring.h>
typedef NLMISC::CSString TPathString;
#else
typedef std::string TPathString;
#endif
namespace NLPIPELINE {
/// Asset database configuration
class CDatabaseConfig
{
public:
~CDatabaseConfig();
/// Searches for the configuration for the specified asset path by recursively going through all parent directories looking for 'database.cfg', initializes and applies the configuration.
static bool init(const std::string &asset);
static void release();
static void initTextureSearchDirectories();
static inline const TPathString &rootPath() { return s_RootPath; }
static inline TPathString configPath() { return s_RootPath + "/database.cfg"; }
private:
static void cleanup();
static void searchDirectories(const char *var);
static CDatabaseConfig s_Instance;
static uint32 s_ConfigFileModification;
static TPathString s_RootPath;
static NLMISC::CConfigFile *s_ConfigFile;
};
} /* namespace NLPIPELINE */
/* end of file */

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save