Skip to content

Commit

Permalink
Add conda package
Browse files Browse the repository at this point in the history
The packaging is done without vcpkg, the dependencies are provided by conda itself.
- Add cmake preset to build conda packages without toolchain
- Add github action to build conda package
- Improve CMakeLists.txt
  • Loading branch information
bruno-at-orange committed May 21, 2024
1 parent ff85c57 commit 0c041aa
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 10 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ set (CMAKE_CXX_STANDARD 17)

project(khiops-gcs LANGUAGES CXX)

# Find dependencies provided by vcpkg (via vcpkg.cmake)
# Find dependencies
find_package(fmt CONFIG REQUIRED)
find_package(google_cloud_cpp_storage CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)

# Hide symbols in the shared libraries
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)

add_library(khiopsdriver_file_gcs MODULE src/gcsplugin.h src/gcsplugin.cpp)
set_target_properties(khiopsdriver_file_gcs PROPERTIES LINK_FLAGS_RELEASE -s)
target_link_options(khiopsdriver_file_gcs PRIVATE $<$<CONFIG:RELEASE>:-s>) # stripping
target_link_libraries(khiopsdriver_file_gcs PRIVATE google-cloud-cpp::storage spdlog::spdlog)

add_executable(KhiopsPluginTest src/khiopsplugintest.cpp)
target_link_libraries(KhiopsPluginTest PRIVATE fmt::fmt)

add_executable(drivertest src/drivertest.cpp)
target_link_libraries(drivertest)
target_link_libraries(drivertest ${CMAKE_DL_LIBS}) # Link to dl

28 changes: 21 additions & 7 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
"configurePresets": [
{
"name": "ninja-multi-vcpkg",
"displayName": "Ninja Multi-Config",
"displayName": "Ninja Multi-Config with vcpkg",
"description": "Configure with vcpkg toolchain and generate Ninja project files for all configurations",
"binaryDir": "${sourceDir}/builds/${presetName}",
"generator": "Ninja Multi-Config",
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake"
},
{
"name": "ninja-multi",
"displayName": "Ninja without vcpkg",
"description": "Configure Ninja project files for all configurations",
"binaryDir": "${sourceDir}/builds/${presetName}",
"generator": "Ninja Multi-Config"
}
],
"buildPresets": [
Expand All @@ -31,10 +38,18 @@
"configuration": "Release"
},
{
"name": "ninja-vcpkg",
"configurePreset": "ninja-multi-vcpkg",
"displayName": "Build",
"description": "Build with Ninja/vcpkg"
"name": "ninja-debug",
"configurePreset": "ninja-multi",
"displayName": "Build (Debug)",
"description": "Build with Ninja",
"configuration": "Debug"
},
{
"name": "ninja-release",
"configurePreset": "ninja-multi",
"displayName": "Build (release)",
"description": "Build with Ninja",
"configuration": "Release"
}
],
"testPresets": [
Expand Down Expand Up @@ -62,5 +77,4 @@
]
}
]
}

}
17 changes: 17 additions & 0 deletions conda/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Set-up the shell to behave more like a general-purpose programming language
set -euo pipefail

# Configure project
cmake --fresh --preset ninja-multi

# Build
cmake --build --preset ninja-release --target khiopsdriver_file_gcs

# Copy binary to conda package
mkdir -p $PREFIX/bin
cp ./builds/ninja-multi/Release/libkhiopsdriver_file_gcs.so "$PREFIX/bin/"



34 changes: 34 additions & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package:
name: khiops-driver-gcs
version: 0.0.1

source:
path: ../

build:
number: 0
requirements:
build:
- cmake
- ninja
- {{ compiler('cxx') }}
host:
- google-cloud-cpp
- spdlog
run:
- google-cloud-cpp
- spdlog

outputs:
- name: khiops-driver-gcs
# test:
# commands:
# - MODL -v
# - MODL_Coclustering -v

about:
home: https://khiops.org
license: BSD+3-clause
summary: Khiops driver to access files on Google Cloud Storage
doc_url: https://khiops.org
dev_url: https://github.com/khiopsml/khiops

0 comments on commit 0c041aa

Please sign in to comment.