2015-10-22 81 views

回答

0

有一個叫Fortran_MODULE_DIRECTORY

良好的措施一個目標屬性,我還添加模塊目錄的目錄裏。 gfortran在包含目錄中查找.mod文件。

set_target_properties(Target PROPERTIES Fortran_MODULE_DIRECTORY "dir") 
target_include_directories(Target PUBLIC "dir") 

編輯

通讀你的問題,我再次看到模塊你有興趣在已經編譯。 Fortran_MODULE_DIRECTORY指定在哪裏PUT .mod文件,並將該目錄添加爲查找它們的位置。 target_include_directories聲明只是指定在哪裏尋找它們。我最熟悉使用gfortran,其中有這它的手冊頁:

-Idir 
     These affect interpretation of the "INCLUDE" directive (as well as of the "#include" directive of the 
     cpp preprocessor). 

     Also note that the general behavior of -I and "INCLUDE" is pretty much the same as of -I with 
     "#include" in the cpp preprocessor, with regard to looking for header.gcc files and other such things. 

     This path is also used to search for .mod files when previously compiled modules are required by a 
     "USE" statement. 

    -Jdir 
     This option specifies where to put .mod files for compiled modules. It is also added to the list of 
     directories to searched by an "USE" statement. 

     The default is the current directory. 

這是CMake的會爲你和你的編譯器做的;你不需要明確指定這些標誌。在你的情況下,只要包含就足夠了,因爲模塊已經被編譯。

但是,如果您發現它不適用於您的編譯器,則可能需要通過設置變量CMAKE_Fortran_FLAGS來手動指定它們。

希望這會有所幫助。

+0

set_target_properties暫停編譯其他模塊,所以我只是把target_include_directories,但我不知道我在做什麼。我是否需要向SET_TARGET_PROPERTIES添加一些內容? – Gonzague

+0

@Gonzague查看編輯答案 – dwwork

相關問題