1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-25 11:52:40 +01:00

cmake: add ability to compile using conan package manager

This commit is contained in:
Anonymous Maarten 2018-06-07 02:19:53 +02:00
parent 1839b9c29d
commit 7d2da28dbc
20 changed files with 384 additions and 132 deletions

View File

@ -4,21 +4,20 @@ image:
clone_depth: 1 clone_depth: 1
shallow_clone: false shallow_clone: false
# All paths in the environment section should be cache:
# cmake-style paths: using forward-slashes (/). - C:\Users\appveyor\.conan -> conanfile.py
- C:\.conan -> conanfile.py
environment: environment:
APPVEYOR_SAVE_CACHE_ON_ERROR: true
PYTHON: "C:\\Python36-x64" PYTHON: "C:\\Python36-x64"
CMAKE_GENERATOR: "Visual Studio 15 2017" CMAKE_GENERATOR_BASE: "Visual Studio 15 2017"
BOOST_ROOT: "C:\\Libraries"
BOOST_VERSION: "1.65.1"
DEP_DIR: "C:\\dependencies"
WIN_DEP_NAME: "openrw-windows-dependencies"
WIN_DEP_URL: "https://github.com/rwengine/openrw-windows-dependencies"
NAME_SUFFIX: "windows" NAME_SUFFIX: "windows"
USE_CONAN: 1
platform: platform:
- Win32 # - Win32
# - x64 - x64
configuration: configuration:
# - Debug # - Debug
@ -27,17 +26,19 @@ configuration:
matrix: matrix:
fast_finish: false fast_finish: false
cache: clone_folder: C:\projects\openrw
- C:\dependencies -> .appveyor.yml, cmake/ctest/script_ci.ctest, cmake/ctest/utils.ctest, , cmake/ctest/configure_windows.ctest
init: init:
- set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH% - set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%
- python --version - python --version
- cmake --version - cmake --version
- msbuild /version - msbuild /version
- pip3 install conan
- conan user
- conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
build_script: build_script:
- ctest -VV -S cmake/ctest/script_ci.ctest - ctest -VV -S "%APPVEYOR_BUILD_FOLDER%/cmake/ctest/script_ci.ctest"
after_build: after_build:
- cd "%APPVEYOR_BUILD_FOLDER%\build" - cd "%APPVEYOR_BUILD_FOLDER%\build"

View File

@ -20,6 +20,10 @@ matrix:
services: docker services: docker
script: script:
- scripts/docker/docker_travis.sh "arch_latest.docker" - scripts/docker/docker_travis.sh "arch_latest.docker"
- os: linux
env: NAME="conan" NAME_SUFFIX="conan" USE_CONAN=1
script:
- scripts/docker/docker_travis.sh "conan_base.docker"
- os: osx - os: osx
env: NAME="Apple macOS" NAME_SUFFIX="mac" env: NAME="Apple macOS" NAME_SUFFIX="mac"
osx_image: xcode9.2 osx_image: xcode9.2

View File

@ -7,7 +7,7 @@ include(GNUInstallDirs)
# Read the configuration arguments # Read the configuration arguments
include("${PROJECT_SOURCE_DIR}/cmake_options.cmake") include("${PROJECT_SOURCE_DIR}/cmake_options.cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
# Include git hash in source # Include git hash in source
include(GetGitRevisionDescription) include(GetGitRevisionDescription)
@ -15,31 +15,45 @@ get_git_head_revision(GIT_REFSPEC GIT_SHA1)
message(STATUS "Building ${CMAKE_PROJECT_NAME} GIT SHA1: ${GIT_SHA1}") message(STATUS "Building ${CMAKE_PROJECT_NAME} GIT SHA1: ${GIT_SHA1}")
include(WrapTargets) include(WrapTargets)
if(USE_CONAN)
if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo_multi.cmake")
message(STATUS "Using conan 'cmake_multi' generator")
include("${CMAKE_BINARY_DIR}/conanbuildinfo_multi.cmake")
else()
message(STATUS "Using conan 'cmake' generator")
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
endif()
conan_basic_setup(TARGETS)
find_package(Boost REQUIRED) rwdep_wrap_conan_targets()
find_package(Boost COMPONENTS program_options system REQUIRED) else()
if(FILESYSTEM_LIBRARY STREQUAL "BOOST") find_package(Boost REQUIRED)
find_package(Boost COMPONENTS program_options system REQUIRED)
if(FILESYSTEM_LIBRARY STREQUAL "BOOST")
find_package(Boost COMPONENTS filesystem system REQUIRED) find_package(Boost COMPONENTS filesystem system REQUIRED)
endif() endif()
if(BUILD_TESTS) if(BUILD_TESTS)
find_package(Boost COMPONENTS unit_test_framework REQUIRED) find_package(Boost COMPONENTS unit_test_framework REQUIRED)
endif()
# Do not link to SDL2main library
set(SDL2_BUILDING_LIBRARY True)
find_package(OpenAL REQUIRED)
find_package(Bullet REQUIRED)
find_package(GLM REQUIRED)
find_package(FFmpeg REQUIRED)
find_package(SDL2 REQUIRED)
rwdep_wrap_find_packages()
endif() endif()
if(CHECK_INCLUDES) if(CHECK_INCLUDES)
find_package(IncludeWhatYouUse REQUIRED) find_package(IncludeWhatYouUse REQUIRED)
endif() endif()
# Do not link to SDL2main library
set(SDL2_BUILDING_LIBRARY True)
set(OpenGL_GL_PREFERENCE GLVND) set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
find_package(OpenAL REQUIRED)
find_package(Bullet REQUIRED)
find_package(GLM REQUIRED)
find_package(FFmpeg REQUIRED)
find_package(SDL2 REQUIRED)
rwdep_wrap_find_packages()
if(CHECK_CLANGTIDY) if(CHECK_CLANGTIDY)
find_package(ClangTidy REQUIRED) find_package(ClangTidy REQUIRED)

View File

@ -1,13 +1,11 @@
# This file does: # This file does:
# - check whether all arguments are defined, # - check whether all arguments are defined,
# - clean the build directory,
# - configure, build and test, # - configure, build and test,
# - coverage and memcheck, # - coverage and memcheck,
# - submit # - submit
set(_ARGS_BOOL set(_ARGS_BOOL
EMPTY_BINARY_DIR USE_CONAN
DEBUG DEBUG
CHECK_INCLUDES CHECK_INCLUDES
BUILD_VIEWER BUILD_VIEWER
@ -32,6 +30,9 @@ set(_ARGS_ONEVAL
BUILDER_NAME BUILDER_NAME
BUILD_NAME BUILD_NAME
CONAN_ARCH
CONAN_PROFILE
CMAKE_GENERATOR CMAKE_GENERATOR
COVERAGE_COMMAND COVERAGE_COMMAND
) )
@ -55,17 +56,6 @@ set(CTEST_COVERAGE_COMMAND "${COVERAGE_COMMAND}")
set(CTEST_SITE "${BUILDER_NAME}") set(CTEST_SITE "${BUILDER_NAME}")
set(CTEST_BUILD_NAME "${BUILD_NAME}") set(CTEST_BUILD_NAME "${BUILD_NAME}")
set(NUMBER_ERRORS "0")
set(NUMBER_WARNINGS "0")
if(EMPTY_BINARY_DIR)
message(STATUS "Removing binary directory '${CTEST_BINARY_DIRECTORY}'...")
if(EXISTS "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt")
message(STATUS "CMakeCache.txt file exists ==> removing")
ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}")
endif()
endif()
set(_CTEST_START_EXTRA_ARGS) set(_CTEST_START_EXTRA_ARGS)
set(_CTEST_CONFIGURE_EXTRA_ARGS) set(_CTEST_CONFIGURE_EXTRA_ARGS)
if(APPEND_RESULTS) if(APPEND_RESULTS)
@ -76,6 +66,70 @@ endif()
message(STATUS "Starting test...") message(STATUS "Starting test...")
ctest_start("${MODEL_NAME}" ${_CTEST_START_EXTRA_ARGS}) ctest_start("${MODEL_NAME}" ${_CTEST_START_EXTRA_ARGS})
if(USE_CONAN)
find_program(CONAN_BIN
NAMES conan
HINTS
"$ENV{HOME}/.local/bin"
)
if(NOT CONAN_BIN)
message(STATUS "Cannot find conan. Installing conan...")
execute_process(
COMMAND pip3 install --user conan
RESULT_VARIABLE RES
)
if(RES)
message(FATAL_ERROR "Installation of conan failed")
endif()
find_program(CONAN_BIN
NAMES conan
HINTS
"$ENV{HOME}/.local/bin"
)
message(STATUS "Found conan: ${CONAN_BIN}")
if(NOT CONAN_BIN)
message(FATAL_ERROR "Cannot find conan.")
endif()
execute_process(
COMMAND "${CONAN_BIN}" user
RESULT_VARIABLE RES
)
if(RES)
message(FATAL_ERROR "Configuration of conan failed")
endif()
execute_process(
COMMAND "${CONAN_BIN}" remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
RESULT_VARIABLE RES
)
if(RES)
message(FATAL_ERROR "Adding bincrafters remote failed")
endif()
endif()
if(DEBUG)
set(CONAN_CONFIGURATION "Debug")
else()
set(CONAN_CONFIGURATION "Release")
endif()
execute_process(
COMMAND
"${CONAN_BIN}" install "${CTEST_SOURCE_DIRECTORY}" -pr "${CONAN_PROFILE}"
-s arch=${CONAN_ARCH} -s build_type=${CONAN_CONFIGURATION} --build missing
WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}"
RESULT_VARIABLE RES
)
if(RES)
message(FATAL_ERROR "conan install failed")
endif()
list(APPEND CONFIGURE_EXTRA_OPTIONS
"-DBOOST_STATIC=True"
)
endif()
# CTEST_CONFIGURATION_TYPE is needed on Windows (no leading underscore) # CTEST_CONFIGURATION_TYPE is needed on Windows (no leading underscore)
if(DEBUG) if(DEBUG)
set(_CMAKE_BUILD_TYPE "Debug") set(_CMAKE_BUILD_TYPE "Debug")
@ -96,6 +150,7 @@ set(_CONFIGURE_OPTIONS
"-DCHECK_INCLUDES=${CHECK_INCLUDES}" "-DCHECK_INCLUDES=${CHECK_INCLUDES}"
"-DCMAKE_BUILD_TYPE=${_CMAKE_BUILD_TYPE}" "-DCMAKE_BUILD_TYPE=${_CMAKE_BUILD_TYPE}"
"-DENABLE_SANITIZERS=${ENABLE_SANITIZERS}" "-DENABLE_SANITIZERS=${ENABLE_SANITIZERS}"
"-DUSE_CONAN=${USE_CONAN}"
) )
message(STATUS "Configuring...") message(STATUS "Configuring...")
@ -113,7 +168,6 @@ message(STATUS "Building...")
ctest_build( ctest_build(
CONFIGURATION "${_CTEST_BUILD_CONFIGURATION}" CONFIGURATION "${_CTEST_BUILD_CONFIGURATION}"
NUMBER_ERRORS _NB_BUILD_ERRORS NUMBER_ERRORS _NB_BUILD_ERRORS
NUMBER_WARNINGS _NB_BUILD_WARNINGS
) )
if(RUN_TESTS) if(RUN_TESTS)

View File

@ -11,3 +11,6 @@ if(MODEL_NAME STREQUAL "EXPERIMENTAL")
else() else()
set(CHECK_INCLUDES FALSE) set(CHECK_INCLUDES FALSE)
endif() endif()
set(CONAN_ARCH "x86_64")
set(CONAN_PROFILE "${CTEST_SOURCE_DIRECTORY}/scripts/conan/darwin")

View File

@ -11,3 +11,6 @@ if(MODEL_NAME STREQUAL "EXPERIMENTAL")
else() else()
set(CHECK_INCLUDES FALSE) set(CHECK_INCLUDES FALSE)
endif() endif()
set(CONAN_ARCH "x86_64")
set(CONAN_PROFILE "${CTEST_SOURCE_DIRECTORY}/scripts/conan/linux")

View File

@ -1,12 +1,7 @@
set(_WIN_NEEDED_VARS set(_WIN_NEEDED_VARS
BOOST_ROOT CMAKE_GENERATOR_BASE
BOOST_VERSION
CMAKE_GENERATOR
CONFIGURATION
DEP_DIR
PLATFORM PLATFORM
WIN_DEP_NAME CONFIGURATION
WIN_DEP_URL
) )
foreach(_WIN_NEEDED_VAR ${_WIN_NEEDED_VARS}) foreach(_WIN_NEEDED_VAR ${_WIN_NEEDED_VARS})
set("${_WIN_NEEDED_VAR}" "$ENV{${_WIN_NEEDED_VAR}}") set("${_WIN_NEEDED_VAR}" "$ENV{${_WIN_NEEDED_VAR}}")
@ -16,90 +11,31 @@ foreach(_WIN_NEEDED_VAR ${_WIN_NEEDED_VARS})
endif() endif()
endforeach() endforeach()
string(REPLACE "." "_" _BOOST_VERSION_UNDERSCORED "${BOOST_VERSION}") string(TOLOWER "${ARCH}" ARCH)
set(BOOST_ROOT "${BOOST_ROOT}\\boost_${_BOOST_VERSION_UNDERSCORED}")
string(TOLOWER "${PLATFORM}" PLATFORM)
if(PLATFORM STREQUAL "win32") if(PLATFORM STREQUAL "win32")
set(CMAKE_GENERATOR "${CMAKE_GENERATOR}") set(CMAKE_GENERATOR "${CMAKE_GENERATOR_BASE}")
set(TRIPLET "x86-windows-static") set(CONAN_ARCH "x86")
elseif(PLATFORM STREQUAL "x64") elseif(PLATFORM STREQUAL "x64")
set(CMAKE_GENERATOR "${CMAKE_GENERATOR} Win64") set(CMAKE_GENERATOR "${CMAKE_GENERATOR_BASE} Win64")
set(TRIPLET "x64-windows-static") set(CONAN_ARCH "x86_64")
else() else()
message(FATAL_ERROR "Unknown platform (${PLATFORM})") message(FATAL_ERROR "Unknown platform (${PLATFORM})")
endif() endif()
string(TOLOWER "${CONFIGURATION}" CONFIGURATION) set(CONFIGURE_EXTRA_OPTIONS ";")
if(CONFIGURATION STREQUAL "debug")
if(CONFIGURATION STREQUAL "Debug")
set(DEBUG TRUE) set(DEBUG TRUE)
set(_LIBRARY_DIR_INFIX "debug") elseif(CONFIGURATION STREQUAL "Release")
elseif(CONFIGURATION STREQUAL "release")
set(DEBUG FALSE) set(DEBUG FALSE)
set(_LIBRARY_DIR_INFIX "")
else() else()
message(FATAL_ERROR "Unknown configuration '${CONFIGURATION}'") message(FATAL_ERROR "Unknown configuration '${CONFIGURATION}'")
endif() endif()
file(MAKE_DIRECTORY "${DEP_DIR}") set(CONAN_PROFILE "${CTEST_SOURCE_DIRECTORY}/scripts/conan/windows")
set(_WIN_DEP_DIR "${DEP_DIR}\\${WIN_DEP_NAME}") set(CONAN_ARCH "x86_64")
set(TRIPLET_DIR "${_WIN_DEP_DIR}\\${TRIPLET}")
message(STATUS "Checking windows dependency dir '${_WIN_DEP_DIR}'...") set(BUILD_VIEWER TRUE)
if(NOT IS_DIRECTORY "${_WIN_DEP_DIR}")
message(STATUS "... does not exist.")
message(STATUS "Executing git clone...")
execute_process(
COMMAND git clone --depth 1 -- "${WIN_DEP_URL}"
WORKING_DIRECTORY "${DEP_DIR}"
RESULT_VARIABLE GIT_RESULT
)
if(GIT_RESULT)
message(FATAL_ERROR "Failed to clone '${WIN_DEP_URL}'")
endif()
else()
message(STATUS "... exists.")
message(STATUS "Skipping git clone")
endif()
set(_INCLUDE_PATH
"${TRIPLET_DIR}\\include"
)
set(ENV{OPENALDIR} "${TRIPLET_DIR}\\include\\AL")
set(ENV{SDL2DIR} "${TRIPLET_DIR}\\include\\SDL2")
set(_LIBRARY_PATH
"${TRIPLET_DIR}\\${_LIBRARY_DIR_INFIX}\\lib"
)
set(_C_FLAGS "/DWIN32 /D_WINDOWS /W3 /utf-8 /MP")
set(_CXX_FLAGS "/DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc /MP")
set(_C_FLAGS_DEBUG "/D_DEBUG /MTd /Z7 /Ob0 /Od /RTC1")
set(_C_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG")
set(_C_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /DNDEBUG")
set(_C_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /DNDEBUG")
set(CMAKE_GENERATOR "${CMAKE_GENERATOR}")
set(DEBUG "${DEBUG}")
set(CONFIGURE_EXTRA_OPTIONS
"-DCMAKE_INCLUDE_PATH=${_INCLUDE_PATH}"
"-DCMAKE_LIBRARY_PATH=${_LIBRARY_PATH}"
"-DCMAKE_C_FLAGS=${_C_FLAGS}"
"-DCMAKE_C_FLAGS_DEBUG=${_C_FLAGS_DEBUG}"
"-DCMAKE_C_FLAGS_MINSIZEREL=${_C_FLAGS_MINSIZEREL}"
"-DCMAKE_C_FLAGS_RELEASE=${_C_FLAGS_RELEASE}"
"-DCMAKE_C_FLAGS_RELWITHDEBINFO=${_C_FLAGS_RELWITHDEBINFO}"
"-DCMAKE_CXX_FLAGS=${_CXX_FLAGS}"
"-DCMAKE_CXX_FLAGS_DEBUG=${_C_FLAGS_DEBUG}"
"-DCMAKE_CXX_FLAGS_MINSIZEREL=${_C_FLAGS_MINSIZEREL}"
"-DCMAKE_CXX_FLAGS_RELEASE=${_C_FLAGS_RELEASE}"
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${_C_FLAGS_RELWITHDEBINFO}"
"-DBOOST_ROOT=${BOOST_ROOT}"
"-DBoost_USE_STATIC_LIBS=TRUE"
"-DBoost_USE_STATIC_RUNTIME=TRUE"
)
set(BUILD_VIEWER FALSE) #FIXME: ENABLE
set(COVERAGE_COMMAND "echo") #FIXME: ENABLE set(COVERAGE_COMMAND "echo") #FIXME: ENABLE
set(CHECK_INCLUDES FALSE) #FIXME: ENABLE set(CHECK_INCLUDES FALSE) #FIXME: ENABLE
set(ENABLE_SANITIZERS "") set(ENABLE_SANITIZERS "")

View File

@ -12,9 +12,19 @@ else()
endif() endif()
set(CTEST_COMMAND "${CMAKE_CTEST_COMMAND}") set(CTEST_COMMAND "${CMAKE_CTEST_COMMAND}")
message(STATUS "CTEST_SOURCE_DIRECTORY=${CTEST_SOURCE_DIRECTORY}")
message(STATUS "CTEST_BINARY_DIRECTORY=${CTEST_BINARY_DIRECTORY}")
openrw_build_name(BUILDER_NAME_BASE BUILD_NAME) openrw_build_name(BUILDER_NAME_BASE BUILD_NAME)
set(BUILDER_NAME_BASE "${BUILDER_NAME_BASE}-$ENV{NAME_SUFFIX}") set(BUILDER_NAME_BASE "${BUILDER_NAME_BASE}-$ENV{NAME_SUFFIX}")
message(STATUS "Removing binary directory '${CTEST_BINARY_DIRECTORY}'...")
if(EXISTS "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt")
message(STATUS "CMakeCache.txt file exists ==> removing")
ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}")
endif()
file(MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS "Linux detected") message(STATUS "Linux detected")
@ -34,6 +44,12 @@ endif()
set(WARNING_MESSAGES) set(WARNING_MESSAGES)
set(ERROR_MESSAGES) set(ERROR_MESSAGES)
if($ENV{USE_CONAN})
set(USE_CONAN TRUE)
else()
set(USE_CONAN FALSE)
endif()
set(SEPARATE_TEST_SUITES FALSE) set(SEPARATE_TEST_SUITES FALSE)
set(RUN_COVERAGE FALSE) set(RUN_COVERAGE FALSE)
set(RUN_MEMCHECK FALSE) set(RUN_MEMCHECK FALSE)
@ -42,7 +58,6 @@ openrw_should_submit_ci(SUBMIT)
# Build with no data and test # Build with no data and test
set(BUILDER_NAME "${BUILDER_NAME_BASE}-nodata") set(BUILDER_NAME "${BUILDER_NAME_BASE}-nodata")
set(APPEND_RESULTS FALSE) set(APPEND_RESULTS FALSE)
set(EMPTY_BINARY_DIR TRUE)
set(TESTS_NODATA TRUE) set(TESTS_NODATA TRUE)
set(RUN_TESTS TRUE) set(RUN_TESTS TRUE)
@ -51,7 +66,6 @@ include("${CTEST_SCRIPT_DIRECTORY}/build.ctest")
# Build with data and do not test # Build with data and do not test
set(BUILDER_NAME "${BUILDER_NAME_BASE}-data") set(BUILDER_NAME "${BUILDER_NAME_BASE}-data")
set(APPEND_RESULTS FALSE) set(APPEND_RESULTS FALSE)
set(EMPTY_BINARY_DIR FALSE)
set(TESTS_NODATA FALSE) set(TESTS_NODATA FALSE)
set(RUN_TESTS FALSE) set(RUN_TESTS FALSE)

View File

@ -12,8 +12,18 @@ else()
endif() endif()
set(CTEST_COMMAND "${CMAKE_CTEST_COMMAND}") set(CTEST_COMMAND "${CMAKE_CTEST_COMMAND}")
message(STATUS "CTEST_SOURCE_DIRECTORY=${CTEST_SOURCE_DIRECTORY}")
message(STATUS "CTEST_BINARY_DIRECTORY=${CTEST_BINARY_DIRECTORY}")
openrw_build_name(BUILDER_NAME BUILD_NAME) openrw_build_name(BUILDER_NAME BUILD_NAME)
message(STATUS "Removing binary directory '${CTEST_BINARY_DIRECTORY}'...")
if(EXISTS "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt")
message(STATUS "CMakeCache.txt file exists ==> removing")
ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}")
endif()
file(MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS "Linux detected") message(STATUS "Linux detected")
@ -33,6 +43,12 @@ endif()
set(WARNING_MESSAGES) set(WARNING_MESSAGES)
set(ERROR_MESSAGES) set(ERROR_MESSAGES)
if($ENV{USE_CONAN})
set(USE_CONAN TRUE)
else()
set(USE_CONAN FALSE)
endif()
set(SEPARATE_TEST_SUITES TRUE) set(SEPARATE_TEST_SUITES TRUE)
if($ENV{RUN_COVERAGE}) if($ENV{RUN_COVERAGE})
@ -49,7 +65,6 @@ else()
set(RES FALSE) set(RES FALSE)
endif() endif()
set(EMPTY_BINARY_DIR TRUE)
set(TESTS_NODATA FALSE) set(TESTS_NODATA FALSE)
set(RUN_TESTS TRUE) set(RUN_TESTS TRUE)

View File

@ -48,3 +48,22 @@ function(rwdep_wrap_find_packages)
rwdep_wrap_find_package(boost_unit_test_framework "${Boost_INCLUDE_DIRS}" "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}") rwdep_wrap_find_package(boost_unit_test_framework "${Boost_INCLUDE_DIRS}" "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
endif() endif()
endfunction() endfunction()
function(rwdep_wrap_conan_target TARGET CONAN_NAME)
add_library("_rwdep_${TARGET}" INTERFACE)
target_link_libraries("_rwdep_${TARGET}" INTERFACE "CONAN_PKG::${CONAN_NAME}")
add_library("rwdep::${TARGET}" ALIAS "_rwdep_${TARGET}")
endfunction()
function(rwdep_wrap_conan_targets)
rwdep_wrap_conan_target(boost boost)
rwdep_wrap_conan_target(boost_program_options boost)
rwdep_wrap_conan_target(boost_filesystem boost)
rwdep_wrap_conan_target(boost_unit_test_framework boost)
rwdep_wrap_conan_target(OpenAL openal)
rwdep_wrap_conan_target(bullet bullet)
rwdep_wrap_conan_target(glm glm)
rwdep_wrap_conan_target(ffmpeg ffmpeg)
rwdep_wrap_conan_target(SDL2 sdl2)
endfunction()

View File

@ -64,6 +64,14 @@ else()
message(FATAL_ERROR "Unknown platform \"${CMAKE_SYSTEM_NAME}\". please update CMakeLists.txt.") message(FATAL_ERROR "Unknown platform \"${CMAKE_SYSTEM_NAME}\". please update CMakeLists.txt.")
endif() endif()
if(USE_CONAN)
if(CONAN_SETTINGS_COMPILER_LIBCXX STREQUAL "libstdc++11")
target_compile_definitions(rw_interface INTERFACE _GLIBCXX_USE_CXX11_ABI=1)
elseif(CONAN_SETTINGS_COMPILER_LIBCXX STREQUAL "libstdc++")
target_compile_definitions(rw_interface INTERFACE _GLIBCXX_USE_CXX11_ABI=0)
endif()
endif()
if(FILESYSTEM_LIBRARY STREQUAL "CXX17") if(FILESYSTEM_LIBRARY STREQUAL "CXX17")
target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=0") target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=0")
elseif(FILESYSTEM_LIBRARY STREQUAL "CXXTS") elseif(FILESYSTEM_LIBRARY STREQUAL "CXXTS")

View File

@ -27,5 +27,6 @@ set(ENABLE_SANITIZERS "" CACHE STRING "Enable selected sanitizer.")
option(TEST_COVERAGE "Enable coverage analysis (implies CMAKE_BUILD_TYPE=Debug)") option(TEST_COVERAGE "Enable coverage analysis (implies CMAKE_BUILD_TYPE=Debug)")
option(SEPARATE_TEST_SUITES "Add each test suite as separate test to CTest") option(SEPARATE_TEST_SUITES "Add each test suite as separate test to CTest")
option(BOOST_STATIC "Link against static Boost libraries") option(BOOST_STATIC "Link against static Boost libraries")
option(USE_CONAN "Use Conan as packet manager")

82
conanfile.py Normal file
View File

@ -0,0 +1,82 @@
from conans import ConanFile, CMake
from conans.errors import ConanException
# FIXME:
# - no sound in cutscenes. Also no subtitles.
class OpenrwConan(ConanFile):
name = 'openrw'
version = 'master'
license = 'GPL3'
url = 'https://github.com/rwengine/openrw'
description = "OpenRW 'Open ReWrite' is an un-official open source recreation of the classic Grand Theft Auto III game executable"
settings = 'os', 'compiler', 'build_type', 'arch'
options = {
'test_data': [True, False],
'viewer': [True, False],
}
default_options = (
'test_data=False',
'viewer=False',
'bullet:shared=False',
'ffmpeg:iconv=False',
'libalsa:disable_python=True', # https://github.com/conan-community/community/issues/3
'sdl2:sdl2main=False',
)
generators = 'cmake',
exports_sources = 'CMakeLists.txt', 'cmake_configure.cmake', 'cmake_options.cmake', 'COPYING', \
'cmake/modules/*', 'benchmarks', 'rwlib/*', 'rwengine/*', 'rwgame/*', 'rwviewer/*', 'tests/*'
_rw_dependencies = {
'game': (
'openal/1.18.2@bincrafters/stable',
'bullet/2.87@bincrafters/stable',
'glm/0.9.8.5@g-truc/stable',
'ffmpeg/4.0@bincrafters/stable',
'sdl2/2.0.8@bincrafters/stable',
'boost/1.67.0@conan/stable',
),
'viewer': (
'Qt/5.11@bincrafters/stable',
)
}
def requirements(self):
for dep in self._rw_dependencies['game']:
self.requires(dep)
if self.options.viewer:
for dep in self._rw_dependencies['viewer']:
self.requires(dep)
def _configure_cmake(self):
cmake = CMake(self)
defs = {
'BUILD_SHARED_LIBS': False,
'CMAKE_BUILD_TYPE': self.settings.build_type,
'BUILD_TESTS': True,
'BUILD_VIEWER': self.options.viewer,
'TESTS_NODATA': not self.options.test_data,
'USE_CONAN': True,
'BOOST_STATIC': not self.options['boost'].shared,
}
cmake.configure(defs=defs)
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
if self.options.viewer:
# FIXME: https://github.com/osechet/conan-qt/issues/6 and https://github.com/conan-io/conan/issues/2619
self.copy('qt.conf', dst='bin', src='rwviewer')
cmake = self._configure_cmake()
cmake.install()
def package_info(self):
self.cpp_info.libs = ['rwengine', 'rwlib']
self.cpp_info.stdcpp = 14

View File

@ -27,6 +27,7 @@ add_executable(rwviewer WIN32
) )
target_link_libraries(rwviewer target_link_libraries(rwviewer
PRIVATE
rwengine rwengine
Qt5::OpenGL Qt5::OpenGL
Qt5::Widgets Qt5::Widgets
@ -37,3 +38,8 @@ openrw_target_apply_options(TARGET rwviewer)
install(TARGETS rwviewer install(TARGETS rwviewer
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
) )
if(USE_CONAN)
set(QT5_ROOT "${CONAN_QT_ROOT}")
configure_file(qt.conf.in qt.conf)
endif()

2
rwviewer/qt.conf.in Normal file
View File

@ -0,0 +1,2 @@
[Paths]
Prefix = @QT5_ROOT@

8
scripts/conan/darwin Normal file
View File

@ -0,0 +1,8 @@
include(default)
[options]
openrw:viewer=True
# https://github.com/bincrafters/community/issues/120
ffmpeg:vdpau=False
ffmpeg:vaapi=False
ffmpeg:xcb=False

11
scripts/conan/linux Normal file
View File

@ -0,0 +1,11 @@
include(default)
[options]
openrw:viewer=True
sdl2:esd=False
sdl2:wayland=True
sdl2:x11=True
# https://github.com/bincrafters/community/issues/120
ffmpeg:vdpau=False
ffmpeg:vaapi=False
ffmpeg:xcb=False

5
scripts/conan/windows Normal file
View File

@ -0,0 +1,5 @@
include(default)
[options]
openrw:viewer=True
ffmpeg:qsv=False

View File

@ -0,0 +1,66 @@
FROM ubuntu:rolling
RUN apt-get update \
&& apt-get install --no-install-recommends --no-upgrade -y \
build-essential \
cmake \
gcc-8 \
g++-8 \
# scripts to install conan \
python3-pip \
python3-distutils \
python3-setuptools \
python3-wheel \
# packet build requirements \
git \
autoconf \
automake \
autotools-dev \
libtool \
m4 \
sudo \
# conan-qt5 dependencies https://github.com/bincrafters/conan-qt/blob/stable/5.11/conanfile.py \
libx11-6 \
libfontconfig1-dev \
libxrender-dev \
libxcursor-dev \
libxext-dev \
libxfixes-dev \
libxft-dev \
libxi-dev \
libgl1-mesa-dev \
libxcb1 \
libxcb1-dev \
libxrandr-dev \
libx11-xcb1 \
libx11-xcb-dev \
libxcb-keysyms1 \
libxcb-keysyms1-dev \
libxcb-image0 \
libxcb-image0-dev \
libxcb-shm0 \
libxcb-shm0-dev \
libxcb-icccm4 \
libx11-dev \
libxcb-icccm4-dev \
libxcb-sync1 \
libxcb-sync-dev \
libxcb-xfixes0-dev \
libxcb-shape0-dev \
libxcb-render-util0-dev \
libxcb-randr0-dev \
libxcb-render-util0 \
libxcb-glx0-dev \
libxcb-xinerama0 \
libxcb-xinerama0-dev \
# conan-ffmpeg dependencies https://github.com/bincrafters/conan-ffmpeg/blob/stable/3.4/conanfile.py \
libasound2-dev \
libpulse-dev \
# conan-sdl2 dependencies https://github.com/bincrafters/conan-sdl2/blob/stable/2.0.8/conanfile.py\
libxinerama-dev \
libxkbcommon-dev \
&& apt-get clean
# RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 50 --slave /usr/bin/g++ g++ /usr/bin/g++-8
CMD [ /bin/bash ]

View File

@ -8,7 +8,7 @@ docker=$1
"$curdir/docker_tool.py" build -d "$docker" -t openrw_build_image "$curdir/docker_tool.py" build -d "$docker" -t openrw_build_image
# Start docker container + add travis user # Start docker container + add travis user
"$curdir/docker_tool.py" create -t openrw_build_image -n openrw_builder -U travis -e NAME_SUFFIX=$NAME_SUFFIX XDG_RUNTIME_DIR=/tmp TRAVIS=$TRAVIS TRAVIS_COMMIT=$TRAVIS_COMMIT TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG TRAVIS_BRANCH=$TRAVIS_BRANCH "$curdir/docker_tool.py" create -t openrw_build_image -n openrw_builder -U travis -e NAME_SUFFIX=$NAME_SUFFIX XDG_RUNTIME_DIR=/tmp TRAVIS=$TRAVIS TRAVIS_COMMIT=$TRAVIS_COMMIT TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG TRAVIS_BRANCH=$TRAVIS_BRANCH USE_CONAN=$USE_CONAN
# execute test # execute test
"$curdir/docker_tool.py" exec -n openrw_builder -U travis -- /bin/bash -c "ctest -VV -S /src/cmake/ctest/script_ci.ctest -VV" "$curdir/docker_tool.py" exec -n openrw_builder -U travis -- /bin/bash -c "ctest -VV -S /src/cmake/ctest/script_ci.ctest -VV"