Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v4

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }}
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D CMAKE_POLICY_VERSION_MINIMUM=3.5

- name: Build
run: cmake --build build --parallel 10
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Publish Python Package

on:
push:
branches:
- main
pull_request:
workflow_dispatch:
release:
types:
Expand Down Expand Up @@ -63,6 +67,7 @@ jobs:
upload_all:
name: Upload release
needs: [build_wheels, build_sdist]
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
environment:
name: pypi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/checkout@v4

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_POLICY_VERSION_MINIMUM=3.5
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D CMAKE_POLICY_VERSION_MINIMUM=3.5

- name: Build
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ concurrency:
jobs:
build-and-test:
runs-on: windows-latest
continue-on-error: true
strategy:
matrix:
build_type: [Release]
Expand All @@ -38,13 +39,8 @@ jobs:
architecture: 'x64'

- name: Run Cmake
if: matrix.architecture == 'Win32'
run: cmake -S . -B build -A ${{ matrix.architecture }} -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -DOPEN_ATMOS_ENABLE_PYTHON_LIBRARY=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5
run: cmake -S . -B build -A ${{ matrix.architecture }} -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_POLICY_VERSION_MINIMUM="3.5"

- name: Run Cmake
if: matrix.architecture == 'x64'
run: cmake -S . -B build -A ${{ matrix.architecture }} -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_POLICY_VERSION_MINIMUM=3.5

- name: Build
run: cmake --build build --config ${{ matrix.build_type }} --parallel 10

Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
cmake_minimum_required(VERSION 3.21)

# must be on the same line so that pyproject.toml can correctly identify the version
project(mechanism_configuration VERSION 0.1.0 LANGUAGES CXX)
project(mechanism_configuration VERSION 0.1.1 LANGUAGES CXX)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
Expand All @@ -13,6 +13,8 @@ endif()

message(STATUS "CMake build configuration for ${PROJECT_NAME} (${CMAKE_BUILD_TYPE}) ${PROJECT_VERSION}")

include(GNUInstallDirs)

################################################################################
# Projet wide setup options

Expand All @@ -21,6 +23,10 @@ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")

option(OPEN_ATMOS_ENABLE_TESTS "Build the tests" ON)
option(OPEN_ATMOS_ENABLE_PYTHON_LIBRARY "Build the python library" ON)
option(OPEN_ATMOS_ENABLE_PIC "Build the library with position independent code" ON)

set(OPEN_ATMOS_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
set(OPEN_ATMOS_LIB_DIR ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})

################################################################################
# Dependencies
Expand Down
4 changes: 2 additions & 2 deletions include/mechanism_configuration/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern "C" {

const char* getVersionString()
{
return "0.1.0";
return "0.1.1";
}
unsigned getVersionMajor()
{
Expand All @@ -21,7 +21,7 @@ extern "C" {
}
unsigned getVersionPatch()
{
return 0+0;
return 1+0;
}
unsigned getVersionTweak()
{
Expand Down
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ else()
set(PYTHON_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}")
endif()

install(TARGETS mechanism_configuration_python LIBRARY DESTINATION .)
install(TARGETS mechanism_configuration_python mechanism_configuration LIBRARY DESTINATION .)
28 changes: 25 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ add_library(open_atmos::mechanism_configuration ALIAS mechanism_configuration)

target_compile_features(mechanism_configuration PUBLIC cxx_std_20)

if(OPEN_ATMOS_ENABLE_PYTHON_LIBRARY)
# Add the -fPIC flag for position-independent code if we are building the python library
# so that it links correctly on linux
if(OPEN_ATMOS_ENABLE_PYTHON_LIBRARY OR OPEN_ATMOS_ENABLE_PIC)
# Add the -fPIC flag for position-independent code if we are building shared libraries
# or the python library so that it links correctly on linux
set_target_properties(mechanism_configuration PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()

set_target_properties(mechanism_configuration PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${OPEN_ATMOS_LIB_DIR}
LIBRARY_OUTPUT_DIRECTORY ${OPEN_ATMOS_LIB_DIR}
RUNTIME_OUTPUT_DIRECTORY ${OPEN_ATMOS_LIB_DIR}
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)

target_sources(mechanism_configuration
PRIVATE
parse_status.cpp
Expand All @@ -32,3 +40,17 @@ target_link_libraries(mechanism_configuration
PUBLIC
yaml-cpp::yaml-cpp
)

if (APPLE)
# set the rpath for the shared library
set_target_properties(mechanism_configuration PROPERTIES
INSTALL_RPATH "@loader_path"
BUILD_WITH_INSTALL_RPATH TRUE
)
elseif(UNIX)
# set the rpath for the shared library
set_target_properties(mechanism_configuration PROPERTIES
INSTALL_RPATH "$ORIGIN"
BUILD_WITH_INSTALL_RPATH TRUE
)
endif()
3 changes: 2 additions & 1 deletion src/v0/first_order_loss_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ namespace mechanism_configuration
YAML::Node products_object{};
std::vector<types::ReactionComponent> reactants;
std::vector<types::ReactionComponent> products;
products.push_back({ .species_name = species, .coefficient = 1.0 });

reactants.push_back({ .species_name = species, .coefficient = 1.0 });
double scaling_factor = object[validation::SCALING_FACTOR] ? object[validation::SCALING_FACTOR].as<double>() : 1.0;

std::string name = "LOSS." + object[validation::MUSICA_NAME].as<std::string>();
Expand Down
12 changes: 6 additions & 6 deletions test/unit/v0/test_first_order_loss_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ TEST(FirstOrderLossConfig, ParseConfig)

// first reaction
{
EXPECT_EQ(process_vector[0].reactants.size(), 0);
EXPECT_EQ(process_vector[0].products.size(), 1);
EXPECT_EQ(process_vector[0].products[0].species_name, "foo");
EXPECT_EQ(process_vector[0].reactants.size(), 1);
EXPECT_EQ(process_vector[0].products.size(), 0);
EXPECT_EQ(process_vector[0].reactants[0].species_name, "foo");
EXPECT_EQ(process_vector[0].name, "LOSS.foo");
EXPECT_EQ(process_vector[0].scaling_factor, 1.0);
}

// second reaction
{
EXPECT_EQ(process_vector[1].reactants.size(), 0);
EXPECT_EQ(process_vector[1].products.size(), 1);
EXPECT_EQ(process_vector[1].products[0].species_name, "bar");
EXPECT_EQ(process_vector[1].reactants.size(), 1);
EXPECT_EQ(process_vector[1].products.size(), 0);
EXPECT_EQ(process_vector[1].reactants[0].species_name, "bar");
EXPECT_EQ(process_vector[1].name, "LOSS.bar");
EXPECT_EQ(process_vector[1].scaling_factor, 2.5);
}
Expand Down
Loading