From ab68ee341967b9172507f0770dd71ebda3562073 Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Wed, 2 Apr 2025 10:47:40 -0500 Subject: [PATCH 1/4] setting rpath (#77) * setting rpath * changig rpath * build both windows tests even if one fails * trying to use one cmake command for building on windows * quoting the cmake vesion on windows --- .github/workflows/windows.yml | 8 ++------ src/CMakeLists.txt | 13 +++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 61cfbf65..3f684e83 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -14,6 +14,7 @@ concurrency: jobs: build-and-test: runs-on: windows-latest + continue-on-error: true strategy: matrix: build_type: [Release] @@ -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 }} -DOPEN_ATMOS_ENABLE_PYTHON_LIBRARY=ON -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4e38c2c6..8fa716a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,3 +32,16 @@ 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" + ) +elseif(UNIX) + # set the rpath for the shared library + set_target_properties(mechanism_configuration PROPERTIES + INSTALL_RPATH "$ORIGIN" + BUILD_WITH_INSTALL_RPATH TRUE + ) +endif() \ No newline at end of file From 6716c77d594bb892f1f13e57f78155dd207664cb Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Wed, 2 Apr 2025 15:00:22 -0500 Subject: [PATCH 2/4] Liboutput (#78) * trying to set library output directory * using proper target * including cibuildwheel actions --- .github/workflows/release.yml | 5 +++++ CMakeLists.txt | 5 +++++ src/CMakeLists.txt | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 988739fe..fc7cb6f4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,10 @@ name: Publish Python Package on: + push: + branches: + - main + pull_request: workflow_dispatch: release: types: @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 091fc219..c6e5fffc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,8 @@ endif() message(STATUS "CMake build configuration for ${PROJECT_NAME} (${CMAKE_BUILD_TYPE}) ${PROJECT_VERSION}") +include(GNUInstallDirs) + ################################################################################ # Projet wide setup options @@ -22,6 +24,9 @@ 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) +set(OPEN_ATMOS_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}) +set(OPEN_ATMOS_LIB_DIR ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) + ################################################################################ # Dependencies diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8fa716a9..42f3cc9c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,6 +13,13 @@ if(OPEN_ATMOS_ENABLE_PYTHON_LIBRARY) 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} + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} +) + target_sources(mechanism_configuration PRIVATE parse_status.cpp From 6adc8833a6282809debec21651bd6e4b85fc6e34 Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Thu, 3 Apr 2025 20:17:51 -0500 Subject: [PATCH 3/4] PIC (#80) Adding an option to enable position-independent code and telling cmake to use the RPATH on linux --- .github/workflows/mac.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- .github/workflows/windows.yml | 2 +- CMakeLists.txt | 1 + python/CMakeLists.txt | 2 +- src/CMakeLists.txt | 8 +++++--- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 0da73b53..c8ee5b4c 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -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 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 42bc8666..a7305e4a 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -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 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 3f684e83..2635f074 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -39,7 +39,7 @@ jobs: architecture: 'x64' - name: Run Cmake - 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: Build run: cmake --build build --config ${{ matrix.build_type }} --parallel 10 diff --git a/CMakeLists.txt b/CMakeLists.txt index c6e5fffc..37523315 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ 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}) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 5a4e6081..65cb6cd1 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -32,4 +32,4 @@ else() set(PYTHON_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}") endif() -install(TARGETS mechanism_configuration_python LIBRARY DESTINATION .) \ No newline at end of file +install(TARGETS mechanism_configuration_python mechanism_configuration LIBRARY DESTINATION .) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 42f3cc9c..7218d5ac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,15 +7,16 @@ 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} ) @@ -44,6 +45,7 @@ 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 From 18391de70960f4ce3de49f3755ceb1bc59f67a61 Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Tue, 8 Apr 2025 11:39:02 -0500 Subject: [PATCH 4/4] correctly placing species as a reactant in a first order loss reaction (#81) * correctly placing species as a reactant in a first order loss reaction * patch release version --- CMakeLists.txt | 2 +- include/mechanism_configuration/version.hpp | 4 ++-- src/v0/first_order_loss_parser.cpp | 3 ++- test/unit/v0/test_first_order_loss_config.cpp | 12 ++++++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37523315..76a9c4f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/include/mechanism_configuration/version.hpp b/include/mechanism_configuration/version.hpp index 4115eeae..8c16c6db 100644 --- a/include/mechanism_configuration/version.hpp +++ b/include/mechanism_configuration/version.hpp @@ -9,7 +9,7 @@ extern "C" { const char* getVersionString() { - return "0.1.0"; + return "0.1.1"; } unsigned getVersionMajor() { @@ -21,7 +21,7 @@ extern "C" { } unsigned getVersionPatch() { - return 0+0; + return 1+0; } unsigned getVersionTweak() { diff --git a/src/v0/first_order_loss_parser.cpp b/src/v0/first_order_loss_parser.cpp index 864707eb..690205d6 100644 --- a/src/v0/first_order_loss_parser.cpp +++ b/src/v0/first_order_loss_parser.cpp @@ -23,7 +23,8 @@ namespace mechanism_configuration YAML::Node products_object{}; std::vector reactants; std::vector 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() : 1.0; std::string name = "LOSS." + object[validation::MUSICA_NAME].as(); diff --git a/test/unit/v0/test_first_order_loss_config.cpp b/test/unit/v0/test_first_order_loss_config.cpp index e6016ea5..0871facb 100644 --- a/test/unit/v0/test_first_order_loss_config.cpp +++ b/test/unit/v0/test_first_order_loss_config.cpp @@ -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); }