diff --git a/.gitignore b/.gitignore index f76ffad86..054aaffb8 100644 --- a/.gitignore +++ b/.gitignore @@ -160,7 +160,7 @@ code/build/* code/build-2010/* build/* install/* -build_vc* +build_* code/nel/tools/build_gamedata/configuration/buildsite.py code/build* build* @@ -218,6 +218,7 @@ 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 @@ -238,14 +239,14 @@ code/ryzom/tools/server/ryzom_ams/old -#tools and external dir's +# Tools and external directories external external_vc14 external_stlport nel_tools* ryzom_tools* -#Dumps +# Dumps *.dmp code/nel/tools/build_gamedata/processes/ai_wmap/ai_build_wmap.cfg diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7366425c8..9417c1f17 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -52,14 +52,14 @@ Linux client build: - echo "disableproc:$disableproc, nb core compile:$(nproc --ignore=$disableproc) optionproc:$optionproc" # Installation des dépendances #- echo "deb http://ftp.debian.org/debian/ jessie-backports non-free contrib main" >> /etc/apt/sources.list - - apt-get update - - apt-get -y upgrade - - apt-get install libxml2 -y g++ gcc cmake libcurl4-openssl-dev libgl1-mesa-dev libjpeg-dev libpng-dev libopenal-dev libfreetype6-dev libxxf86vm-dev libxrandr-dev libxrender-dev libvorbis-dev libluabind-dev libboost-dev libmysqlclient-dev libssl-dev liblzma-dev libxml2-dev makeself libgif-dev patch + - DEBIAN_FRONTEND=noninteractive apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get install libxml2 -y g++ gcc cmake libcurl4-openssl-dev libgl1-mesa-dev libjpeg-dev libpng-dev libopenal-dev libfreetype6-dev libxxf86vm-dev libxrandr-dev libxrender-dev libvorbis-dev libluabind-dev libboost-dev libmysqlclient-dev libssl-dev liblzma-dev libxml2-dev makeself libgif-dev patch # Installation des dépendances des dépendances statiques (à commenter si construction de Khanat en mode dynamique) # libxml2 : python-pyicu (support d'unicode), python-dev (support de... python) - apt-get install -y wget python-pyicu python-dev # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) # Création de l'environnement de compilation - mkdir -p BUILD/x86_64 - cd BUILD/x86_64 @@ -72,6 +72,49 @@ Linux client build: - ./configure --disable-ldap --disable-ldaps --disable-rtsp --disable-dict --disable-ipv6 --disable-crypto-auth --disable-sspi --disable-tls-srp --without-gnutls --without-librtmp --without-libidn --disable-versioned-symbols --disable-pop3 --without-libssh2 --with-ssl - make install $optionproc - cd .. + # Build luabind + - mkdir -p luabind + - wget -q http://http.debian.net/debian/pool/main/l/luabind/luabind_0.9.1+dfsg.orig.tar.gz -O luabind.tar.gz + - wget -q http://http.debian.net/debian/pool/main/l/luabind/luabind_0.9.1+dfsg-11.debian.tar.xz -O luabind-debian.tar.xz + - tar xvf luabind.tar.gz -C luabind --strip 1 || exit 2 + - tar xvf luabind-debian.tar.xz -C luabind || exit 2 + - cd luabind + - for file in $(cat debian/patches/series); do patch -p1 < debian/patches/$file; done + - export -p DEB_HOST_MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH); bjam -d2 release debug install cflags="-fPIC $(dpkg-buildflags --get CFLAGS)" cxxflags="-fPIC $(dpkg-buildflags --get CXXFLAGS) -Wno-deprecated-declarations" linkflags=" $(dpkg-buildflags --get LDFLAGS)" + - export -p DEB_HOST_MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH); bjam -d2 release debug install link=static cflags="-fPIC $(dpkg-buildflags --get CFLAGS)" cxxflags="-fPIC $(dpkg-buildflags --get CXXFLAGS) -Wno-deprecated-declarations" linkflags=" $(dpkg-buildflags --get LDFLAGS)" + - cd .. + # Build libogg + - mkdir -p libogg/build + - wget -q http://http.debian.net/debian/pool/main/libo/libogg/libogg_1.3.2.orig.tar.gz -O libogg.tar.gz + - wget -q http://http.debian.net/debian/pool/main/libo/libogg/libogg_1.3.2-1.diff.gz -O libogg.diff.gz + - tar xvf libogg.tar.gz -C libogg --strip 1 || exit 2 + - gunzip libogg.diff.gz + - cd libogg + - patch -p1 < ../libogg.diff + - cd build + - ../configure --disable-maintainer-mode --host=$(dpkg-architecture -qDEB_HOST_GNU_TYPE) --build=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE) --libdir=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH) --enable-static --prefix=/usr CPPFLAGS="-D_FORTIFY_SOURCE=2" CFLAGS="-Wformat=2 -g -fPIC" CXXFLAGS="-Wformat=2 -g -fPIC" LDFLAGS="-Wl,-z,now" + - make + - make install + - cd ../.. + # Build libvorbis + - mkdir -p libvorbis + - wget -q http://security.debian.org/debian-security/pool/updates/main/libv/libvorbis/libvorbis_1.3.5.orig.tar.gz -O libvorbis.tar.gz + - tar xvf libvorbis.tar.gz -C libvorbis --strip 1 || exit 2 + # Get list package + - wget -q http://security.debian.org/debian-security/pool/updates/main/libv/libvorbis -O list_libvorbis + # get last patch for our release + - line=$(egrep '(libvorbis_1.3.5)(.*)(tar[.]xz)' list_libvorbis | tail -n 1) + # get only name of the patch + - tmp=${line#*href} ; tmp2=${tmp%%>*} ; tmp3=${tmp2#*\"} ; namepatch=${tmp3%\"*} + # download this patch + - wget -q http://security.debian.org/debian-security/pool/updates/main/libv/libvorbis/$namepatch -O libvorbis.debian.tar.xz + - tar xvf libvorbis.debian.tar.xz -C libvorbis || exit 2 + - cd libvorbis + - for file in $(cat debian/patches/series); do patch -p1 < debian/patches/$file; done + - ./configure --enable-static --with-pic + - make + - make install + - cd .. ## Compilation de Khanat # Configuration - cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/ -DCMAKE_BUILD_TYPE=Release -DWITH_RYZOM_SERVER=OFF -DWITH_RYZOM_TOOLS=OFF -DWITH_RYZOM_CLIENT=ON -DWITH_NEL_TESTS=OFF -DWITH_NEL_TOOLS=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_STATIC=ON -DWITH_STATIC_DRIVERS=ON -DWITH_STATIC_EXTERNAL=ON -DWITH_UNIX_STRUCTURE=OFF -DWITH_INSTALL_LIBRARIES=OFF -DWITH_LUA52=ON ../../code @@ -100,10 +143,9 @@ Linux server debian_amd64_strech build: image: amd64/debian:9 script: # Prepare environment - - apt-get update - - apt-get dist-upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y - DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server - - apt-get install -y git libcurl4-openssl-dev libfreetype6-dev @@ -144,7 +186,7 @@ Linux server debian_amd64_strech build: patch - apt-get install -y liblua5.2-0 liblua5.2-dev libluabind-dev libluabind0.9.1v5 # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) # install squish - mkdir -p squish - (cd squish; wget -c https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/libsquish/squish-1.11.zip) @@ -188,8 +230,8 @@ Linux client debian_amd64_strech build: image: amd64/debian:9 script: # Prepare environment - - apt-get update - - apt-get dist-upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y - apt-get install -y autoconf autogen automake @@ -224,7 +266,7 @@ Linux client debian_amd64_strech build: patch - apt-get install -y liblua5.2-0 liblua5.2-dev libluabind-dev libluabind0.9.1v5 libogg-dev libvorbis-dev # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) # Build Curl - wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz - mkdir -p curl/build @@ -254,8 +296,8 @@ Linux client_static debian_amd64_strech build: image: amd64/debian:9 script: # Prepare environment - - apt-get update - - apt-get dist-upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y - apt-get install -y autoconf autogen @@ -291,7 +333,7 @@ Linux client_static debian_amd64_strech build: patch - apt-get install -y liblua5.2-0 liblua5.2-dev # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) # Build Curl - wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz - mkdir -p curl/build @@ -303,6 +345,7 @@ Linux client_static debian_amd64_strech build: - mkdir -p luabind - wget -q http://http.debian.net/debian/pool/main/l/luabind/luabind_0.9.1+dfsg.orig.tar.gz -O luabind.tar.gz - wget -q http://http.debian.net/debian/pool/main/l/luabind/luabind_0.9.1+dfsg-11.debian.tar.xz -O luabind-debian.tar.xz + - ls - tar xvf luabind.tar.gz -C luabind --strip 1 || exit 2 - tar xvf luabind-debian.tar.xz -C luabind || exit 2 - cd luabind @@ -363,8 +406,8 @@ Linux client_static_debug debian_amd64_strech build: image: amd64/debian:9 script: # Prepare environment - - apt-get update - - apt-get dist-upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y - apt-get install -y autoconf autogen @@ -400,7 +443,7 @@ Linux client_static_debug debian_amd64_strech build: patch - apt-get install -y liblua5.2-0 liblua5.2-dev # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) # Build Curl - wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz - mkdir -p curl/build @@ -472,11 +515,11 @@ Linux server_static debian_amd64_strech build: image: amd64/debian:9 script: # Prepare environment - - apt-get update - - apt-get dist-upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y - DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 apache2-utils autoconf autogen automake bison build-essential cmake cpputest default-libmysqlclient-dev fakeroot git libapache2-mod-php libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblua5.2-0 liblua5.2-dev liblzma-dev libogg-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libvorbis-dev libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial mysql-server php php-gd php-imagick php-mysql python3 python3-pip python3-bcrypt python3-venv rrdtool unzip wget zlib1g-dev # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) # Build Curl - wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz - mkdir -p curl/build @@ -563,11 +606,11 @@ Linux server_static_debug debian_amd64_strech build: image: amd64/debian:9 script: # Prepare environment - - apt-get update - - apt-get dist-upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y - DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 apache2-utils autoconf autogen automake bison build-essential cmake cpputest default-libmysqlclient-dev fakeroot git libapache2-mod-php libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblua5.2-0 liblua5.2-dev liblzma-dev libogg-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libvorbis-dev libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial mysql-server php php-gd php-imagick php-mysql python3 python3-pip python3-bcrypt python3-venv rrdtool unzip wget zlib1g-dev # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) # Build Curl - wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz - mkdir -p curl/build @@ -654,12 +697,12 @@ Linux client_static debian_i386_strech build: image: i386/debian:9 script: # Prepare environment - - apt-get update - - apt-get dist-upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y - apt-get install -y autoconf autogen automake bison build-essential cmake cpputest fakeroot libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblzma-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial rrdtool unzip wget zlib1g-dev patch - apt-get install -y liblua5.2-0 liblua5.2-dev # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) # Build Curl - wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz - mkdir -p curl/build @@ -732,12 +775,12 @@ Linux client_static_debug debian_i386_strech build: image: i386/debian:9 script: # Prepare environment - - apt-get update - - apt-get dist-upgrade -y - - apt-get install -y autoconf autogen automake bison build-essential cmake cpputest fakeroot libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblzma-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial rrdtool unzip wget zlib1g-dev patch + - DEBIAN_FRONTEND=noninteractive apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get install -y autoconf autogen automake bison build-essential cmake cpputest fakeroot libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblzma-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial rrdtool unzip wget zlib1g-dev patch - apt-get install -y liblua5.2-0 liblua5.2-dev # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) # Build Curl - wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz - mkdir -p curl/build @@ -852,7 +895,7 @@ Linux client fedora_amd64_27 build: zlib-devel patch # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) # Action - mkdir -p code/build - (cd code/build ; export -p CPPFLAGS="-Wno-deprecated -Wno-deprecated-declarations"; cmake -G "Unix Makefiles" -DWITH_NEL=ON -DWITH_LUA52=ON -DWITH_RYZOM_PATCH=OFF -DWITH_RYZOM_CUSTOM_PATCH_SERVER=OFF -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=ON -DWITH_DRIVER_OPENGL=ON -DWITH_DRIVER_OPENAL=ON -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=ON -DWITH_STATIC_CURL=OFF ..) @@ -876,9 +919,9 @@ Linux client ubuntu_amd64_17_10 build: image: amd64/ubuntu:17.10 script: # Prepare environment - - apt-get update - - apt-get dist-upgrade -y - - apt-get install -y autoconf + - DEBIAN_FRONTEND=noninteractive apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get install -y autoconf autogen automake bison @@ -912,7 +955,7 @@ Linux client ubuntu_amd64_17_10 build: zlib1g-dev - apt-get install -y liblua5.2-0 liblua5.2-dev libluabind-dev libluabind0.9.1v5 libogg-dev libvorbis-dev # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) # Action - mkdir -p code/build - (cd code/build ; export -p CPPFLAGS="-Wno-deprecated -Wno-deprecated-declarations"; cmake -G "Unix Makefiles" -DWITH_NEL=ON -DWITH_LUA52=ON -DWITH_RYZOM_PATCH=OFF -DWITH_RYZOM_CUSTOM_PATCH_SERVER=OFF -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=ON -DWITH_DRIVER_OPENGL=ON -DWITH_DRIVER_OPENAL=ON -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=ON -DWITH_STATIC_CURL=OFF ..) @@ -996,7 +1039,7 @@ Linux client archlinux build: - cd ../.. - yaourt -Syyu --noconfirm --aur boost-build # Apply patch - - (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done) + - (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done) - patch -f -Z -t -p 1 -i patch/02_archlinux_allocator_static_assert_error.patch # Build - mkdir -p luabind @@ -1033,9 +1076,9 @@ Windows client build: script: # Prepare environment - dpkg --add-architecture i386 - - apt-get update - - apt-get dist-upgrade -y - - apt-get install -y + - DEBIAN_FRONTEND=noninteractive apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y + - DEBIAN_FRONTEND=noninteractive apt-get install -y p7zip-full binfmt-support libc6-i386 @@ -1098,7 +1141,7 @@ Linux client test: - mac-ci-build tags: - Docker - image: ubuntu:14.04 + image: ubuntu:18.04 script: # Test de l'installation initiale - ./khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-Linux-x86_64.run @@ -1128,7 +1171,7 @@ Linux client test: - ryzomcore tags: - Docker - image: ubuntu:14.04 + image: ubuntu:18.04 script: - echo "pas encore de deployment" dependencies: @@ -1148,7 +1191,7 @@ Linux client test: - tags tags: - Docker - image: ubuntu:14.04 + image: ubuntu:18.04 script: - echo "pas encore de tag" dependencies: diff --git a/.hgignore b/.hgignore new file mode 100644 index 000000000..990487a2a --- /dev/null +++ b/.hgignore @@ -0,0 +1,268 @@ +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* + +#personal projects +personal/ + +#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 diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..cfb8b4696 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,40 @@ +jobs: + - job: ubuntu16 + pool: + vmImage: 'Ubuntu-16.04' + steps: + - script: | + sudo apt-get update + sudo apt-get install -y software-properties-common + sudo add-apt-repository ppa:ubuntu-toolchain-r/test + sudo apt-get update + sudo apt-get install cmake build-essential -y + sudo apt-get install gcc-8 g++-8 -y + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 60 + sudo apt-get install bison autoconf automake -y + sudo apt-get install libpng12-dev -y + sudo apt-get install libjpeg-dev -y + sudo apt-get install libgif-dev libfreetype6-dev -y + sudo apt-get install freeglut3-dev -y + sudo apt-get install liblua5.1-dev libluabind-dev libcpptest-dev -y + sudo apt-get install libogg-dev libvorbis-dev libopenal-dev -y + sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev libswscale-dev libpostproc-dev -y + sudo apt-get install libmysqlclient-dev -y + sudo apt-get install libxml2-dev -y + sudo apt-get install libcurl4-openssl-dev libssl-dev -y + sudo apt-get install libsquish-dev -y + sudo apt-get install liblzma-dev -y + sudo apt-get install libgsf-1-dev -y + displayName: 'Dependencies' + - script: | + mkdir build + cmake --version + cd build + cmake -DWITH_STATIC=ON -DWITH_NEL_TESTS=OFF -DWITH_NEL_SAMPLES=ON -DWITH_LUA51=ON -DWITH_RYZOM_SERVER=ON -DWITH_RYZOM_TOOLS=OFF -DWITH_NEL_TOOLS=ON -DWITH_LIBGSF=ON ../code + cat CMakeCache.txt + displayName: 'CMake' + - script: | + cd build + make -j`nproc` + displayName: 'Make' \ No newline at end of file diff --git a/code/.clang-format b/code/.clang-format new file mode 100644 index 000000000..90f4ab553 --- /dev/null +++ b/code/.clang-format @@ -0,0 +1,24 @@ +--- +BasedOnStyle: WebKit +AllowShortFunctionsOnASingleLine: All +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + IndentBraces: false +BreakBeforeBraces: Custom +BreakConstructorInitializersBeforeComma: 'false' +NamespaceIndentation: None +PointerAlignment: Right +SortIncludes: 'false' +TabWidth: '4' +UseTab: ForIndentation + +... diff --git a/code/.editorconfig b/code/.editorconfig new file mode 100644 index 000000000..e4aef2c53 --- /dev/null +++ b/code/.editorconfig @@ -0,0 +1,23 @@ +; 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 + +[*.config] +indent_style = space +indent_size = 2 diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 43054b63e..4e5292f2a 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -53,8 +53,8 @@ ENDIF() CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(RyzomCore CXX C) -SET(NL_VERSION_MAJOR 0) -SET(NL_VERSION_MINOR 12) +SET(NL_VERSION_MAJOR 1) +SET(NL_VERSION_MINOR 0) SET(NL_VERSION_PATCH 0) SET(YEAR "2004-${CURRENT_YEAR}") SET(AUTHOR "Winch Gate and The Ryzom Core Community") @@ -91,12 +91,12 @@ NL_SETUP_NELNS_DEFAULT_OPTIONS() NL_SETUP_RYZOM_DEFAULT_OPTIONS() NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS() -NL_SETUP_PREFIX_PATHS() -RYZOM_SETUP_PREFIX_PATHS() - NL_SETUP_BUILD() NL_SETUP_BUILD_FLAGS() +NL_SETUP_PREFIX_PATHS() +RYZOM_SETUP_PREFIX_PATHS() + #----------------------------------------------------------------------------- #Platform specifics @@ -172,6 +172,7 @@ ENDIF() IF(APPLE) FIND_LIBRARY(CARBON_FRAMEWORK Carbon) FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation) + FIND_LIBRARY(SECURITY_FRAMEWORK Security) IF(APPLE_CERTIFICATE) # Find codesign_allocate @@ -196,214 +197,10 @@ IF(APPLE) 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() +INCLUDE(FindHelpers) 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 -lxcb-glx) - 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 - FIND_PACKAGE(Freetype) - - IF(FREETYPE_FOUND) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIBRARIES}) - ELSE() - 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() - 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 - ${WINSDK_LIBRARY_DIR}/IPHlpApi.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(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() + FIND_QT5() ENDIF() IF(WITH_QT) @@ -435,22 +232,41 @@ IF(WITH_NEL) IF(CURL_STATIC) SET(CURL_DEFINITIONS -DCURL_STATICLIB) - SET(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) - SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) + LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) + LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES}) - IF(UNIX) + IF(WIN32) + LIST(APPEND CURL_LIBRARIES Crypt32 Cryptui) + ELSE() # CURL depends on libidn FIND_LIBRARY(IDN_LIBRARY idn) IF(IDN_LIBRARY) - SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${IDN_LIBRARY}) + LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY}) ENDIF() - # CURL Macports version depends on libidn, libintl and libiconv too + # CURL Macports version can depend on libidn, libidn2, libintl, libpsl and libiconv too IF(APPLE) FIND_LIBRARY(INTL_LIBRARY intl) IF(INTL_LIBRARY) - SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${INTL_LIBRARY}) + LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY}) ENDIF() + + FIND_LIBRARY(IDN2_LIBRARY idn2) + IF(IDN2_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${IDN2_LIBRARY}) + ENDIF() + + FIND_LIBRARY(PSL_LIBRARY psl) + IF(PSL_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${PSL_LIBRARY}) + ENDIF() + + FIND_LIBRARY(UNISTRING_LIBRARY unistring) + IF(UNISTRING_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${UNISTRING_LIBRARY}) + ENDIF() + + LIST(APPEND CURL_LIBRARIES ${SECURITY_FRAMEWORK}) ENDIF() ENDIF() ENDIF() @@ -458,6 +274,19 @@ IF(WITH_NEL) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include) ADD_SUBDIRECTORY(nel) + + # Aliases for targets + SET(NELMISC_LIBRARIES nelmisc) + SET(NELNET_LIBRARIES nelnet) + SET(NELLIGO_LIBRARIES nelligo) + SET(NELGEORGES_LIBRARIES nelgeorges) + SET(NEL3D_LIBRARIES nel3d) + SET(NELGUI_LIBRARIES nelgui) + SET(NELSOUND_LIBRARIES nelsound) +ELSE() +# FIND_PACKAGE(NeL COMPONENTS 3d misc pacs sound nimp REQUIRED) + FIND_PACKAGE(NeL REQUIRED) + INCLUDE_DIRECTORIES(${NEL_INCLUDE_DIRS}) ENDIF() IF(WITH_RYZOM) @@ -480,6 +309,10 @@ IF(WITH_STUDIO) ADD_SUBDIRECTORY(studio) ENDIF() +IF(WITH_PERSONAL) + ADD_SUBDIRECTORY(personal) +ENDIF() + # To build the documention, you will have to enable it # and then do the equivalent of "make DoxygenDoc". IF(BUILD_DOCUMENTATION) diff --git a/code/CMakeModules/Find3dsMaxSDK.cmake b/code/CMakeModules/Find3dsMaxSDK.cmake index cf49a90d3..cb00df78e 100644 --- a/code/CMakeModules/Find3dsMaxSDK.cmake +++ b/code/CMakeModules/Find3dsMaxSDK.cmake @@ -11,18 +11,56 @@ if(MAXSDK_INCLUDE_DIR) SET(MAXSDK_FIND_QUIETLY TRUE) endif() +set(_pf_x86 "PROGRAMFILES(x86)") + FIND_PATH(MAXSDK_DIR "include/maxversion.h" HINTS "$ENV{MAXSDK_DIR}" PATHS + "$ENV{ADSK_3DSMAX_SDK_2021}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2020}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2019}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2018}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2017}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2016}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2015}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2014}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2013}/maxsdk" "$ENV{ADSK_3DSMAX_SDK_2012}/maxsdk" "$ENV{3DSMAX_2011_SDK_PATH}/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2021 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2020 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2019 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2018 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2017 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2016 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2015 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2014 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2013 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2012 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2011 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2010 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2009 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2008 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 9 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3dsMax8/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2021 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2020 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2019 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2018 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2017 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2016 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2015 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2014 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2013 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2012 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2011 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3dsMax8/maxsdk" ) FIND_PATH(MAXSDK_INCLUDE_DIR diff --git a/code/CMakeModules/FindFFmpeg.cmake b/code/CMakeModules/FindFFmpeg.cmake new file mode 100644 index 000000000..96cbb6ed0 --- /dev/null +++ b/code/CMakeModules/FindFFmpeg.cmake @@ -0,0 +1,173 @@ +# vim: ts=2 sw=2 +# - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC) +# +# Once done this will define +# FFMPEG_FOUND - System has the all required components. +# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers. +# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components. +# FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components. +# +# For each of the components it will additionaly set. +# - AVCODEC +# - AVDEVICE +# - AVFORMAT +# - AVUTIL +# - POSTPROC +# - SWSCALE +# - SWRESAMPLE +# the following variables will be defined +# _FOUND - System has +# _INCLUDE_DIRS - Include directory necessary for using the headers +# _LIBRARIES - Link these to use +# _DEFINITIONS - Compiler switches required for using +# _VERSION - The components version +# +# Copyright (c) 2006, Matthias Kretz, +# Copyright (c) 2008, Alexander Neundorf, +# Copyright (c) 2011, Michael Jansen, +# +# Redistribution and use is allowed according to the terms of the BSD license. + +include(FindPackageHandleStandardArgs) + +if(NOT FFmpeg_FIND_COMPONENTS) + set(FFmpeg_FIND_COMPONENTS AVFORMAT AVCODEC AVUTIL) +endif() + +# +### Macro: set_component_found +# +# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present. +# +macro(set_component_found _component) + if(${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS) + # message(STATUS " - ${_component} found.") + set(${_component}_FOUND TRUE) + else() + # message(STATUS " - ${_component} not found.") + endif() +endmacro() + +# +### Macro: find_component +# +# Checks for the given component by invoking pkgconfig and then looking up the libraries and +# include directories. +# +macro(find_component _component _pkgconfig _library _header) + if(NOT WIN32) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + find_package(PkgConfig) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_${_component} ${_pkgconfig}) + endif() + endif() + + find_path(${_component}_INCLUDE_DIRS ${_header} + HINTS + ${FFMPEGSDK_INC} + ${PC_LIB${_component}_INCLUDEDIR} + ${PC_LIB${_component}_INCLUDE_DIRS} + PATH_SUFFIXES + ffmpeg + ) + + find_library(${_component}_LIBRARIES NAMES ${_library} + HINTS + ${FFMPEGSDK_LIB} + ${PC_LIB${_component}_LIBDIR} + ${PC_LIB${_component}_LIBRARY_DIRS} + ) + + STRING(REGEX REPLACE "/.*" "/version.h" _ver_header ${_header}) + if(EXISTS "${${_component}_INCLUDE_DIRS}/${_ver_header}") + file(STRINGS "${${_component}_INCLUDE_DIRS}/${_ver_header}" version_str REGEX "^#define[\t ]+LIB${_component}_VERSION_M.*") + + foreach(_str "${version_str}") + if(NOT version_maj) + string(REGEX REPLACE "^.*LIB${_component}_VERSION_MAJOR[\t ]+([0-9]*).*$" "\\1" version_maj "${_str}") + endif() + if(NOT version_min) + string(REGEX REPLACE "^.*LIB${_component}_VERSION_MINOR[\t ]+([0-9]*).*$" "\\1" version_min "${_str}") + endif() + if(NOT version_mic) + string(REGEX REPLACE "^.*LIB${_component}_VERSION_MICRO[\t ]+([0-9]*).*$" "\\1" version_mic "${_str}") + endif() + endforeach() + unset(version_str) + + set(${_component}_VERSION "${version_maj}.${version_min}.${version_mic}" CACHE STRING "The ${_component} version number.") + unset(version_maj) + unset(version_min) + unset(version_mic) + endif(EXISTS "${${_component}_INCLUDE_DIRS}/${_ver_header}") + set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.") + set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.") + + set_component_found(${_component}) + + mark_as_advanced( + ${_component}_INCLUDE_DIRS + ${_component}_LIBRARIES + ${_component}_DEFINITIONS + ${_component}_VERSION) +endmacro() + + +set(FFMPEGSDK $ENV{FFMPEG_HOME}) +if(FFMPEGSDK) + set(FFMPEGSDK_INC "${FFMPEGSDK}/include") + set(FFMPEGSDK_LIB "${FFMPEGSDK}/lib") +endif() + +# Check for all possible components. +find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h) +find_component(AVFORMAT libavformat avformat libavformat/avformat.h) +find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h) +find_component(AVUTIL libavutil avutil libavutil/avutil.h) +find_component(SWSCALE libswscale swscale libswscale/swscale.h) +find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h) +find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h) + +# Check if the required components were found and add their stuff to the FFMPEG_* vars. +foreach(_component ${FFmpeg_FIND_COMPONENTS}) + if(${_component}_FOUND) + # message(STATUS "Required component ${_component} present.") + set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES}) + set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS}) + list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS}) + else() + # message(STATUS "Required component ${_component} missing.") + endif() +endforeach() + +# Build the include path and library list with duplicates removed. +if(FFMPEG_INCLUDE_DIRS) + list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) +endif() + +if(FFMPEG_LIBRARIES) + list(REMOVE_DUPLICATES FFMPEG_LIBRARIES) +endif() + +# cache the vars. +set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE) +set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE) +set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE) + +mark_as_advanced(FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES FFMPEG_DEFINITIONS) + +# Now set the noncached _FOUND vars for the components. +foreach(_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWRESAMPLE SWSCALE) + set_component_found(${_component}) +endforeach () + +# Compile the list of required vars +set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS) +foreach(_component ${FFmpeg_FIND_COMPONENTS}) + list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS) +endforeach() + +# Give a nice error message if some of the required vars are missing. +find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS}) diff --git a/code/CMakeModules/FindGLIB2.cmake b/code/CMakeModules/FindGLIB2.cmake new file mode 100644 index 000000000..942b04530 --- /dev/null +++ b/code/CMakeModules/FindGLIB2.cmake @@ -0,0 +1,217 @@ +# - Try to find GLib2 +# Once done this will define +# +# GLIB2_FOUND - system has GLib2 +# GLIB2_INCLUDE_DIRS - the GLib2 include directory +# GLIB2_LIBRARIES - Link these to use GLib2 +# +# HAVE_GLIB_GREGEX_H glib has gregex.h header and +# supports g_regex_match_simple +# +# Copyright (c) 2006 Andreas Schneider +# Copyright (c) 2006 Philippe Bernery +# Copyright (c) 2007 Daniel Gollub +# Copyright (c) 2007 Alban Browaeys +# Copyright (c) 2008 Michael Bell +# Copyright (c) 2008 Bjoern Ricks +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + + +IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) + # in cache already + SET(GLIB2_FOUND TRUE) +ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) + + INCLUDE(FindPkgConfig) + + ## Glib + IF ( GLIB2_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "REQUIRED" ) + ELSE ( GLIB2_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "" ) + ENDIF ( GLIB2_FIND_REQUIRED ) + + IF ( GLIB2_MIN_VERSION ) + PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} ) + ELSE ( GLIB2_MIN_VERSION ) + PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 ) + ENDIF ( GLIB2_MIN_VERSION ) + IF ( PKG_CONFIG_FOUND ) + IF ( GLIB2_FOUND ) + SET ( GLIB2_CORE_FOUND TRUE ) + ELSE ( GLIB2_FOUND ) + SET ( GLIB2_CORE_FOUND FALSE ) + ENDIF ( GLIB2_FOUND ) + ENDIF ( PKG_CONFIG_FOUND ) + + # Look for glib2 include dir and libraries w/o pkgconfig + IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) + FIND_PATH( + _glibconfig_include_DIR + NAMES + glibconfig.h + PATHS + /opt/gnome/lib64 + /opt/gnome/lib + /opt/lib/ + /opt/local/lib + /sw/lib/ + /usr/lib64 + /usr/lib + /usr/local/include + ${CMAKE_LIBRARY_PATH} + PATH_SUFFIXES + glib-2.0/include + ) + + FIND_PATH( + _glib2_include_DIR + NAMES + glib.h + PATHS + /opt/gnome/include + /opt/local/include + /sw/include + /usr/include + /usr/local/include + PATH_SUFFIXES + glib-2.0 + ) + + #MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}") + + FIND_LIBRARY( + _glib2_link_DIR + NAMES + glib-2.0 + glib + PATHS + /opt/gnome/lib + /opt/local/lib + /sw/lib + /usr/lib + /usr/local/lib + ) + IF ( _glib2_include_DIR AND _glib2_link_DIR ) + SET ( _glib2_FOUND TRUE ) + ENDIF ( _glib2_include_DIR AND _glib2_link_DIR ) + + + IF ( _glib2_FOUND ) + SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} ) + SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} ) + SET ( GLIB2_CORE_FOUND TRUE ) + ELSE ( _glib2_FOUND ) + SET ( GLIB2_CORE_FOUND FALSE ) + ENDIF ( _glib2_FOUND ) + + # Handle dependencies + # libintl + IF ( NOT LIBINTL_FOUND ) + FIND_PATH(LIBINTL_INCLUDE_DIR + NAMES + libintl.h + PATHS + /opt/gnome/include + /opt/local/include + /sw/include + /usr/include + /usr/local/include + ) + + FIND_LIBRARY(LIBINTL_LIBRARY + NAMES + intl + PATHS + /opt/gnome/lib + /opt/local/lib + /sw/lib + /usr/local/lib + /usr/lib + ) + + IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) + SET (LIBINTL_FOUND TRUE) + ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) + ENDIF ( NOT LIBINTL_FOUND ) + + # libiconv + IF ( NOT LIBICONV_FOUND ) + FIND_PATH(LIBICONV_INCLUDE_DIR + NAMES + iconv.h + PATHS + /opt/gnome/include + /opt/local/include + /opt/local/include + /sw/include + /sw/include + /usr/local/include + /usr/include + PATH_SUFFIXES + glib-2.0 + ) + + FIND_LIBRARY(LIBICONV_LIBRARY + NAMES + iconv + PATHS + /opt/gnome/lib + /opt/local/lib + /sw/lib + /usr/lib + /usr/local/lib + ) + + IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) + SET (LIBICONV_FOUND TRUE) + ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) + ENDIF ( NOT LIBICONV_FOUND ) + + IF (LIBINTL_FOUND) + SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY}) + SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR}) + ENDIF (LIBINTL_FOUND) + + IF (LIBICONV_FOUND) + SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) + SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) + ENDIF (LIBICONV_FOUND) + + ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) + ## + + IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) + SET (GLIB2_FOUND TRUE) + ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) + + IF (GLIB2_FOUND) + IF (NOT GLIB2_FIND_QUIETLY) + MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}") + ENDIF (NOT GLIB2_FIND_QUIETLY) + ELSE (GLIB2_FOUND) + IF (GLIB2_FIND_REQUIRED) + MESSAGE (SEND_ERROR "Could not find GLib2") + ENDIF (GLIB2_FIND_REQUIRED) + ENDIF (GLIB2_FOUND) + + # show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view + MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES) + MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY) + MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY) + +ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS) + +IF ( GLIB2_FOUND ) + # Check if system has a newer version of glib + # which supports g_regex_match_simple + INCLUDE( CheckIncludeFiles ) + SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} ) + CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H ) + # Reset CMAKE_REQUIRED_INCLUDES + SET( CMAKE_REQUIRED_INCLUDES "" ) +ENDIF( GLIB2_FOUND ) diff --git a/code/CMakeModules/FindGOBJECT2.cmake b/code/CMakeModules/FindGOBJECT2.cmake new file mode 100644 index 000000000..d0d4cda0d --- /dev/null +++ b/code/CMakeModules/FindGOBJECT2.cmake @@ -0,0 +1,51 @@ +# - Try to find GObject2 +# Find GObject2 headers, libraries and the answer to all questions. +# +# GOBJECT2_FOUND True if GOBJECT2 got found +# GOBJECT2_INCLUDE_DIRS Location of GOBJECT2 headers +# GOBJECT2_LIBRARIES List of libraries to use GOBJECT2 +# +# Copyright (c) 2008 Bjoern Ricks +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +INCLUDE( FindPkgConfig ) + +IF ( GOBJECT2_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "REQUIRED" ) +ELSE( GOBJECT2_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "" ) +ENDIF ( GOBJECT2_FIND_REQUIRED ) + +IF ( GOBJECT2_MIN_VERSION ) + PKG_SEARCH_MODULE( GOBJECT2 ${_pkgconfig_REQUIRED} gobject-2.0>=${GOBJECT2_MIN_VERSION} ) +ELSE ( GOBJECT2_MIN_VERSION ) + PKG_SEARCH_MODULE( GOBJECT2 ${_pkgconfig_REQUIRED} gobject-2.0 ) +ENDIF ( GOBJECT2_MIN_VERSION ) + + +IF( NOT GOBJECT2_FOUND AND NOT PKG_CONFIG_FOUND ) + FIND_PATH( GOBJECT2_INCLUDE_DIRS gobject/gobject.h PATH_SUFFIXES glib-2.0) + FIND_LIBRARY( GOBJECT2_LIBRARIES gobject-2.0 ) + + # Report results + IF ( GOBJECT2_LIBRARIES AND GOBJECT2_INCLUDE_DIRS ) + SET( GOBJECT2_FOUND 1 ) + IF ( NOT GOBJECT2_FIND_QUIETLY ) + MESSAGE( STATUS "Found GOBJECT2: ${GOBJECT2_LIBRARIES}" ) + ENDIF ( NOT GOBJECT2_FIND_QUIETLY ) + ELSE ( GOBJECT2_LIBRARIES AND GOBJECT2_INCLUDE_DIRS ) + IF ( GOBJECT2_FIND_REQUIRED ) + MESSAGE( SEND_ERROR "Could NOT find GOBJECT2" ) + ELSE ( GOBJECT2_FIND_REQUIRED ) + IF ( NOT GOBJECT2_FIND_QUIETLY ) + MESSAGE( STATUS "Could NOT find GOBJECT2" ) + ENDIF ( NOT GOBJECT2_FIND_QUIETLY ) + ENDIF ( GOBJECT2_FIND_REQUIRED ) + ENDIF ( GOBJECT2_LIBRARIES AND GOBJECT2_INCLUDE_DIRS ) +ENDIF( NOT GOBJECT2_FOUND AND NOT PKG_CONFIG_FOUND ) + +MARK_AS_ADVANCED( GOBJECT2_LIBRARIES GOBJECT2_INCLUDE_DIRS ) diff --git a/code/CMakeModules/FindHelpers.cmake b/code/CMakeModules/FindHelpers.cmake new file mode 100644 index 000000000..bc38354f4 --- /dev/null +++ b/code/CMakeModules/FindHelpers.cmake @@ -0,0 +1,959 @@ +MACRO(CONVERT_NUMBER_VERSION _VERSION_NUMBER _BASE _OUT) + SET(${_OUT}) + SET(_NUMBER ${_VERSION_NUMBER}) + WHILE(_NUMBER GREATER 0) + MATH(EXPR _TEMP "${_NUMBER} % ${_BASE}") + LIST(APPEND ${_OUT} ${_TEMP}) + MATH(EXPR _NUMBER "${_NUMBER} / ${_BASE}") + ENDWHILE() +ENDMACRO(CONVERT_NUMBER_VERSION) + +FUNCTION(JOIN VALUES GLUE OUTPUT) + STRING(REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}") + STRING(REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping + SET(${OUTPUT} "${_TMP_STR}" PARENT_SCOPE) +ENDFUNCTION() + +MACRO(PARSE_VERSION_OTHER FILENAME) + IF(EXISTS ${FILENAME}) + SET(_FILTER_ARRAY ${ARGN}) + JOIN("${_FILTER_ARRAY}" "|" _FILTER_REGEX) + FILE(STRINGS ${FILENAME} _FILE REGEX "(${_FILTER_REGEX})[: \t=\(\)\"]+([0-9.]+)") + + IF(_FILE) + FOREACH(_LINE ${_FILE}) + FOREACH(_VAR ${_FILTER_ARRAY}) + IF("${${_VAR}}" STREQUAL "") + STRING(REGEX REPLACE "^.*${_VAR}[: \t=\(\)\"]+([0-9.]+).*$" "\\1" ${_VAR} "${_LINE}") + IF(${_VAR} STREQUAL "${_LINE}") + SET(${_VAR}) + ENDIF() + IF(NOT ${_VAR} AND NOT STREQUAL "0") + SET(${_VAR} 0) + ENDIF() + ENDIF() + ENDFOREACH() + ENDFOREACH() + ENDIF() + ENDIF() +ENDMACRO() + +# macro to define FIND_PACKAGE options with a different package name +MACRO(FIX_PACKAGE_OPTIONS OLDNAME NEWNAME) + # append other options if needed + SET(_OPTIONS COMPONENTS REQUIRED QUIETLY) + + # process each options + FOREACH(_OPTION ${_OPTIONS}) + SET(OLD_OPTION ${OLDNAME}_FIND_${_OPTION}) + IF(DEFINED ) + SET(NEW_OPTION ${NEWNAME}_FIND_${_OPTION}) + SET(${NEW_OPTION} ${OLD_OPTION}) + ENDIF() + ENDFOREACH() +ENDMACRO() + +MACRO(FIND_PACKAGE_HELPER NAME INCLUDE) + # Looks for a directory containing NAME. + # + # NAME is the name of the library, lowercase and uppercase can be mixed + # It should be EXACTLY (same case) the same part as XXXX in FindXXXX.cmake + # + # INCLUDE is the file to check for includes + # + # Following parameters are optional variables and must be prefixed by: + # + # RELEASE is the list of libraries to check in release mode + # DEBUG is the list of libraries to check in debug mode + # SUFFIXES is the PATH_SUFFIXES to check for include file + # QUIET don't display anything + # VERBOSE display more details if not found + # REQUIRED throw an error if not found + # DIR is the base directory where to look for + # + # The first match will be used in the specified order and next matches will be ignored + # + # The following values are defined + # NAME_INCLUDE_DIR - where to find NAME + # NAME_LIBRARIES - link against these to use NAME + # NAME_FOUND - True if NAME is available. + + SET(_PARAMS ${ARGN}) + + SET(_RELEASE_LIBRARIES) + SET(_DEBUG_LIBRARIES) + SET(_SUFFIXES) + SET(_BASE_DIRECTORIES) + + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_VERBOSE OFF) + SET(_IS_DIR OFF) + + IF(_PARAMS) + FOREACH(_PARAM ${_PARAMS}) + IF(_PARAM STREQUAL "RELEASE") + SET(_IS_RELEASE ON) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "DEBUG") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG ON) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "SUFFIXES") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + SET(_IS_SUFFIXES ON) + ELSEIF(_PARAM STREQUAL "QUIET") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + SET(${NAME}_FIND_QUIETLY ON) + ELSEIF(_PARAM STREQUAL "VERBOSE") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + SET(_IS_VERBOSE ON) + ELSEIF(_PARAM STREQUAL "REQUIRED") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + SET(${NAME}_FIND_REQUIRED ON) + ELSEIF(_PARAM STREQUAL "DIR") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR ON) + ELSE() + IF(_IS_RELEASE) + LIST(APPEND _RELEASE_LIBRARIES ${_PARAM}) + ELSEIF(_IS_DEBUG) + LIST(APPEND _DEBUG_LIBRARIES ${_PARAM}) + ELSEIF(_IS_SUFFIXES) + LIST(APPEND _SUFFIXES ${_PARAM}) + ELSEIF(_IS_DIR) + LIST(APPEND _BASE_DIRECTORIES ${_PARAM}) + ELSE() + MESSAGE(STATUS "parameter ${_PARAM} with no prefix") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + # Fixes names if invalid characters are found + IF("${NAME}" MATCHES "^[a-zA-Z0-9]+$") + SET(_NAME_FIXED ${NAME}) + ELSE() + # if invalid characters are detected, replace them by valid ones + STRING(REPLACE "+" "p" _NAME_FIXED ${NAME}) + ENDIF() + + # Create uppercase and lowercase versions of NAME + STRING(TOUPPER ${NAME} _UPNAME) + STRING(TOLOWER ${NAME} _LOWNAME) + + STRING(TOUPPER ${_NAME_FIXED} _UPNAME_FIXED) + STRING(TOLOWER ${_NAME_FIXED} _LOWNAME_FIXED) + + SET(_SUFFIXES ${_SUFFIXES} ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME}) + +# Don't use pkg-config +# IF(NOT WIN32 AND NOT IOS) +# FIND_PACKAGE(PkgConfig QUIET) +# SET(_MODULES ${_LOWNAME} ${_RELEASE_LIBRARIES}) +# LIST(REMOVE_DUPLICATES _MODULES) +# IF(PKG_CONFIG_EXECUTABLE) +# PKG_SEARCH_MODULE(PKG_${_NAME_FIXED} QUIET ${_MODULES}) +# ENDIF() +# ENDIF() + + SET(_INCLUDE_PATHS) + SET(_LIBRARY_PATHS) + + # Check for root directories passed to CMake with -DXXX_DIR=... + IF(DEFINED ${_UPNAME_FIXED}_DIR) + SET(_TMP ${${_UPNAME_FIXED}_DIR}) + GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE) + LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP}) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(DEFINED ${_UPNAME}_DIR) + SET(_TMP ${${_UPNAME}_DIR}) + LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP}) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(_BASE_DIRECTORIES) + FOREACH(_DIR ${_BASE_DIRECTORIES}) + IF(_DIR) + LIST(APPEND _INCLUDE_PATHS ${_DIR}/include ${_DIR}) + LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_DIR} as root directory") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + IF(UNIX) + # Append UNIX standard include paths + SET(_UNIX_INCLUDE_PATHS) + + # Append multiarch include paths + IF(CMAKE_LIBRARY_ARCHITECTURE) + LIST(APPEND _UNIX_INCLUDE_PATHS + /usr/local/include/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/include/${CMAKE_LIBRARY_ARCHITECTURE}) + ENDIF() + + LIST(APPEND _UNIX_INCLUDE_PATHS + /usr/local/include + /usr/include + /sw/include + /opt/local/include + /opt/csw/include + /opt/include) + ENDIF() + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Searching header ${INCLUDE} in: ${_INCLUDE_PATHS} with suffixes ${_SUFFIXES}") + ENDIF() + + # Search for include directory + FIND_PATH(${_UPNAME_FIXED}_INCLUDE_DIR + NAMES ${INCLUDE} + HINTS + ${PKG_${_NAME_FIXED}_INCLUDE_DIRS} + ${_INCLUDE_PATHS} + $ENV{${_UPNAME}_DIR}/include + $ENV{${_UPNAME_FIXED}_DIR}/include + $ENV{${_UPNAME}_DIR} + $ENV{${_UPNAME_FIXED}_DIR} + PATHS + ${_UNIX_INCLUDE_PATHS} + PATH_SUFFIXES + ${_SUFFIXES} + DOC "Include path for ${NAME}" + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_INCLUDE_DIR) + MESSAGE(STATUS "${INCLUDE} found in ${${_UPNAME_FIXED}_INCLUDE_DIR}") + ELSE() + MESSAGE(STATUS "${INCLUDE} not found") + ENDIF() + ENDIF() + + # Append environment variables XXX_DIR + LIST(APPEND _LIBRARY_PATHS + $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX} + $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX}) + + IF(UNIX) + SET(_UNIX_LIBRARY_PATHS) + + # Append multiarch libraries paths + IF(CMAKE_LIBRARY_ARCHITECTURE) + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}) + ENDIF() + + # Append UNIX standard libraries paths + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib + /usr/lib + /lib + /usr/local/X11R6/lib + /usr/X11R6/lib + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib${LIB_SUFFIX}) + ENDIF() + + LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED}) + LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d) + + # Under Windows, some libs may need the lib prefix + IF(WIN32) + SET(_LIBS ${_RELEASE_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _RELEASE_LIBRARIES lib${_LIB}) + ENDFOREACH() + + SET(_LIBS ${_DEBUG_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _DEBUG_LIBRARIES lib${_LIB}) + ENDFOREACH() + ENDIF() + + LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES) + LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES) + + # Search for release library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE + NAMES + ${_RELEASE_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}") + ELSE() + MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}") + ENDIF() + ENDIF() + + # Search for debug library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG + NAMES + ${_DEBUG_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}") + ELSE() + MESSAGE(STATUS "${NAME} debug library not found") + ENDIF() + ENDIF() + + SET(${_UPNAME_FIXED}_FOUND OFF) + + IF(${_UPNAME_FIXED}_INCLUDE_DIR) + # Set also _INCLUDE_DIRS + SET(${_UPNAME_FIXED}_INCLUDE_DIRS ${${_UPNAME_FIXED}_INCLUDE_DIR}) + ENDIF() + + # Library has been found if at least only one library and include are found + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Release and debug libraries found + SET(${_UPNAME_FIXED}_FOUND ON) + SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + # Release library found + SET(${_UPNAME_FIXED}_FOUND ON) + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Debug library found + SET(${_UPNAME_FIXED}_FOUND ON) + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + ENDIF() + + IF(${_UPNAME_FIXED}_FOUND) + IF(NOT ${NAME}_FIND_QUIETLY) + MESSAGE(STATUS "Found ${NAME}: ${${_UPNAME_FIXED}_LIBRARIES}") + ENDIF() + ELSE() + IF(${NAME}_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Error: Unable to find ${NAME}!") + ENDIF() + IF(NOT ${NAME}_FIND_QUIETLY) + MESSAGE(STATUS "Warning: Unable to find ${NAME}!") + ENDIF() + ENDIF() + + MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG) +ENDMACRO() + +MACRO(MESSAGE_VERSION_PACKAGE_HELPER NAME VERSION) + MESSAGE(STATUS "Found ${NAME} ${VERSION}: ${ARGN}") +ENDMACRO() + +MACRO(FIND_LIBRARY_HELPER NAME) + # Looks for libraries. + # + # NAME is the name of the library, lowercase and uppercase can be mixed + # + # Following parameters are optional variables and must be prefixed by: + # + # RELEASE is the list of libraries to check in release mode + # DEBUG is the list of libraries to check in debug mode + # VERBOSE display more details if not found + # REQUIRED throw an error if not found + # DIR is the base directory where to look for + # + # The first match will be used in the specified order and next matches will be ignored + # + # The following values are defined + # NAME_LIBRARIES - link against these to use NAME + + SET(_PARAMS ${ARGN}) + + SET(_RELEASE_LIBRARIES) + SET(_DEBUG_LIBRARIES) + SET(_BASE_DIRECTORIES) + + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_VERBOSE OFF) + SET(_IS_DIR OFF) + + IF(_PARAMS) + FOREACH(_PARAM ${_PARAMS}) + IF(_PARAM STREQUAL "RELEASE") + SET(_IS_RELEASE ON) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "DEBUG") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG ON) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "VERBOSE") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + SET(_IS_VERBOSE ON) + ELSEIF(_PARAM STREQUAL "REQUIRED") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + SET(${NAME}_FIND_REQUIRED ON) + ELSEIF(_PARAM STREQUAL "DIR") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR ON) + ELSE() + IF(_IS_RELEASE) + LIST(APPEND _RELEASE_LIBRARIES ${_PARAM}) + ELSEIF(_IS_DEBUG) + LIST(APPEND _DEBUG_LIBRARIES ${_PARAM}) + ELSEIF(_IS_DIR) + LIST(APPEND _BASE_DIRECTORIES ${_PARAM}) + ELSE() + MESSAGE(STATUS "parameter ${_PARAM} with no prefix") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + # Fixes names if invalid characters are found + IF("${NAME}" MATCHES "^[a-zA-Z0-9]+$") + SET(_NAME_FIXED ${NAME}) + ELSE() + # if invalid characters are detected, replace them by valid ones + STRING(REPLACE "+" "p" _NAME_FIXED ${NAME}) + ENDIF() + + # Create uppercase and lowercase versions of NAME + STRING(TOUPPER ${NAME} _UPNAME) + STRING(TOLOWER ${NAME} _LOWNAME) + + STRING(TOUPPER ${_NAME_FIXED} _UPNAME_FIXED) + STRING(TOLOWER ${_NAME_FIXED} _LOWNAME_FIXED) + + SET(_LIBRARY_PATHS) + + # Check for root directories passed to CMake with -DXXX_DIR=... + IF(DEFINED ${_UPNAME_FIXED}_DIR) + SET(_TMP ${${_UPNAME_FIXED}_DIR}) + GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(DEFINED ${_UPNAME}_DIR) + SET(_TMP ${${_UPNAME}_DIR}) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(_BASE_DIRECTORIES) + FOREACH(_DIR ${_BASE_DIRECTORIES}) + IF(_DIR) + LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_DIR} as root directory") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + # Append environment variables XXX_DIR + LIST(APPEND _LIBRARY_PATHS + $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX} + $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX}) + + IF(UNIX) + SET(_UNIX_LIBRARY_PATHS) + + # Append multiarch libraries paths + IF(CMAKE_LIBRARY_ARCHITECTURE) + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}) + ENDIF() + + # Append UNIX standard libraries paths + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib + /usr/lib + /lib + /usr/local/X11R6/lib + /usr/X11R6/lib + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib${LIB_SUFFIX}) + ENDIF() + + LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED}) + LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d) + + # Under Windows, some libs may need the lib prefix + IF(WIN32) + SET(_LIBS ${_RELEASE_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _RELEASE_LIBRARIES lib${_LIB}) + ENDFOREACH() + + SET(_LIBS ${_DEBUG_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _DEBUG_LIBRARIES lib${_LIB}) + ENDFOREACH() + ENDIF() + + LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES) + LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES) + + # Search for release library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE + NAMES + ${_RELEASE_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}") + ELSE() + MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}") + ENDIF() + ENDIF() + + # Search for debug library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG + NAMES + ${_DEBUG_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}") + ELSE() + MESSAGE(STATUS "${NAME} debug library not found") + ENDIF() + ENDIF() + + # Library has been found if at least only one library and include are found + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Release and debug libraries found + SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + # Release library found + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Debug library found + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + ENDIF() + + MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG) +ENDMACRO() + +MACRO(FIND_LIBCURL) + IF(NOT CURL_FOUND) + FIND_PACKAGE(CURL REQUIRED) + + IF(WIN32 OR CURL_LIBRARY MATCHES "\\.a" OR WITH_STATIC_CURL) + SET(CURL_STATIC ON) + ELSE() + SET(CURL_STATIC OFF) + ENDIF() + + IF(CURL_STATIC) + SET(CURL_DEFINITIONS -DCURL_STATICLIB) + + IF(UNIX) + # CURL can depend on libidn + FIND_LIBRARY(IDN_LIBRARY idn) + IF(IDN_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY}) + ENDIF() + + # CURL Macports version can depend on libidn, libintl and libiconv too + IF(APPLE) + FIND_LIBRARY(INTL_LIBRARY intl) + IF(INTL_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY}) + ENDIF() + ELSE() + # Only used by libcurl under Linux + FIND_PACKAGE(OpenSSL REQUIRED) + + #IF(WIN32) + # SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib) + #ENDIF() + + # Only Linux version of libcurl depends on OpenSSL + LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) + LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES}) + ENDIF() + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() + +MACRO(FIND_LIBXML2) + IF(NOT LIBXML2_FOUND) + FIND_PACKAGE(LibXml2 REQUIRED) + + IF(WIN32 OR WITH_STATIC_LIBXML2) + LIST(APPEND LIBXML2_DEFINITIONS -DLIBXML_STATIC) + ENDIF() + + IF(WITH_LIBXML2_ICONV) + FIND_PACKAGE(Iconv REQUIRED) +# LIST(APPEND CURL_INCLUDE_DIRS ${ICONV_INCLUDE_DIR}) + LIST(APPEND LIBXML2_LIBRARIES ${ICONV_LIBRARIES}) + ENDIF() + + IF(WITH_STATIC) + # libxml2 could need winsock2 library + IF(WIN32) + FIND_LIBRARY(WINSOCK2_LIB ws2_32) + + IF(WINSOCK2_LIB) + LIST(APPEND LIBXML2_LIBRARIES ${WINSOCK2_LIB}) + ENDIF() + + FIND_LIBRARY(CRYPT32_LIB Crypt32) + + IF(CRYPT32_LIB) + LIST(APPEND LIBXML2_LIBRARIES ${CRYPT32_LIB}) + ENDIF() + ELSE() + # under Linux and OS X, recent libxml2 versions are linked against liblzma + FIND_PACKAGE(LibLZMA) + + IF(LIBLZMA_LIBRARIES) + LIST(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES}) + ENDIF() + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() + +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}) + LIST(APPEND QT_LIBRARIES optimized ${_LIB}) + ENDIF() + SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}") + IF(EXISTS ${_LIB}) + LIST(APPEND 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}) + LIST(APPEND QT_LIBRARIES optimized ${_LIB}) + ENDIF() + SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}") + IF(EXISTS ${_LIB}) + LIST(APPEND QT_LIBRARIES debug ${_LIB}) + ENDIF() +ENDMACRO() + +MACRO(ADD_QT_SYSTEM_LIBRARY _NAME) + # Save default suffixes + SET(_OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + + # Define specific suffixes + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) + + # Find the library with specified suffixes + FIND_LIBRARY(${_NAME}_LIBRARY NAMES ${_NAME}) + + # Restore default suffixes + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_OLD_SUFFIXES}) + + IF(${_NAME}_LIBRARY) + MESSAGE(STATUS "Found ${${_NAME}_LIBRARY} ${_NAME}") + + LIST(APPEND QT_LIBRARIES ${${_NAME}_LIBRARY}) + ELSE() + MESSAGE(STATUS "Didn't find ${_NAME}") + ENDIF() +ENDMACRO() + +MACRO(FIND_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) + FIND_PACKAGE(PNG REQUIRED) + FIND_PACKAGE(Jpeg REQUIRED) + + ADD_DEFINITIONS(-DQT_STATICPLUGIN) + + SET(QT_LIBRARIES Qt5::Widgets) + + # Gui + LIST(APPEND QT_LIBRARIES Qt5::Gui Qt5::OpenGL) + + ADD_QT_LIBRARY(PrintSupport) + + IF(WIN32) + LIST(APPEND 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) + + LIST(APPEND 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(GlxSupport) + ADD_QT_LIBRARY(ServiceSupport) + ADD_QT_LIBRARY(EdidSupport) + ADD_QT_LIBRARY(FontDatabaseSupport) + ADD_QT_LIBRARY(ThemeSupport) + ADD_QT_LIBRARY(EventDispatcherSupport) + ADD_QT_LIBRARY(PlatformSupport) + + ADD_QT_LIBRARY(DBus) + + IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a") + LIST(APPEND QT_LIBRARIES "${QT_LIBRARY_DIR}/libxcb-static.a") + ENDIF() + + # always link these in dynamic, API never changes + ADD_QT_SYSTEM_LIBRARY(X11) + ADD_QT_SYSTEM_LIBRARY(Xmu) + ADD_QT_SYSTEM_LIBRARY(X11-xcb) + ADD_QT_SYSTEM_LIBRARY(Xi) + ADD_QT_SYSTEM_LIBRARY(SM) + ADD_QT_SYSTEM_LIBRARY(ICE) + ADD_QT_SYSTEM_LIBRARY(xcb) + ADD_QT_SYSTEM_LIBRARY(GL) + ADD_QT_SYSTEM_LIBRARY(xcb-glx) + ADD_QT_SYSTEM_LIBRARY(fontconfig) + ADD_QT_SYSTEM_LIBRARY(Xrender) + 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") + IF(NOT EXISTS ${HB_LIB}) + SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzz.a") + ENDIF() + ELSEIF(WIN32) + SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib") + ENDIF() + IF(EXISTS ${HB_LIB}) + LIST(APPEND QT_LIBRARIES ${HB_LIB}) + ENDIF() + + # freetype is needed since Qt 5.5 + FIND_PACKAGE(Freetype) + + IF(FREETYPE_FOUND) + LIST(APPEND QT_LIBRARIES ${FREETYPE_LIBRARIES}) + ELSE() + 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}) + LIST(APPEND QT_LIBRARIES ${FREETYPE_LIB}) + ENDIF() + ENDIF() + + ADD_QT_PLUGIN(accessible qtaccessiblewidgets) + + LIST(APPEND QT_LIBRARIES ${PNG_LIBRARIES} ${JPEG_LIBRARY}) + + # Network + LIST(APPEND QT_LIBRARIES Qt5::Network Qt5::Xml) + LIST(APPEND QT_LIBRARIES ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) + + IF(WIN32) + LIST(APPEND QT_LIBRARIES + ${WINSDK_LIBRARY_DIR}/Crypt32.lib + ${WINSDK_LIBRARY_DIR}/WS2_32.Lib + ${WINSDK_LIBRARY_DIR}/IPHlpApi.Lib) + ENDIF() + + # Core + LIST(APPEND QT_LIBRARIES Qt5::Core) + + # pcre is needed since Qt 5.5 + IF(UNIX) + SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a") + IF(NOT EXISTS ${PCRE_LIB}) + SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre2.a") + ENDIF() + ELSEIF(WIN32) + SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib") + ENDIF() + IF(EXISTS ${PCRE_LIB}) + LIST(APPEND QT_LIBRARIES ${PCRE_LIB}) + ENDIF() + + IF(APPLE) + FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre) + + FIND_LIBRARY(SECURITY_FRAMEWORK Security) + + LIST(APPEND QT_LIBRARIES + ${PCRE_LIBRARY} + ${FOUNDATION_FRAMEWORK} + ${CARBON_FRAMEWORK} + ${SECURITY_FRAMEWORK}) + ELSEIF(UNIX) + FIND_PACKAGE(Threads) + LIST(APPEND QT_LIBRARIES ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} -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() +ENDMACRO() diff --git a/code/CMakeModules/FindLIBGSF.cmake b/code/CMakeModules/FindLIBGSF.cmake new file mode 100644 index 000000000..8d749a87d --- /dev/null +++ b/code/CMakeModules/FindLIBGSF.cmake @@ -0,0 +1,57 @@ +# - Try to find libGSF +# +# Once done this will define +# +# LIBGSF_FOUND - System has LibGSF +# LIBGSF_INCLUDE_DIR - The LibGSF include directory +# LIBGSF_LIBRARIES - The libraries needed to use LibGSF +# LIBGSF_DEFINITIONS - Compiler switches required for using LibGSF +# LIBGSF_GSF_EXECUTABLE - The archive utility +# LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE - The office files thumbnailer for the GNOME desktop +# LIBGSF_GSFVBADUMP_EXECUTABLE - The utility to extract Visual Basic for Applications macros + +# Copyright (c) 2009, Pau Garcia i Quiles +# Based off FindLibXml2.cmake from CMake 2.6.4 by Alexander Neundorf +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +IF (LIBGSF_INCLUDE_DIR AND LIBGSF_LIBRARIES) + # in cache already + SET(LIBGSF_FIND_QUIETLY TRUE) +ENDIF (LIBGSF_INCLUDE_DIR AND LIBGSF_LIBRARIES) + +IF (NOT WIN32) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + FIND_PACKAGE(PkgConfig) + PKG_CHECK_MODULES(PC_LIBGSF libgsf-1) + SET(LIBGSF_DEFINITIONS ${PC_LIBGSF_CFLAGS_OTHER}) +ENDIF (NOT WIN32) + +FIND_PATH(LIBGSF_INCLUDE_DIR gsf/gsf.h + HINTS + ${PC_LIBGSF_INCLUDEDIR} + ${PC_LIBGSF_INCLUDE_DIRS} + PATH_SUFFIXES libgsf-1 + ) + +FIND_LIBRARY(LIBGSF_LIBRARIES NAMES gsf-1 libgsf-1 + HINTS + ${PC_LIBGSF_LIBDIR} + ${PC_LIBGSF_LIBRARY_DIRS} + ) + +FIND_PROGRAM(LIBGSF_GSF_EXECUTABLE gsf) +FIND_PROGRAM(LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE gsf-office-thumbnailer) +FIND_PROGRAM(LIBGSF_GSFVBADUMP_EXECUTABLE gsf-vba-dump) + +INCLUDE(FindPackageHandleStandardArgs) + +# handle the QUIETLY and REQUIRED arguments and set LIBGSF_FOUND to TRUE if +# all listed variables are TRUE +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBGSF DEFAULT_MSG LIBGSF_LIBRARIES LIBGSF_INCLUDE_DIR) + +MARK_AS_ADVANCED(LIBGSF_INCLUDE_DIR LIBGSF_LIBRARIES LIBGSF_GSF_EXECUTABLE LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE LIBGSF_GSFVBADUMP_EXECUTABLE ) + diff --git a/code/CMakeModules/FindMySQL.cmake b/code/CMakeModules/FindMySQL.cmake index 8a92cb0c4..631a96224 100644 --- a/code/CMakeModules/FindMySQL.cmake +++ b/code/CMakeModules/FindMySQL.cmake @@ -16,10 +16,12 @@ IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) ELSE() FIND_PATH(MYSQL_INCLUDE_DIR mysql.h - PATH_SUFFIXES mysql + PATH_SUFFIXES mysql mariadb PATHS /usr/include/mysql + /usr/include/mariadb /usr/local/include/mysql + /usr/local/include/mariadb /opt/local/include/mysql5/mysql /opt/local/include/mysql55/mysql /opt/local/include/mysql51/mysql @@ -27,28 +29,29 @@ ELSE() $ENV{SystemDrive}/MySQL/*/include) IF(WIN32 AND MSVC) - FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES libmysql mysqlclient + FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES libmysql mysqlclient libmariadb mariadbclient PATHS $ENV{ProgramFiles}/MySQL/*/lib/opt $ENV{SystemDrive}/MySQL/*/lib/opt) - - FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES libmysqld mysqlclientd + FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES libmysqld mysqlclientd libmariadb mariadbclient PATHS $ENV{ProgramFiles}/MySQL/*/lib/opt $ENV{SystemDrive}/MySQL/*/lib/opt) ELSE() - FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient + FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient mariadbclient PATHS /usr/lib /usr/local/lib + /usr/lib/mariadb /usr/lib/mysql /usr/local/lib/mysql + /usr/local/lib/mariadb /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 mariadbclientd PATHS /usr/lib /usr/local/lib @@ -80,6 +83,10 @@ ELSE() IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) SET(MYSQL_FOUND TRUE) MESSAGE(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}") + IF (MYSQL_LIBRARIES MATCHES "libmariadb" OR MYSQL_LIBRARIES MATCHES "mariadbclient") + SET(MARIADB_FOUND TRUE) + MESSAGE(STATUS "Found MariaDB.") + ENDIF() ELSE() SET(MYSQL_FOUND FALSE) MESSAGE(STATUS "MySQL not found.") diff --git a/code/CMakeModules/FindNeL.cmake b/code/CMakeModules/FindNeL.cmake new file mode 100644 index 000000000..e75163cce --- /dev/null +++ b/code/CMakeModules/FindNeL.cmake @@ -0,0 +1,398 @@ +# NEL_DIR can be specified as root directory + +# Returned variables +# NELDRIVER_XXX_BINARY_DEBUG +# NELDRIVER_XXX_BINARY_RELEASE +# NELDRIVER_XXX_LIBRARY_DEBUG +# NELDRIVER_XXX_LIBRARY_RELEASE +# NELDRIVER_XXX_FOUND +# NEL_DEFINITIONS +# NEL_INCLUDE_DIR +# NEL_INCLUDE_DIRS +# NEL_LIBRARIES +# NELXXX_FOUND +# NELXXX_LIBRARIES + + +INCLUDE(FindHelpers) + +# Init all variables we'll set +SET(NEL_LIBRARIES) +SET(NEL_INCLUDE_DIR) +SET(NEL_INCLUDE_DIRS) +SET(NEL_VERSION) +SET(NEL_STATIC) +SET(NEL_STATIC_DRIVERS) +SET(NEL_VERSION_MAJOR) +SET(NEL_VERSION_MINOR) +SET(NEL_VERSION_PATCH) +SET(NEL_REVISION) +SET(NEL_VERSION) + +SET(NEL_MODULES_FOUND) +SET(NEL_MODULES_AVAILABLE 3d georges gui ligo logic net pacs sound) # cegui pipeline + +SET(NEL_DRIVERS_FOUND) +SET(NEL_DRIVERS_AVAILABLE opengl opengles direct3d dsound fmod openal xaudio2) + +SET(NELMISC_FIND_REQUIRED ${NeL_FIND_REQUIRED}) + +# Force search of NELMISC +FIND_PACKAGE_HELPER(nelmisc nel/misc/types_nl.h RELEASE nelmisc_r nelmisc DEBUG nelmisc_d DIR ${NEL_DIR} VERBOSE QUIET) + +IF(NELMISC_FOUND) + # define NEL_DIR if not specified + IF(NOT NEL_DIR) + GET_FILENAME_COMPONENT(NEL_DIR ${NELMISC_INCLUDE_DIR}/.. ABSOLUTE) + ENDIF() + + # Aliases for include directory + SET(NEL_INCLUDE_DIR ${NELMISC_INCLUDE_DIR}) + SET(NEL_INCLUDE_DIRS ${NEL_INCLUDE_DIR}) + + MESSAGE(STATUS "Found NeL headers in ${NEL_INCLUDE_DIR}") + + GET_FILENAME_COMPONENT(NEL_LIBRARY_DIR ${NELMISC_LIBRARY} DIRECTORY) + + MESSAGE(STATUS "Found NeL library in ${NEL_LIBRARY_DIR}") + + # TODO: implement static version checks for Windows + + # static libraries + IF(UNIX) + GET_FILENAME_COMPONENT(_LIBEXT ${NELMISC_LIBRARY} EXT) + + IF(_LIBEXT STREQUAL ".a") + SET(NEL_STATIC ON) + MESSAGE(STATUS "NeL is using static libraries") + ENDIF() + ENDIF() + + IF(WIN32) + SET(NELDRIVER_DIRS_TO_CHECK + ${NEL_DIR}/bin${LIB_SUFFIX} + ${NEL_DIR} + ) + ELSE() + SET(NELDRIVER_DIRS_TO_CHECK + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}/nel + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/nel + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/nel + /usr/lib + ) + ENDIF() + + # check for static drivers + FOREACH(_DRIVER ${NEL_DRIVERS_AVAILABLE}) + IF(WIN32) + SET(_DRIVER_RELASE_FILE "nel_drv_${_DRIVER}_win_r") + SET(_DRIVER_DEBUG_FILE "nel_drv_${_DRIVER}_win_d") + SET(_DRIVER_SHARED_EXT dll) + SET(_DRIVER_STATIC_EXT lib) + ELSE() + SET(_DRIVER_RELEASE_FILE "nel_drv_${_DRIVER}") + SET(_DRIVER_DEBUG_FILE) + SET(_DRIVER_SHARED_EXT so) + SET(_DRIVER_STATIC_EXT a) + ENDIF() + + STRING(TOUPPER ${_DRIVER} _UPDRIVER) + + FOREACH(_DIR ${NELDRIVER_DIRS_TO_CHECK}) + SET(_FOUND OFF) + + IF(_DRIVER_RELASE_FILE) + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_SHARED_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_BINARY_RELEASE ${_FILE}) + + MESSAGE(STATUS "Found NeL release shared driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS OFF) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_STATIC_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_LIBRARY_RELEASE ${_FILE}) + + MESSAGE(STATUS "Found NeL release static driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS ON) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + ENDIF() + + IF(_DRIVER_DEBUG_FILE) + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_SHARED_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_BINARY_DEBUG ${_FILE}) + + MESSAGE(STATUS "Found NeL debug shared driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS OFF) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_STATIC_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_LIBRARY_DEBUG ${_FILE}) + + MESSAGE(STATUS "Found NeL debug static driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS ON) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + + IF(_FOUND) + SET(NELDRIVER_${_UPDRIVER}_FOUND ON) + LIST(APPEND NEL_DRIVERS_FOUND ${_DRIVER}) + ENDIF() + ENDIF() + ENDFOREACH() + ENDFOREACH() + + MESSAGE(STATUS "Found NeL driver in ${NEL_DRIVER_DIR}") + + PARSE_VERSION_OTHER(${NEL_INCLUDE_DIR}/nel/misc/version_nl.h NL_VERSION_MAJOR NL_VERSION_MINOR NL_VERSION_PATCH NL_REVISION) + + SET(NEL_VERSION_MAJOR ${NL_VERSION_MAJOR}) + SET(NEL_VERSION_MINOR ${NL_VERSION_MINOR}) + SET(NEL_VERSION_PATCH ${NL_VERSION_PATCH}) + SET(NEL_REVISION ${NL_REVISION}) + + IF(NOT NEL_VERSION) + IF(NEL_VERSION_MAJOR OR NEL_VERSION_MINOR} OR NEL_VERSION_PATCH) + SET(NEL_VERSION "${NEL_VERSION_MAJOR}.${NEL_VERSION_MINOR}.${NEL_VERSION_PATCH}") + ELSE() + SET(NEL_VERSION "0.5.0") + ENDIF() + + IF(NEL_REVISION) + SET(NEL_VERSION "${NEL_VERSION}.${NEL_REVISION}") + ENDIF() + ENDIF() + + FIND_PACKAGE(PNG REQUIRED) + IF(PNG_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${PNG_LIBRARIES}) + ENDIF() + + FIND_PACKAGE(Jpeg REQUIRED) + IF(JPEG_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${JPEG_LIBRARY}) + ENDIF() + + FIND_PACKAGE(GIF) + + IF(GIF_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${GIF_LIBRARY}) + ENDIF() + + FIND_LIBXML2() + + IF(LIBXML2_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${LIBXML2_LIBRARIES}) + ENDIF() + + LIST(REMOVE_ITEM NeL_FIND_COMPONENTS misc) + + LIST(APPEND NEL_MODULES_FOUND misc) + LIST(APPEND NEL_LIBRARIES ${NELMISC_LIBRARIES}) +ENDIF() + +IF(NOT NeL_FIND_COMPONENTS) + SET(NeL_FIND_COMPONENTS ${NEL_MODULES_AVAILABLE}) + + # We can skip not installed modules + SET(NeL_FIND_REQUIRED OFF) +ENDIF() + +FOREACH(COMPONENT ${NeL_FIND_COMPONENTS}) + SET(_NAME NeL${COMPONENT}) + STRING(TOUPPER ${_NAME} _UPNAME) + + # module is required + SET(${_NAME}_FIND_REQUIRED ${NeL_FIND_REQUIRED}) + + IF(COMPONENT STREQUAL "3d") + SET(HEADER_FILE shape.h) +# ELSEIF(COMPONENT STREQUAL "cegui") +# SET(HEADER_FILE shape.h) + ELSEIF(COMPONENT STREQUAL "georges") + SET(HEADER_FILE form.h) + ELSEIF(COMPONENT STREQUAL "gui") + SET(HEADER_FILE reflect.h) + ELSEIF(COMPONENT STREQUAL "ligo") + SET(HEADER_FILE primitive.h) + ELSEIF(COMPONENT STREQUAL "logic") + SET(HEADER_FILE logic_state.h) + ELSEIF(COMPONENT STREQUAL "net") + SET(HEADER_FILE sock.h) + ELSEIF(COMPONENT STREQUAL "pacs") + SET(HEADER_FILE primitive_block.h) +# ELSEIF(COMPONENT STREQUAL "pipeline") +# SET(HEADER_FILE shape.h) + ELSEIF(COMPONENT STREQUAL "sound") + SET(HEADER_FILE shape.h) + ELSE() + SET(HEADER_FILE) + ENDIF() + + # display if a component has a wrong name + IF(NOT HEADER_FILE) + MESSAGE(STATUS "NeL module ${COMPONENT} not supported, ignoring it...") + CONTINUE() + ENDIF() + + FIND_PACKAGE_HELPER(${_NAME} nel/${COMPONENT}/${HEADER_FILE} + RELEASE nel${COMPONENT}_r nel${COMPONENT} + DEBUG nel${COMPONENT}_d + QUIET) + + IF(${_UPNAME}_FOUND) + LIST(APPEND NEL_MODULES_FOUND ${COMPONENT}) + + IF(COMPONENT STREQUAL "3d") + IF(NEL_STATIC) + # 3rd party dependencies + FIND_PACKAGE(Freetype REQUIRED) + IF(FREETYPE_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${FREETYPE_LIBRARIES}) + ENDIF() + + # Append static 3D drivers + IF(NEL_STATIC_DRIVERS) + # Direct3D driver (only under Windows) + IF(WIN32) + IF(NELDRIVER_DIRECT3D_LIBRARY_DEBUG) + LIST(APPEND ${_UPNAME}_LIBRARIES debug ${NELDRIVER_DIRECT3D_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_DIRECT3D_LIBRARY_RELEASE) + LIST(APPEND ${_UPNAME}_LIBRARIES optimized ${NELDRIVER_DIRECT3D_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + + # OpenGL driver + IF(NELDRIVER_OPENGL_LIBRARY_DEBUG) + LIST(APPEND ${_UPNAME}_LIBRARIES debug ${NELDRIVER_OPENGL_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_OPENGL_LIBRARY_RELEASE) + LIST(APPEND ${_UPNAME}_LIBRARIES optimized ${NELDRIVER_OPENGL_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + ENDIF() + ELSEIF(COMPONENT STREQUAL "gui") + FIND_PACKAGE(Luabind REQUIRED) + + LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES}) + + FIND_LIBCURL() + + IF(CURL_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${CURL_LIBRARIES}) + LIST(APPEND ${_UPNAME}_DEFINITIONS ${CURL_DEFINITIONS}) + ENDIF() + + # TODO: remove complately OpenSSL requirement on Windows + + # Only used by libcurl under Linux + FIND_PACKAGE(OpenSSL REQUIRED) + + IF(WIN32) + LIST(APPEND OPENSSL_LIBRARIES Crypt32.lib) + ENDIF() + + # Only Linux version of libcurl depends on OpenSSL + LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) + LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES}) + + LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES} ${CURL_LIBRARIES}) + LIST(APPEND NEL_DEFINITIONS ${${_UPNAME}_DEFINITIONS}) + ELSEIF(COMPONENT STREQUAL "sound") + FIND_PACKAGE(Ogg REQUIRED) + + IF(OGG_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${OGG_LIBRARY}) + ENDIF() + + FIND_PACKAGE(Vorbis REQUIRED) + + IF(VORBIS_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY}) + ENDIF() + + IF(NEL_STATIC) + # Link to snd_lowlevel + FIND_LIBRARY_HELPER(nelsnd_lowlevel RELEASE nelsnd_lowlevel_r DEBUG nelsnd_lowlevel_d DIR ${NEL_DIR} REQUIRED) + + IF(NELSND_LOWLEVEL_LIBRARIES) + MESSAGE(STATUS "Found NeL sound lowlevel ${NELSND_LOWLEVEL_LIBRARIES}") + + LIST(APPEND NELSOUND_LIBRARIES ${NELSND_LOWLEVEL_LIBRARIES}) + + IF(NEL_STATIC_DRIVERS) + # DirectSound, XAudio2 and FMod drivers (only under Windows) + IF(WIN32) + # DirectSound + IF(NELDRIVER_DIRECTSOUND_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_DIRECTSOUND_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_DIRECTSOUND_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_DIRECTSOUND_LIBRARY_RELEASE}) + ENDIF() + + # FMod + IF(NELDRIVER_FMOD_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_FMOD_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_FMOD_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_FMOD_LIBRARY_RELEASE}) + ENDIF() + + # XAudio2 + IF(NELDRIVER_XAUDIO2_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_XAUDIO2_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_XAUDIO2_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_XAUDIO2_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + + # OpenAL driver + IF(NELDRIVER_OPENAL_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_OPENAL_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_OPENAL_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_OPENAL_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + ENDIF() + ENDIF() + ENDIF() + + LIST(APPEND NEL_LIBRARIES ${${_UPNAME}_LIBRARIES}) + ENDIF() +ENDFOREACH() + +MESSAGE_VERSION_PACKAGE_HELPER(NeL ${NEL_VERSION} ${NEL_MODULES_FOUND}) diff --git a/code/CMakeModules/FindRyzomGameShare.cmake b/code/CMakeModules/FindRyzomGameShare.cmake new file mode 100644 index 000000000..f76e4dd93 --- /dev/null +++ b/code/CMakeModules/FindRyzomGameShare.cmake @@ -0,0 +1,14 @@ +INCLUDE(FindHelpers) + +FIND_PACKAGE_HELPER(RyzomGameShare game_share/continent.h RELEASE ryzom_gameshare_r ryzom_gameshare DEBUG ryzom_gameshare_d DIR ${NEL_DIR} ${RYZOM_DIR} SUFFIXES ryzom) + +IF(RYZOMGAMESHARE_FOUND) + FIND_PACKAGE(NeL REQUIRED) + LIST(APPEND RYZOMGAMESHARE_INCLUDE_DIRS ${NEL_INCLUDE_DIRS}) + LIST(APPEND RYZOMGAMESHARE_LIBRARIES ${NELMISC_LIBRARIES} ${NELLIGO_LIBRARIES} ${NELNET_LIBRARIES} ${NELGEORGES_LIBRARIES}) + + SET(RYZOM_GAMESHARE_LIBRARIES ${RYZOMGAMESHARE_LIBRARIES}) + SET(RYZOM_GAMESHARE_FOUND ${RYZOMGAMESHARE_FOUND}) + SET(RYZOM_GAMESHARE_INCLUDE_DIR ${RYZOMGAMESHARE_INCLUDE_DIR}) + SET(RYZOM_GAMESHARE_INCLUDE_DIRS ${RYZOMGAMESHARE_INCLUDE_DIRS}) +ENDIF() diff --git a/code/CMakeModules/FindSteam.cmake b/code/CMakeModules/FindSteam.cmake index 44013e6ed..8d9b12372 100644 --- a/code/CMakeModules/FindSteam.cmake +++ b/code/CMakeModules/FindSteam.cmake @@ -1,8 +1,8 @@ # - Locate Steam API # This module defines # STEAM_LIBRARY, the library to link against -# VORBIS_FOUND, if false, do not try to link to VORBIS -# VORBIS_INCLUDE_DIR, where to find headers. +# STEAM_FOUND, if false, do not try to link to STEAM +# STEAM_INCLUDE_DIR, where to find headers. IF(STEAM_LIBRARY AND STEAM_INCLUDE_DIR) # in cache already diff --git a/code/CMakeModules/GetRevision.cmake b/code/CMakeModules/GetRevision.cmake index b9bd6eb84..17a617ba3 100644 --- a/code/CMakeModules/GetRevision.cmake +++ b/code/CMakeModules/GetRevision.cmake @@ -98,4 +98,6 @@ ENDIF() IF(DEFINED REVISION) MESSAGE(STATUS "Found revision ${REVISION}") +ELSE() + SET(REVISION 0) ENDIF() diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index c396bd6cf..5069ec40f 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -41,31 +41,49 @@ ENDMACRO() MACRO(PCH_SET_COMPILE_FLAGS _target) SET(PCH_FLAGS) SET(PCH_ARCHS) + SET(PCH_INCLUDES) - SET(_FLAGS) + # Append target for clang if defined + IF(CMAKE_CXX_COMPILER_TARGET) + LIST(APPEND PCH_FLAGS "--target=${CMAKE_CXX_COMPILER_TARGET}") + ENDIF() + + IF(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) + LIST(APPEND PCH_FLAGS "--gcc-toolchain=${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}") + ENDIF() + + IF(CMAKE_SYSROOT) + LIST(APPEND PCH_FLAGS "--sysroot=${CMAKE_SYSROOT}") + ENDIF() + + IF(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES) + FOREACH(item ${CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES}) + LIST(APPEND PCH_FLAGS "-isystem ${item}") + ENDFOREACH() + ENDIF() # C++ flags - SET(_FLAG ${CMAKE_CXX_FLAGS}) - SEPARATE_ARGUMENTS(_FLAG) + SET(_FLAGS ${CMAKE_CXX_FLAGS}) + SEPARATE_ARGUMENTS(_FLAGS) - LIST(APPEND _FLAGS ${_FLAG}) + LIST(APPEND PCH_FLAGS ${_FLAGS}) # C++ config flags STRING(TOUPPER "${CMAKE_BUILD_TYPE}" _UPPER_BUILD) - SET(_FLAG ${CMAKE_CXX_FLAGS_${_UPPER_BUILD}}) - SEPARATE_ARGUMENTS(_FLAG) + SET(_FLAGS ${CMAKE_CXX_FLAGS_${_UPPER_BUILD}}) + SEPARATE_ARGUMENTS(_FLAGS) - LIST(APPEND _FLAGS ${_FLAG}) + LIST(APPEND PCH_FLAGS ${_FLAGS}) GET_TARGET_PROPERTY(_targetType ${_target} TYPE) SET(_USE_PIC OFF) IF(${_targetType} STREQUAL "SHARED_LIBRARY" OR ${_targetType} STREQUAL "MODULE_LIBRARY") - SET(_FLAG ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) - SEPARATE_ARGUMENTS(_FLAG) - LIST(APPEND _FLAGS ${_FLAG}) + SET(_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) + SEPARATE_ARGUMENTS(_FLAGS) + LIST(APPEND PCH_FLAGS ${_FLAGS}) ELSE() GET_TARGET_PROPERTY(_pic ${_target} POSITION_INDEPENDENT_CODE) IF(_pic) @@ -75,7 +93,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES) FOREACH(item ${DIRINC}) - LIST(APPEND _FLAGS -I"${item}") + LIST(APPEND PCH_INCLUDES "${item}") ENDFOREACH() # NOTE: As cmake files (eg FindQT4) may now use generator expressions around their defines that evaluate @@ -98,14 +116,14 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) ENDFOREACH() ENDIF() - GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS) + GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) ENDFOREACH() ENDIF() - GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS_${_UPPER_BUILD}) + GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS_${_UPPER_BUILD}) IF(DEFINITIONS) FOREACH(item ${DEFINITIONS}) APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item}) @@ -114,22 +132,22 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) GET_TARGET_PROPERTY(oldProps ${_target} COMPILE_FLAGS) IF(oldProps) - SET(_FLAG ${oldProps}) - SEPARATE_ARGUMENTS(_FLAG) - LIST(APPEND _FLAGS ${_FLAG}) + SET(_FLAGS ${oldProps}) + SEPARATE_ARGUMENTS(_FLAGS) + LIST(APPEND PCH_FLAGS ${_FLAGS}) ENDIF() GET_TARGET_PROPERTY(oldPropsBuild ${_target} COMPILE_FLAGS_${_UPPER_BUILD}) IF(oldPropsBuild) - SET(_FLAG ${oldPropsBuild}) - SEPARATE_ARGUMENTS(_FLAG) - LIST(APPEND _FLAGS ${_FLAG}) + SET(_FLAGS ${oldPropsBuild}) + SEPARATE_ARGUMENTS(_FLAGS) + LIST(APPEND PCH_FLAGS ${_FLAGS}) ENDIF() GET_TARGET_PROPERTY(DIRINC ${_target} INCLUDE_DIRECTORIES) IF(DIRINC) FOREACH(item ${DIRINC}) - LIST(APPEND _FLAGS -I"${item}") + LIST(APPEND PCH_INCLUDES "${item}") ENDFOREACH() ENDIF() @@ -147,6 +165,18 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) ENDFOREACH() ENDIF() + GET_TARGET_PROPERTY(OPTIONS ${_target} COMPILE_OPTIONS) + IF(OPTIONS) + SEPARATE_ARGUMENTS(OPTIONS) + LIST(APPEND PCH_FLAGS ${OPTIONS}) + ENDIF() + + GET_TARGET_PROPERTY(OPTIONS ${_target} COMPILE_OPTIONS_${_UPPER_BUILD}) + IF(OPTIONS) + SEPARATE_ARGUMENTS(OPTIONS) + LIST(APPEND PCH_FLAGS ${OPTIONS}) + ENDIF() + GET_TARGET_PROPERTY(_LIBS ${_target} INTERFACE_LINK_LIBRARIES) IF(_LIBS) FOREACH(_LIB ${_LIBS}) @@ -156,7 +186,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) IF(_DIRS) FOREACH(item ${_DIRS}) - LIST(APPEND GLOBAL_DEFINITIONS -I"${item}") + LIST(APPEND PCH_INCLUDES "${item}") ENDFOREACH() ENDIF() @@ -185,7 +215,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) ENDIF() IF(_USE_PIC) - LIST(APPEND _FLAGS ${CMAKE_CXX_COMPILE_OPTIONS_PIC}) + LIST(APPEND PCH_FLAGS ${CMAKE_CXX_COMPILE_OPTIONS_PIC}) ENDIF() ENDIF() @@ -195,92 +225,78 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) IF(_DIRECTORY_FLAGS) SEPARATE_ARGUMENTS(_DIRECTORY_FLAGS) FOREACH(item ${_DIRECTORY_FLAGS}) - LIST(APPEND _FLAGS "${item}") + LIST(APPEND PCH_FLAGS "${item}") ENDFOREACH() ENDIF() - GET_DIRECTORY_PROPERTY(_DIRECTORY_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS) + GET_DIRECTORY_PROPERTY(_DIRECTORY_DEFINITIONS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEFINITIONS) IF(_DIRECTORY_DEFINITIONS) SEPARATE_ARGUMENTS(_DIRECTORY_DEFINITIONS) FOREACH(item ${_DIRECTORY_DEFINITIONS}) - LIST(APPEND _FLAGS "${item}") + LIST(APPEND PCH_FLAGS "${item}") ENDFOREACH() ENDIF() ENDIF() - IF(USE_CPP0X AND gcc_compiler_version GREATER "6.2.0") - LIST(APPEND _FLAGS "-std=gnu++11") - ENDIF() - - # Format definitions - IF(MSVC) - # Fix path with space - SEPARATE_ARGUMENTS(_FLAGS UNIX_COMMAND "${_FLAGS}") + IF(CMAKE_CXX11_EXTENSION_COMPILE_OPTION) + LIST(APPEND PCH_FLAGS "${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}") ENDIF() # Already in list form and items may contain non-leading spaces that should not be split on - LIST(INSERT _FLAGS 0 "${GLOBAL_DEFINITIONS}") + LIST(APPEND PCH_FLAGS "${GLOBAL_DEFINITIONS}") - IF(CLANG) - # Determining all architectures and get common flags - SET(_ARCH_NEXT) - SET(_XARCH_NEXT) - FOREACH(item ${_FLAGS}) - IF(_ARCH_NEXT) - LIST(FIND PCH_ARCHS ${item} ITEM_FOUND) - IF(ITEM_FOUND EQUAL -1) - LIST(APPEND PCH_ARCHS ${item}) - STRING(TOUPPER "${item}" _UPPER_ARCH) - SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item}) - ENDIF() - SET(_ARCH_NEXT OFF) - ELSEIF(_XARCH_NEXT) - SET(_XARCH_NEXT OFF) - ELSE() - IF(item MATCHES "^-arch") - SET(_ARCH_NEXT ON) - ELSEIF(item MATCHES "^-Xarch_") - STRING(REGEX REPLACE "-Xarch_([a-z0-9_]+)" "\\1" item ${item}) - LIST(FIND PCH_ARCHS ${item} ITEM_FOUND) - IF(ITEM_FOUND EQUAL -1) - LIST(APPEND PCH_ARCHS ${item}) - STRING(TOUPPER "${item}" _UPPER_ARCH) - SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item}) - ENDIF() - SET(_XARCH_NEXT ON) - ELSE() - LIST(APPEND PCH_FLAGS ${item}) - ENDIF() - ENDIF() - ENDFOREACH() - - # Get architcture specific flags - SET(_XARCH_NEXT) - FOREACH(item ${_FLAGS}) - IF(_XARCH_NEXT) - STRING(TOUPPER "${_XARCH_NEXT}" _UPPER_XARCH) - LIST(APPEND PCH_ARCH_${_UPPER_XARCH}_FLAGS ${item}) - SET(_XARCH_NEXT OFF) - ELSE() - IF(item MATCHES "^-Xarch_") - STRING(SUBSTRING "${item}" 7 -1 _XARCH_NEXT) - ENDIF() - ENDIF() - ENDFOREACH() - - # Remove duplicated architectures - IF(_ARCHS AND PCH_ARCHS) - LIST(REMOVE_DUPLICATES PCH_ARCHS) - ENDIF() + IF(WIN32) + SET(SYSTEM_FLAG "[-/$]") ELSE() - SET(PCH_FLAGS ${_FLAGS}) + SET(SYSTEM_FLAG "[-$]") ENDIF() - IF(PCH_FLAGS) - LIST(REMOVE_ITEM PCH_FLAGS "") - LIST(REMOVE_DUPLICATES PCH_FLAGS) + SET(_FINAL_FLAGS) + SET(_PREVIOUS_FLAG) + + FOREACH(_FLAG ${PCH_FLAGS}) + # If parameter is really a flag (starts with -) + IF(_FLAG MATCHES "^${SYSTEM_FLAG}") + IF(_PREVIOUS_FLAG) + # Append previous flag + LIST(APPEND _FINAL_FLAGS ${_PREVIOUS_FLAG}) + ENDIF() + + SET(_PREVIOUS_FLAG ${_FLAG}) + ELSE() + IF(_PREVIOUS_FLAG) + # Append previous flag and its parameter + # TODO: escape them only if there is an space + LIST(APPEND _FINAL_FLAGS "${_PREVIOUS_FLAG} \"${_FLAG}\"") + SET(_PREVIOUS_FLAG) + ELSE() + # Shouldn't happen + MESSAGE(FATAL_ERROR "No previous flag before ${_FLAG}") + ENDIF() + ENDIF() + ENDFOREACH() + + IF(_PREVIOUS_FLAG) + LIST(APPEND _FINAL_FLAGS ${_PREVIOUS_FLAG}) ENDIF() + + SET(PCH_FLAGS ${_FINAL_FLAGS}) + + # Remove flags that don't work with PCH + LIST(REMOVE_ITEM PCH_FLAGS "-Wa,--noexecstack") + + # Remove all empty parameters + LIST(REMOVE_ITEM PCH_FLAGS "") + + # Remove duplicate parameters + LIST(REMOVE_DUPLICATES PCH_FLAGS) + + # create a command-line string + STRING(REGEX REPLACE ";" " " PCH_FLAGS "${PCH_FLAGS}") + + # and separate arguments + SEPARATE_ARGUMENTS(PCH_FLAGS) ENDMACRO() MACRO(GET_PDB_FILENAME _out_filename _target) @@ -304,7 +320,7 @@ MACRO(GET_PDB_FILENAME _out_filename _target) SET(${_out_filename} "${_targetOutput}/${_target}${_targetPostfix}.pdb") ENDMACRO(GET_PDB_FILENAME) -MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS) +MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS _includes) IF(CMAKE_CXX_COMPILER_ARG1) # remove leading space in compiler argument STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1}) @@ -314,18 +330,33 @@ MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS) IF(MSVC) GET_PDB_FILENAME(_PDB_FILE ${_PCH_current_target}) - SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${_PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj") + + SET(PCH_TEMP_CONTENT) + + FOREACH(_include ${_includes}) + SET(PCH_TEMP_CONTENT "${PCH_TEMP_CONTENT} -I \"${_include}\"") + ENDFOREACH() + + SET(PCH_TEMP_FILE ${CMAKE_CURRENT_BINARY_DIR}/pch_command.txt) + FILE(WRITE ${PCH_TEMP_FILE} "${PCH_TEMP_CONTENT}") + + SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} /nologo @${PCH_TEMP_FILE} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${_PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj") # Ninja PCH Support # http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES OBJECT_OUTPUTS "${PCH_OUTPUT}.obj") ELSE() SET(HEADER_FORMAT "c++-header") - SET(_FLAGS "") + SET(_FLAGS) IF(APPLE) SET(HEADER_FORMAT "objective-${HEADER_FORMAT}") - SET(_FLAGS ${OBJC_FLAGS}) + LIST(APPEND _FLAGS ${OBJC_FLAGS}) ENDIF() + + FOREACH(_include ${_includes}) + LIST(APPEND _FLAGS -I "${_include}") + ENDFOREACH() + SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} ${_FLAGS} -x ${HEADER_FORMAT} -o ${PCH_OUTPUT} -c ${PCH_INPUT}) ENDIF() ENDMACRO() @@ -467,7 +498,7 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp) PCH_SET_PRECOMPILED_HEADER_OUTPUT(${_targetName} ${_inputh} ${_ARCH} "") LIST(APPEND PCH_OUTPUTS ${PCH_OUTPUT}) - PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_ARCH_${_UPPER_ARCH}_FLAGS};${PCH_FLAGS}") + PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_ARCH_${_UPPER_ARCH}_FLAGS};${PCH_FLAGS}" "${PCH_INCLUDES}") PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch_${_ARCH}) ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH(${_targetName} ${_ARCH}) @@ -476,7 +507,7 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp) PCH_SET_PRECOMPILED_HEADER_OUTPUT(${_targetName} ${_inputh} "" "") LIST(APPEND PCH_OUTPUTS ${PCH_OUTPUT}) - PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_FLAGS}") + PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_FLAGS}" "${PCH_INCLUDES}") PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch) ENDIF() @@ -525,7 +556,13 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp) SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES") ELSE() #Fallback to the "old" precompiled suppport - ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp}) + IF(CMAKE_OSX_ARCHITECTURES AND TARGETS_COUNT GREATER 1) + FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES}) + ADD_PRECOMPILED_HEADER(${_targetName}_${_ARCH} ${_inputh} ${_inputcpp}) + ENDFOREACH() + ELSE() + ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp}) + ENDIF() ENDIF() IF(TARGET ${_targetName}_static) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 95b28bb8a..bd70dd2ff 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -238,6 +238,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) OPTION(WITH_EXTERNAL "With provided external." OFF) ENDIF() OPTION(WITH_STATIC_EXTERNAL "With static external libraries" OFF) + OPTION(WITH_STATIC_RUNTIMES "Use only static C++ runtimes" OFF) IF(UNIX AND NOT APPLE) OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" ON ) ELSE() @@ -246,6 +247,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON ) OPTION(WITH_ASSIMP "Use assimp exporter" OFF) + OPTION(WITH_LIBGSF "Use libgsf for max file library" OFF) ### # GUI toolkits @@ -373,8 +375,14 @@ MACRO(ADD_PLATFORM_LINKFLAGS _FLAGS) SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${_FLAGS}") ENDMACRO() -MACRO(NL_SETUP_BUILD) +MACRO(CONVERT_VERSION_NUMBER _VERSION_NUMBER _BASE) + SET(${_VERSION_NUMBER} 0) + FOREACH(_ARG ${ARGN}) + MATH(EXPR ${_VERSION_NUMBER} "${${_VERSION_NUMBER}} * ${_BASE} + ${_ARG}") + ENDFOREACH() +ENDMACRO() +MACRO(NL_SETUP_BUILD) #----------------------------------------------------------------------------- # Setup the buildmode variables. # @@ -560,6 +568,11 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("-DENABLE_LOGS") ENDIF() + SET(CUSTOM_FLAGS "" CACHE STRING "Custom compile flags (useful for /MPn)") + IF(NOT ${CUSTOM_FLAGS} STREQUAL "") + ADD_PLATFORM_FLAGS(${CUSTOM_FLAGS}) + ENDIF() + IF(MSVC) # Ignore default include paths ADD_PLATFORM_FLAGS("/X") @@ -636,8 +649,14 @@ MACRO(NL_SETUP_BUILD) SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}") ENDIF() - SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}") - SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}") + IF(WITH_STATIC_RUNTIMES) + SET(RUNTIME_FLAG "/MT") + ELSE() + SET(RUNTIME_FLAG "/MD") + ENDIF() + + SET(NL_DEBUG_CFLAGS "/Zi ${RUNTIME_FLAG}d /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}") + SET(NL_RELEASE_CFLAGS "${RUNTIME_FLAG} /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}") SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt ${MSVC_INCREMENTAL_YES_FLAG} ${NL_DEBUG_LINKFLAGS}") SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}") @@ -665,7 +684,7 @@ MACRO(NL_SETUP_BUILD) IF(APPLE) SET(OBJC_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch -fobjc-weak) - + IF(NOT XCODE) IF(CMAKE_OSX_ARCHITECTURES) SET(TARGETS_COUNT 0) @@ -874,7 +893,9 @@ MACRO(NL_SETUP_BUILD) ENDIF() # use c++0x standard to use std::unique_ptr and std::shared_ptr - SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -std=c++0x") + IF(CMAKE_CXX11_EXTENSION_COMPILE_OPTION) + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}") + ENDIF() ADD_PLATFORM_FLAGS("-D_REENTRANT") @@ -950,8 +971,6 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("-fPIC") ENDIF() - SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48") - # hardening ADD_PLATFORM_FLAGS("-fstack-protector --param=ssp-buffer-size=4") @@ -965,6 +984,10 @@ MACRO(NL_SETUP_BUILD) IF(NOT APPLE) ADD_PLATFORM_LINKFLAGS("-Wl,--no-undefined -Wl,--as-needed") + + IF(WITH_STATIC_RUNTIMES) + ADD_PLATFORM_LINKFLAGS("-static-libstdc++") + ENDIF() ENDIF() IF(NOT APPLE) @@ -1023,6 +1046,12 @@ MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE) ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX) MACRO(NL_SETUP_PREFIX_PATHS) + IF(TARGET_X64 AND WIN32) + SET(LIB_SUFFIX "64") + ELSE() + SET(LIB_SUFFIX "") + ENDIF() + ## Allow override of install_prefix/etc path. IF(NOT NL_ETC_PREFIX) IF(WITH_UNIX_STRUCTURE) @@ -1046,7 +1075,7 @@ MACRO(NL_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/sbin path. IF(NOT NL_SBIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(NL_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + SET(NL_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.") ELSE() SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") ENDIF() @@ -1056,7 +1085,7 @@ MACRO(NL_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/bin path. IF(NOT NL_BIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(NL_BIN_PREFIX "bin" CACHE PATH "Installation path for tools and applications.") + SET(NL_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools and applications.") ELSE() SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") ENDIF() @@ -1068,7 +1097,7 @@ MACRO(NL_SETUP_PREFIX_PATHS) IF(LIBRARY_ARCHITECTURE) SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") ELSE() - SET(NL_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + SET(NL_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.") ENDIF() ENDIF() NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX) @@ -1079,7 +1108,11 @@ MACRO(NL_SETUP_PREFIX_PATHS) IF(LIBRARY_ARCHITECTURE) SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.") ELSE() - SET(NL_DRIVER_PREFIX "lib/nel" CACHE PATH "Installation path for drivers.") + IF(WIN32) + SET(NL_DRIVER_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for drivers.") + ELSE() + SET(NL_DRIVER_PREFIX "lib${LIB_SUFFIX}/nel" CACHE PATH "Installation path for drivers.") + ENDIF() ENDIF() ELSE() SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.") @@ -1112,7 +1145,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/sbin path. IF(NOT RYZOM_SBIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(RYZOM_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + SET(RYZOM_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.") ELSE() SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") ENDIF() @@ -1122,7 +1155,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/bin path. IF(NOT RYZOM_BIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(RYZOM_BIN_PREFIX "bin" CACHE PATH "Installation path for tools.") + SET(RYZOM_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools.") ELSE() SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") ENDIF() @@ -1134,7 +1167,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS) IF(LIBRARY_ARCHITECTURE) SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") ELSE() - SET(RYZOM_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + SET(RYZOM_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.") ENDIF() ENDIF() NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX) @@ -1210,4 +1243,4 @@ MACRO(SETUP_EXTERNAL) FIND_PACKAGE(MSVC REQUIRED) FIND_PACKAGE(WindowsSDK REQUIRED) ENDIF() -ENDMACRO(SETUP_EXTERNAL) +ENDMACRO() diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index 84b820d33..3470fcebb 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -20,6 +20,7 @@ ENDIF() IF(WITH_SOUND) FIND_PACKAGE(Ogg) FIND_PACKAGE(Vorbis) + FIND_PACKAGE(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL SWRESAMPLE) IF(WITH_DRIVER_OPENAL) FIND_PACKAGE(OpenAL) diff --git a/code/nel/include/nel/3d/computed_string.h b/code/nel/include/nel/3d/computed_string.h index 517200383..25d12a3ac 100644 --- a/code/nel/include/nel/3d/computed_string.h +++ b/code/nel/include/nel/3d/computed_string.h @@ -178,6 +178,10 @@ public: CVertexBuffer Vertices; CMaterial *Material; CRGBA Color; + ucstring Text; + + uint32 CacheVersion; + /// The width of the string, in pixels (eg: 30) float StringWidth; /// The height of the string, in pixels (eg: 10) @@ -223,6 +227,7 @@ public: */ CComputedString (bool bSetupVB=true) { + CacheVersion = 0; StringWidth = 0; StringHeight = 0; if (bSetupVB) diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 52bda8576..85140b3da 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -224,7 +224,7 @@ public: // @{ // first param is the associated window. // Must be a HWND for Windows (WIN32). - virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show = true, bool resizeable = true) throw(EBadDisplay) = 0; + virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show = true, bool resizeable = true) = 0; // Must be called after a setDisplay that initialize the mode virtual bool setMode(const GfxMode &mode) = 0; virtual bool getModes(std::vector &modes) = 0; diff --git a/code/nel/include/nel/3d/dru.h b/code/nel/include/nel/3d/dru.h index fda543ecd..c23d41382 100644 --- a/code/nel/include/nel/3d/dru.h +++ b/code/nel/include/nel/3d/dru.h @@ -134,14 +134,14 @@ class CDRU public: /// Portable Function which create a GL Driver (using gl dll...). - static IDriver *createGlDriver() throw(EDru); + static IDriver *createGlDriver(); /// Portable Function which create a GL ES Driver (using gl dll...). - static IDriver *createGlEsDriver() throw(EDru); + static IDriver *createGlEsDriver(); #ifdef NL_OS_WINDOWS /// Windows Function which create a Direct3d Driver. - static IDriver *createD3DDriver() throw(EDru); + static IDriver *createD3DDriver(); #endif // NL_OS_WINDOWS /// \name 2D render. diff --git a/code/nel/include/nel/3d/font_generator.h b/code/nel/include/nel/3d/font_generator.h index 5a07733a0..b69249d58 100644 --- a/code/nel/include/nel/3d/font_generator.h +++ b/code/nel/include/nel/3d/font_generator.h @@ -21,8 +21,12 @@ #undef NL_DONT_USE_EXTERNAL_CODE #ifndef NL_DONT_USE_EXTERNAL_CODE -#include -#include FT_FREETYPE_H + +// forward declarations to avoid including freetype.h in headers +typedef int FT_Error; +typedef struct FT_LibraryRec_ *FT_Library; +typedef struct FT_FaceRec_* FT_Face; + #else // NL_DONT_USE_EXTERNAL_CODE #endif // NL_DONT_USE_EXTERNAL_CODE @@ -74,6 +78,8 @@ public: uint32 getUID() { return _UID; } + std::string getFontFileName() const; + private: static uint32 _FontGeneratorCounterUID; diff --git a/code/nel/include/nel/3d/font_manager.h b/code/nel/include/nel/3d/font_manager.h index 26ea02ce0..663e9d23a 100644 --- a/code/nel/include/nel/3d/font_manager.h +++ b/code/nel/include/nel/3d/font_manager.h @@ -59,6 +59,9 @@ class CFontManager CSmartPtr _MatFont; CSmartPtr _TexFont; + // Keep track number of textures created to properly report cache version + uint32 _TexCacheNr; + public: /** @@ -71,6 +74,7 @@ public: _NbChar = 0; _MatFont = NULL; _TexFont = NULL; + _TexCacheNr = 0; } @@ -94,7 +98,6 @@ public: */ CMaterial* getFontMaterial(); - /** * Compute primitive blocks and materials of each character of * the string. @@ -152,7 +155,8 @@ public: void dumpCache (const char *filename) { - _TexFont->dumpTextureFont (filename); + if (_TexFont) + _TexFont->dumpTextureFont (filename); } /** @@ -160,6 +164,15 @@ public: */ void invalidate(); + // get font atlas rebuild count + uint32 getCacheVersion() const + { + if (_TexFont) + return (_TexFont->getCacheVersion() << 16) + _TexCacheNr; + + return 0; + } + }; diff --git a/code/nel/include/nel/3d/landscape.h b/code/nel/include/nel/3d/landscape.h index aa432f88b..a7383963d 100644 --- a/code/nel/include/nel/3d/landscape.h +++ b/code/nel/include/nel/3d/landscape.h @@ -168,9 +168,9 @@ public: void clear(); /// Verify the binding of patchs of all zones. throw EBadBind if error. - void checkBinds() throw(EBadBind); + void checkBinds(); /// Verify the binding of patchs of one zone. throw EBadBind if error. nop if zone not loaded. - void checkBinds(uint16 zoneId) throw(EBadBind); + void checkBinds(uint16 zoneId); /** * Build tileBank. Call this after loading the near and far tile banks. diff --git a/code/nel/include/nel/3d/nelu.h b/code/nel/include/nel/3d/nelu.h index fb30a5012..b64e83672 100644 --- a/code/nel/include/nel/3d/nelu.h +++ b/code/nel/include/nel/3d/nelu.h @@ -64,7 +64,7 @@ public: * * You can access the driver with CNELU::Driver. */ - static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false, bool direct3d=false) throw(EDru); + static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false, bool direct3d=false); /** Init all that we need for a Scene. * - register scene basics models, @@ -108,7 +108,7 @@ public: * - initScene(); * - initEventServer(); */ - static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false, bool direct3d = false) throw(EDru); + static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false, bool direct3d = false); /** Delete all: * - releaseEventServer(); diff --git a/code/nel/include/nel/3d/text_context.h b/code/nel/include/nel/3d/text_context.h index 156ea9f79..1f75e1184 100644 --- a/code/nel/include/nel/3d/text_context.h +++ b/code/nel/include/nel/3d/text_context.h @@ -88,7 +88,7 @@ public: void setShadeOutline (bool b) { _ShadeOutline = b; } - void setShadeExtent (float shext) { _ShadeExtent = shext; } + void setShadeExtent (float x, float y) { _ShadeExtentX = x; _ShadeExtentY = y; } /// The alpha of the shade is multiplied at each draw with the alpha of the color. Default: (0,0,0,255) void setShadeColor (NLMISC::CRGBA color) { _ShadeColor = color; } @@ -150,6 +150,10 @@ public: { nlassert (index < _CacheStrings.size()); CComputedString &rCS = _CacheStrings[index]; + if (rCS.CacheVersion != _FontManager->getCacheVersion()) + { + computeString(rCS.Text, rCS); + } if (_Shaded) { CRGBA bkup = rCS.Color; @@ -157,19 +161,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2D(*_Driver, x+rext, z-rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-rext, z-rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-rext, z+rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x+rext, z+rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x+_ShadeExtent, z, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-_ShadeExtent, z, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2D(*_Driver, x+rextX, z-rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-rextX, z-rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-rextX, z+rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+rextX, z+rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+_ShadeExtentX, z, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-_ShadeExtentX, z, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } else { - rCS.render2D(*_Driver, x+_ShadeExtent, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } rCS.Color= bkup; } @@ -183,6 +188,10 @@ public: { nlassert (index < _CacheStrings.size()); CComputedString &rCS = _CacheStrings[index]; + if (rCS.CacheVersion != _FontManager->getCacheVersion()) + { + computeString(rCS.Text, rCS); + } if(_Shaded) { CRGBA bkup = rCS.Color; @@ -190,19 +199,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2DClip(*_Driver, rdrBuffer, x+rext, z-rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-rext, z-rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-rext, z+rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x+rext, z+rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtent, z, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x, z+_ShadeExtent, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x, z-_ShadeExtent, xmin, ymin, xmax, ymax); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2DClip(*_Driver, rdrBuffer, x+rextX, z-rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-rextX, z-rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-rextX, z+rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+rextX, z+rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtentX, z, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtentX, z, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x, z+_ShadeExtentY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x, z-_ShadeExtentY, xmin, ymin, xmax, ymax); } else { - rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z-_ShadeExtent, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtentX, z-_ShadeExtentY, xmin, ymin, xmax, ymax); } rCS.Color= bkup; } @@ -216,6 +226,11 @@ public: { nlassert (index < _CacheStrings.size()); CComputedString &rCS = _CacheStrings[index]; + if (rCS.CacheVersion != _FontManager->getCacheVersion()) + { + computeString(rCS.Text, rCS); + } + if (_Shaded) { CRGBA bkup = rCS.Color; @@ -223,19 +238,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rext, y-rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rext, y-rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rext, y+rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rext, y+rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtent, y, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y+_ShadeExtent, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rextX, y-rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rextX, y-rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rextX, y+rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rextX, y+rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtentX, y, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtentX, y, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y+_ShadeExtentY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y-_ShadeExtentY, depth, xmin, ymin, xmax, ymax); } else { - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtentX, y-_ShadeExtentY, depth, xmin, ymin, xmax, ymax); } rCS.Color= bkup; } @@ -258,19 +274,20 @@ public: _TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - _TempString.render2D(*_Driver,x+rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + _TempString.render2D(*_Driver,x+rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z+_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z-_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); } else { - _TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } _TempString.Color = bkup; } @@ -297,19 +314,20 @@ public: _TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - _TempString.render2D(*_Driver,x+rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + _TempString.render2D(*_Driver,x+rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z+_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z-_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); } else { - _TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } _TempString.Color = bkup; } @@ -412,7 +430,8 @@ private: bool _ShadeOutline; /// shade's extent (shadow size) - float _ShadeExtent; + float _ShadeExtentX; + float _ShadeExtentY; /// Shade color (default is black) NLMISC::CRGBA _ShadeColor; diff --git a/code/nel/include/nel/3d/text_context_user.h b/code/nel/include/nel/3d/text_context_user.h index b05238dbf..15e93c3f2 100644 --- a/code/nel/include/nel/3d/text_context_user.h +++ b/code/nel/include/nel/3d/text_context_user.h @@ -80,7 +80,7 @@ public: bool getShaded() const; void setShadeOutline(bool b); bool getShadeOutline() const; - void setShadeExtent(float shext) ; + void setShadeExtent(float x, float y); void setShadeColor (NLMISC::CRGBA sc); NLMISC::CRGBA getShadeColor () const; void setKeep800x600Ratio(bool keep); diff --git a/code/nel/include/nel/3d/texture_font.h b/code/nel/include/nel/3d/texture_font.h index e743bb137..865615b63 100644 --- a/code/nel/include/nel/3d/texture_font.h +++ b/code/nel/include/nel/3d/texture_font.h @@ -18,6 +18,7 @@ #define NL_TEXTURE_FONT_H #include "nel/misc/types_nl.h" +#include "nel/misc/rect.h" #include "nel/3d/texture.h" namespace NL3D @@ -25,9 +26,6 @@ namespace NL3D class CFontGenerator; -#define TEXTUREFONT_NBCATEGORY 5 // Config 1 -//#define TEXTUREFONT_NBCATEGORY 4 - // **************************************************************************** /** * CTextureFont @@ -37,32 +35,59 @@ class CTextureFont : public ITexture public: - struct SLetterInfo + // Holds info for glyphs rendered on atlas + struct SGlyphInfo { - // To generate the letter - ucchar Char; - CFontGenerator *FontGenerator; + // font atlas info + uint32 CacheVersion; + + // atlas region with padding + uint32 X, Y, W, H; + + // rendered glyph size without padding + uint32 CharWidth; + uint32 CharHeight; + + // UV coords for rendered glyph without padding + float U0, V0, U1, V1; + + uint32 GlyphIndex; sint Size; bool Embolden; bool Oblique; + CFontGenerator *FontGenerator; + SGlyphInfo() + : CacheVersion(0), + U0(0.f), V0(0.f), U1(0.f), V1(0.f), + X(0), Y(0), W(0), H(0), CharWidth(0), CharHeight(0), + GlyphIndex(0), Size(0), Embolden(false), Oblique(false), FontGenerator(NULL) + { + } + }; - // The less recently used infos - SLetterInfo *Next, *Prev; + // Holds info for glyphs displayed on screen + struct SLetterInfo + { + ucchar Char; + sint Size; + bool Embolden; + bool Oblique; + CFontGenerator *FontGenerator; - uint Cat; // 8x8, 16x16, 24x24, 32x32 - - ////////////////////////////////////////////////////////////////////// - - float U ,V; - uint32 CharWidth; - uint32 CharHeight; - uint32 GlyphIndex; // number of the character in the this font + uint32 GlyphIndex; + uint32 CharWidth; // Displayed glyph height + uint32 CharHeight; // Displayed glyph height sint32 Top; // Distance between origin and top of the texture sint32 Left; // Distance between origin and left of the texture sint32 AdvX; // Advance to the next caracter - SLetterInfo():Char(0), FontGenerator(NULL), Size(0), Embolden(false), Oblique(false), Next(NULL), Prev(NULL), Cat(0), CharWidth(0), CharHeight(0), GlyphIndex(0), Top(0), Left(0), AdvX(0) + SGlyphInfo* glyph; + + SLetterInfo() + : Char(0), Size(0), Embolden(false), Oblique(false), FontGenerator(NULL), + GlyphIndex(0), CharWidth(0), CharHeight(0), Top(0), Left(0), AdvX(0), + glyph(NULL) { } }; @@ -70,14 +95,13 @@ public: struct SLetterKey { ucchar Char; - CFontGenerator *FontGenerator; sint Size; bool Embolden; bool Oblique; + CFontGenerator *FontGenerator; + // Does not use FontGenerator in return value uint32 getVal(); - //bool operator < (const SLetterKey&k) const; - //bool operator == (const SLetterKey&k) const; SLetterKey():Char(0), FontGenerator(NULL), Size(0), Embolden(false), Oblique(false) { @@ -96,19 +120,76 @@ public: void doGenerate (bool async = false); // This function manage the cache if the letter wanted does not exist - SLetterInfo* getLetterInfo (SLetterKey& k); + // \param render Set to true if letter is currently visible on screen + SLetterInfo* getLetterInfo (SLetterKey& k, bool render); void dumpTextureFont (const char *filename); + // Version is increased with each rebuild of font atlas + uint32 getCacheVersion() const { return _CacheVersion; } + private: + uint32 _CacheVersion; + + // current texture size + uint32 _TextureSizeX; + uint32 _TextureSizeY; + + // maximum texture size allowed + uint32 _TextureMaxW; + uint32 _TextureMaxH; + + // padding around glyphs + uint8 _PaddingL, _PaddingT; + uint8 _PaddingR, _PaddingB; // To find a letter in the texture - std::map Accel; - std::vector Letters[TEXTUREFONT_NBCATEGORY]; - SLetterInfo *Front[TEXTUREFONT_NBCATEGORY], *Back[TEXTUREFONT_NBCATEGORY]; + // Keep track of available space in main texture + std::vector _AtlasNodes; - void rebuildLetter (sint cat, sint x, sint y); + std::vector _Letters; + + // lookup letter from letter cache or create new + SLetterInfo* findLetter(SLetterKey& k, bool insert); + + // lower/upper bound of glyphs to render, sizes outside are scaled bitmaps + uint _MinGlyphSize; + uint _MaxGlyphSize; + // start using size stem from this font size + uint _GlyphSizeStepMin; + // every n'th font size is rendered, intermediates are using bitmap scaling + uint _GlyphSizeStep; + + // rendered glyph cache + std::list _GlyphCache; + SGlyphInfo* findLetterGlyph(SLetterInfo *letter, bool insert); + + // render letter glyph into glyph cache + SGlyphInfo* renderLetterGlyph(SLetterInfo *letter, uint32 bitmapFontSize); + + // copy glyph bitmap into texture and invalidate that region + void copyGlyphBitmap(uint8* bitmap, uint32 bitmapW, uint32 bitmapH, uint32 atlasX, uint32 atlasY); + + // Find best fit for WxH rect in atlas + uint fitRegion(uint index, uint width, uint height); + + // Return top/left from font texture or false if there is no more room + bool reserveAtlas(const uint32 width, const uint32 height, uint32 &x, uint32 &y); + + // repack glyphs, resize texture, and invalidate unused glyphs. + void repackAtlas(); + void repackAtlas(uint32 width, uint32 height); + + // resize texture, + bool resizeAtlas(); + + // remove all glyphs from atlas, clear glyph cache, letter info is kept + void clearAtlas(); + + // if return true: newW, newH contains next size font atlas should be resized + // if return false: _TextureMaxW and _TextureMaxH is reached + bool getNextTextureSize(uint32 &newW, uint32 &newH) const; /// Todo: serialize a font texture. public: diff --git a/code/nel/include/nel/3d/u_text_context.h b/code/nel/include/nel/3d/u_text_context.h index 0aa9ea2f9..4c1dfea47 100644 --- a/code/nel/include/nel/3d/u_text_context.h +++ b/code/nel/include/nel/3d/u_text_context.h @@ -205,7 +205,7 @@ public: * set the shadow's size * \param the shade extent */ - virtual void setShadeExtent (float shext) = 0; + virtual void setShadeExtent (float x, float y) = 0; /** * set the shadow's color * The alpha of the shade is multiplied at each draw with the alpha of the color. Default: (0,0,0,255) diff --git a/code/nel/include/nel/gui/css_parser.h b/code/nel/include/nel/gui/css_parser.h new file mode 100644 index 000000000..cfaf03caa --- /dev/null +++ b/code/nel/include/nel/gui/css_parser.h @@ -0,0 +1,150 @@ +// Ryzom - MMORPG Framework +// 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 . + +#ifndef CL_CSS_PARSER_H +#define CL_CSS_PARSER_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/css_style.h" +#include "nel/gui/css_selector.h" + +namespace NLGUI +{ + /** + * \brief CSS style parsing + * \date 2019-03-15 10:50 GMT + * \author Meelis Mägi (Nimetu) + */ + class CCssParser { + public: + // parse style declaration, eg "color: red; font-size: 10px;" + static TStyle parseDecls(const std::string &styleString); + + // parse css stylesheet + void parseStylesheet(const std::string &cssString, std::vector &rules); + + private: + // stylesheet currently parsed + ucstring _Style; + // keep track of current position in _Style + size_t _Position; + + std::vector _Rules; + + private: + // @media ( .. ) { .. } + void readAtRule(); + + // a#id.class[attr=val] { .. } + void readRule(); + + // move past whitespace + void skipWhitespace(); + + // skip valid IDENT + bool skipIdentifier(); + + // skip over {}, (), or [] block + void skipBlock(); + + // skip over string quoted with ' or " + void skipString(); + + // backslash escape + void escape(); + + // normalize newline chars and remove comments + void preprocess(); + + // parse selectors + combinators + std::vector parse_selector(const ucstring &sel, std::string &pseudoElement) const; + + // parse selector and style + void parseRule(const ucstring &selectorString, const ucstring &styleString); + + inline bool is_eof() const + { + return _Position >= _Style.size(); + } + + inline bool is_whitespace(ucchar ch) const + { + return (ch == (ucchar)' ' || ch == (ucchar)'\t' || ch == (ucchar)'\n'); + } + + inline bool is_hex(ucchar ch) const + { + return ((ch >= (ucchar)'0' && ch <= (ucchar)'9') || + (ch >= (ucchar)'a' && ch <= (ucchar)'f') || + (ch >= (ucchar)'A' && ch <= (ucchar)'F')); + } + + inline bool maybe_escape() const + { + // escaping newline (\n) only allowed inside strings + return (_Style.size() - _Position) >= 1 && _Style[_Position] == (ucchar)'\\' && _Style[_Position+1] != '\n'; + } + + inline bool is_quote(ucchar ch) const + { + return ch== (ucchar)'"' || ch == (ucchar)'\''; + } + + inline bool is_block_open(ucchar ch) const + { + return ch == (ucchar)'{' || ch == (ucchar)'[' || ch == (ucchar)'('; + } + + inline bool is_block_close(ucchar ch, ucchar open) const + { + return ((open == '{' && ch == (ucchar)'}') || + (open == '[' && ch == (ucchar)']') || + (open == '(' && ch == (ucchar)')')); + } + + inline bool is_comment_open() const + { + if (_Position+1 > _Style.size()) + return false; + + return _Style[_Position] == (ucchar)'/' && _Style[_Position+1] == (ucchar)'*'; + } + + inline bool is_nonascii(ucchar ch) const + { + return ch >= 0x80 /*&& ch <= 255*/; + } + + inline bool is_alpha(ucchar ch) const + { + return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'); + } + + inline bool is_digit(ucchar ch) const + { + return ch >= '0' && ch <= '9'; + } + + inline bool is_nmchar(ucchar ch) const + { + // checking escape here does not check if next char is '\n' or not + return ch == '_' || ch == '-' || is_alpha(ch) || is_digit(ch) || is_nonascii(ch) || ch == '\\'/*is_escape(ch)*/; + } + }; +}//namespace + +#endif // CL_CSS_PARSER_H + diff --git a/code/nel/include/nel/gui/css_selector.h b/code/nel/include/nel/gui/css_selector.h new file mode 100644 index 000000000..84b039089 --- /dev/null +++ b/code/nel/include/nel/gui/css_selector.h @@ -0,0 +1,107 @@ +// Ryzom - MMORPG Framework +// 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 . + +#ifndef CL_CSS_SELECTOR_H +#define CL_CSS_SELECTOR_H + +#include "nel/misc/types_nl.h" + +namespace NLGUI +{ + class CHtmlElement; + + /** + * \brief CSS selector + * \date 2019-03-15 10:50 GMT + * \author Meelis Mägi (Nimetu) + */ + class CCssSelector + { + public: + enum ECombinator { + NONE = 0, + GENERAL_CHILD, + ADJACENT_SIBLING, + GENERAL_SIBLING, + CHILD_OF + }; + + struct SAttribute { + std::string key; + std::string value; + char op; // =, ~, |, ^, $, * + SAttribute(const std::string &k, const std::string &v, char o) + :key(k),value(v),op(o) + {} + }; + + std::string Element; + std::string Id; + std::vector Class; + std::vector Attr; + std::vector PseudoClass; + + // css combinator or \0 missing (first element) + char Combinator; + + public: + // TODO: rewrite for ECombinator enum + CCssSelector(std::string elm="", std::string id="", std::string cls="", char comb = '\0'); + + // helper for sorting + uint32 specificity() const; + + // set classes used, eg 'class1 class2' + void setClass(const std::string &cls); + + // add attribute to selector + // ' ' op means 'key exists, ignore value' + void addAttribute(const std::string &key, const std::string &val = "", char op = ' '); + + // add pseudo class to selector, eg 'first-child' + void addPseudoClass(const std::string &key); + + // true if no rules have been defined + bool empty() const + { + return Element.empty() && Id.empty() && Class.empty() && Attr.empty() && PseudoClass.empty(); + } + + // Test current selector to html DOM element + // NOTE: Does not check combinator + bool match(const CHtmlElement &elm) const; + + private: + bool matchClass(const CHtmlElement &elm) const; + bool matchAttributes(const CHtmlElement &elm) const; + bool matchPseudoClass(const CHtmlElement &elm) const; + + // match An+B rule to child index (1 based) + bool matchNth(sint childNr, sint a, sint b) const; + + // parse nth-child string to 'a' and 'b' components + // :nth-child(odd) + // :nth-child(even) + // :nth-child(An+B) + // :nth-child(-An+b) + void parseNth(const std::string &pseudo, sint &a, sint &b) const; + + }; + +}//namespace + +#endif // CL_CSS_SELECTOR_H + diff --git a/code/nel/include/nel/gui/css_style.h b/code/nel/include/nel/gui/css_style.h new file mode 100644 index 000000000..74fcf240d --- /dev/null +++ b/code/nel/include/nel/gui/css_style.h @@ -0,0 +1,227 @@ +// Ryzom - MMORPG Framework +// 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 . + +#ifndef CL_CSS_STYLE_H +#define CL_CSS_STYLE_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/rgba.h" +#include "nel/gui/css_selector.h" + +namespace NLGUI +{ + class CHtmlElement; + + typedef std::map TStyle; + + /** + * \brief CSS style rules + * \date 2019-03-15 10:50 GMT + * \author Meelis Mägi (Nimetu) + */ + class CStyleParams + { + public: + struct STextShadow + { + public: + STextShadow(bool enabled = false, bool outline = false, sint32 x=1, sint32 y=1, NLMISC::CRGBA color=NLMISC::CRGBA::Black) + : Enabled(enabled), Outline(outline), X(x), Y(y), Color(color) + { } + + bool Enabled; + bool Outline; + sint32 X; + sint32 Y; + NLMISC::CRGBA Color; + }; + public: + CStyleParams () : FontFamily(""), TextColor(255,255,255,255), TextShadow() + { + FontSize=10; + FontWeight=400; + FontOblique=false; + Underlined=false; + StrikeThrough=false; + GlobalColor=false; + Width=-1; + Height=-1; + MaxWidth=-1; + MaxHeight=-1; + BorderWidth=1; + BackgroundColor=NLMISC::CRGBA::Black; + BackgroundColorOver=NLMISC::CRGBA::Black; + } + + bool hasStyle(const std::string &key) const + { + return StyleRules.find(key) != StyleRules.end(); + } + + std::string getStyle(const std::string &key) const + { + TStyle::const_iterator it = StyleRules.find(key); + return (it != StyleRules.end() ? it->second : ""); + } + + public: + uint FontSize; + uint FontWeight; + bool FontOblique; + std::string FontFamily; + NLMISC::CRGBA TextColor; + STextShadow TextShadow; + bool GlobalColor; + bool Underlined; + bool StrikeThrough; + sint32 Width; + sint32 Height; + sint32 MaxWidth; + sint32 MaxHeight; + sint32 BorderWidth; + NLMISC::CRGBA BackgroundColor; + NLMISC::CRGBA BackgroundColorOver; + + std::string WhiteSpace; + std::string TextAlign; + std::string VerticalAlign; + + TStyle StyleRules; + }; + + class CCssStyle { + public: + struct SStyleRule { + std::vector Selector; + TStyle Properties; + + // pseudo element like ':before' + std::string PseudoElement; + + // returns selector specificity + uint specificity() const; + }; + + // 'browser' style, overwriten with '' + CStyleParams Root; + + // current element style + CStyleParams Current; + + // known style rules sorted by specificity + std::vector _StyleRules; + + private: + std::vector _StyleStack; + + // test if str is one of "thin/medium/thick" and return its pixel value + bool scanCssLength(const std::string& str, uint32 &px) const; + + // read style attribute + void getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams ¤t) const; + void getStyleParams(const TStyle &styleRules, CStyleParams &style, const CStyleParams ¤t) const; + + // extract from styleRules into style.StyleRules (expand shorthand, normalize, calculate current font-size) + void normalize(const TStyle &styleRules, CStyleParams &style, const CStyleParams ¤t) const; + + // apply style.StyleRyles + void apply(CStyleParams &style, const CStyleParams ¤t) const; + + // merge src into dest by overwriting key in dest + void merge(TStyle &dst, const TStyle &src) const; + + // match selector to dom path + bool match(const std::vector &selector, const CHtmlElement &elm) const; + + // parse 'background' into 'background-color', 'background-image', etc + void parseBackgroundShorthand(const std::string &value, CStyleParams &style) const; + + public: + void reset(); + + // parse tag or css file content + void parseStylesheet(const std::string &styleString); + + // set element style from matching css rules + void getStyleFor(CHtmlElement &elm) const; + + inline uint getFontSizeSmaller() const + { + if (Current.FontSize < 5) + return 3; + return Current.FontSize-2; + } + + sint styleStackIndex = 0; + + inline void pushStyle() + { + styleStackIndex++; + _StyleStack.push_back(Current); + + Current.Width=-1; + Current.Height=-1; + Current.MaxWidth=-1; + Current.MaxHeight=-1; + Current.BorderWidth=1; + + Current.StyleRules.clear(); + } + + inline void popStyle() + { + styleStackIndex--; + if (_StyleStack.empty()) + { + Current = Root; + } + else + { + Current = _StyleStack.back(); + _StyleStack.pop_back(); + } + } + + // apply style to this.Root + void applyRootStyle(const std::string &styleString); + void applyRootStyle(const TStyle &styleRules); + + // apply style to this.Current + void applyStyle(const std::string &styleString); + void applyStyle(const TStyle &styleRules); + + void applyCssMinMax(sint32 &width, sint32 &height, sint32 minw=0, sint32 minh=0, sint32 maxw=0, sint32 maxh=0) const; + + // check if current style property matches value + bool checkStyle(const std::string &key, const std::string &val) const + { + return Current.hasStyle(key) && Current.getStyle(key) == val; + } + + bool hasStyle(const std::string &key) const + { + return Current.hasStyle(key); + } + + std::string getStyle(const std::string &key) const + { + return Current.getStyle(key); + } + }; +}//namespace + +#endif // CL_CSS_STYLE_H + diff --git a/code/nel/include/nel/gui/ctrl_scroll.h b/code/nel/include/nel/gui/ctrl_scroll.h index cf01ada78..a22da2cbd 100644 --- a/code/nel/include/nel/gui/ctrl_scroll.h +++ b/code/nel/include/nel/gui/ctrl_scroll.h @@ -175,6 +175,7 @@ namespace NLGUI bool _CallingAH : 1; bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button bool _Frozen : 1; + bool _Scale : 1; // For Target Scroller only: the target offset step in pixel. sint32 _TargetStepX; diff --git a/code/nel/include/nel/gui/ctrl_text_button.h b/code/nel/include/nel/gui/ctrl_text_button.h index 69898639d..e88ec81e1 100644 --- a/code/nel/include/nel/gui/ctrl_text_button.h +++ b/code/nel/include/nel/gui/ctrl_text_button.h @@ -111,9 +111,19 @@ namespace NLGUI sint32 getWMin() const { return _WMin; } void setWMin( sint32 wmin ) { _WMin = wmin; } + sint32 getHMin() const { return _HMin; } + void setHMin( sint32 hmin ) { _HMin = hmin; } + // Compute Size according to bitmap and Text (Ensure as big as possible button) sint32 getWMax() const; + // Set texture directly without _l.tga, _m.tga, _r.tga convention + // Texture size is only read from normal textures + // If updateHeight == false, then _BmpH will keep its value + void setTexture(const std::string &l, const std::string &m, const std::string &r, bool updateHeight = true); + void setTexturePushed(const std::string &l, const std::string &m, const std::string &r); + void setTextureOver(const std::string &l, const std::string &m, const std::string &r); + int luaGetViewText(CLuaState &ls); REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton) @@ -122,6 +132,7 @@ namespace NLGUI REFLECT_SINT32("text_x", getTextX, setTextX) REFLECT_SINT32("wmargin", getWMargin, setWMargin) REFLECT_SINT32("wmin", getWMin, setWMin) + REFLECT_SINT32("hmin", getHMin, setHMin) REFLECT_LUA_METHOD("getViewText", luaGetViewText) REFLECT_EXPORT_END @@ -151,8 +162,8 @@ namespace NLGUI sint32 _BmpLeftW, _BmpMiddleW, _BmpRightW, _BmpH; // Value to add to TextW to get button W. sint32 _WMargin; - // Min W Value - sint32 _WMin; + // Min W, H Value + sint32 _WMin, _HMin; sint32 _TextY; sint32 _TextX; THotSpot _TextPosRef; diff --git a/code/nel/include/nel/gui/curl_certificates.h b/code/nel/include/nel/gui/curl_certificates.h index 021b13360..9d5ad4855 100644 --- a/code/nel/include/nel/gui/curl_certificates.h +++ b/code/nel/include/nel/gui/curl_certificates.h @@ -17,19 +17,22 @@ #ifndef CL_CURL_CERTIFICATES_HTML_H #define CL_CURL_CERTIFICATES_HTML_H -#include - #include "nel/misc/types_nl.h" +// forward declaration to avoid curl.h inclusion everywhere +typedef void CURL; + namespace NLGUI { -#if defined(NL_OS_WINDOWS) - class CCurlCertificates { + class CCurlCertificates + { public: - // cURL SSL certificate loading - static CURLcode sslCtxFunction(CURL *curl, void *sslctx, void *parm); + // allow to use custom PEM certificates + static void addCertificateFile(const std::string &cert); + + // set all CURL options to use custom SSL context function + static void useCertificates(CURL *curl); }; -#endif // NL_OS_WINDOWS } // namespace #endif diff --git a/code/nel/include/nel/gui/dbgroup_combo_box.h b/code/nel/include/nel/gui/dbgroup_combo_box.h index 87e6d758a..723afbdc0 100644 --- a/code/nel/include/nel/gui/dbgroup_combo_box.h +++ b/code/nel/include/nel/gui/dbgroup_combo_box.h @@ -85,6 +85,7 @@ namespace NLGUI // view text void setViewText(const ucstring & text); ucstring getViewText() const; + CViewText *getViewText(); void setTexture(uint i, const ucstring &texture); diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 8d3478579..fc29c840d 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -17,21 +17,22 @@ #ifndef CL_GROUP_HTML_H #define CL_GROUP_HTML_H -#include - #include "nel/misc/types_nl.h" #include "nel/gui/interface_group.h" #include "nel/gui/group_scrolltext.h" #include "nel/gui/group_tree.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/group_table.h" -#include "nel/gui/libwww_types.h" +#include "nel/gui/html_element.h" +#include "nel/gui/css_style.h" -typedef std::map TStyle; +// forward declaration +typedef void CURLM; namespace NLGUI { class CCtrlButton; + class CCtrlTextButton; class CCtrlScroll; class CGroupList; class CGroupMenu; @@ -67,43 +68,17 @@ namespace NLGUI /// Maximum concurrent MultiCurl connections per CGroupHTML instance sint32 curlMaxConnections; - SWebOptions(): curlMaxConnections(2) + SWebOptions(): curlMaxConnections(5) { } }; static SWebOptions options; - - class CStyleParams - { - public: - CStyleParams () : FontFamily(""), TextColor(255,255,255,255) - { - FontSize=10; - FontWeight=400; - FontOblique=false; - Underlined=false; - StrikeThrough=false; - GlobalColor=false; - Width=-1; - Height=-1; - MaxWidth=-1; - MaxHeight=-1; - } - uint FontSize; - uint FontWeight; - bool FontOblique; - std::string FontFamily; - NLMISC::CRGBA TextColor; - bool GlobalColor; - bool Underlined; - bool StrikeThrough; - sint32 Width; - sint32 Height; - sint32 MaxWidth; - sint32 MaxHeight; - }; + // ImageDownload system + enum TDataType {ImgType= 0, BnpType, StylesheetType}; + enum TImageType {NormalImage=0, OverImage}; + // Constructor CGroupHTML(const TCtorParam ¶m); ~CGroupHTML(); @@ -122,8 +97,11 @@ namespace NLGUI // Browse virtual void browse (const char *url); + // load css from local file and insert into active stylesheet collection + void parseStylesheetFile(const std::string &fname); + // parse html string using libxml2 parser - virtual bool parseHtml(std::string htmlString); + bool parseHtml(const std::string &htmlString); // Refresh void refresh(); @@ -134,13 +112,8 @@ namespace NLGUI // Browse error void browseError (const char *msg); - // stop browse - void stopBrowse (); - bool isBrowsing(); - void clean() { stopBrowse(); updateRefreshButton(); removeContent(); } - // Update coords void updateCoords(); @@ -149,6 +122,10 @@ namespace NLGUI // End of the paragraph void endParagraph(); + + // add image download (used by view_bitmap.cpp to load web images) + void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage); + std::string localImageName(const std::string &url); // Timeout void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);} @@ -237,6 +214,8 @@ namespace NLGUI void browseUndo (); // Redo browse: Browse the precedent url undoed. no op if none void browseRedo (); + // disable refresh button + void clearRefresh(); // clear undo/redo void clearUndoRedo(); @@ -245,14 +224,14 @@ namespace NLGUI void setURL(const std::string &url); + int luaClearRefresh(CLuaState &ls); + int luaClearUndoRedo(CLuaState &ls); int luaBrowse(CLuaState &ls); int luaRefresh(CLuaState &ls); int luaRemoveContent(CLuaState &ls); int luaInsertText(CLuaState &ls); int luaAddString(CLuaState &ls); int luaAddImage(CLuaState &ls); - int luaBeginElement(CLuaState &ls); - int luaEndElement(CLuaState &ls); int luaShowDiv(CLuaState &ls); int luaParseHtml(CLuaState &ls); int luaRenderHtml(CLuaState &ls); @@ -260,43 +239,38 @@ namespace NLGUI REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText) REFLECT_LUA_METHOD("browse", luaBrowse) REFLECT_LUA_METHOD("refresh", luaRefresh) + REFLECT_LUA_METHOD("clearUndoRedo", luaClearUndoRedo) + REFLECT_LUA_METHOD("clearRefresh", luaClearRefresh) REFLECT_LUA_METHOD("removeContent", luaRemoveContent) REFLECT_LUA_METHOD("insertText", luaInsertText) REFLECT_LUA_METHOD("addString", luaAddString) REFLECT_LUA_METHOD("addImage", luaAddImage) - REFLECT_LUA_METHOD("beginElement", luaBeginElement) - REFLECT_LUA_METHOD("endElement", luaEndElement) REFLECT_LUA_METHOD("showDiv", luaShowDiv) REFLECT_LUA_METHOD("parseHtml", luaParseHtml) REFLECT_LUA_METHOD("renderHtml", luaRenderHtml) REFLECT_STRING("url", getURL, setURL) REFLECT_FLOAT("timeout", getTimeout, setTimeout) + REFLECT_STRING("title", getTitle, setTitle) REFLECT_EXPORT_END protected : // \name callback from libwww - // Begin of the parsing of a HTML document + // Begin of the rendering of a HTML document virtual void beginBuild (); - // End of the parsing of a HTML document + // End of the rendering of a HTML document virtual void endBuild (); // A new text block has been parsed virtual void addText (const char * buf, int len); // A new begin HTML element has been parsed ( for exemple) - virtual void beginElement (uint element_number, const std::vector &present, const std::vector &value); + virtual void beginElement(CHtmlElement &elm); // A new end HTML element has been parsed ( for exemple) - virtual void endElement (uint element_number); - - // A new begin unparsed element has been found - virtual void beginUnparsedElement(const char *buffer, int length); - - // A new end unparsed element has been found - virtual void endUnparsedElement(const char *buffer, int length); + virtual void endElement(CHtmlElement &elm); // Add GET params to the url virtual void addHTTPGetParams (std::string &url, bool trustedDomain); @@ -304,16 +278,15 @@ namespace NLGUI // Add POST params to the libwww list virtual void addHTTPPostParams (SFormFields &formfields, bool trustedDomain); - // the current request is terminated - virtual void requestTerminated(); - - // libxml2 html parser functions - void htmlElement(xmlNode *node, int element_number); - void htmlWalkDOM(xmlNode *a_node); - // Get Home URL virtual std::string home(); + // parse dom node and all child nodes recursively + void renderDOM(CHtmlElement &elm); + + // Clear style stack and restore default style + void resetCssStyle(); + // Parse style html tag TStyle parseStyle(const std::string &str_styles); @@ -341,7 +314,7 @@ namespace NLGUI void addString(const ucstring &str); // Add an image in the current paragraph - void addImage(const char *image, bool reloadImg=false, const CStyleParams &style = CStyleParams()); + void addImage(const std::string &id, const std::string &img, bool reloadImg=false, const CStyleParams &style = CStyleParams()); // 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); @@ -366,6 +339,8 @@ namespace NLGUI // Set the title void setTitle (const ucstring &title); + void setTitle (const std::string &title); + std::string getTitle() const; // Lookup a url in local file system bool lookupLocalFile (std::string &result, const char *url, bool isUrl); @@ -378,6 +353,14 @@ namespace NLGUI // Current URL std::string _DocumentUrl; std::string _DocumentDomain; + std::string _DocumentHtml; // not updated, only set by first render + // If true, then render _DocumentHtml on next update (replaces content) + bool _RenderNextTime; + // true if renderer is waiting for css files to finish downloading (link rel=stylesheet) + bool _WaitingForStylesheet; + // list of css file urls that are queued up for download + std::vector _StylesheetQueue; + // Valid base href was found bool _IgnoreBaseUrlTag; // Fragment from loading url @@ -410,7 +393,6 @@ namespace NLGUI // Browsing.. bool _Browsing; - bool _Connecting; double _TimeoutValue; // the timeout in seconds double _ConnectingTimeout; sint _RedirectsRemaining; @@ -495,79 +477,13 @@ namespace NLGUI // IL mode bool _LI; - // Current text color - std::vector _TextColor; - inline const NLMISC::CRGBA &getTextColor() const - { - if (_TextColor.empty()) - return TextColor; - return _TextColor.back(); - } - - // Current global color flag - std::vector _GlobalColor; - inline bool getGlobalColor() const - { - if (_GlobalColor.empty()) - return false; - return _GlobalColor.back(); - } - - // Current font name - std::vector _FontFamily; - inline const char* getFontFamily() const - { - if (_FontFamily.empty()) - return ""; - return _FontFamily.back().c_str(); - } - - // Current font size - std::vector _FontSize; - inline uint getFontSize() const - { - if (_FontSize.empty()) - return TextFontSize; - return _FontSize.back(); - } - inline uint getFontSizeSmaller() const - { - if (getFontSize() < 5) - return 3; - return getFontSize()-2; - } - - std::vector _FontWeight; - inline uint getFontWeight() const - { - if (_FontWeight.empty()) - return 400; - return _FontWeight.back(); - } - - std::vector _FontOblique; - inline bool getFontOblique() const - { - if (_FontOblique.empty()) - return false; - return _FontOblique.back(); - } - - std::vector _FontUnderlined; - inline bool getFontUnderlined() const - { - if (_FontUnderlined.empty()) - return false; - return _FontUnderlined.back(); - } - - std::vector _FontStrikeThrough; - inline bool getFontStrikeThrough() const - { - if (_FontStrikeThrough.empty()) - return false; - return _FontStrikeThrough.back(); - } + // Keep track of current element style + CCssStyle _Style; + CHtmlElement _HtmlDOM; + CHtmlElement *_CurrentHTMLElement; + // Backup of CurrentHTMLElement->nextSibling before ::beginElement() is called + // for luaParseHtml() to insert nodes into right place in right order + CHtmlElement *_CurrentHTMLNextSibling; // Current link std::vector _Link; @@ -720,6 +636,8 @@ namespace NLGUI return 0; return _Indent.back(); } + + // Current node is a title bool _Title; @@ -790,10 +708,6 @@ namespace NLGUI typedef std::map > TGroupHtmlByUIDMap; static TGroupHtmlByUIDMap _GroupHtmlByUID; - // 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); @@ -807,12 +721,13 @@ namespace NLGUI void buildHTTPPostParams (SFormFields &formfields); private: + friend class CHtmlParser; + + // move src->Children into CurrentHtmlElement.parent.children element + void spliceFragment(std::list::iterator src); + // decode all HTML entities static ucstring decodeHTMLEntities(const ucstring &str); - - // ImageDownload system - enum TDataType {ImgType= 0, BnpType}; - enum TImageType {NormalImage=0, OverImage}; struct CDataImageDownload { @@ -830,10 +745,11 @@ namespace NLGUI { public: CDataDownload(const std::string &u, const std::string &d, TDataType t, CViewBase *i, const std::string &s, const std::string &m, const CStyleParams &style = CStyleParams(), const TImageType imagetype = NormalImage) - : data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0) + : data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0), ConnectionTimeout(60) { if (t == ImgType) imgs.push_back(CDataImageDownload(i, style, imagetype)); } + ~CDataDownload(); public: CCurlWWWData *data; @@ -845,40 +761,131 @@ namespace NLGUI uint32 redirects; FILE *fp; std::vector imgs; + uint32 ConnectionTimeout; }; - std::vector Curls; + std::list Curls; CURLM *MultiCurl; int RunningCurls; bool startCurlDownload(CDataDownload &download); + void finishCurlDownload(const CDataDownload &download); + void pumpCurlQueue(); void initImageDownload(); void checkImageDownload(); - void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage); - std::string localImageName(const std::string &url); std::string getAbsoluteUrl(const std::string &url); bool isTrustedDomain(const std::string &domain); void setImage(CViewBase *view, const std::string &file, const TImageType type); void setImageSize(CViewBase *view, const CStyleParams &style = CStyleParams()); + void setTextButtonStyle(CCtrlTextButton *ctrlButton, const CStyleParams &style); + void setTextStyle(CViewText *pVT, const CStyleParams &style); + // BnpDownload system void initBnpDownload(); void checkBnpDownload(); bool addBnpDownload(std::string url, const std::string &action, const std::string &script, const std::string &md5sum); std::string localBnpName(const std::string &url); + // add css file from to download queue + void addStylesheetDownload(std::vector links); + + // stop all curl downalods (html and data) void releaseDownloads(); void checkDownloads(); + // _CurlWWW download finished + void htmlDownloadFinished(bool success, const std::string &error); + // images, stylesheets, etc finished downloading + void dataDownloadFinished(bool success, const std::string &error, CDataDownload &data); + // 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); + // stylesheet finished downloading. if local file does not exist, then it failed (404) + void cssDownloadFinished(const std::string &url, const std::string &local); + + // read common table/tr/td parameters and push them to _CellParams + void getCellsParameters(const CHtmlElement &elm, bool inherit); + + // render _HtmlDOM + void renderDocument(); + + // :before, :after rendering + void renderPseudoElement(const std::string &pseudo, const CHtmlElement &elm); + + // apply background from current style (for html, body) + void applyBackground(const CHtmlElement &elm); + + // HTML elements + void htmlA(const CHtmlElement &elm); + void htmlAend(const CHtmlElement &elm); + void htmlBASE(const CHtmlElement &elm); + void htmlBODY(const CHtmlElement &elm); + void htmlBR(const CHtmlElement &elm); + void htmlDD(const CHtmlElement &elm); + void htmlDDend(const CHtmlElement &elm); + //void htmlDEL(const CHtmlElement &elm); + void htmlDIV(const CHtmlElement &elm); + void htmlDIVend(const CHtmlElement &elm); + void htmlDL(const CHtmlElement &elm); + void htmlDLend(const CHtmlElement &elm); + void htmlDT(const CHtmlElement &elm); + void htmlDTend(const CHtmlElement &elm); + //void htmlEM(const CHtmlElement &elm); + void htmlFONT(const CHtmlElement &elm); + void htmlFORM(const CHtmlElement &elm); + void htmlH(const CHtmlElement &elm); + void htmlHend(const CHtmlElement &elm); + void htmlHEAD(const CHtmlElement &elm); + void htmlHEADend(const CHtmlElement &elm); + void htmlHR(const CHtmlElement &elm); + void htmlHTML(const CHtmlElement &elm); + void htmlI(const CHtmlElement &elm); + void htmlIend(const CHtmlElement &elm); + void htmlIMG(const CHtmlElement &elm); + void htmlINPUT(const CHtmlElement &elm); + void htmlLI(const CHtmlElement &elm); + void htmlLIend(const CHtmlElement &elm); + void htmlLUA(const CHtmlElement &elm); + void htmlLUAend(const CHtmlElement &elm); + void htmlMETA(const CHtmlElement &elm); + void htmlOBJECT(const CHtmlElement &elm); + void htmlOBJECTend(const CHtmlElement &elm); + void htmlOL(const CHtmlElement &elm); + void htmlOLend(const CHtmlElement &elm); + void htmlOPTION(const CHtmlElement &elm); + void htmlOPTIONend(const CHtmlElement &elm); + void htmlP(const CHtmlElement &elm); + void htmlPend(const CHtmlElement &elm); + void htmlPRE(const CHtmlElement &elm); + void htmlPREend(const CHtmlElement &elm); + void htmlSCRIPT(const CHtmlElement &elm); + void htmlSCRIPTend(const CHtmlElement &elm); + void htmlSELECT(const CHtmlElement &elm); + void htmlSELECTend(const CHtmlElement &elm); + //void htmlSMALL(const CHtmlElement &elm); + //void htmlSPAN(const CHtmlElement &elm); + //void htmlSTRONG(const CHtmlElement &elm); + void htmlSTYLE(const CHtmlElement &elm); + void htmlSTYLEend(const CHtmlElement &elm); + void htmlTABLE(const CHtmlElement &elm); + void htmlTABLEend(const CHtmlElement &elm); + void htmlTD(const CHtmlElement &elm); + void htmlTDend(const CHtmlElement &elm); + void htmlTEXTAREA(const CHtmlElement &elm); + void htmlTEXTAREAend(const CHtmlElement &elm); + void htmlTH(const CHtmlElement &elm); + void htmlTHend(const CHtmlElement &elm); + void htmlTITLE(const CHtmlElement &elm); + void htmlTITLEend(const CHtmlElement &elm); + void htmlTR(const CHtmlElement &elm); + void htmlTRend(const CHtmlElement &elm); + //void htmlU(const CHtmlElement &elm); + void htmlUL(const CHtmlElement &elm); + void htmlULend(const CHtmlElement &elm); }; // adapter group that store y offset for inputs inside an html form diff --git a/code/nel/include/nel/gui/group_menu.h b/code/nel/include/nel/gui/group_menu.h index d4f940088..cfe91f7f9 100644 --- a/code/nel/include/nel/gui/group_menu.h +++ b/code/nel/include/nel/gui/group_menu.h @@ -351,6 +351,9 @@ namespace NLGUI void setMinW(sint32 minW); void setMinH(sint32 minH); + // change fontsize for new menu items + void setFontSize(uint32 fontSize); + // Gray a line on the RootMenu void setGrayedLine(uint line, bool g); diff --git a/code/nel/include/nel/gui/group_paragraph.h b/code/nel/include/nel/gui/group_paragraph.h index 0004850fa..02f948582 100644 --- a/code/nel/include/nel/gui/group_paragraph.h +++ b/code/nel/include/nel/gui/group_paragraph.h @@ -206,6 +206,11 @@ namespace NLGUI invalidateContent(); } + /// temporarily enable mouse over effect + // will be automatically disabled when mouse leaves element + void enableTempOver() { _TempOver = true; } + void disableTempOver() { _TempOver = false; } + /// \from CInterfaceElement void onInvalidateContent(); sint32 getMaxUsedW() const; @@ -233,6 +238,8 @@ namespace NLGUI // Do we have a color under the element pointed by the mouse bool _Over; + // Temporarily force mouse over effect. Deactivated when mouse moves away + bool _TempOver; // If over is true so we have a color NLMISC::CRGBA _OverColor; diff --git a/code/nel/include/nel/gui/html_element.h b/code/nel/include/nel/gui/html_element.h new file mode 100644 index 000000000..bac681c1c --- /dev/null +++ b/code/nel/include/nel/gui/html_element.h @@ -0,0 +1,86 @@ +// Ryzom - MMORPG Framework +// 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 . + +#ifndef CL_HTML_ELEMENT_H +#define CL_HTML_ELEMENT_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/css_style.h" + +namespace NLGUI +{ + /** + * \brief HTML element + * \date 2019-04-25 18:23 GMT + * \author Meelis Mägi (Nimetu) + */ + class CHtmlElement + { + public: + enum ENodeType { + NONE = 0, + ELEMENT_NODE = 1, + TEXT_NODE = 3, + }; + + uint ID; // libwww element enum + ENodeType Type; + std::string Value; // text node value or element node name + std::map Attributes; + std::list Children; + + // class names for css matching + std::set ClassNames; + + // defined style and :before/:after pseudo elements + TStyle Style; + TStyle StyleBefore; + TStyle StyleAfter; + + // hierarchy + CHtmlElement *parent; + CHtmlElement *previousSibling; + CHtmlElement *nextSibling; + + // n'th ELEMENT_NODE in parent.Children, for :nth-child() rules + uint childIndex; + + CHtmlElement(ENodeType type = NONE, std::string value = ""); + + // returns true if rhs is same pointer + friend bool operator==(const CHtmlElement &lhs, const CHtmlElement &rhs) + { + return &lhs == &rhs; + } + + bool hasAttribute(const std::string &key) const; + + bool hasNonEmptyAttribute(const std::string &key) const; + + std::string getAttribute(const std::string &key) const; + + bool hasClass(const std::string &key) const; + + // update Children index/parent/next/prevSibling pointers + void reindexChilds(); + + // debug + std::string toString(bool tree = false, uint depth = 0) const; + }; +} + +#endif + diff --git a/code/nel/include/nel/gui/html_parser.h b/code/nel/include/nel/gui/html_parser.h new file mode 100644 index 000000000..760640234 --- /dev/null +++ b/code/nel/include/nel/gui/html_parser.h @@ -0,0 +1,52 @@ +// Ryzom - MMORPG Framework +// 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 . + +#ifndef CL_HTML_PARSER_H +#define CL_HTML_PARSER_H + +#include "nel/misc/types_nl.h" + +namespace NLGUI +{ + class CHtmlElement; + + /** + * \brief HTML parsing + * \date 2019-03-15 10:50 GMT + * \author Meelis Mägi (Nimetu) + */ + class CHtmlParser + { + public: + bool parseHtml(std::string htmlString) const; + + // parse html string into DOM, extract + bool useStyle = true; + if (elm.hasAttribute("media")) + { + std::string media = trim(toLower(elm.Attributes["media"])); + useStyle = media.empty() || media.find("all") != std::string::npos || media.find("screen") != std::string::npos; + + //