Skip to content

Windows Build Terminal

Fabian Wein edited this page Oct 30, 2023 · 25 revisions

This is a brief guiedeline to build Windows on command line using Intel oneAPI for the Fortran compiler and mkl.

Install buildchain

  • Install Microsoft Visual Studio Community Edition for C++ with build tools (nmake, cmake, ...). Note that we will use the original cmake
  • Install Intel oneAPI C++/Fortran and Math Kernel Library with all dependent packages (the installer will help you) from oneAPI BaseKit and oneAPI HPCKit
  • Install git with options for command line
  • Install CMake from Kitware
  • Install a standard text editor like Notepad++ - one always needs a fast and good editor around :)

List of compilers

Compilers can be selected prior initial build generation by cmake by setting the environment variables CC, CXX and FC. E.g. set CC=ixc, set CXX=icx. Make sure, the compilers are in Path (e.g. call setvars). On Linux usually different executables are used for C and C++ compiler, e.g. icc and icpc for Intel classic compilers. On Windows the compilers are often combined C/C++ and the names change for Intel compilers - be careful and set double, e.g. CC=icx and CXX=icx

  • cl - Microsoft Visual Studio C/C++ compiler. Has so old OpenMP that openCFS itself will have only one thread.
  • icx - Intel oneAPI combined C/C++ compiler based on LLVM with MSVC compatible command line interface. At time of writing cannot compile boost - use MSVC precompiled.
  • (icpx - Intel oneAPI combined (C/?)C++ compiler based on LLVM with gcc compatible command line interface - don't use)
  • ifx - Intel oneAPI Fortran compiler based on LLVM
  • icl - Intel oneAPI classic combined C/C++ - announced to be removed mid 2023
  • ifort - Intel oneAPI classic Fortran compiler
  • clang, clang++ - LLVM compiler distributed Microsoft Visual Studio (check with --version)
  • (clang, clang++ - from Intel oneAPI in windows\bin-llvm. Seems to be icx and icpx. check with --version)

Setup buildchain

  • configure git and best is to add shh keys to the gitlab server (via ssh-keygen)
  • add C:\Program Files\Git\usr\bin to your Path in environment settings. openCFS need patch.exe from there. Make sure by calling patch --help on cmd that this worked. Otherwise openCFS will fail building it's cfsdeps.
  • add C:\Program Files (x86)\Intel\oneAPI to your Path and always run setvars before creating a new openCFS build directory with cmake
  • prepare a .cfs_platform_defaults.cmake and place it in your home directory. You can use the following content as a template
set(BUILD_TESTING_DEFAULT ON)
set(TESTSUITE_PYTHON ON)

# add here your personal defaults for convenience
set(USE_CGAL_DEFAULT OFF)
set(USE_EMBEDDED_PYTHON_DEFAULT OFF)

set(USER_HOME "$ENV{HOME}")

# setting CFS_DEPS_CACHE_DIR allows to share precompiled over builds
set(CFS_DEPS_CACHE_DIR_DEFAULT "${USER_HOME}/code/cfsdepscache")

# debug mode
if(CFS_BINARY_DIR MATCHES /debug)
  set(DEBUG_DEFAULT ON)
  set(USE_OPENMP_DEFAULT OFF)
endif()

First time build

  • start cmd and make sure that nmake /?, patch --help and ifx or ifort are found. On problems found, you probably forgot to call setvars
  • clone cfs e.g. to code\cfs in your home. E.g. git clone --recurse-submodules ssh://git@gitlab.com/openCFS/CFS.git cfs see git-workflow
  • create there a build directory, e.g. code\cfs\release and go there

CMake configuration

  • We assume to be in a created and empty (!) build directory within the cloned openCFS source.
  • One can either call cmake-gui .. or cmake .. -G "NMake Makefiles.
  • After the initial configuration one can always call cmake-gui . or cmake ., independent on what has been called before.
  • The . can be optionally used instead of .. after the initial call.

cmake-gui

  • With cmake-gui you can choose the Generator (e.g. NMake Makefiles) and choose the compilers before configuring openCFS.
  • All options can be checked and changed graphically.
  • On Windows there is no terminal based GUI ccmake as on other platforms.

cmake

  • to work purely terminal based (e.g. via ssh and Windows's OpenSSH-Server) you can change settings in cmake like cmake . -DUSE_EMBEDDED_PYTHON=ON. You can check current settings like grep USE CMakeCache.txt.
  • for a terminal based access keep your .cfs_platform_defaults.cmake in the home directory in shape.

CMake generators

cmake knows many generators. For Windows command line access, the two most common are "NMake Makefiles" which is the official Microsoft tool and "Ninja" which is also used on other platform.

nmake

  • select by cmake .. -G "NMake Makefiles"
  • nmake is very slow and cannot build in parallel, however it is the native solution and robust to use. It works similar to make on Linux, just with nmake.
  • default compilers are MSVC for C/C++ and ifx for Fortran. Note that openCFS runs itself only serial with MSVC due to too old OpenMP (but the external solvers are in parallel).
  • after cmake just run nmake to build openCFS

ninja

  • select by cmake .. -G Ninja
  • fast and parallel build tool for all platforms. More for the experienced ones.
  • Ninja comes with Visual Studio and does not need to be installed.
  • selects as default compilers icx,icpx and ifx but icpx will fail. So you need to select your C++ compiler manually. E.g. via set CC=icx and set CXX=icx.
  • ninja builds by default in parallel. But openCFS needs its dependencies built in serial. So first build with ninja -j 1 cfsdeps and then you can build the rest in parallel via ninja or ninja -j 5 if you want to control the number of threads (here to 5).

Boost issue

  • at time of writing (02.2023) the used boost version (1.78.0) cannot be build with Intel oneAPI 2023.0 C++ compilers.
  • the solution is to have a build of boost with MSVC and copy the precompiled package, e.g. from boost_1.78.0_WIN10_X86_64_C-MSVC-19.34.31937.0.zip to boost_1.78.0_WIN10_X86_64_C-IntelLLVM-2023.0.0.zip
  • for openAPI 2023.2 this also applies to muparser, vtk and flann.
  • for that it helps to have a fixed CFS_DEPS_CACHE_DIR e.g. in your .cfs_patform_defaults.cmake set via
set(USER_HOME "$ENV{HOME}")
set(CFS_DEPS_CACHE_DIR_DEFAULT "${USER_HOME}/code/cfsdepscache")

Clone this wiki locally