mirror of https://github.com/aap/librw.git
Merge branch 'master' of github.com:aap/librw
This commit is contained in:
commit
857526df46
|
@ -0,0 +1,46 @@
|
|||
name: Build using conan
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
release:
|
||||
types: published
|
||||
jobs:
|
||||
build-cmake:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
||||
platform: ['null', 'gl3', 'd3d9', 'ps2']
|
||||
exclude:
|
||||
- os: windows-latest
|
||||
platform: ps2
|
||||
- os: ubuntu-latest
|
||||
platform: d3d9
|
||||
- os: ubuntu-latest
|
||||
platform: ps2 # FIXME: add ps2toolchain conan package + ps2 profile
|
||||
- os: macos-latest
|
||||
platform: d3d9
|
||||
- os: macos-latest
|
||||
platform: ps2
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: "Setup conan"
|
||||
run: |
|
||||
python -m pip install conan
|
||||
conan user
|
||||
conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
|
||||
conan config set log.print_run_commands=True
|
||||
- name: "conan install (download/build dependencies)"
|
||||
run: |
|
||||
conan install ${{ github.workspace }} -if build -o platform=${{ matrix.platform }} --build missing
|
||||
env:
|
||||
CONAN_SYSREQUIRES_MODE: enabled
|
||||
- name: "conan build (build librw)"
|
||||
run: |
|
||||
conan build ${{ github.workspace }} -if build -bf build -pf package
|
||||
- name: "conan package (package librw)"
|
||||
run: |
|
||||
conan package ${{ github.workspace }} -if build -bf build -pf package
|
|
@ -1,15 +0,0 @@
|
|||
set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A (partial) re-implementation of RenderWare Graphics")
|
||||
set(CPACK_PACKAGE_VENDOR "librw")
|
||||
|
||||
# FIXME: better description of the project
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
|
||||
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
|
||||
|
||||
# set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeCPackOptions.cmake")
|
||||
|
||||
include(CPack)
|
|
@ -1,7 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.8)
|
||||
|
||||
project(librw C CXX)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
if(PS2DEV AND EE)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/cmake/ee.cmake")
|
||||
endif()
|
||||
|
@ -19,6 +20,16 @@ if(NOT LIBRW_PLATFORM IN_LIST LIBRW_PLATFORMS)
|
|||
message(FATAL_ERROR "Illegal LIBRW_PLATFORM=${LIBRW_PLATFORM}")
|
||||
endif()
|
||||
|
||||
set(LIBRW_GL3_GFXLIBS "GLFW" "SDL2")
|
||||
set(LIBRW_GL3_GFXLIB "GLFW" CACHE STRING "gfxlib for gl3")
|
||||
set_property(CACHE LIBRW_GL3_GFXLIB PROPERTY STRINGS ${LIBRW_GL3_GFXLIBS})
|
||||
if(LIBRW_PLATFORM_GL3)
|
||||
message(STATUS "LIBRW_GL3_GFXLIB = ${LIBRW_GL3_GFXLIB} (choices=${LIBRW_GL3_GFXLIBS})")
|
||||
endif()
|
||||
if(NOT LIBRW_GL3_GFXLIB IN_LIST LIBRW_GL3_GFXLIBS)
|
||||
message(FATAL_ERROR "Illegal LIBRW_GL3_GFXLIB=${LIBRW_GL3_GFXLIB}")
|
||||
endif()
|
||||
|
||||
if(LIBRW_PLATFORM_PS2)
|
||||
enable_language(DSM)
|
||||
endif()
|
||||
|
@ -41,7 +52,7 @@ endif()
|
|||
|
||||
if(LIBRW_INSTALL)
|
||||
include(CMakePackageConfigHelpers)
|
||||
configure_package_config_file(librw-config.cmake.in librw-config.cmake
|
||||
configure_package_config_file(cmake/librw-config.cmake.in librw-config.cmake
|
||||
INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}"
|
||||
)
|
||||
install(
|
||||
|
@ -49,9 +60,16 @@ if(LIBRW_INSTALL)
|
|||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||
)
|
||||
install(
|
||||
EXPORT librw-targets
|
||||
EXPORT librw-targets NAMESPACE librw::
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||
)
|
||||
|
||||
include(CMakeCPack.cmake)
|
||||
set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A (partial) re-implementation of RenderWare Graphics")
|
||||
set(CPACK_PACKAGE_VENDOR "aap")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
|
||||
include(CPack)
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(SDL2 IMPORTED_TARGET "sdl2")
|
||||
if(TARGET PkgConfig::SDL2 AND NOT TARGET sdl2::sdl2)
|
||||
add_library(_sdl2 INTERFACE)
|
||||
target_link_libraries(_sdl2 INTERFACE PkgConfig::SDL2)
|
||||
add_library(SDL2::SDL2 ALIAS _sdl2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT SDL2_FOUND)
|
||||
find_path(SDL2_INCLUDE_DIR sdl2.h)
|
||||
find_library(SDL2_LIBRARY sdl2)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(libuv
|
||||
REQUIRED_VARS SDL2_INCLUDE_DIR SDL2_LIBRARY
|
||||
)
|
||||
|
||||
if(NOT TARGET SDL2::SDL2)
|
||||
add_library(SDL2::SDL2 UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::SDL2 PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
|
@ -0,0 +1,19 @@
|
|||
include("${CMAKE_CURRENT_LIST_DIR}/librw-targets.cmake")
|
||||
|
||||
set(LIBRW_PLATFORM "@LIBRW_PLATFORM@")
|
||||
set(LIBRW_PLATFORMS "@LIBRW_PLATFORMS@")
|
||||
set(LIBRW_PLATFORM_@LIBRW_PLATFORM@ ON)
|
||||
|
||||
if(LIBRW_PLATFORM_GL3)
|
||||
set(LIBRW_GL3_GFXLIB "@LIBRW_GL3_GFXLIB@")
|
||||
set(LIBRW_GL3_GFXLIBS "@LIBRW_GL3_GFXLIBS@")
|
||||
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
find_package(OpenGL REQUIRED)
|
||||
if(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
|
||||
find_package(GLEW REQUIRED)
|
||||
find_package(glfw3 REQUIRED)
|
||||
elseif(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
|
||||
find_package(SDL2 REQUIRED)
|
||||
endif()
|
||||
endif()
|
|
@ -0,0 +1,111 @@
|
|||
from conans import ConanFile, CMake, tools
|
||||
from conans.errors import ConanInvalidConfiguration
|
||||
import os
|
||||
import shutil
|
||||
import textwrap
|
||||
|
||||
|
||||
class LibrwConan(ConanFile):
|
||||
name = "librw"
|
||||
version = "master"
|
||||
license = "MIT"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "cmake", "cmake_find_package"
|
||||
options = {
|
||||
"platform": ["null", "gl3", "d3d9", "ps2"],
|
||||
"gl3_gfxlib": ["glfw", "sdl2"],
|
||||
}
|
||||
default_options = {
|
||||
"platform": "gl3",
|
||||
"gl3_gfxlib": "glfw",
|
||||
"sdl2:vulkan": False,
|
||||
"sdl2:opengl": True,
|
||||
"sdl2:sdl2main": False,
|
||||
}
|
||||
no_copy_source = True
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
self.options["sdl2"].directx = False
|
||||
|
||||
def configure(self):
|
||||
if self.options.platform != "gl3":
|
||||
del self.options.gl3_gfxlib
|
||||
if self.options.platform == "d3d9" and self.settings.os != "Windows":
|
||||
raise ConanInvalidConfiguration("d3d9 can only be built for Windows")
|
||||
|
||||
def requirements(self):
|
||||
if self.options.platform == "gl3":
|
||||
self.requires("glew/2.1.0")
|
||||
if self.options.gl3_gfxlib == "glfw":
|
||||
self.requires("glfw/3.3.2")
|
||||
elif self.options.gl3_gfxlib == "sdl2":
|
||||
self.requires("sdl2/2.0.12@bincrafters/stable")
|
||||
|
||||
def export_sources(self):
|
||||
for d in ("cmake", "skeleton", "src", "tools"):
|
||||
shutil.copytree(src=d, dst=os.path.join(self.export_sources_folder, d))
|
||||
self.copy("args.h")
|
||||
self.copy("rw.h")
|
||||
self.copy("CMakeLists.txt")
|
||||
self.copy("LICENSE")
|
||||
|
||||
@property
|
||||
def _librw_platform(self):
|
||||
return {
|
||||
"null": "NULL",
|
||||
"gl3": "GL3",
|
||||
"d3d9": "D3D9",
|
||||
"ps2": "PS2",
|
||||
}[str(self.options.platform)]
|
||||
|
||||
def build(self):
|
||||
if self.source_folder == self.build_folder:
|
||||
raise Exception("cannot build with source_folder == build_folder")
|
||||
tools.save("Findglfw3.cmake",
|
||||
textwrap.dedent(
|
||||
"""
|
||||
if(NOT TARGET glfw)
|
||||
message(STATUS "Creating glfw TARGET")
|
||||
add_library(glfw INTERFACE IMPORTED)
|
||||
set_target_properties(glfw PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES CONAN_PKG::glfw) #$<BUILD_INTERFACE:CONAN_PKG::glfw>)
|
||||
endif()
|
||||
"""), append=True)
|
||||
tools.save("CMakeLists.txt",
|
||||
textwrap.dedent(
|
||||
"""
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(cmake_wrapper)
|
||||
|
||||
include("{}/conanbuildinfo.cmake")
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
add_subdirectory("{}" librw)
|
||||
""").format(self.install_folder.replace("\\", "/"),
|
||||
self.source_folder.replace("\\", "/")))
|
||||
cmake = CMake(self)
|
||||
cmake.definitions["LIBRW_PLATFORM"] = self._librw_platform
|
||||
cmake.definitions["LIBRW_INSTALL"] = True
|
||||
if self.options.platform == "gl3":
|
||||
cmake.definitions["LIBRW_GL3_GFXLIB"] = str(self.options.gl3_gfxlib).upper()
|
||||
cmake.configure(source_folder=self.build_folder)
|
||||
cmake.build()
|
||||
|
||||
def package(self):
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.includedirs.append(os.path.join("include", "librw"))
|
||||
self.cpp_info.libs = ["librw"]
|
||||
if self.options.platform == "null":
|
||||
self.cpp_info.defines.append("RW_NULL")
|
||||
elif self.options.platform == "gl3":
|
||||
self.cpp_info.defines.append("RW_GL3")
|
||||
if self.options.gl3_gfxlib == "sdl2":
|
||||
self.cpp_info.defines.append("LIBRW_SDL2")
|
||||
elif self.options.platform == "d3d9":
|
||||
self.cpp_info.defines.append("RW_D3D9")
|
||||
elif self.options.platform == "ps2":
|
||||
self.cpp_info.defines.append("RW_PS2")
|
|
@ -1,12 +0,0 @@
|
|||
include("${CMAKE_CURRENT_LIST_DIR}/librw-targets.cmake")
|
||||
|
||||
set(LIBRW_PLATFORM "@LIBRW_PLATFORM@")
|
||||
set(LIBRW_PLATFORMS "@LIBRW_PLATFORMS@")
|
||||
set(LIBRW_PLATFORM_@LIBRW_PLATFORM@ ON)
|
||||
|
||||
if(LIBRW_PLATFORM_GL3)
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLEW REQUIRED)
|
||||
find_package(glfw3 REQUIRED)
|
||||
endif()
|
|
@ -1,5 +1,6 @@
|
|||
add_library(librw_skeleton
|
||||
glfw.cpp
|
||||
sdl2.cpp
|
||||
skeleton.cpp
|
||||
skeleton.h
|
||||
win.cpp
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
if(LIBRW_PLATFORM_GL3)
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLEW REQUIRED)
|
||||
find_package(glfw3 REQUIRED)
|
||||
endif()
|
||||
|
||||
add_library(librw
|
||||
"${PROJECT_SOURCE_DIR}/args.h"
|
||||
"${PROJECT_SOURCE_DIR}/rw.h"
|
||||
|
@ -99,6 +92,7 @@ add_library(librw
|
|||
ps2/rwps2impl.h
|
||||
ps2/rwps2plg.h
|
||||
)
|
||||
add_library(librw::librw ALIAS librw)
|
||||
|
||||
target_include_directories(librw
|
||||
INTERFACE
|
||||
|
@ -144,12 +138,33 @@ set_target_properties(librw
|
|||
)
|
||||
|
||||
if(LIBRW_PLATFORM_GL3)
|
||||
|
||||
|
||||
if(LIBRW_PLATFORM_GL3)
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLEW REQUIRED)
|
||||
|
||||
target_link_libraries(librw
|
||||
PUBLIC
|
||||
glfw
|
||||
GLEW::GLEW
|
||||
OpenGL::GL
|
||||
GLEW::GLEW
|
||||
)
|
||||
if (LIBRW_GL3_GFXLIB STREQUAL "GLFW")
|
||||
find_package(glfw3 REQUIRED)
|
||||
target_link_libraries(librw
|
||||
PUBLIC
|
||||
glfw
|
||||
)
|
||||
elseif (LIBRW_GL3_GFXLIB STREQUAL "SDL2")
|
||||
find_package(SDL2 REQUIRED)
|
||||
target_compile_definitions(librw PUBLIC LIBRW_SDL2)
|
||||
target_link_libraries(librw
|
||||
PUBLIC
|
||||
SDL2::SDL2
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
elseif(LIBRW_PLATFORM_D3D9)
|
||||
target_link_libraries(librw
|
||||
PUBLIC
|
||||
|
@ -174,6 +189,7 @@ if(LIBRW_INSTALL)
|
|||
FILES
|
||||
base.err
|
||||
rwbase.h
|
||||
rwcharset.h
|
||||
rwerror.h
|
||||
rwplg.h
|
||||
rwrender.h
|
||||
|
@ -203,6 +219,7 @@ if(LIBRW_INSTALL)
|
|||
FILES
|
||||
gl/rwwdgl.h
|
||||
gl/rwgl3.h
|
||||
gl/rwgl3plg.h
|
||||
gl/rwgl3shader.h
|
||||
DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/src/gl"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue