# CMake --build error: file not found

**URL:** <https://discourse.cmake.org/t/cmake-build-error-file-not-found/10331>\
**Category:** Code\
**Tags:** os:linux, gen:makefiles\
**Created:** [March 8, 2024, 3:35pm UTC](https://discourse.cmake.org/t/cmake-build-error-file-not-found/10331 "2024-03-08T15:35:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![asimplecoder](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/f17d59/32.png) [@asimplecoder](https://discourse.cmake.org/u/asimplecoder)\
**Post date:** [March 8, 2024, 3:35pm UTC](https://discourse.cmake.org/t/cmake-build-error-file-not-found/10331/1 "2024-03-08T15:35:03Z")

</div>

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:

```cmake
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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)\
**Post date:** [March 8, 2024, 8:59pm UTC](https://discourse.cmake.org/t/cmake-build-error-file-not-found/10331/2 "2024-03-08T20:59:22Z")

</div>

Cannot have space in genex. Put a semicolon between `warn;all`

---

<div class="post-metadata">

**Author:** ![asimplecoder](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/f17d59/32.png) [@asimplecoder](https://discourse.cmake.org/u/asimplecoder)\
**Post date:** [March 9, 2024, 6:33am UTC](https://discourse.cmake.org/t/cmake-build-error-file-not-found/10331/3 "2024-03-09T06:33:04Z")

</div>

@scivision thanks for the remark! I did not think about the whitespace issue.

I found out that with the semicolon `;`, I also needed to quote the whole genex expression:

```auto
add_compile_options(
         "$<$<COMPILE_LANGUAGE:Fortran>:-warn;all>"
         "$<$<COMPILE_LANGUAGE:Fortran>:-stand;f18>"
)

```

Without quoting, apparently the compiler complains about:

```plaintext
ifort: command line warning #10006: ignoring unknown option '-warn all'
ifort: command line warning #10006: ignoring unknown option '-stand f18'

```

but those are indeed valid flags.

I wonder why is that, since from the docs, quoting should fix trhe spacing issue, but here apparently both quoting and `;` in place of the space are needed for it to work.

EDIT: ok, thinking about it, maybe only quoting the genex makes CMake to `' single quote '` the expression containing spaces, which is indeed invalid option because of the quotes.

---

<div class="post-metadata">

**Author:** ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)\
**Post date:** [March 10, 2024, 2:42am UTC](https://discourse.cmake.org/t/cmake-build-error-file-not-found/10331/4 "2024-03-10T02:42:55Z")

</div>

Yes I forgot to say quote and semicolon

---

<div class="post-metadata">

**Author:** ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)\
**Post date:** [March 10, 2024, 2:45am UTC](https://discourse.cmake.org/t/cmake-build-error-file-not-found/10331/5 "2024-03-10T02:45:16Z")

</div>

If you use `C_BOOL` between C or C++ and Fortran with Intel compiler you will need

```cmake
"$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<NOT:$<BOOL:${WIN32}>>>:-fpscomp;logicals>"

```

> **[Fortran logical boolean C\_BOOL](https://www.scivision.dev/fortran-logical-byte-size/)**
>
> Fortran uses 4-byte booleans, while C/C++ typically uses 1-byte bool. Intel oneAPI needs -fpscomp logicals to use correct values.
