Skip to content

Commit

Permalink
Merge pull request #209 from q4a/xd_dev
Browse files Browse the repository at this point in the history
Update CMakeLists and some code for building on Linux
  • Loading branch information
Xottab-DUTY committed May 30, 2018
2 parents a1dbe79 + 39bcd22 commit ce61a9b
Show file tree
Hide file tree
Showing 35 changed files with 677 additions and 87 deletions.
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 2.8.0)
project(OpenXRay)

include(${PROJECT_SOURCE_DIR}/cmake/utils.cmake)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive --std=c++17")

add_definitions(-D_MT -D_CPPUNWIND -DPURE_DYNAMIC_CAST -DDECLARE_SPECIALIZATION -DM_NOSTDCONTAINERS_EXT -DUSE_OGL)

set(LUA_INCLUDE_DIR Externals/LuaJIT/src)
set(LUA_LIBRARIES luajit)
set(LUA_FOUND 1)
if (NOT WIN32)
find_package(OpenSSL REQUIRED)
find_package(Theora REQUIRED)
find_package(OGG REQUIRED)
find_package(SDL2 REQUIRED)
find_package(LZO REQUIRED)
find_package(JPEG REQUIRED)
endif()

include_directories(${LUA_INCLUDE_DIR})
include_directories(${CMAKE_SOURCE_DIR} {CMAKE_SOURCE_DIR}/Common ${CMAKE_SOURCE_DIR}/Externals ${CMAKE_SOURCE_DIR}/Externals/gli/external/glm ${CMAKE_SOURCE_DIR}/../sdk/include/loki)

add_subdirectory(Externals)
add_subdirectory(src)
7 changes: 7 additions & 0 deletions Externals/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_subdirectory(LuaJIT)
add_subdirectory(luabind)
add_subdirectory(lzo)
add_subdirectory(cximage)
add_subdirectory(NVTT)
#add_subdirectory(gli)
#add_subdirectory(glew)
7 changes: 7 additions & 0 deletions Externals/NVTT/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.0)
project(nvtt)
add_definitions(-DHAVE_SIGNAL_H -DHAVE_EXECINFO_H)
add_subdirectory(src/nvcore)
add_subdirectory(src/nvimage)
add_subdirectory(src/nvmath)
add_subdirectory(src/nvtt)
2 changes: 1 addition & 1 deletion Externals/NVTT/src/nvcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SET(CORE_SRCS
Library.h
Library.cpp)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../include)

# targets
ADD_DEFINITIONS(-DNVCORE_EXPORTS)
Expand Down
2 changes: 2 additions & 0 deletions Externals/NVTT/src/nvcore/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#endif

#if NV_OS_LINUX && defined(HAVE_EXECINFO_H)
# include <sys/types.h>
# include <unistd.h> // getpid
# include <execinfo.h> // backtrace
# if NV_CC_GNUC // defined(HAVE_CXXABI_H)
# include <cxxabi.h>
Expand Down
16 changes: 15 additions & 1 deletion Externals/NVTT/src/nvcore/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@

#else // NV_NO_ASSERT

# if NV_CC_MSVC
// @@ Does this work in msvc-6 and earlier?
# define nvDebugBreak() __debugbreak()
//# define nvDebugBreak() __asm { int 3 }
# elif NV_OS_ORBIS
# define nvDebugBreak() __debugbreak()
# elif NV_CC_GNUC
# define nvDebugBreak() __builtin_trap()
# else
# error "No nvDebugBreak()!"
# endif

/*
# if NV_CC_MSVC
// @@ Does this work in msvc-6 and earlier?
// @@ Do I have to include <intrin.h> ?
Expand All @@ -39,13 +52,14 @@
# define nvDebugBreak() __asm__ volatile ("trap");
# elif NV_CC_GNUC && NV_CPU_X86 && NV_OS_DARWIN
# define nvDebugBreak() __asm__ volatile ("int3");
# elif NV_CC_GNUC && NV_CPU_X86
# elif NV_CC_GNUC && NV_CPU_X86
# define nvDebugBreak() __asm__ ( "int %0" : :"I"(3) )
# else
# include <signal.h>
# define nvDebugBreak() raise(SIGTRAP);
// define nvDebugBreak() *((int *)(0)) = 0
# endif
*/

# define nvAssertMacro(exp) \
do { \
Expand Down
4 changes: 2 additions & 2 deletions Externals/NVTT/src/nvimage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PROJECT(nvimage)

SET(IMAGE_SRCS
SET(IMAGE_SRCS
nvimage.h
FloatImage.h
FloatImage.cpp
Expand All @@ -27,7 +27,7 @@ SET(IMAGE_SRCS
PsdFile.h
TgaFile.h)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../include)

IF(PNG_FOUND)
SET(LIBS ${LIBS} ${PNG_LIBRARIES})
Expand Down
6 changes: 3 additions & 3 deletions Externals/NVTT/src/nvimage/ImageIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ FloatImage * nv::ImageIO::loadFloat(const char * fileName)
StdInputStream stream(fileName);

if (stream.isError()) {
return false;
return NULL;
}

return loadFloat(fileName, stream);
Expand Down Expand Up @@ -233,7 +233,7 @@ Image * nv::ImageIO::loadTGA(Stream & s)
case TGA_TYPE_INDEXED:
if( tga.colormap_type!=1 || tga.colormap_size!=24 || tga.colormap_length>256 ) {
nvDebug( "*** ImageIO::loadTGA: Error, only 24bit paletted images are supported.\n" );
return false;
return NULL;
}
pal = true;
break;
Expand All @@ -254,7 +254,7 @@ Image * nv::ImageIO::loadTGA(Stream & s)

default:
nvDebug( "*** ImageIO::loadTGA: Error, unsupported image type.\n" );
return false;
return NULL;
}

const uint pixel_size = (tga.pixel_size/8);
Expand Down
2 changes: 1 addition & 1 deletion Externals/NVTT/src/nvmath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SET(MATH_SRCS
Basis.h Basis.cpp
Triangle.h Triangle.cpp TriBox.cpp)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../include)

# targets
ADD_DEFINITIONS(-DNVMATH_EXPORTS)
Expand Down
2 changes: 1 addition & 1 deletion Externals/NVTT/src/nvmath/TriBox.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/********************************************************/
/* AABB-triangle overlap test code */
/* by Tomas Akenine-Möller */
/* by Tomas Akenine-Möller */
/* Function: int triBoxOverlap(float boxcenter[3], */
/* float boxhalfsize[3],float triverts[3][3]); */
/* History: */
Expand Down
4 changes: 2 additions & 2 deletions Externals/NVTT/src/nvmath/Triangle.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// This code is in the public domain -- Ignacio Castaño <[email protected]>
// This code is in the public domain -- Ignacio Castaño <[email protected]>

#include <nvmath/Triangle.h>

using namespace nv;


/// Tomas Möller, barycentric ray-triangle test.
/// Tomas Möller, barycentric ray-triangle test.
bool rayTest_Moller(const Triangle & t, Vector3::Arg orig, Vector3::Arg dir, float * out_t, float * out_u, float * out_v)
{
// find vectors for two edges sharing vert0
Expand Down
4 changes: 2 additions & 2 deletions Externals/NVTT/src/nvmath/Triangle.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This code is in the public domain -- Ignacio Castaño <[email protected]>
// This code is in the public domain -- Ignacio Castaño <[email protected]>

#ifndef NV_MATH_TRIANGLE_H
#define NV_MATH_TRIANGLE_H
Expand Down Expand Up @@ -44,7 +44,7 @@ namespace nv
};


// Tomas Akenine-Möller box-triangle test.
// Tomas Akenine-Möller box-triangle test.
NVMATH_API bool triBoxOverlap(Vector3::Arg boxcenter, Vector3::Arg boxhalfsize, const Triangle & triangle);
NVMATH_API bool triBoxOverlapNoBounds(Vector3::Arg boxcenter, Vector3::Arg boxhalfsize, const Triangle & triangle);

Expand Down
8 changes: 4 additions & 4 deletions Externals/NVTT/src/nvmath/nvmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ inline bool isZero(const float f, const float epsilon = NV_EPSILON)

inline bool isFinite(const float f)
{
#if NV_OS_WIN32
#if NV_OS_WIN32 && !NV_CC_GNUC
return _finite(f) != 0;
#elif NV_OS_DARWIN
#elif NV_OS_DARWIN || NV_CC_GNUC
return isfinite(f);
#elif NV_OS_LINUX
return finitef(f);
Expand All @@ -130,9 +130,9 @@ inline bool isFinite(const float f)

inline bool isNan(const float f)
{
#if NV_OS_WIN32
#if NV_OS_WIN32 && !NV_CC_GNUC
return _isnan(f) != 0;
#elif NV_OS_DARWIN
#elif NV_OS_DARWIN || NV_CC_GNUC
return isnan(f);
#elif NV_OS_LINUX
return isnanf(f);
Expand Down
2 changes: 1 addition & 1 deletion Externals/NVTT/src/nvtt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ IF(CUDA_FOUND)
INCLUDE_DIRECTORIES(${CUDA_INCLUDE_PATH})
ENDIF(CUDA_FOUND)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../include)

ADD_DEFINITIONS(-DNVTT_EXPORTS)

Expand Down
40 changes: 40 additions & 0 deletions Externals/cximage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 2.8.0)
project(cximage)

set(SOURCES
ximacfg.cpp
ximaenc.cpp
ximaexif.cpp
ximage.cpp
ximainfo.cpp
ximaint.cpp
ximajpg.cpp
ximalpha.cpp
ximalyr.cpp
ximapal.cpp
ximasel.cpp
ximath.cpp
xmemfile.cpp
)

set(HEADERS
xfile.h
ximacfg.h
ximadef.h
ximage.h
ximaiter.h
ximajpg.h
ximath.h
xiofile.h
xmemfile.h
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive --std=c++14")
add_definitions(-DCXIMAGE_BUILD)

include_directories("." ${CMAKE_SOURCE_DIR})

add_library(cximage STATIC ${SOURCES} ${HEADERS})

set_target_properties(cximage PROPERTIES PREFIX "")
target_link_libraries(cximage)
3 changes: 3 additions & 0 deletions Externals/cximage/ximacfg.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#if !defined(__ximaCFG_h)
#define __ximaCFG_h
#if !defined(WIN32)
#include <cstddef>
#endif

extern "C" void* cxalloc(size_t size);
extern "C" void cxfree(void* ptr);
Expand Down
6 changes: 6 additions & 0 deletions Externals/cximage/ximadef.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,16 @@ typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned int UINT;
typedef const char* LPCTSTR;

typedef DWORD COLORREF;
typedef unsigned int HANDLE;
typedef void* HRGN;
typedef void* HDC;

typedef int boolean;

#define _tfopen fopen

#ifndef BOOL
#define BOOL bool
Expand Down
12 changes: 8 additions & 4 deletions Externals/cximage/ximainfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include "ximage.h"

#if !defined(WIN32)
#define _tcsnicmp(a,b,c) strcasecmp(a,b)
#endif

////////////////////////////////////////////////////////////////////////////////
/**
* \return the color used for transparency, and/or for background color
Expand Down Expand Up @@ -538,7 +542,7 @@ void CxImage::SetOffset(long x,long y)
////////////////////////////////////////////////////////////////////////////////
/**
* \sa SetJpegQuality, GetJpegQualityF
* \author [DP]; changes [Stefan Schürmans]
* \author [DP]; changes [Stefan Schürmans]
*/
BYTE CxImage::GetJpegQuality() const
{
Expand All @@ -547,7 +551,7 @@ BYTE CxImage::GetJpegQuality() const
////////////////////////////////////////////////////////////////////////////////
/**
* \sa SetJpegQuality, GetJpegQuality
* \author [Stefan Schürmans]
* \author [Stefan Schürmans]
*/
float CxImage::GetJpegQualityF() const
{
Expand All @@ -557,7 +561,7 @@ float CxImage::GetJpegQualityF() const
/**
* quality level for JPEG and JPEG2000
* \param q: can be from 0 to 100
* \author [DP]; changes [Stefan Schürmans]
* \author [DP]; changes [Stefan Schürmans]
*/
void CxImage::SetJpegQuality(BYTE q){
info.fQuality = (float)q;
Expand All @@ -567,7 +571,7 @@ void CxImage::SetJpegQuality(BYTE q){
* quality level for JPEG and JPEG2000
* necessary for JPEG2000 when quality is between 0.0 and 1.0
* \param q: can be from 0.0 to 100.0
* \author [Stefan Schürmans]
* \author [Stefan Schürmans]
*/
void CxImage::SetJpegQualityF(float q){
if (q>0) info.fQuality = q;
Expand Down
Loading

0 comments on commit ce61a9b

Please sign in to comment.