Skip to content

Commit 3823d95

Browse files
committed
Add Find*.cmake files, update build instructions for Linux, add current Linux status
1 parent d609d8d commit 3823d95

File tree

6 files changed

+390
-1
lines changed

6 files changed

+390
-1
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@ and work on the source code.
99

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

12-
Build instructions: [doc/howto/build.txt](doc/howto/build.txt)
12+
Build instructions (Windows): [doc/howto/build.txt](doc/howto/build.txt)
13+
14+
Build instructions (Linux):
15+
Dependencies (Ubuntu 18.04): sudo apt install git cmake lua5.1-dev libssl-dev libtheora-dev libogg-dev liblzo2-dev libjpeg-dev
16+
Init: git submodule update --init --recursive
17+
Building: mkdir bin && cd bin && cmake ../src
18+
19+
Current status (Linux):
20+
Build Failed:
21+
[ 70%] Building CXX object Externals/NVTT/src/nvimage/CMakeFiles/nvimage.dir/ImageIO.cpp.o
22+
In function ‘nv::FloatImage* nv::ImageIO::loadFloat(const char*)’:
23+
xray-16/src/Externals/NVTT/src/nvimage/ImageIO.cpp:138:10: error: cannot convert ‘bool’ to ‘nv::FloatImage*’ in return
24+
return false;
25+
^~~~~
26+
27+
1328

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

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ find_package(Theora REQUIRED)
1313
find_package(OGG REQUIRED)
1414
find_package(SDL2 REQUIRED)
1515
find_package(LZO REQUIRED)
16+
find_package(JPEG REQUIRED)
1617

1718
include_directories(${LUA_INCLUDE_DIR})
1819
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)

src/cmake/FindLZO.cmake

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#https://raw.githubusercontent.com/dfelinto/blender/master/build_files/cmake/Modules/FindLZO.cmake
2+
# - Find LZO library
3+
# Find the native LZO includes and library
4+
# This module defines
5+
# LZO_INCLUDE_DIRS, where to find lzo1x.h, Set when
6+
# LZO_INCLUDE_DIR is found.
7+
# LZO_LIBRARIES, libraries to link against to use LZO.
8+
# LZO_ROOT_DIR, The base directory to search for LZO.
9+
# This can also be an environment variable.
10+
# LZO_FOUND, If false, do not try to use LZO.
11+
#
12+
# also defined, but not for general use are
13+
# LZO_LIBRARY, where to find the LZO library.
14+
15+
#=============================================================================
16+
# Copyright 2015 Blender Foundation.
17+
#
18+
# Distributed under the OSI-approved BSD License (the "License");
19+
# see accompanying file Copyright.txt for details.
20+
#
21+
# This software is distributed WITHOUT ANY WARRANTY; without even the
22+
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23+
# See the License for more information.
24+
#=============================================================================
25+
26+
# If LZO_ROOT_DIR was defined in the environment, use it.
27+
IF(NOT LZO_ROOT_DIR AND NOT $ENV{LZO_ROOT_DIR} STREQUAL "")
28+
SET(LZO_ROOT_DIR $ENV{LZO_ROOT_DIR})
29+
ENDIF()
30+
31+
SET(_lzo_SEARCH_DIRS
32+
${LZO_ROOT_DIR}
33+
/usr/local
34+
/sw # Fink
35+
/opt/local # DarwinPorts
36+
)
37+
38+
FIND_PATH(LZO_INCLUDE_DIR lzo/lzo1x.h
39+
HINTS
40+
${_lzo_SEARCH_DIRS}
41+
PATH_SUFFIXES
42+
include
43+
)
44+
45+
FIND_LIBRARY(LZO_LIBRARY
46+
NAMES
47+
lzo2
48+
HINTS
49+
${_lzo_SEARCH_DIRS}
50+
PATH_SUFFIXES
51+
lib64 lib
52+
)
53+
54+
# handle the QUIETLY and REQUIRED arguments and set LZO_FOUND to TRUE if
55+
# all listed variables are TRUE
56+
INCLUDE(FindPackageHandleStandardArgs)
57+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZO DEFAULT_MSG
58+
LZO_LIBRARY LZO_INCLUDE_DIR)
59+
60+
IF(LZO_FOUND)
61+
SET(LZO_LIBRARIES ${LZO_LIBRARY})
62+
SET(LZO_INCLUDE_DIRS ${LZO_INCLUDE_DIR})
63+
ENDIF(LZO_FOUND)
64+
65+
MARK_AS_ADVANCED(
66+
LZO_INCLUDE_DIR
67+
LZO_LIBRARY
68+
)

src/cmake/FindOGG.cmake

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#https://raw.githubusercontent.com/freeorion/freeorion/master/cmake/FindOgg.cmake
2+
#.rst:
3+
# FindOgg
4+
# -------
5+
#
6+
# Find the native Ogg includes and library.
7+
#
8+
# IMPORTED Targets
9+
# ^^^^^^^^^^^^^^^^
10+
#
11+
# This module defines :prop_tgt:`IMPORTED` target ``Ogg::Ogg``, if
12+
# Ogg has been found.
13+
#
14+
# Result Variables
15+
# ^^^^^^^^^^^^^^^^
16+
#
17+
# This module defines the following variables:
18+
#
19+
# ::
20+
#
21+
# OGG_INCLUDE_DIRS - where to find ogg.h, etc.
22+
# OGG_LIBRARIES - List of libraries when using ogg.
23+
# OGG_FOUND - True if ogg found.
24+
#
25+
# Hints
26+
# ^^^^^
27+
#
28+
# A user may set ``OGGDIR`` environment to a ogg installation root
29+
# to tell this module where to look.
30+
31+
32+
set(_OGG_SEARCHES)
33+
34+
# Search OGGDIR first when is set.
35+
if(ENV{OGGDIR})
36+
set(_OGG_SEARCH_ROOT PATHS $ENV{OGGDIR} NO_DEFAULT_PATH)
37+
list(APPEND _OGG_SEARCHES _OGG_SEARCH_ROOT)
38+
endif()
39+
40+
# Normal search.
41+
set(_OGG_SEARCH_NORMAL
42+
PATH ""
43+
)
44+
list(APPEND _OGG_SEARCHES _OGG_SEARCH_NORMAL)
45+
46+
set(OGG_NAMES ogg libogg)
47+
set(OGG_NAMES_DEBUG oggd ogg_D oggD ogg_D)
48+
49+
foreach(search ${_OGG_SEARCHES})
50+
find_path(OGG_INCLUDE_DIR NAMES ogg.h ${${search}} PATH_SUFFIXES ogg)
51+
endforeach()
52+
53+
# Allow OGG_LIBRARY to be set manually, as the location of the
54+
# ogg library
55+
if(NOT OGG_LIBRARY)
56+
foreach(search ${_OGG_SEARCHES})
57+
find_library(OGG_LIBRARY_RELEASE NAMES ${OGG_NAMES} ${${search}} PATH_SUFFIXES lib)
58+
find_library(OGG_LIBRARY_DEBUG NAMES ${OGG_NAMES_DEBUG} ${${search}} PATH_SUFFIXES lib)
59+
endforeach()
60+
61+
include(SelectLibraryConfigurations)
62+
select_library_configurations(OGG)
63+
endif()
64+
65+
unset(OGG_NAMES)
66+
unset(OGG_NAMES_DEBUG)
67+
68+
mark_as_advanced(OGG_LIBRARY OGG_INCLUDE_DIR)
69+
70+
# handle the QUIETLY and REQUIRED argument and set OGG_FOUND to TRUE if
71+
# all listed variables are TRUE
72+
include(FindPackageHandleStandardArgs)
73+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ogg REQUIRED_VARS OGG_LIBRARY OGG_INCLUDE_DIR)
74+
75+
if(OGG_FOUND)
76+
set(OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR})
77+
78+
if(NOT OGG_LIBRARIES)
79+
set(OGG_LIBRARIES ${OGG_LIBRARY})
80+
endif()
81+
82+
if(NOT TARGET Ogg::Ogg)
83+
add_library(Ogg::Ogg UNKNOWN IMPORTED)
84+
set_target_properties(Ogg::Ogg PROPERTIES
85+
INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}")
86+
87+
if(OGG_LIBRARY_RELEASE)
88+
set_property(TARGET Ogg::Ogg APPEND PROPERTY
89+
IMPORTED_CONFIGURATIONS RELEASE)
90+
set_target_properties(Ogg::Ogg PROPERTIES
91+
IMPORTED_LOCATION_RELEASE "${OGG_LIBRARY_RELEASE}")
92+
endif()
93+
94+
if(OGG_LIBRARY_DEBUG)
95+
set_property(TARGET Ogg::Ogg APPEND PROPERTY
96+
IMPORTED_CONFIGURATIONS DEBUG)
97+
set_target_properties(Ogg::Ogg PROPERTIES
98+
IMPORTED_LOCATION_DEBUG "${OGG_LIBRARY_DEBUG}")
99+
endif()
100+
101+
if(NOT OGG_LIBRARY_RELEASE AND NOT OGG_LIBRARY_DEBUG)
102+
set_property(TARGET Ogg::Ogg APPEND PROPERTY
103+
IMPORTED_LOCATION "${OGG_LIBRARY}")
104+
endif()
105+
endif()
106+
endif()

src/cmake/FindSDL2.cmake

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#https://raw.githubusercontent.com/freeorion/freeorion/master/cmake/FindSDL.cmake
2+
#.rst:
3+
# FindSDL
4+
# -------
5+
#
6+
# Find the native SDL includes and library.
7+
#
8+
# IMPORTED Targets
9+
# ^^^^^^^^^^^^^^^^
10+
#
11+
# This module defines :prop_tgt:`IMPORTED` targets
12+
#
13+
# ::
14+
#
15+
# ``SDL::SDL`` - The SDL library.
16+
# ``SDL::main`` - The SDLmain library.
17+
#
18+
# Result Variables
19+
# ^^^^^^^^^^^^^^^^
20+
#
21+
# This module defines the following variables:
22+
#
23+
# ::
24+
#
25+
# SDL_INCLUDE_DIRS - where to find SDL.h, etc.
26+
# SDL_LIBRARIES - List of librarie when using SDL
27+
# SDL_VERSION - SDL version from SDL_version.hpp
28+
# SDL_MAJOR_VERSION - SDL major version number (X in X.y.z)
29+
# SDL_MINOR_VERSION - SDL minor version number (Y in x.Y.z)
30+
# SDL_PATCH_VERSION - SDL patch version number (Z in x.y.Z)
31+
# SDL_FOUND - True if SDL found.
32+
#
33+
# Controls
34+
# ^^^^^^^^
35+
#
36+
# ::
37+
#
38+
# SDL_NO_MAIN - If set to true the SDLmain library is skipped
39+
# from the SDL_LIBRARIES to let the application
40+
# handle the various entry point variants used
41+
# by different operating systems.
42+
#
43+
# Hints
44+
# ^^^^^
45+
#
46+
# A user may set ``SDL_ROOT`` to a SDL installation root to tell this
47+
# module where to look.
48+
#
49+
# On OSX, this will prefer the Framework version (if found) over others.
50+
# People will have to manually change the cache values of SDL2_LIBRARY to
51+
# override this selection or set the CMake environment
52+
# CMAKE_INCLUDE_PATH to modify the search paths.
53+
54+
#=============================================================================
55+
# Copyright 2003-2009 Kitware, Inc.
56+
# Copyright 2012 Benjamin Eikel
57+
#
58+
# Distributed under the OSI-approved BSD License (the "License");
59+
# see accompanying file Copyright.txt for details.
60+
#
61+
# This software is distributed WITHOUT ANY WARRANTY; without even the
62+
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
63+
# See the License for more information.
64+
#=============================================================================
65+
# (To distribute this file outside of CMake, substitute the full
66+
# License text for the above reference.)
67+
68+
69+
set(_SDL_SEARCHES)
70+
71+
# Search SDL_ROOT first when is set.
72+
if(SDL_ROOT)
73+
set(_SDL_SEARCH_ROOT PATH ${SDL_ROOT} NO_DEFAULT_PATH)
74+
list(APPEND _SDL_SEARCHES _OGG_SEARCH_ROOT)
75+
endif()
76+
77+
# Normal search.
78+
set(_SDL_SEARCH_NORMAL
79+
PATH ""
80+
)
81+
list(APPEND _SDL_SEARCHES _SDL_SEARCH_NORMAL)
82+
83+
foreach(search ${_SDL_SEARCHES})
84+
find_path(SDL_INCLUDE_DIR NAMES SDL.h ${${search}} PATH_SUFFIXES SDL2)
85+
endforeach()
86+
87+
if(SDL_INCLUDE_DIR)
88+
file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" _SDL_VERSION_HPP_CONTENTS REGEX "#define SDL_((MAJOR|MINOR)_VERSION|PATCHLEVEL)")
89+
foreach(v MAJOR_VERSION MINOR_VERSION PATCHLEVEL)
90+
if("${_SDL_VERSION_HPP_CONTENTS}" MATCHES "#define SDL_${v} +([0-9]+)")
91+
set(SDL_${v} "${CMAKE_MATCH_1}")
92+
endif()
93+
endforeach()
94+
set(SDL_PATCH_VERSION ${SDL_PATCHLEVEL})
95+
unset(SDL_PATCHLEVEL)
96+
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_PATCH_VERSION}")
97+
endif()
98+
99+
# Allow SDL_LIBRARY to be set manually, as the location of the
100+
# SDL library
101+
if(NOT SDL_LIBRARY)
102+
foreach(search ${_SDL_SEARCHES})
103+
find_library(SDL_LIBRARY NAMES SDL2 ${${search}} PATH_SUFFIXES lib64 lib)
104+
endforeach()
105+
endif()
106+
107+
if(NOT SDL_NO_MAIN AND NOT ${SDL_INCLUDE_DIR} MATCHES ".framework")
108+
foreach(search ${_SDL_SEARCHES})
109+
# Non-OS X framework versions expect you to also dynamically link to
110+
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
111+
# seem to provide SDL2main for compatibility even though they don't
112+
# necessarily need it.
113+
find_library(SDL_MAIN_LIBRARY NAMES SDL2main ${${search}} PATH_SUFFIXES lib64 lib)
114+
endforeach()
115+
endif()
116+
117+
include(FindPackageHandleStandardArgs)
118+
find_package_handle_standard_args(SDL REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR
119+
VERSION_VAR SDL_VERSION)
120+
121+
if(SDL_FOUND)
122+
set(SDL_INCLUDE_DIRS ${SDL_INCLUDE_DIRS})
123+
124+
if(NOT SDL_LIBRARIES)
125+
set(SDL_LIBRARIES ${SDL_LIBRARY})
126+
127+
# For SDL2main
128+
if(NOT SDL_NO_MAIN AND SDL_MAIN_LIBRARY)
129+
set(SDL_LIBRARIES ${SDL_MAIN_LIBRARY} ${SDL_LIBRARIES})
130+
endif()
131+
132+
if(APPLE)
133+
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
134+
set(SDL_LIBRARIES ${SDL_LIBRARIES} "-framework Cocoa")
135+
endif()
136+
endif()
137+
138+
if(NOT TARGET SDL::SDL)
139+
add_library(SDL::SDL UNKNOWN IMPORTED)
140+
set_target_properties(SDL::SDL PROPERTIES
141+
INTERFACE_INCLUDE_DIRECTORIES "${SDL_INCLUDE_DIRS}")
142+
143+
if(SDL_LIBRARY)
144+
set_property(TARGET SDL::SDL APPEND PROPERTY
145+
IMPORTED_LOCATION "${SDL_LIBRARY}")
146+
endif()
147+
endif()
148+
149+
if(NOT TARGET SDL::main AND SDL_MAIN_LIBRARY)
150+
add_library(SDL::main UNKNOWN IMPORTED)
151+
152+
if(SDL_MAIN_LIBRARY)
153+
set_property(TARGET SDL::main APPEND PROPERTY
154+
IMPORTED_LOCATION "${SDL_MAIN_LIBRARY}")
155+
endif()
156+
157+
158+
add_dependencies(SDL::SDL SDL::main)
159+
endif()
160+
endif()

0 commit comments

Comments
 (0)