2012-07-12 44 views
0

我有一個使用cmake構建的fortran代碼版本。目前它正在Mac OS X上工作,但是當我嘗試在Linux上構建它時,它失敗了。 Cmake成功生成makefile,但是當我嘗試運行makefile時,嘗試複製模塊時失敗。cmake在linux上覆制fortran模塊失敗

頂級cmake的文件是:

cmake_minimum_required (VERSION 2.8) 

# Start Project and note the language used. 
project (v3fit_suite Fortran) 

# Set a directories to build all binary files. 
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/bin) 
set (LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/lib) 

# Fortran specific settings. The first setting tells the compiler to use the C preprocessor. The second places a common directory to place all of the module files. 
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp") 
set (CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build/modules) 

# List all the subdirectories these are in library dependancy order. 
add_subdirectory (LIBSTELL) 
add_subdirectory (VMEC2000) 
add_subdirectory (V3FITA) 
add_subdirectory (MAKEGRID) 
add_subdirectory (V3POST) 
add_subdirectory (V3RFUN) 

所有模塊應該被複制到構建/模塊。當我運行在Linux上使用詳細的Makefile文件= 1,我得到:

/usr/bin/cmake -H/home/user/reconstruction -B/home/user/reconstruction --check-build-system CMakeFiles/Makefile.cmake 0 
/usr/bin/cmake -E cmake_progress_start /home/user/reconstruction/CMakeFiles /home/user/reconstruction/CMakeFiles/progress.marks 
make -f CMakeFiles/Makefile2 all 
make[1]: Entering directory `/home/user/reconstruction' 
make -f LIBSTELL/CMakeFiles/stell.dir/build.make LIBSTELL/CMakeFiles/stell.dir/depend 
make[2]: Entering directory `/home/user/reconstruction' 
cd /home/user/reconstruction && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/user/reconstruction /home/user/reconstruction/LIBSTELL /home/user/reconstruction /home/user/reconstruction/LIBSTELL /home/user/reconstruction/LIBSTELL/CMakeFiles/stell.dir/DependInfo.cmake --color= 
make[2]: Leaving directory `/home/user/reconstruction' 
make -f LIBSTELL/CMakeFiles/stell.dir/build.make LIBSTELL/CMakeFiles/stell.dir/requires 
make[2]: Entering directory `/home/user/reconstruction' 
make -f LIBSTELL/CMakeFiles/stell.dir/build.make LIBSTELL/CMakeFiles/stell.dir/Sources/Modules/stel_kinds.f.o.provides.build 
make[3]: Entering directory `/home/user/reconstruction' 
/usr/bin/cmake -E cmake_progress_report /home/user/reconstruction/CMakeFiles 
[ 0%] Building Fortran object LIBSTELL/CMakeFiles/stell.dir/Sources/Modules/stel_kinds.f.o 
cd /home/user/reconstruction/LIBSTELL && /usr/bin/f95 -o CMakeFiles/stell.dir/Sources/Modules/stel_kinds.f.o -cpp -J../build/modules -c /home/user/reconstruction/LIBSTELL/Sources/Modules/stel_kinds.f 
/usr/bin/cmake -E cmake_copy_f90_mod build/modules/stel_kinds LIBSTELL/CMakeFiles/stell.dir/stel_kinds.mod.stamp GNU 
Error copying Fortran module "build/modules/stel_kinds". Tried "build/modules/STEL_KINDS.mod" and "build/modules/stel_kinds.mod". 
make[3]: *** [LIBSTELL/CMakeFiles/stell.dir/Sources/Modules/stel_kinds.f.o.provides.build] Error 1 
make[3]: Leaving directory `/home/user/reconstruction' 
make[2]: *** [LIBSTELL/CMakeFiles/stell.dir/Sources/Modules/stel_kinds.f.o.provides] Error 2 
make[2]: Leaving directory `/home/user/reconstruction' 
make[1]: *** [LIBSTELL/CMakeFiles/stell.dir/all] Error 2 
make[1]: Leaving directory `/home/user/reconstruction' 
make: *** [all] Error 2 

我使用gfortran作爲我的編譯器,而不是f95的時候有同樣的問題。爲什麼在Mac OS X上工作但在Linux上失敗?在Mac OS X上,我安裝了2.8.8版本的cmake和Linux版本2.8。

+0

該錯誤表明腳本由於某種原因找不到該文件。文件「build/modules/stel_kinds.mod」存在嗎? – Wug 2012-07-12 16:15:02

回答

0

原來有一個看似無關的錯誤導致了問題。我有一些語句來添加一個空的包含路徑。

find_library (NETCDF_F netcdff PATHS ${NETCDF_LIB_PATH}) 
find_file (NETCDF_I netcdf.inc ${NETCDF_INC_PATH}) 
if (NETCDF_C AND NETCDF_F AND NETCDF_I) 
    message (STATUS "Using netcdf") 
    set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -D NETCDF -I ${NETCDF_INC_PATH}") 
endif() 

即使'NETCDF_INC_PATH'爲空時,if語句總是顯示爲true。這在編譯器命令行中導致了一個額外的-I,它將所有東西搞砸了。