Skip to content

Commit

Permalink
Add Find*.cmake files, update build instructions for Linux, add curre…
Browse files Browse the repository at this point in the history
…nt Linux status
  • Loading branch information
q4a committed May 11, 2018
1 parent d609d8d commit 3823d95
Show file tree
Hide file tree
Showing 6 changed files with 390 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,22 @@ and work on the source code.

Changelist is available in [wiki](https://github.com/OpenXRay/xray-16/wiki/Changes).

Build instructions: [doc/howto/build.txt](doc/howto/build.txt)
Build instructions (Windows): [doc/howto/build.txt](doc/howto/build.txt)

Build instructions (Linux):
Dependencies (Ubuntu 18.04): sudo apt install git cmake lua5.1-dev libssl-dev libtheora-dev libogg-dev liblzo2-dev libjpeg-dev
Init: git submodule update --init --recursive
Building: mkdir bin && cd bin && cmake ../src

Current status (Linux):
Build Failed:
[ 70%] Building CXX object Externals/NVTT/src/nvimage/CMakeFiles/nvimage.dir/ImageIO.cpp.o
In function ‘nv::FloatImage* nv::ImageIO::loadFloat(const char*)’:
xray-16/src/Externals/NVTT/src/nvimage/ImageIO.cpp:138:10: error: cannot convert ‘bool’ to ‘nv::FloatImage*’ in return
return false;
^~~~~



If you find a bug or have an enhancement request, file an [Issue](https://github.com/openxray/xray-16/issues).

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ find_package(Theora REQUIRED)
find_package(OGG REQUIRED)
find_package(SDL2 REQUIRED)
find_package(LZO REQUIRED)
find_package(JPEG REQUIRED)

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)
Expand Down
68 changes: 68 additions & 0 deletions src/cmake/FindLZO.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#https://raw.githubusercontent.com/dfelinto/blender/master/build_files/cmake/Modules/FindLZO.cmake
# - Find LZO library
# Find the native LZO includes and library
# This module defines
# LZO_INCLUDE_DIRS, where to find lzo1x.h, Set when
# LZO_INCLUDE_DIR is found.
# LZO_LIBRARIES, libraries to link against to use LZO.
# LZO_ROOT_DIR, The base directory to search for LZO.
# This can also be an environment variable.
# LZO_FOUND, If false, do not try to use LZO.
#
# also defined, but not for general use are
# LZO_LIBRARY, where to find the LZO library.

#=============================================================================
# Copyright 2015 Blender Foundation.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================

# If LZO_ROOT_DIR was defined in the environment, use it.
IF(NOT LZO_ROOT_DIR AND NOT $ENV{LZO_ROOT_DIR} STREQUAL "")
SET(LZO_ROOT_DIR $ENV{LZO_ROOT_DIR})
ENDIF()

SET(_lzo_SEARCH_DIRS
${LZO_ROOT_DIR}
/usr/local
/sw # Fink
/opt/local # DarwinPorts
)

FIND_PATH(LZO_INCLUDE_DIR lzo/lzo1x.h
HINTS
${_lzo_SEARCH_DIRS}
PATH_SUFFIXES
include
)

FIND_LIBRARY(LZO_LIBRARY
NAMES
lzo2
HINTS
${_lzo_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)

# handle the QUIETLY and REQUIRED arguments and set LZO_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZO DEFAULT_MSG
LZO_LIBRARY LZO_INCLUDE_DIR)

IF(LZO_FOUND)
SET(LZO_LIBRARIES ${LZO_LIBRARY})
SET(LZO_INCLUDE_DIRS ${LZO_INCLUDE_DIR})
ENDIF(LZO_FOUND)

MARK_AS_ADVANCED(
LZO_INCLUDE_DIR
LZO_LIBRARY
)
106 changes: 106 additions & 0 deletions src/cmake/FindOGG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#https://raw.githubusercontent.com/freeorion/freeorion/master/cmake/FindOgg.cmake
#.rst:
# FindOgg
# -------
#
# Find the native Ogg includes and library.
#
# IMPORTED Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines :prop_tgt:`IMPORTED` target ``Ogg::Ogg``, if
# Ogg has been found.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables:
#
# ::
#
# OGG_INCLUDE_DIRS - where to find ogg.h, etc.
# OGG_LIBRARIES - List of libraries when using ogg.
# OGG_FOUND - True if ogg found.
#
# Hints
# ^^^^^
#
# A user may set ``OGGDIR`` environment to a ogg installation root
# to tell this module where to look.


set(_OGG_SEARCHES)

# Search OGGDIR first when is set.
if(ENV{OGGDIR})
set(_OGG_SEARCH_ROOT PATHS $ENV{OGGDIR} NO_DEFAULT_PATH)
list(APPEND _OGG_SEARCHES _OGG_SEARCH_ROOT)
endif()

# Normal search.
set(_OGG_SEARCH_NORMAL
PATH ""
)
list(APPEND _OGG_SEARCHES _OGG_SEARCH_NORMAL)

set(OGG_NAMES ogg libogg)
set(OGG_NAMES_DEBUG oggd ogg_D oggD ogg_D)

foreach(search ${_OGG_SEARCHES})
find_path(OGG_INCLUDE_DIR NAMES ogg.h ${${search}} PATH_SUFFIXES ogg)
endforeach()

# Allow OGG_LIBRARY to be set manually, as the location of the
# ogg library
if(NOT OGG_LIBRARY)
foreach(search ${_OGG_SEARCHES})
find_library(OGG_LIBRARY_RELEASE NAMES ${OGG_NAMES} ${${search}} PATH_SUFFIXES lib)
find_library(OGG_LIBRARY_DEBUG NAMES ${OGG_NAMES_DEBUG} ${${search}} PATH_SUFFIXES lib)
endforeach()

include(SelectLibraryConfigurations)
select_library_configurations(OGG)
endif()

unset(OGG_NAMES)
unset(OGG_NAMES_DEBUG)

mark_as_advanced(OGG_LIBRARY OGG_INCLUDE_DIR)

# handle the QUIETLY and REQUIRED argument and set OGG_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ogg REQUIRED_VARS OGG_LIBRARY OGG_INCLUDE_DIR)

if(OGG_FOUND)
set(OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR})

if(NOT OGG_LIBRARIES)
set(OGG_LIBRARIES ${OGG_LIBRARY})
endif()

if(NOT TARGET Ogg::Ogg)
add_library(Ogg::Ogg UNKNOWN IMPORTED)
set_target_properties(Ogg::Ogg PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}")

if(OGG_LIBRARY_RELEASE)
set_property(TARGET Ogg::Ogg APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(Ogg::Ogg PROPERTIES
IMPORTED_LOCATION_RELEASE "${OGG_LIBRARY_RELEASE}")
endif()

if(OGG_LIBRARY_DEBUG)
set_property(TARGET Ogg::Ogg APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(Ogg::Ogg PROPERTIES
IMPORTED_LOCATION_DEBUG "${OGG_LIBRARY_DEBUG}")
endif()

if(NOT OGG_LIBRARY_RELEASE AND NOT OGG_LIBRARY_DEBUG)
set_property(TARGET Ogg::Ogg APPEND PROPERTY
IMPORTED_LOCATION "${OGG_LIBRARY}")
endif()
endif()
endif()
160 changes: 160 additions & 0 deletions src/cmake/FindSDL2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#https://raw.githubusercontent.com/freeorion/freeorion/master/cmake/FindSDL.cmake
#.rst:
# FindSDL
# -------
#
# Find the native SDL includes and library.
#
# IMPORTED Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines :prop_tgt:`IMPORTED` targets
#
# ::
#
# ``SDL::SDL`` - The SDL library.
# ``SDL::main`` - The SDLmain library.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables:
#
# ::
#
# SDL_INCLUDE_DIRS - where to find SDL.h, etc.
# SDL_LIBRARIES - List of librarie when using SDL
# SDL_VERSION - SDL version from SDL_version.hpp
# SDL_MAJOR_VERSION - SDL major version number (X in X.y.z)
# SDL_MINOR_VERSION - SDL minor version number (Y in x.Y.z)
# SDL_PATCH_VERSION - SDL patch version number (Z in x.y.Z)
# SDL_FOUND - True if SDL found.
#
# Controls
# ^^^^^^^^
#
# ::
#
# SDL_NO_MAIN - If set to true the SDLmain library is skipped
# from the SDL_LIBRARIES to let the application
# handle the various entry point variants used
# by different operating systems.
#
# Hints
# ^^^^^
#
# A user may set ``SDL_ROOT`` to a SDL installation root to tell this
# module where to look.
#
# On OSX, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of SDL2_LIBRARY to
# override this selection or set the CMake environment
# CMAKE_INCLUDE_PATH to modify the search paths.

#=============================================================================
# Copyright 2003-2009 Kitware, Inc.
# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)


set(_SDL_SEARCHES)

# Search SDL_ROOT first when is set.
if(SDL_ROOT)
set(_SDL_SEARCH_ROOT PATH ${SDL_ROOT} NO_DEFAULT_PATH)
list(APPEND _SDL_SEARCHES _OGG_SEARCH_ROOT)
endif()

# Normal search.
set(_SDL_SEARCH_NORMAL
PATH ""
)
list(APPEND _SDL_SEARCHES _SDL_SEARCH_NORMAL)

foreach(search ${_SDL_SEARCHES})
find_path(SDL_INCLUDE_DIR NAMES SDL.h ${${search}} PATH_SUFFIXES SDL2)
endforeach()

if(SDL_INCLUDE_DIR)
file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" _SDL_VERSION_HPP_CONTENTS REGEX "#define SDL_((MAJOR|MINOR)_VERSION|PATCHLEVEL)")
foreach(v MAJOR_VERSION MINOR_VERSION PATCHLEVEL)
if("${_SDL_VERSION_HPP_CONTENTS}" MATCHES "#define SDL_${v} +([0-9]+)")
set(SDL_${v} "${CMAKE_MATCH_1}")
endif()
endforeach()
set(SDL_PATCH_VERSION ${SDL_PATCHLEVEL})
unset(SDL_PATCHLEVEL)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_PATCH_VERSION}")
endif()

# Allow SDL_LIBRARY to be set manually, as the location of the
# SDL library
if(NOT SDL_LIBRARY)
foreach(search ${_SDL_SEARCHES})
find_library(SDL_LIBRARY NAMES SDL2 ${${search}} PATH_SUFFIXES lib64 lib)
endforeach()
endif()

if(NOT SDL_NO_MAIN AND NOT ${SDL_INCLUDE_DIR} MATCHES ".framework")
foreach(search ${_SDL_SEARCHES})
# Non-OS X framework versions expect you to also dynamically link to
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
# seem to provide SDL2main for compatibility even though they don't
# necessarily need it.
find_library(SDL_MAIN_LIBRARY NAMES SDL2main ${${search}} PATH_SUFFIXES lib64 lib)
endforeach()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR
VERSION_VAR SDL_VERSION)

if(SDL_FOUND)
set(SDL_INCLUDE_DIRS ${SDL_INCLUDE_DIRS})

if(NOT SDL_LIBRARIES)
set(SDL_LIBRARIES ${SDL_LIBRARY})

# For SDL2main
if(NOT SDL_NO_MAIN AND SDL_MAIN_LIBRARY)
set(SDL_LIBRARIES ${SDL_MAIN_LIBRARY} ${SDL_LIBRARIES})
endif()

if(APPLE)
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
set(SDL_LIBRARIES ${SDL_LIBRARIES} "-framework Cocoa")
endif()
endif()

if(NOT TARGET SDL::SDL)
add_library(SDL::SDL UNKNOWN IMPORTED)
set_target_properties(SDL::SDL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_INCLUDE_DIRS}")

if(SDL_LIBRARY)
set_property(TARGET SDL::SDL APPEND PROPERTY
IMPORTED_LOCATION "${SDL_LIBRARY}")
endif()
endif()

if(NOT TARGET SDL::main AND SDL_MAIN_LIBRARY)
add_library(SDL::main UNKNOWN IMPORTED)

if(SDL_MAIN_LIBRARY)
set_property(TARGET SDL::main APPEND PROPERTY
IMPORTED_LOCATION "${SDL_MAIN_LIBRARY}")
endif()


add_dependencies(SDL::SDL SDL::main)
endif()
endif()
Loading

0 comments on commit 3823d95

Please sign in to comment.