From 9b407b74b9e04e7bc14ec350d368bb518efc0f49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jason=20Mar=C3=A9chal?= <45510813+JasonMarechal25@users.noreply.github.com> Date: Thu, 4 Jan 2024 14:59:23 +0100 Subject: [PATCH] Feature/cpp20 (#740) Activate cpp20 flag for compilation Use devtoolset 10 on centOS. Use gcc 10 on CentOS and Ubuntu --- .github/workflows/build_centos7.yml | 5 ++--- .github/workflows/build_ubuntu.yml | 3 +++ CMakeLists.txt | 2 +- docker/centos7-system-deps | 2 +- src/cpp/helpers/FileInBuffer.cpp | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_centos7.yml b/.github/workflows/build_centos7.yml index d6aea8e3f..19c1ae7a4 100644 --- a/.github/workflows/build_centos7.yml +++ b/.github/workflows/build_centos7.yml @@ -4,7 +4,6 @@ on: merge_group: push: branches: - - main - develop pull_request: release: @@ -131,7 +130,7 @@ jobs: - name: Configure run: | [[ ${{ matrix.xprs }} == "XPRESS-ON" ]] && XPRESS_VALUE="ON" || XPRESS_VALUE="OFF" - source /opt/rh/devtoolset-9/enable + source /opt/rh/devtoolset-10/enable export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib:$LD_LIBRARY_PATH export PATH=/usr/lib64/openmpi/bin:$PATH cmake3 -B _build -S . \ @@ -145,7 +144,7 @@ jobs: -DALLOW_RUN_AS_ROOT=ON - name: Build run: | - source /opt/rh/devtoolset-9/enable + source /opt/rh/devtoolset-10/enable export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib:$LD_LIBRARY_PATH export PATH=/usr/lib64/openmpi/bin:$PATH cmake3 --build _build --config Release -j8 --target install diff --git a/.github/workflows/build_ubuntu.yml b/.github/workflows/build_ubuntu.yml index da34dd653..5614af854 100644 --- a/.github/workflows/build_ubuntu.yml +++ b/.github/workflows/build_ubuntu.yml @@ -61,6 +61,7 @@ jobs: run: | sudo apt-get update --fix-missing sudo apt-get install -y ccache cmake libgtest-dev libjsoncpp-dev libtbb-dev libopenmpi-dev + sudo apt-get install -y g++-10 gcc-10 - name: Read antares-solver version id: antares-version @@ -103,7 +104,9 @@ jobs: [[ ${{ matrix.xprs }} == "XPRESS-ON" ]] && XPRESS_VALUE="ON" || XPRESS_VALUE="OFF" cmake -B _build -S . \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_C_COMPILER=/usr/bin/gcc-10 \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \ -DDEPS_INSTALL_DIR=rte-antares-deps-Release \ -DBUILD_TESTING=ON \ -DCMAKE_BUILD_TYPE=Release \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 1647e625a..e3fb6c5fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ set(CMAKE_INSTALL_RPATH $ORIGIN) set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) set (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) -set (CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set (CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/docker/centos7-system-deps b/docker/centos7-system-deps index 753157e6c..b534fed80 100644 --- a/docker/centos7-system-deps +++ b/docker/centos7-system-deps @@ -8,7 +8,7 @@ RUN yum install -y epel-release RUN \ yum install -y wget git epel-release redhat-lsb-core gcc gcc-c++ make centos-release-scl scl-utils &&\ - yum install -y cmake3 devtoolset-9 environment-modules rpm-build zlib-devel &&\ + yum install -y cmake3 devtoolset-10-gcc* environment-modules rpm-build zlib-devel &&\ yum install -y jsoncpp-devel openmpi-devel doxygen graphviz &&\ yum install -y gtest-devel &&\ yum install -y install python3-devel && \ diff --git a/src/cpp/helpers/FileInBuffer.cpp b/src/cpp/helpers/FileInBuffer.cpp index 3c903ceff..fd3574e0b 100644 --- a/src/cpp/helpers/FileInBuffer.cpp +++ b/src/cpp/helpers/FileInBuffer.cpp @@ -8,7 +8,7 @@ FileBuffer FileInBuffer::run(const std::filesystem::path& filePath) { std::ifstream file(filePath); std::stringstream buffer; if (file.bad()) { - std::cerr << "Error while reading file : " << filePath.c_str() << std::endl; + std::cerr << "Error while reading file : " << filePath << std::endl; return {}; } buffer << file.rdbuf();