libprima / prima

PRIMA is a package for solving general nonlinear optimization problems without using derivatives. It provides the reference implementation for Powell's derivative-free optimization methods, i.e., COBYLA, UOBYQA, NEWUOA, BOBYQA, and LINCOA. PRIMA means Reference Implementation for Powell's methods with Modernization and Amelioration, P for Powell.
http://libprima.net
BSD 3-Clause "New" or "Revised" License
291 stars 35 forks source link

Fix compilation with Intel compiler on Windows #118

Closed TLCFEM closed 5 months ago

TLCFEM commented 7 months ago

Some changes to make it compile with Intel compiler.

jschueller commented 7 months ago
TLCFEM commented 7 months ago
  • we already supported some of the new and old versions of intel compilers what version are you using, maybe its something we do not support yet ?

It is mainly about the VS generator. Things are all fine with ninja. For VS, mixing source files is not supported. So have to split into two object libraries.

add_library(primac_f OBJECT cintrf.f90 cobyla_c.f90 lincoa_c.f90 bobyqa_c.f90 newuoa_c.f90 uobyqa_c.f90)
add_library(primac_c OBJECT prima.c)

Then need to define the macro add_compile_definitions(PRIMAC_EXPORTS).

Also, the .mod files are not placed directly under fortran/mod but fortran/mod/${CMAKE_CFG_INTDIR} for VS generator, so need to include this folder otherwise .mod cannot be found.

  • the declspec macros should only appear in declaration, never in definition so I doubt this is correct

Indeed, it is not correct. They have been reverted.

jschueller commented 7 months ago
TLCFEM commented 7 months ago
  • so you should modify the macro in prima.h to use primac_c_EXPORTS, not define another one

primac_c_EXPORTS is also not defined since now primac_c is an object library not a shared one. I think target_EXPORTS is only defined for shared libraries.

TLCFEM commented 7 months ago
  • this should be added to be tested in the github workflow cmake.yml

Depending on how you want it to be, there are multiple options, like,

  1. add a parallel step
      - name: Build
        if: ${{ matrix.os == 'windows-latest' }}
        run: |
          cmake --version
          cmake -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=. -LAH -DCMAKE_C_FLAGS="${{ matrix.toolchain.cflags }}" -DCMAKE_Fortran_FLAGS="${{ matrix.toolchain.fflags }}" .
  2. add matrix.generator = ninja and specialise later in matrix.include.
jschueller commented 7 months ago

The simpler the better

zaikunzhang commented 6 months ago

Thank you @TLCFEM for proposing this. Excuse me for the late response. Is there an agreement on this? Thanks.