mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-21 18:02:43 +01:00
cmake: add ability to compile using conan package manager
This commit is contained in:
parent
1839b9c29d
commit
7d2da28dbc
@ -4,21 +4,20 @@ image:
|
||||
clone_depth: 1
|
||||
shallow_clone: false
|
||||
|
||||
# All paths in the environment section should be
|
||||
# cmake-style paths: using forward-slashes (/).
|
||||
cache:
|
||||
- C:\Users\appveyor\.conan -> conanfile.py
|
||||
- C:\.conan -> conanfile.py
|
||||
|
||||
environment:
|
||||
APPVEYOR_SAVE_CACHE_ON_ERROR: true
|
||||
PYTHON: "C:\\Python36-x64"
|
||||
CMAKE_GENERATOR: "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"
|
||||
CMAKE_GENERATOR_BASE: "Visual Studio 15 2017"
|
||||
NAME_SUFFIX: "windows"
|
||||
USE_CONAN: 1
|
||||
|
||||
platform:
|
||||
- Win32
|
||||
# - x64
|
||||
# - Win32
|
||||
- x64
|
||||
|
||||
configuration:
|
||||
# - Debug
|
||||
@ -27,17 +26,19 @@ configuration:
|
||||
matrix:
|
||||
fast_finish: false
|
||||
|
||||
cache:
|
||||
- C:\dependencies -> .appveyor.yml, cmake/ctest/script_ci.ctest, cmake/ctest/utils.ctest, , cmake/ctest/configure_windows.ctest
|
||||
clone_folder: C:\projects\openrw
|
||||
|
||||
init:
|
||||
- set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%
|
||||
- python --version
|
||||
- cmake --version
|
||||
- msbuild /version
|
||||
- pip3 install conan
|
||||
- conan user
|
||||
- conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
|
||||
|
||||
build_script:
|
||||
- ctest -VV -S cmake/ctest/script_ci.ctest
|
||||
- ctest -VV -S "%APPVEYOR_BUILD_FOLDER%/cmake/ctest/script_ci.ctest"
|
||||
|
||||
after_build:
|
||||
- cd "%APPVEYOR_BUILD_FOLDER%\build"
|
||||
|
@ -20,6 +20,10 @@ matrix:
|
||||
services: docker
|
||||
script:
|
||||
- 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
|
||||
env: NAME="Apple macOS" NAME_SUFFIX="mac"
|
||||
osx_image: xcode9.2
|
||||
|
@ -7,7 +7,7 @@ include(GNUInstallDirs)
|
||||
# Read the configuration arguments
|
||||
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(GetGitRevisionDescription)
|
||||
@ -15,31 +15,45 @@ get_git_head_revision(GIT_REFSPEC GIT_SHA1)
|
||||
message(STATUS "Building ${CMAKE_PROJECT_NAME} GIT SHA1: ${GIT_SHA1}")
|
||||
|
||||
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)
|
||||
find_package(Boost COMPONENTS program_options system REQUIRED)
|
||||
if(FILESYSTEM_LIBRARY STREQUAL "BOOST")
|
||||
find_package(Boost COMPONENTS filesystem system REQUIRED)
|
||||
endif()
|
||||
if(BUILD_TESTS)
|
||||
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
|
||||
rwdep_wrap_conan_targets()
|
||||
else()
|
||||
find_package(Boost REQUIRED)
|
||||
find_package(Boost COMPONENTS program_options system REQUIRED)
|
||||
if(FILESYSTEM_LIBRARY STREQUAL "BOOST")
|
||||
find_package(Boost COMPONENTS filesystem system REQUIRED)
|
||||
endif()
|
||||
if(BUILD_TESTS)
|
||||
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()
|
||||
|
||||
if(CHECK_INCLUDES)
|
||||
find_package(IncludeWhatYouUse REQUIRED)
|
||||
endif()
|
||||
|
||||
# Do not link to SDL2main library
|
||||
set(SDL2_BUILDING_LIBRARY True)
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
|
||||
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)
|
||||
find_package(ClangTidy REQUIRED)
|
||||
|
@ -1,13 +1,11 @@
|
||||
# This file does:
|
||||
# - check whether all arguments are defined,
|
||||
# - clean the build directory,
|
||||
# - configure, build and test,
|
||||
# - coverage and memcheck,
|
||||
# - submit
|
||||
|
||||
set(_ARGS_BOOL
|
||||
EMPTY_BINARY_DIR
|
||||
|
||||
USE_CONAN
|
||||
DEBUG
|
||||
CHECK_INCLUDES
|
||||
BUILD_VIEWER
|
||||
@ -32,6 +30,9 @@ set(_ARGS_ONEVAL
|
||||
BUILDER_NAME
|
||||
BUILD_NAME
|
||||
|
||||
CONAN_ARCH
|
||||
CONAN_PROFILE
|
||||
|
||||
CMAKE_GENERATOR
|
||||
COVERAGE_COMMAND
|
||||
)
|
||||
@ -55,17 +56,6 @@ set(CTEST_COVERAGE_COMMAND "${COVERAGE_COMMAND}")
|
||||
set(CTEST_SITE "${BUILDER_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_CONFIGURE_EXTRA_ARGS)
|
||||
if(APPEND_RESULTS)
|
||||
@ -76,6 +66,70 @@ endif()
|
||||
message(STATUS "Starting test...")
|
||||
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)
|
||||
if(DEBUG)
|
||||
set(_CMAKE_BUILD_TYPE "Debug")
|
||||
@ -96,6 +150,7 @@ set(_CONFIGURE_OPTIONS
|
||||
"-DCHECK_INCLUDES=${CHECK_INCLUDES}"
|
||||
"-DCMAKE_BUILD_TYPE=${_CMAKE_BUILD_TYPE}"
|
||||
"-DENABLE_SANITIZERS=${ENABLE_SANITIZERS}"
|
||||
"-DUSE_CONAN=${USE_CONAN}"
|
||||
)
|
||||
|
||||
message(STATUS "Configuring...")
|
||||
@ -113,7 +168,6 @@ message(STATUS "Building...")
|
||||
ctest_build(
|
||||
CONFIGURATION "${_CTEST_BUILD_CONFIGURATION}"
|
||||
NUMBER_ERRORS _NB_BUILD_ERRORS
|
||||
NUMBER_WARNINGS _NB_BUILD_WARNINGS
|
||||
)
|
||||
|
||||
if(RUN_TESTS)
|
||||
|
@ -11,3 +11,6 @@ if(MODEL_NAME STREQUAL "EXPERIMENTAL")
|
||||
else()
|
||||
set(CHECK_INCLUDES FALSE)
|
||||
endif()
|
||||
|
||||
set(CONAN_ARCH "x86_64")
|
||||
set(CONAN_PROFILE "${CTEST_SOURCE_DIRECTORY}/scripts/conan/darwin")
|
||||
|
@ -11,3 +11,6 @@ if(MODEL_NAME STREQUAL "EXPERIMENTAL")
|
||||
else()
|
||||
set(CHECK_INCLUDES FALSE)
|
||||
endif()
|
||||
|
||||
set(CONAN_ARCH "x86_64")
|
||||
set(CONAN_PROFILE "${CTEST_SOURCE_DIRECTORY}/scripts/conan/linux")
|
||||
|
@ -1,12 +1,7 @@
|
||||
set(_WIN_NEEDED_VARS
|
||||
BOOST_ROOT
|
||||
BOOST_VERSION
|
||||
CMAKE_GENERATOR
|
||||
CONFIGURATION
|
||||
DEP_DIR
|
||||
CMAKE_GENERATOR_BASE
|
||||
PLATFORM
|
||||
WIN_DEP_NAME
|
||||
WIN_DEP_URL
|
||||
CONFIGURATION
|
||||
)
|
||||
foreach(_WIN_NEEDED_VAR ${_WIN_NEEDED_VARS})
|
||||
set("${_WIN_NEEDED_VAR}" "$ENV{${_WIN_NEEDED_VAR}}")
|
||||
@ -16,90 +11,31 @@ foreach(_WIN_NEEDED_VAR ${_WIN_NEEDED_VARS})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
string(REPLACE "." "_" _BOOST_VERSION_UNDERSCORED "${BOOST_VERSION}")
|
||||
set(BOOST_ROOT "${BOOST_ROOT}\\boost_${_BOOST_VERSION_UNDERSCORED}")
|
||||
|
||||
string(TOLOWER "${PLATFORM}" PLATFORM)
|
||||
string(TOLOWER "${ARCH}" ARCH)
|
||||
if(PLATFORM STREQUAL "win32")
|
||||
set(CMAKE_GENERATOR "${CMAKE_GENERATOR}")
|
||||
set(TRIPLET "x86-windows-static")
|
||||
set(CMAKE_GENERATOR "${CMAKE_GENERATOR_BASE}")
|
||||
set(CONAN_ARCH "x86")
|
||||
elseif(PLATFORM STREQUAL "x64")
|
||||
set(CMAKE_GENERATOR "${CMAKE_GENERATOR} Win64")
|
||||
set(TRIPLET "x64-windows-static")
|
||||
set(CMAKE_GENERATOR "${CMAKE_GENERATOR_BASE} Win64")
|
||||
set(CONAN_ARCH "x86_64")
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown platform (${PLATFORM})")
|
||||
endif()
|
||||
|
||||
string(TOLOWER "${CONFIGURATION}" CONFIGURATION)
|
||||
if(CONFIGURATION STREQUAL "debug")
|
||||
set(CONFIGURE_EXTRA_OPTIONS ";")
|
||||
|
||||
if(CONFIGURATION STREQUAL "Debug")
|
||||
set(DEBUG TRUE)
|
||||
set(_LIBRARY_DIR_INFIX "debug")
|
||||
elseif(CONFIGURATION STREQUAL "release")
|
||||
elseif(CONFIGURATION STREQUAL "Release")
|
||||
set(DEBUG FALSE)
|
||||
set(_LIBRARY_DIR_INFIX "")
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown configuration '${CONFIGURATION}'")
|
||||
endif()
|
||||
|
||||
file(MAKE_DIRECTORY "${DEP_DIR}")
|
||||
set(_WIN_DEP_DIR "${DEP_DIR}\\${WIN_DEP_NAME}")
|
||||
set(TRIPLET_DIR "${_WIN_DEP_DIR}\\${TRIPLET}")
|
||||
set(CONAN_PROFILE "${CTEST_SOURCE_DIRECTORY}/scripts/conan/windows")
|
||||
set(CONAN_ARCH "x86_64")
|
||||
|
||||
message(STATUS "Checking windows dependency dir '${_WIN_DEP_DIR}'...")
|
||||
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(BUILD_VIEWER TRUE)
|
||||
set(COVERAGE_COMMAND "echo") #FIXME: ENABLE
|
||||
set(CHECK_INCLUDES FALSE) #FIXME: ENABLE
|
||||
set(ENABLE_SANITIZERS "")
|
||||
|
@ -12,9 +12,19 @@ else()
|
||||
endif()
|
||||
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)
|
||||
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")
|
||||
message(STATUS "Linux detected")
|
||||
|
||||
@ -34,6 +44,12 @@ endif()
|
||||
set(WARNING_MESSAGES)
|
||||
set(ERROR_MESSAGES)
|
||||
|
||||
if($ENV{USE_CONAN})
|
||||
set(USE_CONAN TRUE)
|
||||
else()
|
||||
set(USE_CONAN FALSE)
|
||||
endif()
|
||||
|
||||
set(SEPARATE_TEST_SUITES FALSE)
|
||||
set(RUN_COVERAGE FALSE)
|
||||
set(RUN_MEMCHECK FALSE)
|
||||
@ -42,7 +58,6 @@ openrw_should_submit_ci(SUBMIT)
|
||||
# Build with no data and test
|
||||
set(BUILDER_NAME "${BUILDER_NAME_BASE}-nodata")
|
||||
set(APPEND_RESULTS FALSE)
|
||||
set(EMPTY_BINARY_DIR TRUE)
|
||||
set(TESTS_NODATA TRUE)
|
||||
set(RUN_TESTS TRUE)
|
||||
|
||||
@ -51,7 +66,6 @@ include("${CTEST_SCRIPT_DIRECTORY}/build.ctest")
|
||||
# Build with data and do not test
|
||||
set(BUILDER_NAME "${BUILDER_NAME_BASE}-data")
|
||||
set(APPEND_RESULTS FALSE)
|
||||
set(EMPTY_BINARY_DIR FALSE)
|
||||
set(TESTS_NODATA FALSE)
|
||||
set(RUN_TESTS FALSE)
|
||||
|
||||
|
@ -12,8 +12,18 @@ else()
|
||||
endif()
|
||||
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)
|
||||
|
||||
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")
|
||||
message(STATUS "Linux detected")
|
||||
|
||||
@ -33,6 +43,12 @@ endif()
|
||||
set(WARNING_MESSAGES)
|
||||
set(ERROR_MESSAGES)
|
||||
|
||||
if($ENV{USE_CONAN})
|
||||
set(USE_CONAN TRUE)
|
||||
else()
|
||||
set(USE_CONAN FALSE)
|
||||
endif()
|
||||
|
||||
set(SEPARATE_TEST_SUITES TRUE)
|
||||
|
||||
if($ENV{RUN_COVERAGE})
|
||||
@ -49,7 +65,6 @@ else()
|
||||
set(RES FALSE)
|
||||
endif()
|
||||
|
||||
set(EMPTY_BINARY_DIR TRUE)
|
||||
set(TESTS_NODATA FALSE)
|
||||
set(RUN_TESTS TRUE)
|
||||
|
||||
|
@ -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}")
|
||||
endif()
|
||||
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()
|
||||
|
@ -64,6 +64,14 @@ else()
|
||||
message(FATAL_ERROR "Unknown platform \"${CMAKE_SYSTEM_NAME}\". please update CMakeLists.txt.")
|
||||
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")
|
||||
target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=0")
|
||||
elseif(FILESYSTEM_LIBRARY STREQUAL "CXXTS")
|
||||
|
@ -27,5 +27,6 @@ set(ENABLE_SANITIZERS "" CACHE STRING "Enable selected sanitizer.")
|
||||
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(BOOST_STATIC "Link against static Boost libraries")
|
||||
|
||||
option(USE_CONAN "Use Conan as packet manager")
|
||||
|
82
conanfile.py
Normal file
82
conanfile.py
Normal 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
|
@ -27,9 +27,10 @@ add_executable(rwviewer WIN32
|
||||
)
|
||||
|
||||
target_link_libraries(rwviewer
|
||||
rwengine
|
||||
Qt5::OpenGL
|
||||
Qt5::Widgets
|
||||
PRIVATE
|
||||
rwengine
|
||||
Qt5::OpenGL
|
||||
Qt5::Widgets
|
||||
)
|
||||
|
||||
openrw_target_apply_options(TARGET rwviewer)
|
||||
@ -37,3 +38,8 @@ openrw_target_apply_options(TARGET rwviewer)
|
||||
install(TARGETS rwviewer
|
||||
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
2
rwviewer/qt.conf.in
Normal file
@ -0,0 +1,2 @@
|
||||
[Paths]
|
||||
Prefix = @QT5_ROOT@
|
8
scripts/conan/darwin
Normal file
8
scripts/conan/darwin
Normal 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
11
scripts/conan/linux
Normal 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
5
scripts/conan/windows
Normal file
@ -0,0 +1,5 @@
|
||||
include(default)
|
||||
|
||||
[options]
|
||||
openrw:viewer=True
|
||||
ffmpeg:qsv=False
|
66
scripts/docker/conan_base.docker
Normal file
66
scripts/docker/conan_base.docker
Normal 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 ]
|
@ -8,7 +8,7 @@ docker=$1
|
||||
"$curdir/docker_tool.py" build -d "$docker" -t openrw_build_image
|
||||
|
||||
# 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
|
||||
"$curdir/docker_tool.py" exec -n openrw_builder -U travis -- /bin/bash -c "ctest -VV -S /src/cmake/ctest/script_ci.ctest -VV"
|
||||
|
Loading…
Reference in New Issue
Block a user