Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
19c544441b | |||
94d2cb6e56 | |||
42de1f7dad | |||
e03f3436a6 | |||
0c8282ab5d | |||
d302d7ebd5 |
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_TEXTURE_NAME RSETexture)
|
||||
endif()
|
||||
set(RSP_TEXTURE_LIB_NAME RSPTexture${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-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]])
|
||||
sh 'git submodule update --init --recursive'
|
||||
dir("build") {
|
||||
rtConanRun(clientId: "conan", command: "install .. --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 -DRSPTEXTURE_SHARED=ON -DRSPTEXTURE_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-Texture.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 -DRSPTEXTURE_SHARED=ON -DRSPTEXTURE_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']]
|
||||
}
|
||||
}
|
||||
)
|
||||
|
54
README.md
54
README.md
@ -44,45 +44,39 @@ Due to issue with copyrights, I can't provide samples... You need to extract HMT
|
||||
|
||||
Necessary libs (provided only in windows release) for running and for compiling.
|
||||
|
||||
- libpng (1.6.37)
|
||||
- [zlib](https://www.zlib.net/) (1.3.1)
|
||||
- [libpng](http://www.libpng.org/pub/png/libpng.html) (1.6.43)
|
||||
|
||||
### 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).
|
||||
libpng16-dev distrib package can be used on debian/ubuntu.
|
||||
|
||||
To compile, just clone and launch cmake:
|
||||
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 (I've abandonned the support for conan v1 as it's now considered as deprecated).
|
||||
|
||||
```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:
|
||||
If your CMake<3.23, you should use this command for generation instead of preset one:
|
||||
|
||||
```shell
|
||||
mkdir build
|
||||
cd build
|
||||
conan install .. --build=missing
|
||||
cmake .. -G "MinGW Makefiles"
|
||||
make
|
||||
```
|
||||
`cmake . -S build -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DRSPTEXTURE_SHARED=ON -DRSPTEXTURE_STATIC=OFF -DBUILD_TOOLS=ON -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"`
|
||||
|
||||
If you want to do it manually without Conan support, you will probably need to specify the dependency flags for CMake. Ex:
|
||||
Beware to use the same release/debug configuration with CMake using Conan! Adjust CMake preset or Conan configuration if necessary.
|
||||
|
||||
`cmake.exe -D"ZLIB_INCLUDE_DIR=zlib/1.2.12/include" -D"ZLIB_LIBRARY=zlib/1.2.12/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"`
|
||||
On Windows environment, you can use MinGW `-G "MinGW Makefiles"` or Ninja `-G "Ninja"` as CMake generator.
|
||||
|
||||
We can also use cross-compilation (after installing `mingw64` and `cmake` packages on your distrib):
|
||||
### Compiling (options)
|
||||
|
||||
```shell
|
||||
mkdir build && cd build
|
||||
cmake -DGNU_HOST=x86_64-w64-mingw32 \
|
||||
-DCMAKE_TOOLCHAIN_FILE=../mingw_cross_toolchain.cmake \
|
||||
-D"ZLIB_INCLUDE_DIR=zlib/1.2.12/include" \
|
||||
-D"ZLIB_LIBRARY=zlib/1.2.12/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 .
|
||||
```
|
||||
There are a few configurable build options:
|
||||
|
||||
- RSPTEXTURE_SHARED Enable the build of shared version of the library ("shared" conan option)
|
||||
- RSPTEXTURE_STATIC Enable the build of static version of the library ("shared" conan option)
|
||||
- BUILD_TOOLS Enable the build of the standalone tools (necessary to use the lib directly) ("tools" conan option)
|
||||
|
||||
### Compiling (old-way)
|
||||
|
||||
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.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" -DRSPTEXTURE_SHARED=ON -DRSPTEXTURE_STATIC=OFF -DBUILD_TOOLS=ON . -G "MinGW Makefiles"`
|
||||
|
||||
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})
|
||||
|
||||
|
||||
@ -40,9 +40,11 @@ if(BUILD_TOOLS)
|
||||
endif()
|
||||
|
||||
# Link externals libraries to the linker
|
||||
if(RSPTEXTURE_SHARED)
|
||||
target_link_libraries(rse-texture PRIVATE rsp-texture-lib ${PNG_LIBRARIES})
|
||||
elseif(RSPTEXTURE_STATIC)
|
||||
target_link_libraries(rse-texture PRIVATE rsp-texture-libstatic ${PNG_LIBRARIES})
|
||||
if (TARGET PNG::PNG)
|
||||
if(RSPTEXTURE_SHARED)
|
||||
target_link_libraries(rse-texture PRIVATE rsp-texture-lib PNG::PNG)
|
||||
elseif(RSPTEXTURE_STATIC)
|
||||
target_link_libraries(rse-texture PRIVATE rsp-texture-libstatic PNG::PNG)
|
||||
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)
|
126
conanfile.py
Normal file
126
conanfile.py
Normal file
@ -0,0 +1,126 @@
|
||||
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_texture(ConanFile):
|
||||
name = "rsptexturelib"
|
||||
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-Texture"
|
||||
description = "Rogue Squadron 3D (PC) game textures files (HMT) 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("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-Texture.git", target=".", args=cargs)
|
||||
|
||||
# def _patch(self):
|
||||
# replace_in_file(self, os.path.join(self.source_folder, "RSPTextureLib", "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["RSPTEXTURE_SHARED"] = self.options.shared
|
||||
tc.cache_variables["RSPTEXTURE_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", "RSETexture")
|
||||
self.cpp_info.set_property("cmake_target_name", "RSETexture")
|
||||
self.cpp_info.set_property("cmake_module_target_name", "RSETexture::RSETexture")
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
|
||||
self.cpp_info.names["cmake_find_package"] = "RSETexture"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "RSETexture"
|
||||
|
||||
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 = ["{}RSETexture{}{}".format(prefix, major_min_version, suffix)]
|
@ -1,13 +0,0 @@
|
||||
[requires]
|
||||
zlib/1.2.12
|
||||
libpng/1.6.37
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
cmake_find_package
|
||||
|
||||
[options]
|
||||
libpng:shared=True
|
||||
|
||||
[imports]
|
||||
bin, *.dll -> ./bin
|
Loading…
x
Reference in New Issue
Block a user