Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Support for Cross-Platform Builds and Github Actions for Windows Release #60

Open
wants to merge 36 commits into
base: master
Choose a base branch
from

Conversation

zhongjingjogy
Copy link

@zhongjingjogy zhongjingjogy commented Oct 11, 2024

CMake Support for Cross-Platform Builds

People might want to build opencalphad with CMake and using toolchain on different platforms.

Targets

  • Build the oc library
  • Build the command line interface, i.e., oc6p
  • Build the Fortran examples using liboctq.F90. (Note that there are multiple version of libooctq.F90 and a unified one might be needed.)

Disadvantages

  • Time is needed to be spent to check if everything is fine.
  • Dependency on CMake is needed.
  • For Windows, Msys2 is needed and the related toolchains should be installed correctly.

Advantages

  • Multi-Platform Support: CMake is designed to work across multiple platforms (Windows, Linux, macOS, etc.) and with various compilers (GCC, Intel, etc.). This ensures that Fortran project can be built and run on different environments without significant modifications.
  • Modular Design: CMake allows you to break down the project into smaller, reusable modules. This makes it easier to manage large projects with multiple source files and dependencies.

Prerequisite:

  • CMake
  • Fortran compiler
  • C compiler
  • C++ compiler

Tested on:

  • Windows with MSYS2 + MinGW-w64 (gcc version 14.2.0)
  • Ubuntu 20.04 with GCC (gcc version 9.4.0)

Steps to build:

  1. Clone the repository
  2. Create a build directory and run cmake
    • Linux:
    mkdir build
    cd build
    cmake ../
    make
    
    • Windows with MSYS2 + MinGW-w64:
    mkdir build
    cd build
    cmake ../ -G Ninja
    ninja
    

Github Actions for Windows Release

Github actions is merely activated in a github-actions branches. Decision is needed to made where github actions is necessary or not. One might modify the .github/workflows/msys2-build-and-release.yml to select the specific branch.

name: Build and Release OC6P (MSYS2 and NSIS)

on:
  push:
    branches:
      - github-actions # replace this line with the exact branch to be released.
    tags:
      - 'v*.*.*'
  workflow_dispatch:

@zhongjingjogy zhongjingjogy changed the title Add CMake Support for Cross-Platform Builds of OpenCalphad CMake Support for Cross-Platform Builds and Github Actions for Windows Release Oct 12, 2024
@CINTROINI
Copy link

CMake Support for Cross-Platform Builds

People might want to build opencalphad with CMake and using toolchain on different platforms.

Targets

  • Build the oc library
  • Build the command line interface, i.e., oc6p
  • Build the Fortran examples using liboctq.F90. (Note that there are multiple version of libooctq.F90 and a unified one might be needed.)

Disadvantages

  • Time is needed to be spent to check if everything is fine.
  • Dependency on CMake is needed.
  • For Windows, Msys2 is needed and the related toolchains should be installed correctly.

Advantages

  • Multi-Platform Support: CMake is designed to work across multiple platforms (Windows, Linux, macOS, etc.) and with various compilers (GCC, Intel, etc.). This ensures that Fortran project can be built and run on different environments without significant modifications.
  • Modular Design: CMake allows you to break down the project into smaller, reusable modules. This makes it easier to manage large projects with multiple source files and dependencies.

Prerequisite:

  • CMake
  • Fortran compiler
  • C compiler
  • C++ compiler

Tested on:

  • Windows with MSYS2 + MinGW-w64 (gcc version 14.2.0)
  • Ubuntu 20.04 with GCC (gcc version 9.4.0)

Steps to build:

  1. Clone the repository

  2. Create a build directory and run cmake

    • Linux:
    mkdir build
    cd build
    cmake ../
    make
    
    • Windows with MSYS2 + MinGW-w64:
    mkdir build
    cd build
    cmake ../ -G Ninja
    ninja
    

Github Actions for Windows Release

Github actions is merely activated in a github-actions branches. Decision is needed to made where github actions is necessary or not. One might modify the .github/workflows/msys2-build-and-release.yml to select the specific branch.

name: Build and Release OC6P (MSYS2 and NSIS)

on:
  push:
    branches:
      - github-actions # replace this line with the exact branch to be released.
    tags:
      - 'v*.*.*'
  workflow_dispatch:

Hi @zhongjingjogy ,

thanks for this PR.
Please find another CMakelist.txt file CMakeLists.txt I'm using for my projets.

I prefer separate the building of the standalone program and the dynamic libraries from the coupling of OC with other C++, Python or Fortran codes.

Here, the build of OC only generate the binary for standalone use and the 'libOPENCALPHAD' library that I use elsewhere in other C++ projects.

CI

@zhongjingjogy
Copy link
Author

Merge CINTROINI's implementation and Try to align CMake Variable naming convention with each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants