Hi all.<br><br>I have a problem with Fortran_MODULE_DIRECTORY only being applied in the first of several subdirectory projects. Here&#39;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 &quot;Unix Makefiles&quot; -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 &quot;Unix Makefiles&quot; 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 &quot;Unix Makefiles&quot; 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 &quot;-module foobar&quot; 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&#39;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.<br><br>Petr<br>