[CMake] Fortran_MODULE_DIRECTORY ignored in second subdir

Petr Kmoch petr.kmoch at gmail.com
Tue Feb 12 08:15:50 EST 2013


Hi all.

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:

$cat source_dir/CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.7)

project(Top) # No Fortran here

add_executable(topper src/main.cpp)

add_subdirectory(sub)
add_subdirectory(sub2)
##

$cat source_dir/sub/CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.7)

project(Fort Fortran)

add_executable(exe src/exe.f)
set_target_properties(exe PROPERTIES Fortran_MODULE_DIRECTORY foobar)
##

$cat source_dir/sub2/CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.7)

project(Fort2 Fortran)

add_executable(exe2 src/exe.f)
set_target_properties(exe2 PROPERTIES Fortran_MODULE_DIRECTORY foobar)
##

I run CMake like this:
$cd build_dir
$FC=ifort cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING=Debug
../source_dir

Then, I have this output:
$cat sub/CMakeFiles/exe.dir/flags.make
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

# compile Fortran with /some_path_to_ifort/ifort
Fortran_FLAGS = -g -module foobar

Fortran_DEFINES =
##

$cat sub2/CMakeFiles/exe2.dir/flags.make
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

# compile Fortran with /some_path_to_ifort/ifort
Fortran_FLAGS = -g

Fortran_DEFINES =
##

The flags "-module foobar" are only present in sub, not in sub2. Am I doing
something wrong, or is that a bug in CMake?

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?

Thanks in advance.

Petr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130212/7ba4168b/attachment.htm>


More information about the CMake mailing list