I forgot to add that if, immediately after running CMake, I run it again (without changing a single file), the flags "-module foobar" appear in the sub2/.../flags.cmake as well.<br><br>Petr<br><br><div class="gmail_quote">
On Tue, Feb 12, 2013 at 2:15 PM, Petr Kmoch <span dir="ltr"><<a href="mailto:petr.kmoch@gmail.com" target="_blank">petr.kmoch@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all.<br><br>I have a problem with Fortran_MODULE_DIRECTORY only being applied in the first of several subdirectory projects. Here's a simplified setup to demonstrate the issue. It has a toplevel C++ project and two subdirectory projects which use Fortran:<br>
<br>$cat source_dir/CMakeLists.txt:<br>cmake_minimum_required(VERSION 2.8.7)<br><br>project(Top) # No Fortran here<br><br>add_executable(topper src/main.cpp)<br><br>add_subdirectory(sub)<br>add_subdirectory(sub2)<br>##<br>
<br>$cat source_dir/sub/CMakeLists.txt:<br>cmake_minimum_required(VERSION 2.8.7)<br><br>project(Fort Fortran)<br><br>add_executable(exe src/exe.f)<br>set_target_properties(exe PROPERTIES Fortran_MODULE_DIRECTORY foobar)<br>
##<br><br>$cat source_dir/sub2/CMakeLists.txt:<br>cmake_minimum_required(VERSION 2.8.7)<br><br>project(Fort2 Fortran)<br><br>add_executable(exe2 src/exe.f)<br>set_target_properties(exe2 PROPERTIES Fortran_MODULE_DIRECTORY foobar)<br>
##<br><br>I run CMake like this:<br>$cd build_dir<br>$FC=ifort cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING=Debug ../source_dir<br><br>Then, I have this output:<br>$cat sub/CMakeFiles/exe.dir/flags.make<br>
# CMAKE generated file: DO NOT EDIT!<br># Generated by "Unix Makefiles" Generator, CMake Version 2.8<br><br># compile Fortran with /some_path_to_ifort/ifort<br>Fortran_FLAGS = -g -module foobar<br><br>Fortran_DEFINES =<br>
##<br><br>$cat sub2/CMakeFiles/exe2.dir/flags.make<br># CMAKE generated file: DO NOT EDIT!<br># Generated by "Unix Makefiles" Generator, CMake Version 2.8<br><br># compile Fortran with /some_path_to_ifort/ifort<br>
Fortran_FLAGS = -g<br><br>Fortran_DEFINES =<br>##<br><br>The flags "-module foobar" are only present in sub, not in sub2. Am I doing something wrong, or is that a bug in CMake?<br><br>My real setup doesn't really allow me to enable Fortran in the toplevel project; is there a way to make this work without that?<br>
<br>Thanks in advance.<span class="HOEnZb"><font color="#888888"><br><br>Petr<br>
</font></span></blockquote></div><br>