1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-10-06 09:07:19 +02:00

CMake: FindSFML+FindMAD, set library paths as SYSTEM, remove dead stuff.

This commit is contained in:
Daniel Evans 2016-05-19 22:28:12 +01:00
parent b8062714a9
commit 9f85f283cb
13 changed files with 469 additions and 677 deletions

View File

@ -2,30 +2,32 @@ cmake_minimum_required(VERSION 2.8)
project(OpenRW)
#
# Options
#
# Global Build Configuration
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DRW_DEBUG=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pthread -Wextra -Wpedantic")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
# Optional components
SET(BUILD_SCRIPT_TOOL TRUE CACHE BOOL "Build script decompiler tool")
SET(BUILD_TESTS TRUE CACHE BOOL "Build test suite")
SET(BUILD_OLD_TOOLS FALSE CACHE BOOL "Build old datadump and analyzer tools")
SET(BUILD_TOOLS FALSE CACHE BOOL "Build editor application")
option(BUILD_TESTS "Build test suite")
option(BUILD_VIEWER "Build GUI data viewer")
option(BUILD_SCRIPT_TOOL "Build script decompiler tool")
# Features
SET(ENABLE_PROFILE_RENDERER TRUE CACHE BOOL "Enable higher precision rendering profiler")
# Compile-time Options & Features
option(ENABLE_SCRIPT_DEBUG "Enable verbose script execution")
option(ENABLE_PROFILING "Enable detailed profiling metrics")
# Options
SET(ENABLE_SCRIPT_DEBUG FALSE CACHE BOOL "Enable verbose script execution")
IF(APPLE)
set(OPENRW_PLATFORM_LIBS iconv)
ENDIF()
#
# Build configuration
#
# Make GLM use radians
add_definitions(-DGLM_FORCE_RADIANS)
IF(${PROFILING})
IF(${ENABLE_PROFILING})
add_definitions(-DRENDER_PROFILER=0 -DRW_PROFILER=1)
else()
add_definitions(-DRENDER_PROFILER=0 -DRW_PROFILER=0)
@ -35,25 +37,30 @@ IF(${ENABLE_SCRIPT_DEBUG})
add_definitions(-DSCM_DEBUG_INSTRUCTIONS)
ENDIF()
# Find dependancies
IF(APPLE)
set(OPENRW_PLATFORM_LIBS iconv)
ENDIF()
find_package(OpenGL REQUIRED)
find_package(Bullet REQUIRED)
find_package(SFML 2 COMPONENTS system window audio graphics network REQUIRED)
find_package(MAD REQUIRED)
IF(BUILD_OLD_TOOLS)
add_subdirectory(analyzer)
add_subdirectory(datadump)
ENDIF()
#
# Components
#
add_subdirectory(rwlib)
add_subdirectory(rwengine)
add_subdirectory(rwgame)
IF(BUILD_SCRIPT_TOOL)
IF(${BUILD_SCRIPT_TOOL})
add_subdirectory(scripttool)
ENDIF()
IF(${BUILD_TOOLS})
IF(${BUILD_VIEWER})
add_subdirectory(rwviewer)
ENDIF()
IF(${BUILD_TESTS})
add_subdirectory(tests)
add_subdirectory(tests)
ENDIF()

View File

@ -1,10 +1,10 @@
# OpenRW
OpenRW is a re-implementation of Rockstar Games' Grand Theft Auto III, a classic 3D action
game first published in 2001.
OpenRW is an open source re-implementation of Rockstar Games' Grand Theft Auto III,
a classic 3D action game first published in 2001.
This project requires a legitimate copy of the original PC game data in order to run. Without
this data it will not be possible to use openrw.
OpenRW requires a legitimate copy of the original PC game data in order to run.
Without this data it will not be possible to run openrw.
## Building
@ -13,20 +13,21 @@ Dependencies:
* Bullet
* GLM (0.9.5+)
* SFML (2.0+)
* libmad
* Boost Test
Global Options:
* BUILD_TESTS — Builds the test suite
* BUILD_TOOLS — Builds the rwviewer application
* BUILD\_OLD\_TOOLS Builds old, unmaintained tools (datadump & analyzer)
* BUILD_TESTS — Build the test suite
* BUILD_VIEWER - Build the Qt GUI for viewing data
* BUILD_SCRIPT_TOOL - Build the script dissassembler
### Recomended build
```
$ mkdir build
$ cd build
$ cmake ../
$ cmake ../ -DCMAKE_BUILD_TYPE=Release
```
## Running
@ -44,7 +45,9 @@ This is the game binary
### rwviewer
This Qt application enables viewing of the game data files and models.
This is a Qt tool for opening the game data. It currently supports looking at
objects and their models, and a primitive world viewer. It needs more work to
be useful for looking inside archives and viewing textures.
## Documentation

View File

@ -1,7 +0,0 @@
add_executable(analyzer main.cpp)
include_directories(${CMAKE_SOURCE_DIR}/rwengine/include)
target_link_libraries( analyzer rwengine sfml-graphics )
install(TARGETS analyzer RUNTIME DESTINATION bin)

View File

@ -1,77 +0,0 @@
#include <BinaryStream.hpp>
#include <TextureArchive.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <sstream>
int main(int argc, char** argv)
{
std::cout << std::showbase;
std::string gtapath = argv[1];
auto ojg = RW::BinaryStream::parse(gtapath +"/models/MISC.TXD");
// auto ojg = RW::BinaryStream::parse("OJG.TXD");
auto texture = RW::TextureArchive::create(*ojg);
std::cout << "Found " << texture->numTextures << " textures!" << std::endl;
sf::Image img;
for (size_t i = 0; i < texture->numTextures; i++) {
auto &tex = texture->textures[i];
std::cout << "Processing " << tex.header.diffuseName << std::endl;
img.create(tex.header.width, tex.header.height);
for (int j = 0; j < tex.header.width; j++) {
for (int i = 0; i < tex.header.width; i++) {
bool hasAlpha = (tex.header.rasterFormat & 0x0500) == 0x0500;
if (tex.header.rasterFormat & 0x2000) {
uint8_t pixelIndex = 4 * tex.body.pixels[j*tex.header.width + i];
img.setPixel(i, j, {
tex.body.palette[pixelIndex + 0],
tex.body.palette[pixelIndex + 1],
tex.body.palette[pixelIndex + 2],
(hasAlpha ? tex.body.palette[pixelIndex + 3] : static_cast<sf::Uint8>(255))
});
} else {
uint8_t pixel = 4 * tex.body.pixels[j*tex.header.width + i];
img.setPixel(i, j, {
tex.body.pixels[pixel + 0],
tex.body.pixels[pixel + 1],
tex.body.pixels[pixel + 2],
tex.body.pixels[pixel + 3],
});
}
}
}
std::stringstream ss;
ss << tex.header.diffuseName << ".png";
img.saveToFile(ss.str());
size_t scaleUp = 8;
img.create(16*scaleUp, 16*scaleUp);
for (int j = 0; j < 16; j++) {
for (int i = 0; i < 16; i++) {
uint8_t pixelIndex = 4 * (j*16 + i);
for (u_int32_t y = 0; y < scaleUp; y++) {
for (u_int32_t x = 0; x < scaleUp; x++) {
img.setPixel((i*scaleUp)+x, (j*scaleUp)+y, {
tex.body.palette[pixelIndex + 0],
tex.body.palette[pixelIndex + 1],
tex.body.palette[pixelIndex + 2],
tex.body.palette[pixelIndex + 3],
});
}
}
}
}
img.saveToFile("palette"+ ss.str());
}
return 0;
}

View File

@ -0,0 +1,35 @@
#
# This script defines the following variables:
# - MAD_LIBRARY: The mad library
# - MAD_FOUND: true if all the required modules are found
# - MAD_INCLUDE_DIR: the path where SFML headers are located (the directory containing the SFML/Config.hpp file)
#
set(FIND_MAD_PATHS
${MAD_ROOT}
$ENV{MAD_ROOT}
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt)
find_path(MAD_INCLUDE_DIR mad.h
PATH_SUFFIXES include
PATHS ${FIND_MAD_PATHS})
find_library(MAD_LIBRARY
NAMES mad
PATH_SUFFIXES lib64 lib
PATHS ${FIND_MAD_PATHS})
if (MAD_INCLUDE_DIR AND MAD_LIBRARY)
set (MAD_FOUND TRUE)
endif ()
if (MAD_FOUND AND NOT MAD_FIND_QUIETLY)
message(STATUS "Found MAD in ${MAD_INCLUDE_DIR}")
endif()

View File

@ -0,0 +1,368 @@
# This script locates the SFML library
# ------------------------------------
#
# Usage
# -----
#
# When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main).
# If none is given, the SFML_LIBRARIES variable will be empty and you'll end up linking to nothing.
# example:
# find_package(SFML COMPONENTS graphics window system) // find the graphics, window and system modules
#
# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
# If nothing is specified, the version won't be checked (i.e. any version will be accepted).
# example:
# find_package(SFML COMPONENTS ...) // no specific version required
# find_package(SFML 2 COMPONENTS ...) // any 2.x version
# find_package(SFML 2.4 COMPONENTS ...) // version 2.4 or greater
#
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
# Since you have to link yourself all the SFML dependencies when you link it statically, the following
# additional variables are defined: SFML_XXX_DEPENDENCIES and SFML_DEPENDENCIES (see their detailed
# description below).
# In case of static linking, the SFML_STATIC macro will also be defined by this script.
# example:
# set(SFML_STATIC_LIBRARIES TRUE)
# find_package(SFML 2 COMPONENTS network system)
#
# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless
# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details.
# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
# are available for both release and debug modes.
#
# If SFML is not installed in a standard path, you can use the SFML_ROOT CMake (or environment) variable
# to tell CMake where SFML is.
#
# Output
# ------
#
# This script defines the following variables:
# - For each specified module XXX (system, window, graphics, network, audio, main):
# - SFML_XXX_LIBRARY_DEBUG: the name of the debug library of the xxx module (set to SFML_XXX_LIBRARY_RELEASE is no debug version is found)
# - SFML_XXX_LIBRARY_RELEASE: the name of the release library of the xxx module (set to SFML_XXX_LIBRARY_DEBUG is no release version is found)
# - SFML_XXX_LIBRARY: the name of the library to link to for the xxx module (includes both debug and optimized names if necessary)
# - SFML_XXX_FOUND: true if either the debug or release library of the xxx module is found
# - SFML_XXX_DEPENDENCIES: the list of libraries the module depends on, in case of static linking
# - SFML_LIBRARIES: the list of all libraries corresponding to the required modules
# - SFML_FOUND: true if all the required modules are found
# - SFML_INCLUDE_DIR: the path where SFML headers are located (the directory containing the SFML/Config.hpp file)
# - SFML_DEPENDENCIES: the list of libraries SFML depends on, in case of static linking
#
# example:
# find_package(SFML 2 COMPONENTS system window graphics audio REQUIRED)
# include_directories(${SFML_INCLUDE_DIR})
# add_executable(myapp ...)
# target_link_libraries(myapp ${SFML_LIBRARIES})
# define the SFML_STATIC macro if static build was chosen
if(SFML_STATIC_LIBRARIES)
add_definitions(-DSFML_STATIC)
endif()
# define the list of search paths for headers and libraries
set(FIND_SFML_PATHS
${SFML_ROOT}
$ENV{SFML_ROOT}
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt)
# find the SFML include directory
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
PATH_SUFFIXES include
PATHS ${FIND_SFML_PATHS})
# check the version number
set(SFML_VERSION_OK TRUE)
if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR)
# extract the major and minor version numbers from SFML/Config.hpp
# we have to handle framework a little bit differently:
if("${SFML_INCLUDE_DIR}" MATCHES "SFML.framework")
set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/Headers/Config.hpp")
else()
set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/SFML/Config.hpp")
endif()
FILE(READ "${SFML_CONFIG_HPP_INPUT}" SFML_CONFIG_HPP_CONTENTS)
STRING(REGEX REPLACE ".*#define SFML_VERSION_MAJOR ([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}")
STRING(REGEX REPLACE ".*#define SFML_VERSION_MINOR ([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}")
STRING(REGEX REPLACE ".*#define SFML_VERSION_PATCH ([0-9]+).*" "\\1" SFML_VERSION_PATCH "${SFML_CONFIG_HPP_CONTENTS}")
if (NOT "${SFML_VERSION_PATCH}" MATCHES "^[0-9]+$")
set(SFML_VERSION_PATCH 0)
endif()
math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10000 + ${SFML_FIND_VERSION_MINOR} * 100 + ${SFML_FIND_VERSION_PATCH}")
# if we could extract them, compare with the requested version number
if (SFML_VERSION_MAJOR)
# transform version numbers to an integer
math(EXPR SFML_VERSION "${SFML_VERSION_MAJOR} * 10000 + ${SFML_VERSION_MINOR} * 100 + ${SFML_VERSION_PATCH}")
# compare them
if(SFML_VERSION LESS SFML_REQUESTED_VERSION)
set(SFML_VERSION_OK FALSE)
endif()
else()
# SFML version is < 2.0
if (SFML_REQUESTED_VERSION GREATER 10900)
set(SFML_VERSION_OK FALSE)
set(SFML_VERSION_MAJOR 1)
set(SFML_VERSION_MINOR x)
set(SFML_VERSION_PATCH x)
endif()
endif()
endif()
# find the requested modules
set(SFML_FOUND TRUE) # will be set to false if one of the required modules is not found
foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER})
# no suffix for sfml-main, it is always a static library
if(FIND_SFML_COMPONENT_LOWER STREQUAL "main")
# release library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
NAMES ${FIND_SFML_COMPONENT_NAME}
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
# debug library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
NAMES ${FIND_SFML_COMPONENT_NAME}-d
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
else()
# static release library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
NAMES ${FIND_SFML_COMPONENT_NAME}-s
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
# static debug library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
NAMES ${FIND_SFML_COMPONENT_NAME}-s-d
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
# dynamic release library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
NAMES ${FIND_SFML_COMPONENT_NAME}
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
# dynamic debug library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG
NAMES ${FIND_SFML_COMPONENT_NAME}-d
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
# choose the entries that fit the requested link type
if(SFML_STATIC_LIBRARIES)
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE})
endif()
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG})
endif()
else()
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE})
endif()
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG})
endif()
endif()
endif()
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG OR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
# library found
set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND TRUE)
# if both are found, set SFML_XXX_LIBRARY to contain both
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY debug ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG}
optimized ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
endif()
# if only one debug/release variant is found, set the other to be equal to the found one
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
# debug and not release
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
endif()
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG)
# release and not debug
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
endif()
else()
# library not found
set(SFML_FOUND FALSE)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND FALSE)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY "")
set(FIND_SFML_MISSING "${FIND_SFML_MISSING} SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY")
endif()
# mark as advanced
MARK_AS_ADVANCED(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
# add to the global list of libraries
set(SFML_LIBRARIES ${SFML_LIBRARIES} "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}")
endforeach()
# in case of static linking, we must also define the list of all the dependencies of SFML libraries
if(SFML_STATIC_LIBRARIES)
# detect the OS
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(FIND_SFML_OS_WINDOWS 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(FIND_SFML_OS_LINUX 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(FIND_SFML_OS_FREEBSD 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(FIND_SFML_OS_MACOSX 1)
endif()
# start with an empty list
set(SFML_DEPENDENCIES)
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
# macro that searches for a 3rd-party library
macro(find_sfml_dependency output friendlyname)
# No lookup in environment variables (PATH on Windows), as they may contain wrong library versions
find_library(${output} NAMES ${ARGN} PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib NO_SYSTEM_ENVIRONMENT_PATH)
if(${${output}} STREQUAL "${output}-NOTFOUND")
unset(output)
set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${friendlyname}")
endif()
endmacro()
# sfml-system
list(FIND SFML_FIND_COMPONENTS "system" FIND_SFML_SYSTEM_COMPONENT)
if(NOT ${FIND_SFML_SYSTEM_COMPONENT} EQUAL -1)
# update the list -- these are only system libraries, no need to find them
if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD OR FIND_SFML_OS_MACOSX)
set(SFML_SYSTEM_DEPENDENCIES "pthread")
endif()
if(FIND_SFML_OS_LINUX)
set(SFML_SYSTEM_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} "rt")
endif()
if(FIND_SFML_OS_WINDOWS)
set(SFML_SYSTEM_DEPENDENCIES "winmm")
endif()
set(SFML_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} ${SFML_DEPENDENCIES})
endif()
# sfml-network
list(FIND SFML_FIND_COMPONENTS "network" FIND_SFML_NETWORK_COMPONENT)
if(NOT ${FIND_SFML_NETWORK_COMPONENT} EQUAL -1)
# update the list -- these are only system libraries, no need to find them
if(FIND_SFML_OS_WINDOWS)
set(SFML_NETWORK_DEPENDENCIES "ws2_32")
endif()
set(SFML_DEPENDENCIES ${SFML_NETWORK_DEPENDENCIES} ${SFML_DEPENDENCIES})
endif()
# sfml-window
list(FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT)
if(NOT ${FIND_SFML_WINDOW_COMPONENT} EQUAL -1)
# find libraries
if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
find_sfml_dependency(X11_LIBRARY "X11" X11)
find_sfml_dependency(LIBXCB_LIBRARIES "XCB" xcb libxcb)
find_sfml_dependency(X11_XCB_LIBRARY "X11-xcb" X11-xcb libX11-xcb)
find_sfml_dependency(XCB_RANDR_LIBRARY "xcb-randr" xcb-randr libxcb-randr)
find_sfml_dependency(XCB_IMAGE_LIBRARY "xcb-image" xcb-image libxcb-image)
endif()
if(FIND_SFML_OS_LINUX)
find_sfml_dependency(UDEV_LIBRARIES "UDev" udev libudev)
endif()
# update the list
if(FIND_SFML_OS_WINDOWS)
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "opengl32" "winmm" "gdi32")
elseif(FIND_SFML_OS_LINUX)
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${LIBXCB_LIBRARIES} ${X11_XCB_LIBRARY} ${XCB_RANDR_LIBRARY} ${XCB_IMAGE_LIBRARY} ${UDEV_LIBRARIES})
elseif(FIND_SFML_OS_FREEBSD)
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${LIBXCB_LIBRARIES} ${X11_XCB_LIBRARY} ${XCB_RANDR_LIBRARY} ${XCB_IMAGE_LIBRARY} "usbhid")
elseif(FIND_SFML_OS_MACOSX)
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "-framework OpenGL -framework Foundation -framework AppKit -framework IOKit -framework Carbon")
endif()
set(SFML_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} ${SFML_DEPENDENCIES})
endif()
# sfml-graphics
list(FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT)
if(NOT ${FIND_SFML_GRAPHICS_COMPONENT} EQUAL -1)
# find libraries
find_sfml_dependency(FREETYPE_LIBRARY "FreeType" freetype)
find_sfml_dependency(JPEG_LIBRARY "libjpeg" jpeg)
# update the list
set(SFML_GRAPHICS_DEPENDENCIES ${FREETYPE_LIBRARY} ${JPEG_LIBRARY})
set(SFML_DEPENDENCIES ${SFML_GRAPHICS_DEPENDENCIES} ${SFML_DEPENDENCIES})
endif()
# sfml-audio
list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT)
if(NOT ${FIND_SFML_AUDIO_COMPONENT} EQUAL -1)
# find libraries
find_sfml_dependency(OPENAL_LIBRARY "OpenAL" openal openal32)
find_sfml_dependency(OGG_LIBRARY "Ogg" ogg)
find_sfml_dependency(VORBIS_LIBRARY "Vorbis" vorbis)
find_sfml_dependency(VORBISFILE_LIBRARY "VorbisFile" vorbisfile)
find_sfml_dependency(VORBISENC_LIBRARY "VorbisEnc" vorbisenc)
find_sfml_dependency(FLAC_LIBRARY "FLAC" FLAC)
# update the list
set(SFML_AUDIO_DEPENDENCIES ${OPENAL_LIBRARY} ${FLAC_LIBRARY} ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY})
set(SFML_DEPENDENCIES ${SFML_DEPENDENCIES} ${SFML_AUDIO_DEPENDENCIES})
endif()
endif()
# handle errors
if(NOT SFML_VERSION_OK)
# SFML version not ok
set(FIND_SFML_ERROR "SFML found but version too low (requested: ${SFML_FIND_VERSION}, found: ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH})")
set(SFML_FOUND FALSE)
elseif(SFML_STATIC_LIBRARIES AND FIND_SFML_DEPENDENCIES_NOTFOUND)
set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})")
set(SFML_FOUND FALSE)
elseif(NOT SFML_FOUND)
# include directory or library not found
set(FIND_SFML_ERROR "Could NOT find SFML (missing: ${FIND_SFML_MISSING})")
endif()
if (NOT SFML_FOUND)
if(SFML_FIND_REQUIRED)
# fatal error
message(FATAL_ERROR ${FIND_SFML_ERROR})
elseif(NOT SFML_FIND_QUIETLY)
# error but continue
message("${FIND_SFML_ERROR}")
endif()
endif()
# handle success
if(SFML_FOUND AND NOT SFML_FIND_QUIETLY)
message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH} in ${SFML_INCLUDE_DIR}")
endif()

View File

@ -1,5 +0,0 @@
add_executable(datadump main.cpp)
include_directories(${CMAKE_SOURCE_DIR}/rwengine/include)
target_link_libraries( datadump rwengine )
install(TARGETS datadump RUNTIME DESTINATION bin)

View File

@ -1,536 +0,0 @@
#include <unistd.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <BinaryStream.hpp>
#include <loaders/LoaderCOL.hpp>
#include <loaders/LoaderIFP.hpp>
#include <loaders/rwbinarystream.h>
using RW::BSSectionHeader;
using RW::BSFrameList;
using RW::BSFrameListFrame;
using RW::BSClump;
using namespace RW;
template<class T> T readStructure(char* data, size_t& dataI)
{
size_t orgoff = dataI; dataI += sizeof(T);
return *reinterpret_cast<T*>(data+orgoff);
}
BSSectionHeader readHeader(char* data, size_t& dataI)
{
return readStructure<BSSectionHeader>(data, dataI);
}
bool loadFile(const char *filename, char **data, size_t* size = nullptr)
{
std::ifstream dfile(filename);
if ( ! dfile.is_open()) {
std::cerr << "Error opening file " << filename << std::endl;
return false;
}
dfile.seekg(0, std::ios_base::end);
size_t length = dfile.tellg();
dfile.seekg(0);
*data = new char[length];
dfile.read(*data, length);
if(size) *size = length;
return true;
}
void dumpModelFile(char* data)
{
BinaryStreamSection root(data);
auto clump = root.readStructure<BSClump>();
std::cout << "numatomics(" << clump.numatomics << ")" << std::endl;
size_t dataI = 0;
while(root.hasMoreData(dataI))
{
auto sec = root.getNextChildSection(dataI);
switch(sec.header.id)
{
case RW::SID_FrameList:
{
/*auto list =*/ sec.readStructure<BSFrameList>();
}
break;
case RW::SID_GeometryList:
{
/*auto list =*/ sec.readStructure<BSGeometryList>();
size_t gdataI = 0;
while(sec.hasMoreData(gdataI))
{
auto item = sec.getNextChildSection(gdataI);
if(item.header.id == RW::SID_Geometry)
{
auto geom = item.readStructure<BSGeometry>();
std::cout << " verts(" << geom.numverts << ") tris(" << geom.numtris << ")" << std::endl;
}
}
}
break;
}
}
auto frameheader = readHeader(data, dataI);
std::cout << "ID = " << std::hex << (unsigned long)frameheader.id << " (IsFrameList = " << (frameheader.id == RW::SID_FrameList) << ")" << std::endl;
readHeader(data, dataI);
BSFrameList frames = readStructure<BSFrameList>(data, dataI);
std::cout << " Frame List Data" << std::endl;
std::cout << " Frames = " << std::dec << (unsigned long)frames.numframes << std::endl;
for(size_t i = 0; i < frames.numframes; ++i)
{
BSFrameListFrame frame = readStructure<BSFrameListFrame>(data, dataI);
std::cout << " Frame Data" << std::endl;
std::cout << " Index = " << std::dec << (unsigned long)frame.index << std::endl;
std::cout << " Position = " << frame.position.x << " " << frame.position.y << " " << frame.position.z << std::endl;
// std::cout << " Rotation = " << std::endl;
// std::cout << " " << frame.rotation.a.x << " " << frame.rotation.a.y << " " << frame.rotation.a.z << std::endl;
// std::cout << " " << frame.rotation.b.x << " " << frame.rotation.b.y << " " << frame.rotation.b.z << std::endl;
// std::cout << " " << frame.rotation.c.x << " " << frame.rotation.c.y << " " << frame.rotation.c.z << std::endl;
}
auto nextHeader = readHeader(data, dataI);
while(nextHeader.id == RW::SID_Extension)
{
for(size_t i = 0; i < 2; ++i) {
auto firstHeader = readHeader(data, dataI);
if(firstHeader.id == RW::SID_NodeName)
{
std::cout << " Name = " << std::string(data+dataI, firstHeader.size) << std::endl;
}
else if(firstHeader.id == RW::SID_HAnimPLG)
{
std::cout << " Bone Information Present" << std::endl;
}
dataI += firstHeader.size;
}
nextHeader = readHeader(data, dataI);
}
readHeader(data, dataI); // Structure Header..
auto geomlist = readStructure<BSGeometryList>(data, dataI);
std::cout << " Geometry List Data" << std::endl;
std::cout << " Geometries = " << std::dec << geomlist.numgeometry << std::endl;
for(size_t i = 0; i < geomlist.numgeometry; ++i)
{
auto geomHeader = readHeader(data, dataI);
size_t basedata = dataI;
readHeader(data, dataI);
auto geom = readStructure<BSGeometry>(data, dataI);
std::cout << " Geometry Data" << std::endl;
std::cout << " Flags = " << std::hex << static_cast<unsigned long>(geom.flags) << std::endl;
std::cout << " UV Sets = " << std::dec << static_cast<unsigned long>(geom.numuvs) << std::endl;
std::cout << " Flags = " << std::hex << static_cast<unsigned long>(geom.geomflags) << std::endl;
std::cout << " Triangles = " << std::dec << static_cast<unsigned long>(geom.numtris) << std::endl;
std::cout << " Verticies = " << static_cast<unsigned long>(geom.numverts) << std::endl;
std::cout << " Frames = " << static_cast<unsigned long>(geom.numframes) << std::endl;
if(geomHeader.versionid < 0x1003FFFF)
{
std::cout << " Some extra colour info" << std::endl;
/*auto colors =*/ readStructure<BSGeometryColor>(data, dataI);
}
if(geom.flags & BSGeometry::VertexColors)
{
std::cout << " Vertex Colours Present" << std::endl;
for(size_t v = 0; v < geom.numverts; ++v)
{
auto c = readStructure<BSColor>(data, dataI);
std::cout << " " << v << ": " << c.r << " " << c.g << " " << c.b << std::endl;
}
}
if(geom.flags & BSGeometry::TexCoords1 || geom.flags & BSGeometry::TexCoords2)
{
std::cout << " UV Coords Present" << std::endl;
for(size_t v = 0; v < geom.numverts; ++v)
{
auto coords = readStructure<BSGeometryUV>(data, dataI);
std::cout << " " << v << ": U" << coords.u << " V" << coords.v << std::endl;
}
}
for(size_t j = 0; j < geom.numtris; ++j)
{
auto tri = readStructure<BSGeometryTriangle>(data, dataI);
std::cout << " Triangle " << std::dec
<< static_cast<unsigned long>(tri.first) << " "
<< static_cast<unsigned long>(tri.second) << " "
<< static_cast<unsigned long>(tri.third) << " "
<< "A: " << static_cast<unsigned long>(tri.attrib) << std::endl;
}
auto bounds = readStructure<BSGeometryBounds>(data,dataI);
std::cout << " Bounding Radius = " << bounds.radius << std::endl;
for(size_t v = 0; v < geom.numverts; ++v)
{
auto p = readStructure<BSTVector3>(data, dataI);
std::cout << " v " << p.x << " " << p.y << " " << p.z << std::endl;
}
if(geom.flags & BSGeometry::StoreNormals)
{
std::cout << " Vertex Normals present" << std::endl;
for(size_t v = 0; v < geom.numverts; ++v)
{
auto p = readStructure<BSTVector3>(data, dataI);
std::cout << " n " << p.x << " " << p.y << " " << p.z << std::endl;
}
}
/*auto materialListHeader =*/ readHeader(data, dataI);
readHeader(data, dataI); // Ignore the structure header..
auto materialList = readStructure<BSMaterialList>(data, dataI);
std::cout << " Material List Data" << std::endl;
std::cout << " Materials = " << materialList.nummaterials << std::endl;
// Skip over the per-material byte values that I don't know what do.
dataI += sizeof(uint32_t) * materialList.nummaterials;
for(size_t m = 0; m < materialList.nummaterials; ++m)
{
auto materialHeader = readHeader(data, dataI);
size_t secbase = dataI;
readHeader(data, dataI);
auto material = readStructure<BSMaterial>(data, dataI);
std::cout << " Material Data" << std::endl;
std::cout << " Textures = " << std::dec << material.numtextures << std::endl;
std::cout << " Color = " << material.color.r << " " << material.color.g << " " << material.color.b << std::endl;
for(size_t t = 0; t < material.numtextures; ++t)
{
auto textureHeader = readHeader(data, dataI);
size_t texsecbase = dataI;
readHeader(data, dataI);
/*auto texture =*/ readStructure<BSTexture>(data, dataI);
auto nameHeader = readHeader(data, dataI);
std::string textureName(data+dataI, nameHeader.size);
dataI += nameHeader.size;
auto alphaHeader = readHeader(data, dataI);
std::string alphaName(data+dataI, alphaHeader.size);
std::cout << " Texture Data" << std::endl;
std::cout << " Name = " << textureName << std::endl;
std::cout << " Alpha = " << alphaName << std::endl;
dataI = texsecbase + textureHeader.size;
}
dataI = secbase + materialHeader.size;
}
// Jump to the start of the next geometry
dataI = basedata + geomHeader.size;
}
}
void dumpTextureDictionary(char* data)
{
BinaryStreamSection root(data);
auto texdict = root.readStructure<BSTextureDictionary>();
std::cout << std::dec << "tecount(" << texdict.numtextures << ")" << std::endl;
size_t dataI = 0;
while(root.hasMoreData(dataI))
{
BinaryStreamSection sec = root.getNextChildSection(dataI);
if(sec.header.id == RW::SID_TextureNative)
{
auto texnative = sec.readStructure<BSTextureNative>();
std::cout << "texture(\"" << texnative.diffuseName << "\")" << std::endl;
std::cout << " size(" << std::dec << texnative.width << "x" << texnative.height << ") format(" << std::hex << texnative.rasterformat << ")" << std::endl;
std::cout << " uvmode(" << std::hex << (texnative.wrapU+0) << "x" << (texnative.wrapV+0) << ") platform(" << std::hex << texnative.platform << ")" << std::endl;
}
}
/*
if(native.rasterformat & BSTextureNative::FORMAT_EXT_PAL8)
{
// Read the palette
auto palette = readStructure<BSPaletteData>(data, dataI);
// We can just do this for the time being until we need to compress or something
uint8_t fullcolor[native.width * native.height * 4];
// Pretend the pallet is uint8
for(size_t y = 0; y < native.height; ++y)
{
for(size_t x = 0; x < native.width; ++x)
{
size_t texI = ((y*native.width)+x) * 4;
size_t palI = static_cast<size_t>(data[dataI+(y*native.width)+x])*4;
fullcolor[texI+0] = palette.palette[palI+0];
fullcolor[texI+1] = palette.palette[palI+1];
fullcolor[texI+2] = palette.palette[palI+2];
fullcolor[texI+3] = 255;
}
}
GLuint texid = 0;
glGenTextures(1, &texid);
glBindTexture(GL_TEXTURE_2D, texid);
// todo: not completely ignore everything the TXD says.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, native.width, native.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, fullcolor);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
std::string name = std::string(native.diffuseName);
loadedTextures.insert(std::make_pair(name, texid));
};
*/
}
void dumpBinaryStreamSection(BinaryStreamSection& parent, size_t depth, size_t maxdepth = 7)
{
std::cout << std::string(depth, ' ') << "ID(" << std::hex << int(parent.header.id) << ") ";
std::cout << "size(" << std::dec << int(parent.header.size) << "b) ";
std::cout << "version(" << std::hex << int(parent.header.versionid) << ") ";
size_t sectionOffset = 0, j = 0;
bool readchildren = false;
// Handle the specialised bits
switch(parent.header.id)
{
case RW::SID_Struct:
{
std::cout << "structure";
}
break;
case RW::SID_String:
{
std::cout << "string(\"" << std::string(parent.raw()) << "\")";
}
break;
case RW::SID_GeometryList:
{
auto list = parent.readStructure<BSGeometryList>();
std::cout << std::dec << "gcount(" << list.numgeometry << ")";
readchildren = true;
}
break;
case RW::SID_Geometry:
{
auto geometry = parent.readStructure<BSGeometry>();
std::cout << std::dec << "tcount(" << geometry.numtris << ") vcount(" << geometry.numverts << ")";
readchildren = true;
}
break;
case RW::SID_MaterialList:
{
auto list = parent.readStructure<BSMaterialList>();
std::cout << std::dec << "mcount(" << list.nummaterials << ")";
readchildren = true;
}
break;
case RW::SID_Material:
{
auto material = parent.readStructure<BSMaterial>();
std::cout << std::dec << "tcount(" << material.numtextures << ")";
readchildren = true;
}
break;
case RW::SID_Texture:
{
/*auto texture =*/ parent.readStructure<BSTexture>();
std::cout << "texture";
readchildren = true;
}
break;
case RW::SID_TextureNative:
{
auto texture = parent.readStructure<BSTextureNative>();
std::cout << std::dec << "size(" << texture.width << "x" << texture.height << ") ";
std::cout << " format(" << std::hex << texture.rasterformat << ")";
}
break;
case RW::SID_NodeName:
{
std::string name(parent.raw(), parent.header.size);
std::cout << " nodename(\"" << name << "\")";
}
break;
case RW::SID_FrameList:
{
auto list = parent.readStructure<RW::BSFrameList>();
size_t fdataI = sizeof(RW::BSSectionHeader) + sizeof(RW::BSFrameList);
std::cout << " frames(" << std::dec << list.numframes << ") " << fdataI << " " << parent.offset;
for(size_t f = 0; f < list.numframes; ++f) {
auto frame = parent.readSubStructure<RW::BSFrameListFrame>(fdataI); fdataI += sizeof(RW::BSFrameListFrame);
std::cout << std::endl << std::string(depth, ' ') << " index(" << frame.index << ") position (" << std::dec << frame.position.x << " " << frame.position.y << " " << frame.position.z << ")";
}
readchildren = true;
}
break;
case RW::SID_Atomic:
{
std::cout << " atomic";
readchildren = true;
}
break;
case RW::SID_Clump:
case RW::SID_TextureDictionary:
case RW::SID_Extension:
{
readchildren = true;
}
break;
default:
{
std::cout << "Unknown Section";
}
};
std::cout << std::endl;
if(readchildren)
{
while(parent.hasMoreData(sectionOffset) && (j++) < 100 && depth < maxdepth)
{
BinaryStreamSection sec = parent.getNextChildSection(sectionOffset);
dumpBinaryStreamSection(sec, depth+1);
}
}
}
void dumpCollisionModel(char* data, size_t size)
{
LoaderCOL coll;
if(coll.load(data, size)) {
std::cout << "Collision instances: " << coll.instances.size() << std::endl;
for(auto it = coll.instances.begin(); it != coll.instances.end(); ++it) {
CollisionModel* model = (*it).get();
std::cout << "Collision data (version " << model->version << ")" << std::endl;
std::cout << " model: " << model->name << std::endl;
std::cout << " model id: " << model->modelid << std::endl;
std::cout << " spheres: " << model->spheres.size() << std::endl;
for( size_t b = 0; b < model->spheres.size(); ++b ) {
auto& box = model->spheres[b];
std::cout << " radius: " << box.radius << " center: " << box.center.x << " " << box.center.y << " " << box.center.z << std::endl;
}
std::cout << " boxes: " << model->boxes.size() << std::endl;
for( size_t b = 0; b < model->boxes.size(); ++b ) {
auto& box = model->boxes[b];
std::cout << " min: " << box.min.x << " " << box.min.y << " " << box.min.z << " max: " << box.max.x << " " << box.max.y << " " << box.max.z << std::endl;
}
std::cout << " faces: " << model->indices.size()/3 << std::endl;
std::cout << " verts: " << model->vertices.size() << std::endl;
for( size_t v = 0; v < model->vertices.size(); ++v ) {
std::cout << " " << model->vertices[v].x << ", " << model->vertices[v].y << ", " << model->vertices[v].z << std::endl;
}
}
}
}
void dumpGenericTree(char* data)
{
BinaryStreamSection root(data);
dumpBinaryStreamSection(root, 0);
}
void dumpAnimationFile(char* data)
{
LoaderIFP loader;
if(loader.loadFromMemory(data)) {
std::cout << loader.animations.size() << " animations" << std::endl;
for( auto it = loader.animations.begin();
it != loader.animations.end(); ++it ) {
Animation* a = it->second;
std::cout << a->name << std::endl;
std::cout << " " << a->bones.size() << " bones" << std::endl;
for( auto bit = a->bones.begin();
bit != a->bones.end(); ++bit ) {
std::cout << " " << bit->first << " (" << bit->second->frames.size() << " frames)" << std::endl;
for( auto fit = bit->second->frames.begin();
fit != bit->second->frames.end();
++fit ) {
std::cout << " f " << fit->starttime << std::endl;
}
}
}
}
}
int main(int argc, char** argv)
{
bool raw = false;
int c;
while ((c = getopt (argc, argv, "t")) != -1) {
switch (c) {
case 't':
raw = true;
break;
}
}
char *data;
size_t size;
if(raw) {
if(loadFile(argv[2], &data)) {
dumpGenericTree(data);
}
} else {
for (int i = 1; i < argc; ++i) {
if ( ! loadFile(argv[i], &data, &size))
continue;
std::string fname = argv[i];
auto ext = fname.substr(fname.size()-3);
std::transform(ext.begin(), ext.begin(), ext.end(), ::tolower);
if(ext == "dff")
{
std::cout << "Dumping model file" << std::endl;
dumpModelFile(data);
}
else if(ext == "txd")
{
std::cout << "Dumping texture archive" << std::endl;
dumpTextureDictionary(data);
}
else if(ext == "col")
{
std::cout << "Dumping Collsion file" << std::endl;
dumpCollisionModel(data, size);
}
else if(ext == "ifp")
{
std::cout << "Dumping animation file" << std::endl;
dumpAnimationFile(data);
}
else
{
std::cout << "I'm not sure what that is" << std::endl;
}
delete[] data;
}
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

View File

@ -11,13 +11,14 @@ add_library(rwengine
target_link_libraries(rwengine
rwlib
sfml-window
sfml-audio
mad
${MAD_LIBRARY}
${SFML_LIBRARIES}
${OPENRW_PLATFORM_LIBS})
include_directories(SYSTEM
${BULLET_INCLUDE_DIR}
${MAD_INCLUDE_DIR}
${SFML_INCLUDE_DIR}
)
include_directories(

View File

@ -19,6 +19,7 @@ add_executable(rwgame
include_directories(SYSTEM
${BULLET_INCLUDE_DIR}
${SFML_INCLUDE_DIR}
)
include_directories(
"${CMAKE_SOURCE_DIR}/rwengine/include"
@ -26,10 +27,7 @@ include_directories(
target_link_libraries( rwgame
rwengine
sfml-graphics
sfml-window
sfml-network
sfml-system
${SFML_LIBRARIES}
${OPENGL_LIBRARIES}
${BULLET_LIBRARIES})

View File

@ -23,12 +23,13 @@ add_executable(rwviewer
AnimationListModel.cpp
AnimationListWidget.cpp)
include_directories("${CMAKE_SOURCE_DIR}/rwengine/include" ${BULLET_INCLUDE_DIR})
include_directories(
"${CMAKE_SOURCE_DIR}/rwengine/include")
include_directories(SYSTEM
${BULLET_INCLUDE_DIR})
target_link_libraries(rwviewer
rwengine
sfml-graphics
sfml-system
${OPENGL_LIBRARIES}
${BULLET_LIBRARIES})
qt5_use_modules(rwviewer Widgets OpenGL)

View File

@ -1,3 +1,9 @@
##############################################################################
# Unit Tests
##############################################################################
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
set(TEST_SOURCES
"main.cpp"
"test_animation.cpp"
@ -39,23 +45,21 @@ ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
add_executable(run_tests ${TEST_SOURCES})
include_directories(include)
include_directories("${CMAKE_SOURCE_DIR}/tests")
include_directories(
include
"${CMAKE_SOURCE_DIR}/tests"
"${CMAKE_SOURCE_DIR}/rwengine/include"
"${CMAKE_SOURCE_DIR}/rwgame")
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
include_directories("${CMAKE_SOURCE_DIR}/rwengine/include" "${CMAKE_SOURCE_DIR}/rwgame")
include_directories(${BULLET_INCLUDE_DIR} SYSTEM)
include_directories(SYSTEM
${BULLET_INCLUDE_DIR}
${SFML_INCLUDE_DIR})
target_link_libraries(run_tests
rwengine
sfml-window
sfml-system
sfml-graphics
${OPENGL_LIBRARIES}
BulletDynamics
BulletCollision
LinearMath
${SFML_LIBRARIES}
${BULLET_LIBRARIES}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
add_test(UnitTests run_tests)