Skip to content

Commit 5a33028

Browse files
authored
Merge pull request #245 from q4a/xd_dev
update all CMakeLists.txt, *.cmake and .travis.yml
2 parents 920b85e + 08b0286 commit 5a33028

36 files changed

+5119
-174
lines changed

.travis.yml

Lines changed: 75 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,84 @@
1-
language: cpp
2-
cache: ccache
1+
# Based on https://github.com/ldionne/hana/blob/master/.travis.yml
2+
dist: xenial
33
sudo: required
4-
dist: trusty
5-
compiler:
6-
- g++
7-
install: export CXX="g++-7"
4+
cache: ccache
5+
language: cpp
6+
7+
#branches:
8+
# only:
9+
# - linux
10+
# - xd_dev
11+
# - "/^v\\d+\\./"
12+
813
os:
914
- linux
15+
16+
matrix:
17+
include:
18+
- env: C_COMPILER=gcc-7 CXX_COMPILER=g++-7 TARGET_CPU=x64 BUILD_CONFIGURATION=Release
19+
addons: &gcc7
20+
apt:
21+
sources:
22+
- sourceline: 'ppa:ubuntu-toolchain-r/test'
23+
packages:
24+
- g++-7
25+
26+
- env: C_COMPILER=gcc-7 CXX_COMPILER=g++-7 TARGET_CPU=x86 BUILD_CONFIGURATION=Release
27+
addons: *gcc7
28+
29+
- env: C_COMPILER=gcc-7 CXX_COMPILER=g++-7 TARGET_CPU=x64 BUILD_CONFIGURATION=Debug
30+
addons: *gcc7
31+
32+
- env: C_COMPILER=gcc-7 CXX_COMPILER=g++-7 TARGET_CPU=x86 BUILD_CONFIGURATION=Debug
33+
addons: *gcc7
34+
35+
# - env: C_COMPILER=clang-5.0 CXX_COMPILER=clang++-5.0 TARGET_CPU=x64 BUILD_CONFIGURATION=Release
36+
# addons: &clang50
37+
# apt:
38+
# sources:
39+
# - llvm-toolchain-trusty-5.0
40+
# packages:
41+
# - clang-5.0
42+
43+
# - env: C_COMPILER=clang-5.0 CXX_COMPILER=clang++-5.0 TARGET_CPU=x84 BUILD_CONFIGURATION=Release
44+
# addons: *clang50
45+
46+
# - env: C_COMPILER=clang-6.0 CXX_COMPILER=clang++-6.0 TARGET_CPU=x64 BUILD_CONFIGURATION=Release
47+
# addons: &clang60
48+
# apt:
49+
# sources:
50+
# - llvm-toolchain-trusty-6.0
51+
# packages:
52+
# - clang-6.0
53+
54+
# - env: C_COMPILER=clang-6.0 CXX_COMPILER=clang++-6.0 TARGET_CPU=x84 BUILD_CONFIGURATION=Release
55+
# addons: *clang60
56+
57+
58+
install:
59+
- export CC=${C_COMPILER}
60+
- export CXX=${CXX_COMPILER}
61+
- ${CXX} --version
62+
1063
before_script:
11-
- g++ --version
12-
- sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libpugixml-dev libopenal-dev libtbb-dev libcrypto++-dev liblockfile-dev libfreeimage-dev
13-
- sudo apt-get install cmake lua5.1-dev libssl-dev libogg-dev libtheora-dev libvorbis-dev libsdl2-dev liblzo2-dev libjpeg-dev libncurses5-dev
64+
- export core_count=$(nproc || echo 4) && echo core_count = $core_count
1465
- mkdir bin
1566
- cd bin
16-
- cmake ..
67+
- if [ $TARGET_CPU == x64 ]; then
68+
sudo apt-get install -y libglew-dev libegl1-mesa-dev libgles2-mesa-dev libpugixml-dev libopenal-dev libtbb-dev libcrypto++-dev liblockfile-dev libfreeimage-dev;
69+
sudo apt-get install -y cmake liblua5.1-0-dev libssl-dev libogg-dev libtheora-dev libvorbis-dev libsdl2-dev liblzo2-dev libjpeg-dev libncurses5-dev;
70+
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_CONFIGURATION;
71+
fi
72+
73+
- if [ $TARGET_CPU == x86 ]; then
74+
sudo dpkg --add-architecture i386 && sudo apt-get -qq update && sudo apt-get install -y gcc-multilib g++-7-multilib libpulse-dev:i386 libglib2.0-dev:i386;
75+
sudo apt-get install -y libglew-dev:i386 libegl1-mesa-dev:i386 libgles2-mesa-dev:i386 libpugixml-dev:i386 libopenal-dev:i386 libtbb-dev:i386 libcrypto++-dev:i386 liblockfile-dev:i386 libfreeimage-dev:i386;
76+
sudo apt-get install -y cmake liblua5.1-0-dev:i386 libssl-dev:i386 libogg-dev:i386 libtheora-dev:i386 libvorbis-dev:i386 libsdl2-dev:i386 liblzo2-dev:i386 libjpeg-dev:i386 libncurses5-dev:i386;
77+
CFLAGS="-m32 -march=native" CXXFLAGS="-m32 -march=native" cmake .. -DCMAKE_BUILD_TYPE=$BUILD_CONFIGURATION -DCMAKE_ASM_FLAGS=-m32;
78+
fi
79+
1780
script:
18-
- if [ $TRAVIS_OS_NAME == linux ]; then make && file src/xrCore/xrCore.so; fi
19-
addons:
20-
apt:
21-
sources:
22-
- ubuntu-toolchain-r-test
23-
packages:
24-
- g++-7
81+
- if [ $TRAVIS_OS_NAME == linux ]; then make -j $core_count && file src/xrCore/xrCore.so; fi
82+
2583
notifications:
2684
email: false
27-
env:
28-
global:
29-
- LANG="en_US.UTF-8"

CMakeLists.txt

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,107 @@ project(OpenXRay)
44
include(${PROJECT_SOURCE_DIR}/cmake/utils.cmake)
55

66
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
7+
set(CMAKE_SKIP_BUILD_RPATH TRUE)
8+
if(NOT WIN32)
9+
set(CMAKE_INSTALL_PREFIX "") # Skip all *nix-style installing for a while. Use DESTDIR
10+
endif()
11+
12+
include(cotire)
13+
14+
function(xr_install tgt)
15+
if(NOT MSVC)
16+
install(TARGETS ${tgt} DESTINATION "."
17+
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
18+
GROUP_READ GROUP_EXECUTE
19+
WORLD_READ WORLD_EXECUTE) # chmod 755
20+
else()
21+
install(TARGETS ${tgt}
22+
CONFIGURATIONS Debug
23+
RUNTIME DESTINATION Debug/
24+
LIBRARY DESTINATION Debug/)
25+
install(FILES $<TARGET_PDB_FILE:${tgt}>
26+
CONFIGURATIONS Debug
27+
DESTINATION Debug/ )
28+
install(TARGETS ${tgt}
29+
CONFIGURATIONS Release
30+
RUNTIME DESTINATION Release/
31+
LIBRARY DESTINATION Release/)
32+
endif()
33+
endfunction()
34+
35+
# Use only if install defined outside target directory(like luabind, for example)
36+
function(xr_install_file tgt)
37+
if(NOT MSVC)
38+
install(FILES $<TARGET_FILE:${tgt}> DESTINATION "."
39+
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
40+
GROUP_READ GROUP_EXECUTE
41+
WORLD_READ WORLD_EXECUTE) # chmod 755
42+
else()
43+
install($<TARGET_FILE:${tgt}>
44+
CONFIGURATIONS Debug
45+
RUNTIME DESTINATION Debug/)
46+
install(FILES $<TARGET_PDB_FILE:${tgt}>
47+
CONFIGURATIONS Debug
48+
DESTINATION Debug/ )
49+
install($<TARGET_FILE:${tgt}>
50+
CONFIGURATIONS Release
51+
RUNTIME DESTINATION Release/)
52+
endif()
53+
endfunction()
754

855
find_program(CCACHE_FOUND ccache)
956
if(CCACHE_FOUND)
1057
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
1158
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
59+
set(ENV{CCACHE_SLOPPINESS} pch_defines,time_macros)
1260
endif(CCACHE_FOUND)
1361

14-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive --std=c++17")
62+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
63+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
64+
message(FATAL_ERROR "Building with a gcc version less than 7.0 is not supported.")
65+
endif()
66+
endif()
67+
68+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive --std=c++17 -Wno-attributes -pipe")
1569
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive") This is for the future versions
1670
#set(CMAKE_CXX_STANDARD 14) #Otherwise adds -std=gnu++11 and breaks successful building
1771
#set(CMAKE_CXX_STANDARD_REQUIRED ON)
1872
#set(CMAKE_CXX_EXTENSIONS OFF)
1973

74+
set(LUA_LIBRARIES luajit)
75+
76+
if(NOT CMAKE_BUILD_TYPE)
77+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
78+
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
79+
add_definitions(-DDEBUG)
80+
set(LUA_LIBRARIES luajit-debug)
81+
endif()
82+
83+
set(LUA_FOUND true)
84+
85+
message("CMake build ${CMAKE_BUILD_TYPE}, CFLAGS=${CMAKE_C_FLAGS}, CXXFLAGS=${CMAKE_CXX_FLAGS}")
86+
2087
add_definitions(-D_MT -D_CPPUNWIND -DPURE_DYNAMIC_CAST -DDECLARE_SPECIALIZATION -DM_NOSTDCONTAINERS_EXT -DUSE_OGL)
2188

2289
set(LUA_INCLUDE_DIR Externals/LuaJIT/src)
23-
set(LUA_LIBRARIES luajit)
24-
set(LUA_FOUND 1)
90+
2591
if (NOT WIN32)
92+
if(EXISTS ${CMAKE_SOURCE_DIR}/Externals/cryptopp/dsa.h)
93+
file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/Externals/cryptopp)
94+
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/Externals/cryptopp)
95+
endif()
96+
find_package(GLEW REQUIRED)
97+
find_package(FreeImage REQUIRED)
98+
find_package(LockFile REQUIRED)
99+
find_package(OpenAL REQUIRED)
26100
find_package(Crypto++ REQUIRED)
27101
find_package(PugiXML REQUIRED)
28102
find_package(Theora REQUIRED)
29103
find_package(OGG REQUIRED)
30104
find_package(SDL2 REQUIRED)
31105
find_package(LZO REQUIRED)
32106
find_package(JPEG REQUIRED)
107+
find_package(TBB REQUIRED)
33108
endif()
34109

35110
include_directories(${LUA_INCLUDE_DIR})

Externals/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
include(luajit.cmake)
22
add_subdirectory(luabind)
3-
add_subdirectory(lzo)
3+
xr_install_file(luabind)
44
add_subdirectory(cximage)
5-
add_subdirectory(NVTT)
5+
#add_subdirectory(lzo)
6+
#add_subdirectory(NVTT)
67
add_subdirectory(OPCODE)
78
add_subdirectory(ode)
89
#add_subdirectory(pugixml)

Externals/OPCODE/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
project(OPCODE)
22
add_dir (
3-
"."
4-
)
3+
"."
4+
)
55

66
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
77

8-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include)
8+
include_directories(
9+
${CMAKE_CURRENT_SOURCE_DIR}/../../src
10+
${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include
11+
${SDL_INCLUDE_DIRS}
12+
)
913

1014
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})
1115

1216
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
1317
target_link_libraries(${PROJECT_NAME} xrCore)
18+
xr_install(${PROJECT_NAME})

Externals/cximage/CMakeLists.txt

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,44 @@ cmake_minimum_required(VERSION 2.8.0)
22
project(cximage)
33

44
set(SOURCES
5-
ximacfg.cpp
6-
ximaenc.cpp
7-
ximaexif.cpp
8-
ximage.cpp
9-
ximainfo.cpp
10-
ximaint.cpp
11-
ximajpg.cpp
12-
ximalpha.cpp
13-
ximalyr.cpp
14-
ximapal.cpp
15-
ximasel.cpp
16-
ximath.cpp
17-
xmemfile.cpp
5+
ximacfg.cpp
6+
ximaenc.cpp
7+
ximaexif.cpp
8+
ximage.cpp
9+
ximainfo.cpp
10+
ximaint.cpp
11+
ximajpg.cpp
12+
ximalpha.cpp
13+
ximalyr.cpp
14+
ximapal.cpp
15+
ximasel.cpp
16+
ximath.cpp
17+
xmemfile.cpp
1818
)
1919

2020
set(HEADERS
21-
xfile.h
22-
ximacfg.h
23-
ximadef.h
24-
ximage.h
25-
ximaiter.h
26-
ximajpg.h
27-
ximath.h
28-
xiofile.h
29-
xmemfile.h
21+
xfile.h
22+
ximacfg.h
23+
ximadef.h
24+
ximage.h
25+
ximaiter.h
26+
ximajpg.h
27+
ximath.h
28+
xiofile.h
29+
xmemfile.h
3030
)
3131

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

35-
include_directories("." ${CMAKE_SOURCE_DIR})
35+
include_directories(
36+
${CMAKE_CURRENT_SOURCE_DIR}
37+
${CMAKE_CURRENT_SOURCE_DIR}/../../src
38+
)
3639

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

3942
set_target_properties(cximage PROPERTIES PREFIX "")
4043
target_link_libraries(cximage)
44+
set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
45+

Externals/luajit.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ endif()
319319
add_library( ${LIB_NAME} SHARED ${LJCORE_C} ${DEPS} )
320320
set_target_properties ( ${LIB_NAME} PROPERTIES PREFIX "" )
321321
target_link_libraries ( ${LIB_NAME} ${LIBS} )
322+
xr_install(${LIB_NAME})
322323
#endif()
323324

324325
if(NOT ${BUILD_LIB_ONLY})

Externals/ode/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_D
1313
add_definitions(-DdSINGLE -D_SECURE_SCL=0 -DLINUX -D_cdecl= -D__forceinline=inline)
1414

1515
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})
16+
xr_install(${PROJECT_NAME})

cmake/FindFreeImage.cmake

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#https://github.com/castano/nvidia-texture-tools/blob/48f5dd4603c9f8ce8d47e8547b8b3c1c71d27da7/cmake/FindFreeImage.cmake
2+
#
3+
# Try to find the FreeImage library and include path.
4+
# Once done this will define
5+
#
6+
# FREEIMAGE_FOUND
7+
# FREEIMAGE_INCLUDE_PATH
8+
# FREEIMAGE_LIBRARY
9+
#
10+
11+
IF (WIN32)
12+
FIND_PATH( FREEIMAGE_INCLUDE_PATH FreeImage.h
13+
${FREEIMAGE_ROOT_DIR}/include
14+
${FREEIMAGE_ROOT_DIR}
15+
DOC "The directory where FreeImage.h resides")
16+
FIND_LIBRARY( FREEIMAGE_LIBRARY
17+
NAMES FreeImage freeimage
18+
PATHS
19+
${FREEIMAGE_ROOT_DIR}/lib
20+
${FREEIMAGE_ROOT_DIR}
21+
DOC "The FreeImage library")
22+
ELSE (WIN32)
23+
FIND_PATH( FREEIMAGE_INCLUDE_PATH FreeImage.h
24+
/usr/include
25+
/usr/local/include
26+
/sw/include
27+
/opt/local/include
28+
DOC "The directory where FreeImage.h resides")
29+
FIND_LIBRARY( FREEIMAGE_LIBRARY
30+
NAMES FreeImage freeimage
31+
PATHS
32+
/usr/lib64
33+
/usr/lib
34+
/usr/local/lib64
35+
/usr/local/lib
36+
/sw/lib
37+
/opt/local/lib
38+
DOC "The FreeImage library")
39+
ENDIF (WIN32)
40+
41+
SET(FREEIMAGE_LIBRARIES ${FREEIMAGE_LIBRARY})
42+
43+
IF (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY)
44+
SET( FREEIMAGE_FOUND TRUE CACHE BOOL "Set to TRUE if FreeImage is found, FALSE otherwise")
45+
MESSAGE(STATUS "Found FreeImage: ${FREEIMAGE_INCLUDE_PATH}, ${FREEIMAGE_LIBRARY}")
46+
ELSE (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY)
47+
SET( FREEIMAGE_FOUND FALSE CACHE BOOL "Set to TRUE if FreeImage is found, FALSE otherwise")
48+
MESSAGE(FATAL_ERROR "FreeImage not found.")
49+
ENDIF (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY)
50+
51+
MARK_AS_ADVANCED(
52+
FREEIMAGE_FOUND
53+
FREEIMAGE_LIBRARY
54+
FREEIMAGE_LIBRARIES
55+
FREEIMAGE_INCLUDE_PATH)
56+

0 commit comments

Comments
 (0)