dear CMake developers,

We have observed a changed and surprising behavior
in CMake 3.3.0-rc3 with Fortran module dependency scanning and
preprocessing compared to earlier CMake versions
(for instance 3.2.3). I have checked open bugs and email
list archives but could not find this mentioned.

To give an example the following Fortran source fails to compile:
"""
program example
#ifdef SOMEDEF
   use mymodule
#endif
   call hello()
end program
"""

with:
"""
main.F90:3:7:

    use mymodule
       1
Fatal Error: Can't open module file ‘mymodule.mod’ for reading at (1): No
such file or directory
"""

It seems that Fortran dependencies are scanned prior
to pre-processing. This seems different compared to 3.2.3 (and earlier
versions). Not sure this is a bug or a feature.
All relevant files (CMakeLists.txt, main.F90, mymodule.F90) for a complete
minimal example are attached.
I can also submit this directly to http://www.cmake.org/Bug/
in case this is not a feature.

Thank you and best wishes,
  radovan
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(example)

enable_language(Fortran)

add_definitions(-DSOMEDEF)

add_executable(example.x main.F90 mymodule.F90)
#ifdef SOMEDEF
module mymodule

contains
   subroutine hello()
       print *, 'hello'
   end subroutine
end module
#else
subroutine empty()
end subroutine
#endif
program example
#ifdef SOMEDEF
   use mymodule
#endif
   call hello()
end program
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to