Hi everyone,
I’m working on a Fortran project, using CMake as a build system generator.
To support multiple platforms, I do make use of genexes to control conditional options/definitions:
if (WIN32)
if (intel-compiler)
add_compile_options(
$<$<COMPILE_LANGUAGE:Fortran>:-warn:all>
$<$<COMPILE_LANGUAGE:Fortran>:-stand:f18>
)
endif()
else()
if (intel-compiler)
add_compile_options(
$<$<COMPILE_LANGUAGE:Fortran>:-warn all>
$<$<COMPILE_LANGUAGE:Fortran>:-stand f18>
)
else()
add_compile_options(
$<$<COMPILE_LANGUAGE:Fortran>:-Wall>
$<$<COMPILE_LANGUAGE:Fortran>:-Wimplicit-interface>
$<$<COMPILE_LANGUAGE:Fortran>:-Wunused-parameter>
$<$<COMPILE_LANGUAGE:Fortran>:-pedantic>
$<$<COMPILE_LANGUAGE:Fortran>:-std=f2018>
)
endif()
endif()
First, the problem: when compiling using Intel compilers on UNIX OS, I get following error:
Scanning dependencies of target BsaLib
[ 3%] Building Fortran object src/CMakeFiles/BsaLib.dir/BsaLib.F90.o
ifort: error #10236: File not found: '$<1:-warn'
ifort: error #10236: File not found: 'all>'
ifort: command line warning #10006: ignoring unknown option '-assume nocc_omp'
ifort: command line warning #10006: ignoring unknown option '-qparallel'
gmake[2]: *** [src/CMakeFiles/BsaLib.dir/build.make:75: src/CMakeFiles/BsaLib.dir/BsaLib.F90.o] Error 1
gmake[2]: *** Deleting file 'src/CMakeFiles/BsaLib.dir/BsaLib.F90.o'
gmake[1]: *** [CMakeFiles/Makefile2:116: src/CMakeFiles/BsaLib.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
Looks like the compile options are not correctly passed (if I disable them all, compiles and run fine). Any suggestion on the source of the problem?
Then, I would realy appreciate if experts might suggest a better, more sustainable approach to do such thing of supporting different platforms.
Thanks everybody!