diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml
index 1bc57aef1..d6829f37a 100644
--- a/.github/workflows/dev-ci.yml
+++ b/.github/workflows/dev-ci.yml
@@ -86,7 +86,7 @@ jobs:
- name: Run build steps in Docker container
run: |
docker run --name build_container -v $GITHUB_WORKSPACE:/workspace centos7withcmake:latest /bin/bash -c "
- source /opt/rh/devtoolset-9/enable &&
+ source /opt/rh/devtoolset-9/enable &&
cmake -S /workspace/metrix-simulator/external -B /workspace/metrix-simulator/build/external &&
cmake --build /workspace/metrix-simulator/build/external --parallel 2 &&
cmake -S /workspace/metrix-simulator -Wno-dev -DCMAKE_BUILD_TYPE=Release -DBoost_ROOT=/usr/local/src/__w/Boost/Boost/boost_1_73_0/installBoost -DBoost_INCLUDE_DIR=/usr/local/src/__w/Boost/Boost/boost_1_73_0/installBoost -DCMAKE_INSTALL_PREFIX=/workspace/metrix-simulator/build/install -B /workspace/metrix-simulator/build &&
@@ -215,6 +215,13 @@ jobs:
run: >
cmake --build %GITHUB_WORKSPACE%\metrix-simulator\build\external --parallel 2 --config Release
+ - name: List SuiteSparse directory content
+ run: dir /s %GITHUB_WORKSPACE%\metrix-simulator\build\external\suitesparse
+
+ - name: Add SuiteSparse DLLs to PATH
+ shell: pwsh
+ run: echo "${{ github.workspace }}\metrix-simulator\build\external\suitesparse\bin" >> $GITHUB_PATH
+
- name: Configure CMake
run: >
cmake -Wno-dev -S %GITHUB_WORKSPACE%\metrix-simulator -B %GITHUB_WORKSPACE%\metrix-simulator\build
diff --git a/metrix-simulator/CMakeLists.txt b/metrix-simulator/CMakeLists.txt
index 5474e29ca..e24bdfcd0 100755
--- a/metrix-simulator/CMakeLists.txt
+++ b/metrix-simulator/CMakeLists.txt
@@ -1,4 +1,4 @@
-#
+#
# Copyright (c) 2021, RTE (http://www.rte-france.com)
# See AUTHORS.txt
# All rights reserved.
@@ -6,27 +6,36 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
-#
+#
+# Minimal CMake required version
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
+# Include helper functions for creating config files
include(CMakePackageConfigHelpers)
-project(MetrixSimulator
+# Project description
+project(MetrixSimulator
VERSION 7.4.0
LANGUAGES C CXX)
+# Explicitly activate policies
cmake_policy(SET CMP0074 NEW) # Use _ROOT variables to find package
+if(POLICY CMP0167)
+ # The new version of this policy removes the FindBoost.cmake and uses the official Boost Cmake support
+ # However it's only available after the version 1.70+ so, since we ask for version 1.66+, we need the old policy
+ cmake_policy(SET CMP0167 OLD)
+endif()
-message("Build directory : ${CMAKE_BINARY_DIR}")
-message("Source directory : ${CMAKE_SOURCE_DIR}")
+# Show build and source directories
+message("-- Build directory : ${CMAKE_BINARY_DIR}")
+message("-- Source directory : ${CMAKE_SOURCE_DIR}")
+# Enable C++11 standards
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED true)
-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
-set(INSTALL_CMAKE_DIR cmake CACHE PATH "Installation directory for cmake files")
-
+# Specify some parameters depending on if it's run on the compiler
if(MSVC)
add_definitions(-D_WIN32_WINNT=0x0A00)
add_compile_definitions("_CRT_SECURE_NO_WARNINGS")
@@ -46,29 +55,69 @@ else()
set(CMAKE_C_FLAGS_RELEASE "-O3")
endif(MSVC)
+# Add custom cmake modules to the path
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+# Specify where the cmake files will be installed
+set(INSTALL_CMAKE_DIR cmake CACHE PATH "Installation directory for cmake files")
+
+# ==================================== Boost =================================================
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.66.0 REQUIRED COMPONENTS system program_options log filesystem)
+# ================================ Sirius_solver =============================================
+# Add an option to use or not shared library for sirius solver
option(USE_SIRIUS_SHARED "Use shared library for sirius solver" OFF)
if (USE_SIRIUS_SHARED)
- set(SIRIUS_NAME sirius_solver)
+ message("-- Use shared sirius_solver in ${sirius_solver_DIR}")
+ set(SIRIUS_NAME sirius_solver)
else()
- set(SIRIUS_NAME sirius_solver_static)
+ message("-- Use static sirius_solver in ${sirius_solver_static_DIR}")
+ set(SIRIUS_NAME sirius_solver_static)
endif()
+# Define already existing sirius installation path
set(${SIRIUS_NAME}_ROOT ${CMAKE_CURRENT_BINARY_DIR}/external/sirius_solver CACHE PATH "Path where a Sirius installation already exists")
+
+# Find the sirius_solver package
find_package(${SIRIUS_NAME} REQUIRED)
-# SUITESPARSE
-set(SUITESPARSE_HOME ${CMAKE_CURRENT_BINARY_DIR}/external/suitesparse CACHE PATH "Path where an SuiteSparse installation already exists")
-find_package(SuiteSparse REQUIRED)
+# ================================= SuiteSparse ==============================================
+# Add suitesparse cmake directory to the path
+set(SUITESPARSE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/suitesparse CACHE PATH "Path where an SuiteSparse installation already exists")
+list(APPEND CMAKE_PREFIX_PATH "${SUITESPARSE_DIR}/lib/cmake")
+
+# Find the required SuiteSparse packages
+find_package(AMD REQUIRED)
+find_package(COLAMD REQUIRED)
+find_package(BTF REQUIRED)
+find_package(KLU REQUIRED)
+# Find the actual library name
+find_library(SUITESPARSECONFIG_LIB
+ NAMES suitesparseconfig SuiteSparse_config
+ PATHS ${SUITESPARSE_DIR}/lib
+ REQUIRED
+)
+
+# Create an "imported" targer if it does not already exists
+if(NOT TARGET SuiteSparse::config)
+ add_library(SuiteSparse::config UNKNOWN IMPORTED)
+ set_target_properties(SuiteSparse::config PROPERTIES
+ IMPORTED_LOCATION "${SUITESPARSECONFIG_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${SUITESPARSE_DIR}/include"
+ )
+endif()
+
+# ================================= The rest ==============================================
+# Add the log directory to the build
add_subdirectory(log)
message(STATUS "METRIX")
-set(METRIX_HEADERS
+# Define required headers
+set(METRIX_HEADERS
src/calcul.h
src/err/error.h
src/parametres.h
@@ -92,17 +141,18 @@ set(METRIX_HEADERS
src/margin_variations_compute.h
)
-set(METRIX_SOURCES
+# Define required source files
+set(METRIX_SOURCES
src/calculmacrofonctions.cpp
- src/err/error.cpp
- src/reseau.cpp
- src/calculrepports.cpp
- src/calculecrirecontraintesdodu.cpp
- src/connexite.cpp
- src/err/IoDico.cpp
+ src/err/error.cpp
+ src/reseau.cpp
+ src/calculrepports.cpp
+ src/calculecrirecontraintesdodu.cpp
+ src/connexite.cpp
+ src/err/IoDico.cpp
src/calculeEmpilementGroupes.cpp
src/metrix.cpp
- src/metrix2assess.cpp
+ src/metrix2assess.cpp
src/config/configuration.cpp
src/config/input_configuration.cpp
src/config/variant_configuration.cpp
@@ -115,38 +165,40 @@ set(METRIX_SOURCES
src/margin_variations_compute.cpp
)
+# Define binary executable file name
set(target "metrix-simulator")
+# Generate a version.h file
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config/version.h)
-add_executable(${target}
-${METRIX_HEADERS} ${METRIX_SOURCES})
+# Create the executable
+add_executable(${target}
+ ${METRIX_HEADERS} ${METRIX_SOURCES})
+# Add the required directories for the executable
target_include_directories(${target}
PRIVATE
metrix::log
src
${SIRIUS_NAME}
- SuiteSparse::SuiteSparse_KLU
- SuiteSparse::SuiteSparse_AMD
- SuiteSparse::SuiteSparse_COLAMD
- SuiteSparse::SuiteSparse_BTF
- SuiteSparse::SuiteSparse_Config
${Boost_INCLUDE_DIRS}
)
+
+# Add the required libraries
target_link_libraries(${target}
PRIVATE
metrix::log
${SIRIUS_NAME}
- SuiteSparse::SuiteSparse_KLU
- SuiteSparse::SuiteSparse_AMD
- SuiteSparse::SuiteSparse_COLAMD
- SuiteSparse::SuiteSparse_BTF
- SuiteSparse::SuiteSparse_Config
+ SuiteSparse::config
+ SuiteSparse::AMD
+ SuiteSparse::COLAMD
+ SuiteSparse::BTF
+ SuiteSparse::KLU
${Boost_LIBRARIES}
$<$:msvcrt.lib>
)
+# Checks whether the shared library for Sirius is available and installs it
if (USE_SIRIUS_SHARED)
# Export sirius library if using shared
get_target_property(sirius_PATH_LIB_RELEASE sirius_solver IMPORTED_LOCATION_RELEASE)
@@ -162,12 +214,13 @@ if (USE_SIRIUS_SHARED)
install(FILES ${sirius_PATH_LIB} DESTINATION lib)
endif()
+# Option to enable code coverage (disabled by default)
set(CODE_COVERAGE FALSE CACHE BOOL "Enable code coverage")
if (CODE_COVERAGE)
- message(STATUS "CODE COVERAGE")
- set(CMAKE_BUILD_TYPE "Debug")
- list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
- include(cmake/CodeCoverage)
+ message(STATUS "CODE COVERAGE") # Output message for code coverage
+ set(CMAKE_BUILD_TYPE "Debug") # Switch to Debug build type
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") # Add current source to module path
+ include(cmake/CodeCoverage) # Include custom code coverage script
CODE_COVERAGE(NAME code-coverage
OUTPUT_DIR coverage
ROOT_DIR src
@@ -176,24 +229,36 @@ if (CODE_COVERAGE)
)
endif()
+# Install SuiteSparse config files
+install(FILES "${SUITESPARSECONFIG_LIB}" DESTINATION lib)
+
+# Install the executable to bin directory
install(TARGETS ${target} EXPORT targets RUNTIME DESTINATION bin)
+# Install the CMake configuration files
install(EXPORT targets
FILE metrix-simulator-config.cmake
DESTINATION ${INSTALL_CMAKE_DIR}
)
+# Install 'etc' directory to the root of install
install(DIRECTORY ${PROJECT_SOURCE_DIR}/etc DESTINATION .)
+# Option to run a reduced scope of tests
option(METRIX_RUN_ALL_TESTS "Run reduced scope of tests" ON)
+# Enable CTest for running tests
enable_testing()
-add_subdirectory(tests)
+# Add the tests subdirectory, which contains the tests
+add_subdirectory(tests)
+# Generate a basic package version file for the installed package
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/metrix-simulator-config.cmake"
VERSION ${MetrixSimulator_VERSION}
COMPATIBILITY SameMajorVersion
)
+
+# Install the generated version file to the CMake install directory
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/metrix-simulator-config.cmake"
DESTINATION ${INSTALL_CMAKE_DIR}
)
diff --git a/metrix-simulator/cmake/FindSuiteSparse.cmake b/metrix-simulator/cmake/FindSuiteSparse.cmake
deleted file mode 100644
index a47f33dc1..000000000
--- a/metrix-simulator/cmake/FindSuiteSparse.cmake
+++ /dev/null
@@ -1,122 +0,0 @@
-# Copyright (c) 2021, RTE (http://www.rte-france.com)
-# See AUTHORS.txt
-# All rights reserved.
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at http://mozilla.org/MPL/2.0/.
-# SPDX-License-Identifier: MPL-2.0
-#
-
-# - Find SUITESPARSE
-# Find the native SUITESPARSE includes and library
-#
-# SUITESPARSE_INCLUDE_DIR - where to find klu.h, etc.
-# SUITESPARSE_LIBRARIES - List of libraries when using SuiteSparse.
-# SUITESPARSE_FOUND - True if SuiteSparse found.
-
-IF(NOT SUITESPARSE_HOME AND NOT $ENV{SUITESPARSE_HOME} STREQUAL "")
- SET(SUITESPARSE_HOME $ENV{SUITESPARSE_HOME})
-ENDIF()
-
-IF(NOT SUITESPARSE_HOME AND NOT $ENV{SUITESPARSE_ROOT} STREQUAL "")
- SET(SUITESPARSE_HOME $ENV{SUITESPARSE_ROOT})
-ENDIF()
-
-IF(NOT SUITESPARSE_HOME AND NOT $ENV{SUITESPARSE_INSTALL_DIR} STREQUAL "")
- SET(SUITESPARSE_HOME $ENV{SUITESPARSE_INSTALL_DIR})
-ENDIF()
-
-FIND_PATH(KLU_INCLUDE_DIR NAME klu.h HINTS ${SUITESPARSE_HOME}/include)
-FIND_LIBRARY(KLU_LIBRARY NAME klu libklu HINTS ${SUITESPARSE_HOME}/lib)
-
-MARK_AS_ADVANCED(KLU_INCLUDE_DIR KLU_LIBRARY)
-
-FIND_LIBRARY(SUITESPARSE_CONFIG_LIBRARY NAME suitesparseconfig libsuitesparseconfig HINTS ${SUITESPARSE_HOME}/lib)
-MARK_AS_ADVANCED(SUITESPARSE_CONFIG_LIBRARY)
-
-FIND_LIBRARY(AMD_LIBRARY NAME amd libamd HINTS ${SUITESPARSE_HOME}/lib)
-MARK_AS_ADVANCED(AMD_LIBRARY)
-
-FIND_LIBRARY(COLAMD_LIBRARY NAME colamd libcolamd HINTS ${SUITESPARSE_HOME}/lib)
-MARK_AS_ADVANCED(COLAMD_LIBRARY)
-
-FIND_LIBRARY(BTF_LIBRARY NAME btf libbtf HINTS ${SUITESPARSE_HOME}/lib)
-MARK_AS_ADVANCED(BTF_LIBRARY)
-
-# Handle the QUIETLY and REQUIRED arguments and set SUITESPARSE_FOUND
-# to TRUE if all listed variables are TRUE.
-# (Use ${CMAKE_ROOT}/Modules instead of ${CMAKE_CURRENT_LIST_DIR} because CMake
-# itself includes this FindSuiteSparse when built with an older CMake that does
-# not provide it. The older CMake also does not have CMAKE_CURRENT_LIST_DIR.)
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(SuiteSparse DEFAULT_MSG KLU_INCLUDE_DIR KLU_LIBRARY AMD_LIBRARY COLAMD_LIBRARY BTF_LIBRARY)
-
-IF(SuiteSparse_FOUND)
-
- SET(SUITESPARSE_INCLUDE_DIRS ${KLU_INCLUDE_DIR})
- if(NOT TARGET SuiteSparse::SuiteSparse_Config)
- add_library(SuiteSparse::SuiteSparse_Config UNKNOWN IMPORTED)
- if(SUITESPARSE_INCLUDE_DIRS)
- set_target_properties(SuiteSparse::SuiteSparse_Config PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${SUITESPARSE_INCLUDE_DIRS}")
- endif()
- if(EXISTS "${SUITESPARSE_CONFIG_LIBRARY}")
- set_target_properties(SuiteSparse::SuiteSparse_Config PROPERTIES
- IMPORTED_LINK_INTERFACE_LANGUAGES "C"
- IMPORTED_LOCATION "${SUITESPARSE_CONFIG_LIBRARY}")
- endif()
- endif()
-
- if(NOT TARGET SuiteSparse::SuiteSparse_KLU)
- add_library(SuiteSparse::SuiteSparse_KLU UNKNOWN IMPORTED)
- if(SUITESPARSE_INCLUDE_DIRS)
- set_target_properties(SuiteSparse::SuiteSparse_KLU PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${SUITESPARSE_INCLUDE_DIRS}")
- endif()
- if(EXISTS "${KLU_LIBRARY}")
- set_target_properties(SuiteSparse::SuiteSparse_KLU PROPERTIES
- IMPORTED_LINK_INTERFACE_LANGUAGES "C"
- IMPORTED_LOCATION "${KLU_LIBRARY}")
- endif()
- endif()
-
- if(NOT TARGET SuiteSparse::SuiteSparse_AMD)
- add_library(SuiteSparse::SuiteSparse_AMD UNKNOWN IMPORTED)
- if(SUITESPARSE_INCLUDE_DIRS)
- set_target_properties(SuiteSparse::SuiteSparse_AMD PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${SUITESPARSE_INCLUDE_DIRS}")
- endif()
- if(EXISTS "${AMD_LIBRARY}")
- set_target_properties(SuiteSparse::SuiteSparse_AMD PROPERTIES
- IMPORTED_LINK_INTERFACE_LANGUAGES "C"
- IMPORTED_LOCATION "${AMD_LIBRARY}")
- endif()
- endif()
-
- if(NOT TARGET SuiteSparse::SuiteSparse_COLAMD)
- add_library(SuiteSparse::SuiteSparse_COLAMD UNKNOWN IMPORTED)
- if(SUITESPARSE_INCLUDE_DIRS)
- set_target_properties(SuiteSparse::SuiteSparse_COLAMD PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${SUITESPARSE_INCLUDE_DIRS}")
- endif()
- if(EXISTS "${COLAMD_LIBRARY}")
- set_target_properties(SuiteSparse::SuiteSparse_COLAMD PROPERTIES
- IMPORTED_LINK_INTERFACE_LANGUAGES "C"
- IMPORTED_LOCATION "${COLAMD_LIBRARY}")
- endif()
- endif()
-
- if(NOT TARGET SuiteSparse::SuiteSparse_BTF)
- add_library(SuiteSparse::SuiteSparse_BTF UNKNOWN IMPORTED)
- if(SUITESPARSE_INCLUDE_DIRS)
- set_target_properties(SuiteSparse::SuiteSparse_BTF PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${SUITESPARSE_INCLUDE_DIRS}")
- endif()
- if(EXISTS "${BTF_LIBRARY}")
- set_target_properties(SuiteSparse::SuiteSparse_BTF PROPERTIES
- IMPORTED_LINK_INTERFACE_LANGUAGES "C"
- IMPORTED_LOCATION "${BTF_LIBRARY}")
- endif()
- endif()
-
-ENDIF()
diff --git a/metrix-simulator/external/CMakeLists.txt b/metrix-simulator/external/CMakeLists.txt
index c4cf268f7..8bf118948 100644
--- a/metrix-simulator/external/CMakeLists.txt
+++ b/metrix-simulator/external/CMakeLists.txt
@@ -1,4 +1,4 @@
-#
+#
# Copyright (c) 2021, RTE (http://www.rte-france.com)
# See AUTHORS.txt
# All rights reserved.
@@ -6,41 +6,55 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
-#
+#
+# Minimal CMake required version
+cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
-cmake_minimum_required(VERSION 3.9.6 FATAL_ERROR)
-
-set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel (CMake defaults)")
+# Project description
+project(Metrix-external
+ DESCRIPTION "External libraries used by metrix-simulator"
+ LANGUAGES CXX C) # language is required to identify compiler ID and version
+# Activate new behaviour of the policy if necessary
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
+# Type of build
+set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel (CMake defaults)")
+
# Add custom cmake modules to the path
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
-project(Metrix-external CXX C) # language is required to identify compiler ID and version
-
+# Set a few directories
set(DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/src CACHE PATH "Directory where 3rd parties are downloaded.")
set(TMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/tmp CACHE PATH "Directory where 3rd parties temporary files are created.")
+# Enable C++11 standards
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED true)
-include(ExternalProject)
-include(GetPatchCommand)
-include(CloneUrl)
+# Include extra modules
+include(ExternalProject) # Used to download and build external projects
+include(GetPatchCommand) # Used to get the name of a patch file
+include(CloneUrl) # Used to adapt the URL to use login/password (method "get_url")
+# ================================ SuiteSparse =============================================
+# URL and version
set(suitesparse_url https://github.com/DrTimothyAldenDavis/SuiteSparse.git)
-set(suitesparse_tag_version v5.4.0)
+set(suitesparse_tag_version v7.10.1)
+# Adapt the URL if needed with NNI (the login) and NNI_PASSWORD (the password)
if(DEFINED ENV{NNI} AND DEFINED ENV{NNI_PASSWORD})
get_url(NAME suitesparse URL ${suitesparse_url} NNI $ENV{NNI} PASSWORD $ENV{NNI_PASSWORD})
set(suitesparse_url ${SUITEPARSE_URL})
endif()
+# Get the path file name as "suitesparse_patch"
GetPatchCommand(${CMAKE_CURRENT_SOURCE_DIR} suitesparse)
+
+# Build SuiteSparse only if it is not already present
if(SuiteSparse_FOUND)
message(STATUS "SuiteSparse Already found")
add_custom_target(suitesparse)
@@ -56,22 +70,28 @@ else()
PATCH_COMMAND ${suitesparse_patch}
CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
-
+ LIST_SEPARATOR ^^
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+ -DSUITESPARSE_ENABLE_PROJECTS=suitesparse_config^^amd^^colamd^^btf^^klu
+ -DKLU_USE_CHOLMOD:BOOL=OFF
+ -DSUITESPARSE_REQUIRE_BLAS:BOOL=OFF
)
ExternalProject_Get_Property(suitesparse install_dir)
set(SUITESPARSE_HOME ${install_dir})
endif()
+# ================================ Sirius_solver =============================================
+# URL
set(sirius_solver_url https://github.com/rte-france/sirius-solver.git)
+# Adapt the URL if needed with NNI (the login) and NNI_PASSWORD (the password)
if(DEFINED ENV{NNI} AND DEFINED ENV{NNI_PASSWORD})
get_url(NAME sirius URL ${sirius_solver_url} NNI $ENV{NNI} PASSWORD $ENV{NNI_PASSWORD})
set(sirius_solver_url ${SIRIUS_URL})
endif()
-set(sirius_solver_ROOT ${CMAKE_CURRENT_BINARY_DIR}/sirius_solver)
+# Build SuiteSparse only if it is not already present
find_package(sirius_solver QUIET)
if(sirius_solver_FOUND)
message(STATUS "Sirius solver already found")
diff --git a/metrix-simulator/external/suitesparse/patch/suitesparse.patch b/metrix-simulator/external/suitesparse/patch/suitesparse.patch
index d5b1e9e86..b6616051a 100644
--- a/metrix-simulator/external/suitesparse/patch/suitesparse.patch
+++ b/metrix-simulator/external/suitesparse/patch/suitesparse.patch
@@ -1,319 +1,65 @@
-diff -urpN SuiteSparse/AMD/CMakeLists.txt SuiteSparse.patch/AMD/CMakeLists.txt
---- SuiteSparse/AMD/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100
-+++ SuiteSparse.patch/AMD/CMakeLists.txt 2019-11-06 12:04:23.625796280 +0100
-@@ -0,0 +1,58 @@
-+file(READ "Include/amd.h" _file_content)
-+string(REGEX REPLACE ".*#define[ \t]+AMD_MAIN_VERSION[ \t]+([0-9]+).*" "\\1" AMD_VERSION_MAJOR "${_file_content}")
-+string(REGEX REPLACE ".*#define[ \t]+AMD_SUB_VERSION[ \t]+([0-9]+).*" "\\1" AMD_VERSION_MINOR "${_file_content}")
-+string(REGEX REPLACE ".*#define[ \t]+AMD_SUBSUB_VERSION[ \t]+([0-9]+).*" "\\1" AMD_VERSION_PATCH "${_file_content}")
-+set(AMD_VERSION_STRING "${AMD_VERSION_MAJOR}.${AMD_VERSION_MINOR}.${AMD_VERSION_PATCH}")
-+message("AMD_VERSION_STRING=${AMD_VERSION_STRING}")
-+
-+set(AMD_SRCS
-+ Source/amd_1.c
-+ Source/amd_2.c
-+ Source/amd_aat.c
-+ Source/amd_control.c
-+ Source/amd_defaults.c
-+ Source/amd_dump.c
-+ #Source/amd_global.c
-+ Source/amd_info.c
-+ Source/amd_order.c
-+ Source/amd_post_tree.c
-+ Source/amd_postorder.c
-+ Source/amd_preprocess.c
-+ Source/amd_valid.c
-+ )
-+
-+add_library(amd-i OBJECT ${AMD_SRCS})
-+target_compile_definitions(amd-i PRIVATE DINT)
-+target_include_directories(amd-i PRIVATE Include $)
-+
-+add_library(amd-l OBJECT ${AMD_SRCS})
-+target_compile_definitions(amd-l PRIVATE DLONG)
-+target_include_directories(amd-l PRIVATE Include $)
-+
-+add_library(amd STATIC $ $)
-+set_target_properties(amd PROPERTIES
-+ OUTPUT_NAME $<$:lib>amd
-+ SOVERSION ${AMD_VERSION_MAJOR}
-+ VERSION ${AMD_VERSION_STRING}
-+ WINDOWS_EXPORT_ALL_SYMBOLS TRUE
-+ )
-+
-+target_include_directories(amd
-+ PUBLIC
-+ $
-+ $
-+ )
-+
-+target_link_libraries(amd PUBLIC suitesparseconfig)
-+
-+install(TARGETS amd
-+ EXPORT suitesparse-targets
-+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
-+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
-+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
-+ )
-+
-+install(DIRECTORY Include/
-+ DESTINATION ${INCLUDE_INSTALL_DIR}
-+ FILES_MATCHING PATTERN "*.h"
-+ )
-diff -urpN SuiteSparse/BTF/CMakeLists.txt SuiteSparse.patch/BTF/CMakeLists.txt
---- SuiteSparse/BTF/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100
-+++ SuiteSparse.patch/BTF/CMakeLists.txt 2019-11-06 12:04:23.625796280 +0100
-@@ -0,0 +1,47 @@
-+file(READ "Include/btf.h" _file_content)
-+string(REGEX REPLACE ".*#define[ \t]+BTF_MAIN_VERSION[ \t]+([0-9]+).*" "\\1" BTF_VERSION_MAJOR "${_file_content}")
-+string(REGEX REPLACE ".*#define[ \t]+BTF_SUB_VERSION[ \t]+([0-9]+).*" "\\1" BTF_VERSION_MINOR "${_file_content}")
-+string(REGEX REPLACE ".*#define[ \t]+BTF_SUBSUB_VERSION[ \t]+([0-9]+).*" "\\1" BTF_VERSION_PATCH "${_file_content}")
-+set(BTF_VERSION_STRING "${BTF_VERSION_MAJOR}.${BTF_VERSION_MINOR}.${BTF_VERSION_PATCH}")
-+message("BTF_VERSION_STRING=${BTF_VERSION_STRING}")
-+
-+set(BTF_SRCS
-+ Source/btf_maxtrans.c
-+ Source/btf_order.c
-+ Source/btf_strongcomp.c
-+ )
-+
-+add_library(btf-i OBJECT ${BTF_SRCS})
-+target_include_directories(btf-i PRIVATE Include $)
-+
-+add_library(btf-l OBJECT ${BTF_SRCS})
-+target_compile_definitions(btf-l PRIVATE DLONG)
-+target_include_directories(btf-l PRIVATE Include $)
-+
-+add_library(btf STATIC $ $)
-+set_target_properties(btf PROPERTIES
-+ OUTPUT_NAME $<$:lib>btf
-+ SOVERSION ${BTF_VERSION_MAJOR}
-+ VERSION ${BTF_VERSION_STRING}
-+ WINDOWS_EXPORT_ALL_SYMBOLS TRUE
-+ )
-+
-+target_include_directories(btf
-+ PUBLIC
-+ $
-+ $
-+ )
-+
-+target_link_libraries(btf PUBLIC suitesparseconfig)
-+
-+install(TARGETS btf
-+ EXPORT suitesparse-targets
-+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
-+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
-+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
-+ )
-+
-+install(DIRECTORY Include/
-+ DESTINATION ${INCLUDE_INSTALL_DIR}
-+ FILES_MATCHING PATTERN "*.h"
-+ )
-diff -urpN SuiteSparse/CMakeLists.txt SuiteSparse.patch/CMakeLists.txt
---- SuiteSparse/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100
-+++ SuiteSparse.patch/CMakeLists.txt 2019-11-06 12:04:23.625796280 +0100
-@@ -0,0 +1,22 @@
-+cmake_minimum_required(VERSION 3.4.3 FATAL_ERROR)
-+
-+project(suitesparse)
-+
-+set(INCLUDE_INSTALL_DIR "include")
-+set(LIB_INSTALL_DIR "lib")
-+set(BIN_INSTALL_DIR "bin")
-+set(CONFIG_INSTALL_DIR "cmake")
-+
-+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-+
-+add_subdirectory(SuiteSparse_config)
-+add_subdirectory(AMD)
-+add_subdirectory(BTF)
-+add_subdirectory(COLAMD)
-+add_subdirectory(KLU)
-+
-+install(EXPORT suitesparse-targets
-+ NAMESPACE SuiteSparse::
-+ FILE suitesparse-config.cmake
-+ DESTINATION ${CONFIG_INSTALL_DIR}
-+ )
-diff -urpN SuiteSparse/COLAMD/CMakeLists.txt SuiteSparse.patch/COLAMD/CMakeLists.txt
---- SuiteSparse/COLAMD/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100
-+++ SuiteSparse.patch/COLAMD/CMakeLists.txt 2019-11-06 12:04:23.625796280 +0100
-@@ -0,0 +1,45 @@
-+file(READ "Include/colamd.h" _file_content)
-+string(REGEX REPLACE ".*#define[ \t]+COLAMD_MAIN_VERSION[ \t]+([0-9]+).*" "\\1" COLAMD_VERSION_MAJOR "${_file_content}")
-+string(REGEX REPLACE ".*#define[ \t]+COLAMD_SUB_VERSION[ \t]+([0-9]+).*" "\\1" COLAMD_VERSION_MINOR "${_file_content}")
-+string(REGEX REPLACE ".*#define[ \t]+COLAMD_SUBSUB_VERSION[ \t]+([0-9]+).*" "\\1" COLAMD_VERSION_PATCH "${_file_content}")
-+set(COLAMD_VERSION_STRING "${COLAMD_VERSION_MAJOR}.${COLAMD_VERSION_MINOR}.${COLAMD_VERSION_PATCH}")
-+message("COLAMD_VERSION_STRING=${COLAMD_VERSION_STRING}")
-+
-+set(COLAMD_SRCS
-+ Source/colamd.c
-+ )
-+
-+add_library(colamd-i OBJECT ${COLAMD_SRCS})
-+target_include_directories(colamd-i PRIVATE Include $)
-+
-+add_library(colamd-l OBJECT ${COLAMD_SRCS})
-+target_compile_definitions(colamd-l PRIVATE DLONG)
-+target_include_directories(colamd-l PRIVATE Include $)
-+
-+add_library(colamd STATIC $ $)
-+set_target_properties(colamd PROPERTIES
-+ OUTPUT_NAME $<$:lib>colamd
-+ SOVERSION ${COLAMD_VERSION_MAJOR}
-+ VERSION ${COLAMD_VERSION_STRING}
-+ WINDOWS_EXPORT_ALL_SYMBOLS TRUE
-+ )
-+
-+target_include_directories(colamd
-+ PUBLIC
-+ $
-+ $
-+ )
-+
-+target_link_libraries(colamd PUBLIC suitesparseconfig)
-+
-+install(TARGETS colamd
-+ EXPORT suitesparse-targets
-+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
-+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
-+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
-+ )
-+
-+install(DIRECTORY Include/
-+ DESTINATION ${INCLUDE_INSTALL_DIR}
-+ FILES_MATCHING PATTERN "*.h"
-+ )
-diff -urpN SuiteSparse/KLU/CMakeLists.txt SuiteSparse.patch/KLU/CMakeLists.txt
---- SuiteSparse/KLU/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100
-+++ SuiteSparse.patch/KLU/CMakeLists.txt 2019-11-06 12:04:23.625796280 +0100
-@@ -0,0 +1,80 @@
-+file(READ "Include/klu.h" _file_content)
-+string(REGEX REPLACE ".*#define[ \t]+KLU_MAIN_VERSION[ \t]+([0-9]+).*" "\\1" KLU_VERSION_MAJOR "${_file_content}")
-+string(REGEX REPLACE ".*#define[ \t]+KLU_SUB_VERSION[ \t]+([0-9]+).*" "\\1" KLU_VERSION_MINOR "${_file_content}")
-+string(REGEX REPLACE ".*#define[ \t]+KLU_SUBSUB_VERSION[ \t]+([0-9]+).*" "\\1" KLU_VERSION_PATCH "${_file_content}")
-+set(KLU_VERSION_STRING "${KLU_VERSION_MAJOR}.${KLU_VERSION_MINOR}.${KLU_VERSION_PATCH}")
-+message("KLU_VERSION_STRING=${KLU_VERSION_STRING}")
-+
-+set(KLU_SRCS
-+ Source/klu.c
-+ Source/klu_diagnostics.c
-+ Source/klu_dump.c
-+ Source/klu_extract.c
-+ Source/klu_factor.c
-+ Source/klu_free_numeric.c
-+ Source/klu_kernel.c
-+ Source/klu_refactor.c
-+ Source/klu_scale.c
-+ Source/klu_solve.c
-+ Source/klu_sort.c
-+ Source/klu_tsolve.c
-+ )
-+
-+set(COMMON_SRCS
-+ Source/klu_analyze.c
-+ Source/klu_analyze_given.c
-+ Source/klu_defaults.c
-+ Source/klu_free_symbolic.c
-+ Source/klu_memory.c
-+ )
-+
-+add_library(klu-i OBJECT ${KLU_SRCS})
-+
-+add_library(klu-z OBJECT ${KLU_SRCS})
-+target_compile_definitions(klu-z PRIVATE COMPLEX)
-+
-+add_library(klu-l OBJECT ${KLU_SRCS})
-+target_compile_definitions(klu-l PRIVATE DLONG)
-+
-+add_library(klu-zl OBJECT ${KLU_SRCS})
-+target_compile_definitions(klu-zl PRIVATE COMPLEX DLONG)
-+
-+add_library(common-i OBJECT ${COMMON_SRCS})
-+
-+add_library(common-l OBJECT ${COMMON_SRCS})
-+target_compile_definitions(common-l PRIVATE DLONG)
-+
-+set_target_properties(klu-i klu-z klu-l klu-zl common-i common-l PROPERTIES
-+ INCLUDE_DIRECTORIES $
-+ )
-+
-+add_library(klu STATIC
-+ $ $ $ $
-+ $ $
-+ )
-+set_target_properties(klu PROPERTIES
-+ OUTPUT_NAME $<$:lib>klu
-+ SOVERSION ${KLU_VERSION_MAJOR}
-+ VERSION ${KLU_VERSION_STRING}
-+ WINDOWS_EXPORT_ALL_SYMBOLS TRUE
-+ )
-+
-+target_include_directories(klu
-+ PUBLIC
-+ $
-+ $
-+ )
-+
-+target_link_libraries(klu PUBLIC amd btf colamd)
-+
-+install(TARGETS klu
-+ EXPORT suitesparse-targets
-+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
-+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
-+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
-+ )
-+
-+install(DIRECTORY Include/
-+ DESTINATION ${INCLUDE_INSTALL_DIR}
-+ FILES_MATCHING PATTERN "*.h"
-+ )
-diff -urpN SuiteSparse/SuiteSparse_config/CMakeLists.txt SuiteSparse.patch/SuiteSparse_config/CMakeLists.txt
---- SuiteSparse/SuiteSparse_config/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100
-+++ SuiteSparse.patch/SuiteSparse_config/CMakeLists.txt 2019-11-06 12:05:07.732293598 +0100
-@@ -0,0 +1,43 @@
-+file(READ "SuiteSparse_config.h" _file_content)
-+string(REGEX REPLACE ".*#define[ \t]+SUITESPARSE_MAIN_VERSION[ \t]+([0-9]+).*" "\\1" SUITESPARSE_VERSION_MAJOR "${_file_content}")
-+string(REGEX REPLACE ".*#define[ \t]+SUITESPARSE_SUB_VERSION[ \t]+([0-9]+).*" "\\1" SUITESPARSE_VERSION_MINOR "${_file_content}")
-+string(REGEX REPLACE ".*#define[ \t]+SUITESPARSE_SUBSUB_VERSION[ \t]+([0-9]+).*" "\\1" SUITESPARSE_VERSION_PATCH "${_file_content}")
-+set(SUITESPARSE_VERSION_STRING "${SUITESPARSE_VERSION_MAJOR}.${SUITESPARSE_VERSION_MINOR}.${SUITESPARSE_VERSION_PATCH}")
-+message("SUITESPARSE_VERSION_STRING=${SUITESPARSE_VERSION_STRING}")
-+
-+set(SUITESPARSECONFIG_SRCS
-+ SuiteSparse_config.c
-+ )
-+
-+add_library(suitesparseconfig STATIC ${SUITESPARSECONFIG_SRCS})
-+set_target_properties(suitesparseconfig PROPERTIES
-+ OUTPUT_NAME suitesparseconfig
-+ SOVERSION ${SUITESPARSE_VERSION_MAJOR}
-+ VERSION ${SUITESPARSE_VERSION_STRING}
-+ WINDOWS_EXPORT_ALL_SYMBOLS TRUE
-+ )
-+
-+include(GenerateExportHeader)
-+generate_export_header(suitesparseconfig
-+ BASE_NAME suitesparse
-+ )
-+
-+target_include_directories(suitesparseconfig
-+ PUBLIC
-+ $
-+ $
-+ $
-+ )
-+
-+target_link_libraries(suitesparseconfig $<$:rt> $<$:m>)
-+
-+install(TARGETS suitesparseconfig
-+ EXPORT suitesparse-targets
-+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
-+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
-+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
-+ )
-+
-+install(FILES SuiteSparse_config.h ${CMAKE_CURRENT_BINARY_DIR}/suitesparse_export.h
-+ DESTINATION ${INCLUDE_INSTALL_DIR}
-+ )
+Index: SuiteSparse_config/CMakeLists.txt
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/SuiteSparse_config/CMakeLists.txt b/SuiteSparse_config/CMakeLists.txt
+--- a/SuiteSparse_config/CMakeLists.txt (revision 31572b33461e17eb3836c8cda9b1e5920ab1dfa0)
++++ b/SuiteSparse_config/CMakeLists.txt (date 1744182969364)
+@@ -127,7 +127,19 @@
+ # find the BLAS
+ #-------------------------------------------------------------------------------
+
+-include ( SuiteSparseBLAS )
++option ( SUITESPARSE_REQUIRE_BLAS "Must not be set to OFF if any SuiteSparse project requires BLAS functions" ON )
++
++if ( SUITESPARSE_REQUIRE_BLAS )
++ include ( SuiteSparseBLAS )
++else ( )
++ # It doesn't actually matter which Fortran integer size is selected here.
++ # But we might as well respect any user flags.
++ if ( SUITESPARSE_USE_64BIT_BLAS )
++ include ( SuiteSparseBLAS64 )
++ else ( )
++ include ( SuiteSparseBLAS32 )
++ endif ( )
++endif ( )
+
+ #-------------------------------------------------------------------------------
+ # configure files
+Index: CMakeLists.txt
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+--- a/CMakeLists.txt (revision 31572b33461e17eb3836c8cda9b1e5920ab1dfa0)
++++ b/CMakeLists.txt (date 1744182926833)
+@@ -64,6 +64,7 @@
+
+ # CHOLMOD options affecting dependencies
+ option ( CHOLMOD_CAMD "ON (default): use CAMD/CCOLAMD. OFF: do not use CAMD/CCOLAMD" ON )
++option ( CHOLMOD_SUPERNODAL "ON (default): use Supernodal Module. OFF: do not use Supernodal Module" ON )
+
+ # KLU options affecting dependencies
+ option ( KLU_USE_CHOLMOD "ON (default): use CHOLMOD in KLU. OFF: do not use CHOLMOD in KLU" ON )
+@@ -266,6 +267,19 @@
+ endif ( )
+
+
++# BLAS is only required for some sub-projects
++option ( SUITESPARSE_REQUIRE_BLAS "Must not be set to OFF if any SuiteSparse project requires BLAS functions" ON )
++
++if ( ("cholmod" IN_LIST SUITESPARSE_ENABLE_PROJECTS AND CHOLMOD_SUPERNODAL)
++ OR "paru" IN_LIST SUITESPARSE_ENABLE_PROJECTS
++ OR "spqr" IN_LIST SUITESPARSE_ENABLE_PROJECTS
++ OR "umfpack" IN_LIST SUITESPARSE_ENABLE_PROJECTS )
++ if ( NOT SUITESPARSE_REQUIRE_BLAS )
++ message ( FATAL_ERROR "SUITESPARSE_REQUIRE_BLAS must not be set to OFF when building CHOLMOD with SUPERNODAL, ParU, SPQR, or UMFPACK." )
++ endif ( )
++
++endif ( )
++
+ #-------------------------------------------------------------------------------
+ # include selected projects
+ #-------------------------------------------------------------------------------