Skip to content

Commit

Permalink
build: use conan (#48)
Browse files Browse the repository at this point in the history
build: use conan
  • Loading branch information
TheWillard authored Oct 5, 2024
1 parent a980217 commit e717a7d
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 106 deletions.
51 changes: 27 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@ on:
push:
pull_request:

env:
VCPKG_COMMIT: cc97b4536ae749ec0e4f643488b600b217540fb3
VCPKG_DIR: C:/deps/vcpkg
CMAKE_PRESET: ninja-msvc-vcpkg

jobs:
job_build_cpp:
name: win
runs-on: windows-latest

steps:
# Checkout
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand All @@ -27,42 +21,51 @@ jobs:
vsversion: 2022
toolset: 14

# Install latest CMake
- uses: lukka/get-cmake@latest

- name: Create folder
run: |
mkdir ${{ env.VCPKG_DIR }}
- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main

- name: Print conan version
run: echo "${{ steps.conan.outputs.version }}"

# Setup vcpkg and build deps
- name: Restore artifacts, or Run vcpkg, build and cache artifacts
uses: lukka/run-vcpkg@v11
id: runvcpkg
- name: cache ~/.conan2
id: cache-conan
uses: actions/cache@v2
env:
cache-name: cache-conan-modules
with:
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT }}
vcpkgDirectory: ${{ env.VCPKG_DIR }}
path: ~/.conan2/
key: ${{ runner.os }}-builder-${{ env.cache-name }}-${{ hashFiles('conanfile.py') }}
restore-keys: ${{ runner.os }}-builder-${{ env.cache-name }}-

- name: Conan install
run: conan install . -s build_type=Release --output-folder=build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja --profile:host=./ci-conan-profile --profile:build=./ci-conan-profile

- name: Run CMake consuming CMakePresets.json and vcpkg.json by mean of vcpkg.
uses: lukka/run-cmake@v10
with:
configurePreset: ninja-release-vcpkg-win
buildPreset: ninja-msvc-vcpkg-release
- name: Create build dir
run: mkdir build/ninja-release-win

- name: Run CMake
run: |
cmake --preset ninja-release-win
cmake --build --preset ninja-msvc-release
# Build the mod
- uses: gruppe-adler/action-release-with-hemtt@v3
name: 'Build Mod with HEMTT'
id: build

# Upload the mod
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.build.outputs.mod_name }}
path: ${{ steps.build.outputs.release_path }}

# zip it
- uses: papeloto/action-zip@v1
with:
files: \@${{ steps.build.outputs.mod_name }}/
files: ${{ steps.build.outputs.release_path }}
dest: \@${{ steps.build.outputs.mod_name }}.zip

# release it
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
build
*.pbo
CMakeSettings.json
CMakeUserPresets.json

# CMake
CMakeCache.txt
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required (VERSION 3.12)

cmake_policy(SET CMP0091 NEW)

#----Make changes here
#This is your project name. And also the filename of the resulting plugin.
project (grad_meh)
Expand Down
40 changes: 20 additions & 20 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
"version": 5,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"minor": 28,
"patch": 0
},
"configurePresets": [
{
"name": "ninja-debug-vcpkg-win",
"displayName": "Ninja/Windows/Debug/VCPKG Config",
"description": "Ninja/Windows/Debug/VCPKG Config",
"binaryDir": "${sourceDir}/builds/${presetName}",
"name": "ninja-debug-win",
"displayName": "Ninja/Windows/Debug/Config",
"description": "Ninja/Windows/Debug/Config",
"binaryDir": "${sourceDir}/build/${presetName}",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
"value": "${sourceDir}/build/conan_toolchain.cmake"
},
"CMAKE_INSTALL_PREFIX": {
"type": "FILEPATH",
"value": "${sourceDir}/install"
},
"USE_64BIT_BUILD": true,
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"USE_STATIC_LINKING": true,
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
},
Expand All @@ -34,10 +34,10 @@
}
},
{
"name": "ninja-release-vcpkg-win",
"displayName": "Ninja/Windows/Release/VCPKG Config",
"inherits": "ninja-debug-vcpkg-win",
"description": "Ninja/Windows/Release/VCPKG Config",
"name": "ninja-release-win",
"displayName": "Ninja/Windows/Release/Config",
"inherits": "ninja-debug-win",
"description": "Ninja/Windows/Release/Config",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
Expand All @@ -46,20 +46,20 @@
],
"buildPresets": [
{
"name": "ninja-msvc-vcpkg-debug",
"configurePreset": "ninja-debug-vcpkg-win",
"displayName": "Build ninja-msvc-vcpkg (Debug)",
"description": "Build ninja-msvc-vcpkg (Debug) Configurations",
"name": "ninja-msvc-debug",
"configurePreset": "ninja-debug-win",
"displayName": "Build ninja-msvc (Debug)",
"description": "Build ninja-msvc (Debug) Configurations",
"targets": "install",
"configuration": "Debug"
},
{
"name": "ninja-msvc-vcpkg-release",
"configurePreset": "ninja-release-vcpkg-win",
"displayName": "Build ninja-msvc-vcpkg (Release)",
"description": "Build ninja-msvc-vcpkg Configurations",
"name": "ninja-msvc-release",
"configurePreset": "ninja-release-win",
"displayName": "Build ninja-msvc (Release)",
"description": "Build ninja-msvc Configurations",
"targets": "install",
"configuration": "Release"
}
]
}
}
9 changes: 5 additions & 4 deletions addons/main/script_version.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#define MAJOR 0
#define MINOR 7
#define PATCHLVL 1
#define BUILD 8
#define MAJOR 1
#define MINOR 0
#define PATCHLVL 0
#define BUILD beta.3

8 changes: 8 additions & 0 deletions ci-conan-profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.version=193
os=Windows
22 changes: 22 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps

class MehRecipe(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"

def requirements(self):
self.requires("fmt/10.2.1")
self.requires("nlohmann_json/3.11.3")
self.requires("pcl/1.13.1")
self.requires("clipper2/1.3.0")
self.requires("plog/1.1.10")
self.requires("gdal/3.8.3")
self.requires("openimageio/2.5.9.0")
self.requires("libpng/1.6.43", override=True)
self.requires("boost/1.84.0", override=True)
self.requires("expat/[>=2.6.2 <3]", override=True)
self.requires("openjpeg/2.5.2", override=True)

def build_requirements(self):
self.tool_requires("cmake/3.29.0")
33 changes: 17 additions & 16 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.15)
cmake_minimum_required (VERSION 3.28)


file(GLOB_RECURSE INTERCEPT_PLUGIN_SOURCES *.h *.hpp *.c *.cpp)
Expand All @@ -21,9 +21,10 @@ set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME ON)

find_package(Boost 1.82.0 REQUIRED COMPONENTS system filesystem thread iostreams)
find_package(Boost 1.84.0 REQUIRED COMPONENTS system filesystem thread iostreams)

# OIIO
message(STATIC ${INTERCEPT_LINK_TYPE})
if("${INTERCEPT_LINK_TYPE}" STREQUAL "static")
add_definitions(-DOIIO_STATIC_DEFINE)
add_definitions(-DGRAD_AFF_STATIC_DEFINE)
Expand All @@ -46,7 +47,7 @@ find_package(GDAL CONFIG REQUIRED)
find_package(PCL CONFIG REQUIRED)

# Clipper
find_package(polyclipping CONFIG REQUIRED)
find_package(clipper2 CONFIG REQUIRED)


#include the Intercept headers from the submodule
Expand Down Expand Up @@ -82,15 +83,15 @@ include(FetchContent)
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG master # Optionally specify a commit hash, version tag or branch here
GIT_TAG v0.5.0 # Optionally specify a commit hash, version tag or branch here
)
# Set any global configuration variables such as `Rust_TOOLCHAIN` before this line!
FetchContent_MakeAvailable(Corrosion)

# Import targets defined in a package or workspace manifest `Cargo.toml` file

corrosion_import_crate(MANIFEST_PATH rvff-cxx/Cargo.toml)
corrosion_add_cxxbridge(rust-lib CRATE rvff-cxx MANIFEST_PATH rvff-cxx FILES lib.rs)
corrosion_add_cxxbridge(rust-lib CRATE rvff_cxx MANIFEST_PATH rvff-cxx FILES lib.rs)

include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_library(${INTERCEPT_PLUGIN_NAME} SHARED ${INTERCEPT_PLUGIN_SOURCES} ${INTERCEPT_HOST_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/version.cpp)
Expand All @@ -99,13 +100,13 @@ target_include_directories(${INTERCEPT_PLUGIN_NAME} PUBLIC ${OPENIMAGEIO_INCLUDE

target_link_libraries(${INTERCEPT_PLUGIN_NAME} GDAL::GDAL)

target_link_libraries(${INTERCEPT_PLUGIN_NAME} OpenImageIO::OpenImageIO OpenImageIO::OpenImageIO_Util)
target_link_libraries(${INTERCEPT_PLUGIN_NAME} openimageio::openimageio)

target_link_libraries(${INTERCEPT_PLUGIN_NAME} ${Boost_LIBRARIES})
target_link_libraries(${INTERCEPT_PLUGIN_NAME} nlohmann_json nlohmann_json::nlohmann_json)
target_link_libraries(${INTERCEPT_PLUGIN_NAME} fmt::fmt-header-only)
target_link_libraries(${INTERCEPT_PLUGIN_NAME} ${PCL_LIBRARIES})
target_link_libraries(${INTERCEPT_PLUGIN_NAME} polyclipping::polyclipping)
target_link_libraries(${INTERCEPT_PLUGIN_NAME} nlohmann_json::nlohmann_json)
target_link_libraries(${INTERCEPT_PLUGIN_NAME} fmt::fmt)
target_link_libraries(${INTERCEPT_PLUGIN_NAME} PCL::PCL)
target_link_libraries(${INTERCEPT_PLUGIN_NAME} clipper2::clipper2)

target_link_libraries(${INTERCEPT_PLUGIN_NAME} plog::plog)

Expand All @@ -117,11 +118,7 @@ endif()

if(MSVC)
# Note: This is required because we use `cxx` which uses `cc` to compile and link C++ code.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
corrosion_set_env_vars(rvff-cxx "CFLAGS=-MTd" "CXXFLAGS=-MTd")
else()
corrosion_set_env_vars(rvff-cxx "CFLAGS=-MT" "CXXFLAGS=-MT")
endif()
corrosion_set_env_vars(rvff_cxx "CFLAGS=-MD$<$<CONFIG:Debug>:d>" "CXXFLAGS=-MD$<$<CONFIG:Debug>:d>")
endif()

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${INTERCEPT_INCLUDE_PATH})
Expand All @@ -138,7 +135,7 @@ else()
set(CMAKE_CXX_FLAGS_RELEASE "/MT /Zi /O2 /Ob1 /EHsc /MP") #with debug info
# /FORCE:MULTIPLE requrired to ignore second definition of tiff stuff in gdal (conflicting with oiio?)
target_link_options(${INTERCEPT_PLUGIN_NAME} PUBLIC "/FORCE:MULTIPLE")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/DEBUG:FULL /NODEFAULT:LIBCMTD")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/DEBUG:FULL")# /NODEFAULT:LIBCMTD")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/OPT:REF /DEBUG:FULL /NODEFAULT:LIBCMTD")
endif()

Expand All @@ -149,6 +146,10 @@ if("${PLUGIN_FOLDER}" STREQUAL "")
SET(PLUGIN_FOLDER "${ARMA_PATH}\\@grad_meh\\intercept")
endif()

message("Build Type: " ${CMAKE_BUILD_TYPE})
message("Use Static Linking: " ${USE_STATIC_LINKING})
message("Cmake Install Prefix: " ${CMAKE_INSTALL_PREFIX})

message("grad_meh plugin folder: " ${PLUGIN_FOLDER})
if(NOT "${PLUGIN_FOLDER}" STREQUAL "")
add_custom_command(TARGET ${INTERCEPT_PLUGIN_NAME} POST_BUILD
Expand Down
25 changes: 13 additions & 12 deletions src/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <pcl/search/impl/search.hpp>
#include <pcl/search/impl/organized.hpp>

#include <polyclipping/clipper.hpp>
#include <clipper2/clipper.h>

#include <ogr_geometry.h>

Expand Down Expand Up @@ -69,7 +69,7 @@ void writeArea(rvff::cxx::OprwCxx& wrp, fs::path& basePathGeojson, const std::ve
ec.extract(cluster_indices);

pcl::PCDWriter writer;
ClipperLib::Paths paths;
Clipper2Lib::Paths64 paths;
paths.reserve(nPoints);

for (std::vector<pcl::PointIndices>::const_iterator it = cluster_indices.begin(); it != cluster_indices.end(); ++it)
Expand All @@ -82,27 +82,28 @@ void writeArea(rvff::cxx::OprwCxx& wrp, fs::path& basePathGeojson, const std::ve
cloudCluster->is_dense = true;

for (auto& point : *cloudCluster) {
ClipperLib::Path polygon;
polygon.push_back(ClipperLib::IntPoint(point.x - buffer, point.y));
polygon.push_back(ClipperLib::IntPoint(point.x, point.y - buffer));
polygon.push_back(ClipperLib::IntPoint(point.x + buffer, point.y));
polygon.push_back(ClipperLib::IntPoint(point.x, point.y + buffer));
Clipper2Lib::Path64 polygon;
polygon.push_back(Clipper2Lib::Point64(point.x - buffer, point.y));
polygon.push_back(Clipper2Lib::Point64(point.x, point.y - buffer));
polygon.push_back(Clipper2Lib::Point64(point.x + buffer, point.y));
polygon.push_back(Clipper2Lib::Point64(point.x, point.y + buffer));
paths.push_back(polygon);
}
}

ClipperLib::Paths solution;
ClipperLib::Clipper c;
c.AddPaths(paths, ClipperLib::ptSubject, true);
c.Execute(ClipperLib::ctUnion, solution, ClipperLib::pftNonZero);
//Clipper2Lib::Paths64 solution;
//Clipper2Lib::Clip c;
//c.AddPaths(paths, Clipper2Lib::ptSubject, true);
//c.Execute(Clipper2Lib::ctUnion, solution, Clipper2Lib::pftNonZero);
Clipper2Lib::Paths64 solution = Clipper2Lib::Union(paths, Clipper2Lib::FillRule::NonZero);

std::vector<OGRLinearRing*> rings;
rings.reserve(solution.size());

for (auto& path : solution) {
auto ring = new OGRLinearRing();
for (auto& point : path) {
ring->addPoint(point.X, point.Y);
ring->addPoint(point.x, point.y);
}
ring->closeRings();
rings.push_back(ring);
Expand Down
2 changes: 1 addition & 1 deletion src/geojsons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ void writeGeojsons(rvff::cxx::OprwCxx& wrp, std::filesystem::path& basePathGeojs
for (auto& genericMapType : genericMapTypes) {
if (objectMap.find(genericMapType) != objectMap.end()) {
if (genericMapType == "tree") {
writeArea(wrp, basePathGeojson, objectMap["tree"], 15, 5, 10, 7, "forest");
writeArea(wrp, basePathGeojson, objectMap["tree"], 13, 4, 10, 7, "forest");
}
else if (genericMapType == "rock") {
writeArea(wrp, basePathGeojson, objectMap["rock"], 10, 4, 10, 7, "rocks");
Expand Down
2 changes: 1 addition & 1 deletion src/rvff-cxx
Submodule rvff-cxx updated 1 files
+1 −1 Cargo.toml
Loading

0 comments on commit e717a7d

Please sign in to comment.