Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
cac6f188e3 | |||
d15c58ef2e | |||
753089aec8 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -75,3 +75,4 @@ install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
CMakeUserPresets.json
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
|
||||
# CMake requirement and general configuration
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_policy(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
cmake_policy(VERSION 3.15)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
|
||||
if(DEFINED ENV{MS_COMPATIBLE})
|
||||
set(CMAKE_GNUtoMS ON) # Enable compatibility level to exported libraries
|
||||
@ -24,7 +24,6 @@ else() # Standalone project mode, should not be used for release.
|
||||
set(RSE_TERRAIN_NAME RSETerrain)
|
||||
endif()
|
||||
set(RSP_TERRAIN_LIB_NAME RSPTerrain${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR})
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
|
||||
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
|
||||
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
|
||||
|
13
Jenkinsfile
vendored
13
Jenkinsfile
vendored
@ -12,7 +12,6 @@ pipeline {
|
||||
stage('Prepare') {
|
||||
steps {
|
||||
cleanWs()
|
||||
rtConanClient(id: "conan", userHome: "/home/jackcartersmith")
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
@ -22,20 +21,16 @@ pipeline {
|
||||
dir("linux") {
|
||||
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Terrain'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Terrain.git']]])
|
||||
sh 'git submodule update --init --recursive'
|
||||
dir("build") {
|
||||
rtConanRun(clientId: "conan", command: "install .. -pr:b=default -pr:h=default --build=missing")
|
||||
}
|
||||
cmakeBuild buildDir: 'build', installation: 'latest', steps: [[args: 'all']]
|
||||
sh 'conan install . -of build -s build_type=Release -o "&:tools=True" -pr:b=default -pr:h=default --build=missing'
|
||||
cmakeBuild buildDir: 'build', cmakeArgs: '-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DRSPTERRAIN_SHARED=ON -DRSPTERRAIN_STATIC=OFF -DBUILD_TOOLS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release', installation: 'latest', steps: [[args: 'all']]
|
||||
}
|
||||
},
|
||||
windows: {
|
||||
dir("windows") {
|
||||
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Terrain'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Terrain.git']]])
|
||||
sh 'git submodule update --init --recursive'
|
||||
dir("build") {
|
||||
rtConanRun(clientId: "conan", command: "install .. -pr:b=default -pr:h=windows --build=missing")
|
||||
}
|
||||
cmakeBuild buildDir: 'build', cmakeArgs: '-DGNU_HOST=x86_64-w64-mingw32 -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw_cross_toolchain.cmake', installation: 'latest', steps: [[args: 'all']]
|
||||
sh 'conan install . -of build -s build_type=Release -o "&:tools=True" -pr:b=default -pr:h=windows --build=missing'
|
||||
cmakeBuild buildDir: 'build', cmakeArgs: '-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DRSPTERRAIN_SHARED=ON -DRSPTERRAIN_STATIC=OFF -DBUILD_TOOLS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres', installation: 'latest', steps: [[args: 'all']]
|
||||
}
|
||||
}
|
||||
)
|
||||
|
47
README.md
47
README.md
@ -43,46 +43,33 @@ Due to issue with copyrights, I can't provide samples... You need to extract HOB
|
||||
|
||||
### Dependencies
|
||||
|
||||
- libpng (1.6.37)
|
||||
- obj-lib: as obj file exporter. (https://git.jcsmith.fr/jackcartersmith/obj)
|
||||
- [zlib](https://www.zlib.net/) (1.3.1)
|
||||
- [libpng](http://www.libpng.org/pub/png/libpng.html) (1.6.43)
|
||||
- [obj-lib](https://git.jcsmith.fr/jackcartersmith/obj "obj file exporter")
|
||||
|
||||
### Compiling
|
||||
|
||||
You can compile on both Windows (MinGW) or native Linux system thanks to CMake, you only need to adjust your dependencies on Windows or use Conan packages manager (https://conan.io).
|
||||
You can compile on both Windows (MinGW) or native Linux environment thanks to CMake, you only need to adjust your dependencies on Windows or use Conan packages manager (https://conan.io).
|
||||
libpng16-dev distrib package can be used on debian/ubuntu.
|
||||
|
||||
To compile, just clone (**don't forget git submodules**) and launch cmake:
|
||||
|
||||
|
||||
### Compiling
|
||||
|
||||
I've a preference for compiling libraries by hand, mainly for backward compatibility, but I recommend using Conan packages manager (https://conan.io) for simplicity. (**Don't forget git submodules**)
|
||||
|
||||
```shell
|
||||
cmake .
|
||||
make
|
||||
make install
|
||||
conan install . -of build -b missing -s build_type=Release -o tools=True -pr:b=default -pr:h=default
|
||||
cmake --preset conan-release -G "Unix Makefiles"
|
||||
cmake --build --preset conan-release
|
||||
```
|
||||
|
||||
On Windows system, I can suggest you to use Conan support to help you with dependencies:
|
||||
On Windows environment, you can use MinGW `-G "MinGW Makefiles"` or Ninja `-G "Ninja"` as CMake generator.
|
||||
|
||||
```shell
|
||||
mkdir build
|
||||
cd build
|
||||
conan install .. --build=missing
|
||||
cmake .. -G "MinGW Makefiles"
|
||||
make
|
||||
```
|
||||
### Compiling (HARDCORE)
|
||||
|
||||
If you want to do it manually without Conan support, you will probably need to specify the dependency flags for CMake. Ex:
|
||||
If you want to do it manually without Conan, you will probably need to specify the dependency flags for CMake. Ex:
|
||||
|
||||
`cmake.exe -D"ZLIB_INCLUDE_DIR=zlib/1.2.11/include" -D"ZLIB_LIBRARY=zlib/1.2.11/lib/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=libpng/1.6.37/include" -D"PNG_LIBRARY=libpng/1.6.37/lib/libpng.dll.a" . -G "MinGW Makefiles"`
|
||||
`cmake.exe -D"ZLIB_INCLUDE_DIR=zlib/1.3.1/include" -D"ZLIB_LIBRARY=zlib/1.3.1/lib/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=libpng/1.6.43/include" -D"PNG_LIBRARY=libpng/1.6.43/lib/libpng.dll.a" . -G "MinGW Makefiles"`
|
||||
|
||||
We can also use cross-compilation (after installing `mingw64` and `cmake` packages on your distrib):
|
||||
|
||||
```shell
|
||||
mkdir build && cd build
|
||||
cmake -DGNU_HOST=x86_64-w64-mingw32 \
|
||||
-DCMAKE_TOOLCHAIN_FILE=../cmake/mingw_cross_toolchain.cmake \
|
||||
-D"ZLIB_INCLUDE_DIR=zlib/1.2.11/include" \
|
||||
-D"ZLIB_LIBRARY=zlib/1.2.11/lib/libzlib.dll.a" \
|
||||
-D"PNG_PNG_INCLUDE_DIR=libpng/1.6.37/include" \
|
||||
-D"PNG_LIBRARY=libpng/1.6.37/lib/libpng.dll.a" \
|
||||
..
|
||||
cmake --build .
|
||||
```
|
||||
I've tested cross-compilation too, but since I want to check that Conan is working properly at each release, I've integrated it into the Jenkins flow using Conan for the cross-abstraction.
|
||||
|
@ -12,7 +12,7 @@ include(CheckCSourceCompiles)
|
||||
|
||||
if(BUILD_TOOLS)
|
||||
# Import needed packages and references their include path
|
||||
find_package(PNG 1.6.37 REQUIRED)
|
||||
find_package(PNG 1.6.40 REQUIRED)
|
||||
include_directories(${PNG_INCLUDE_DIR})
|
||||
find_package(GLEW REQUIRED)
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
@ -44,9 +44,13 @@ if(BUILD_TOOLS)
|
||||
endif()
|
||||
|
||||
# Link externals libraries to the linker
|
||||
if(RSPTERRAIN_SHARED)
|
||||
target_link_libraries(rse-terrain PRIVATE rsp-terrain-lib ${PNG_LIBRARIES} ${GLEW_LIBRARIES} ${AUX_LIBS})
|
||||
elseif(RSPTERRAIN_STATIC)
|
||||
target_link_libraries(rse-terrain PRIVATE rsp-terrain-libstatic ${PNG_LIBRARIES} ${GLEW_LIBRARIES} ${AUX_LIBS})
|
||||
if (TARGET GLEW::GLEW)
|
||||
if (TARGET PNG::PNG)
|
||||
if(RSPTERRAIN_SHARED)
|
||||
target_link_libraries(rse-terrain PRIVATE rsp-terrain-lib PNG::PNG GLEW::GLEW ${AUX_LIBS})
|
||||
elseif(RSPTERRAIN_STATIC)
|
||||
target_link_libraries(rse-terrain PRIVATE rsp-terrain-libstatic PNG::PNG GLEW::GLEW ${AUX_LIBS})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
@ -1,8 +0,0 @@
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
IF("${GNU_HOST}" STREQUAL "")
|
||||
SET(GNU_HOST i586-mingw32msvc)
|
||||
ENDIF()
|
||||
# Prefix detection only works with compiler id "GNU"
|
||||
SET(CMAKE_C_COMPILER ${GNU_HOST}-gcc)
|
||||
# CMake doesn't automatically look for prefixed 'windres', do it manually:
|
||||
SET(CMAKE_RC_COMPILER ${GNU_HOST}-windres)
|
129
conanfile.py
Normal file
129
conanfile.py
Normal file
@ -0,0 +1,129 @@
|
||||
import os
|
||||
from conan import ConanFile
|
||||
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake
|
||||
from conan.tools.files import copy
|
||||
from conan.tools.scm import Git, Version
|
||||
|
||||
required_conan_version = ">=2.3"
|
||||
|
||||
class rse_terrain(ConanFile):
|
||||
name = "rspterrainlib"
|
||||
package_type = "library"
|
||||
version = "2.1.0"
|
||||
revision_mode = "scm"
|
||||
license = "GPL-3.0"
|
||||
author = "JackCarterSmith <jackcartersmith@jcsmith.fr>"
|
||||
url = "https://git.jcsmith.fr/JCS-Prod/RSE-Terrain"
|
||||
description = "Rogue Squadron 3D (PC) game terrain files (hmp) extractor"
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
generators = "CMakeDeps"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"tools": [True, False],
|
||||
"fPIC": [True, False]
|
||||
}
|
||||
|
||||
default_options = {
|
||||
"shared": True,
|
||||
"tools": False,
|
||||
"fPIC": True
|
||||
}
|
||||
|
||||
@property
|
||||
def _is_msvc(self):
|
||||
return str(self.settings.compiler) in ["Visual Studio", "msvc"]
|
||||
|
||||
#def validate(self):
|
||||
# if self.settings.os == "Macos":
|
||||
# raise ConanInvalidConfiguration("MacOS not supported")
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
|
||||
def configure(self):
|
||||
self.options["libpng"].shared = True
|
||||
self.options["libpng"].sse = True
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
|
||||
def requirements(self):
|
||||
if self.options.tools:
|
||||
self.requires("glew/2.2.0")
|
||||
self.requires("zlib/1.3.1")
|
||||
self.requires("libpng/1.6.43")
|
||||
|
||||
def source(self):
|
||||
git = Git(self)
|
||||
cargs = ['--single-branch', '--recursive', '--depth', '1', '--branch', 'v' + self.version]
|
||||
git.clone(url="https://git.jcsmith.fr/JCS-Prod/RSE-Terrain.git", target=".", args=cargs)
|
||||
|
||||
# def _patch(self):
|
||||
# replace_in_file(self, os.path.join(self.source_folder, "RSPTerrainLib", "CMakeLists.txt"),
|
||||
# 'set_target_properties(rsp-texture-libstatic PROPERTIES OUTPUT_NAME "${RSP_TEXTURE_LIB_NAME}_static")',
|
||||
# 'set_target_properties(rsp-texture-libstatic PROPERTIES OUTPUT_NAME "${RSP_TEXTURE_LIB_NAME}")')
|
||||
|
||||
def export_sources(self):
|
||||
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
|
||||
|
||||
# def layout(self):
|
||||
# cmake_layout(self, src_folder='.', build_folder='build')
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.cache_variables["RSPTERRAIN_SHARED"] = self.options.shared
|
||||
tc.cache_variables["RSPTERRAIN_STATIC"] = not self.options.shared
|
||||
tc.cache_variables["BUILD_TOOLS"] = self.options.tools
|
||||
#tc.cache_variables["BUILD_DEBUG"] = self.settings.build_type == "Debug"
|
||||
tc.generate()
|
||||
|
||||
#cmdeps = CMakeDeps(self)
|
||||
#cmpdeps.set_property("zlib", "cmake_find_mode", "both")
|
||||
#cmpdeps.set_property("libpng", "cmake_find_mode", "both")
|
||||
#if self.options.shared:
|
||||
#cmdeps.configuration = "ReleaseShared"
|
||||
#cmdeps.generate()
|
||||
|
||||
for dep in self.dependencies.values():
|
||||
if len(dep.cpp_info.bindirs) > 0:
|
||||
if self.settings.os == "Windows":
|
||||
if self._is_msvc:
|
||||
copy(self, "*.dll", dep.cpp_info.bindirs[0], os.path.join(self.build_folder, "bin", str(self.settings.build_type)))
|
||||
else:
|
||||
copy(self, "*.dll", dep.cpp_info.bindirs[0], os.path.join(self.build_folder, "bin"))
|
||||
else:
|
||||
copy(self, "*.so", dep.cpp_info.bindirs[0], os.path.join(self.build_folder, "bin"))
|
||||
|
||||
def build(self):
|
||||
cmbuilder = CMake(self)
|
||||
#self._patch()
|
||||
cmbuilder.configure()
|
||||
cmbuilder.build()
|
||||
|
||||
def package(self):
|
||||
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
|
||||
copy(self, pattern="*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include"))
|
||||
copy(self, pattern="*.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
|
||||
copy(self, pattern="*.so", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
|
||||
copy(self, pattern="*.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
|
||||
copy(self, pattern="*.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_file_name", "RSETerrain")
|
||||
self.cpp_info.set_property("cmake_target_name", "RSETerrain")
|
||||
self.cpp_info.set_property("cmake_module_target_name", "RSETerrain::RSETerrain")
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
|
||||
self.cpp_info.names["cmake_find_package"] = "RSETerrain"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "RSETerrain"
|
||||
|
||||
self.cpp_info.includedirs = ["include"]
|
||||
|
||||
prefix = "lib" if self._is_msvc else ""
|
||||
#suffix = "d" if self.settings.build_type == "Debug" else ""
|
||||
suffix = ""
|
||||
major_min_version = f"{Version(self.version).major}{Version(self.version).minor}"
|
||||
|
||||
self.cpp_info.libs = ["{}RSETerrain{}{}".format(prefix, major_min_version, suffix)]
|
||||
if self.settings.os in ["Linux", "Android", "FreeBSD", "SunOS", "AIX"]:
|
||||
self.cpp_info.system_libs.append("m")
|
@ -1,15 +0,0 @@
|
||||
[requires]
|
||||
zlib/1.2.12
|
||||
libpng/1.6.37
|
||||
glew/2.2.0
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
cmake_find_package
|
||||
|
||||
[options]
|
||||
libpng:shared=True
|
||||
glew:shared=True
|
||||
|
||||
[imports]
|
||||
bin, *.dll -> ./bin
|
Loading…
x
Reference in New Issue
Block a user