我将我的一个项目移动到CMake(因为语法简单),我以前使用autotools(autoconf,automake等)。我遇到了一个小问题,CMake没有意识到我的源代码树中有FORTRAN代码。
我构建的库之一取决于C ++和FORTRAN源代码。我使用以下语法来构建库
add_library(matrix
double/matrix_constructor_double.cpp
double/matrix_io_double.cpp
double/matrix_miscmath_double.cpp
double/matrix_miscop_double.cpp
double/matrix_overload_double.cpp
double/matrix_setters_double.cpp
double/eigsrt_double.f
double/pkconv_double.f)
CMake运行得很好,但是当我尝试制作项目时,我得到以下内容:
Scanning dependencies of target matrix
[ 45%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_constructor_double.cpp.o
[ 50%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_io_double.cpp.o
[ 54%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_miscmath_double.cpp.o
[ 59%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_miscop_double.cpp.o
[ 63%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_overload_double.cpp.o
[ 68%] Building CXX object src/matrix/CMakeFiles/matrix.dir/double/matrix_setters_double.cpp.o
它完全忽略了我已经指定了FORTRAN代码。在autotools中,这不是问题。此外,CMake也没有认识到我有FORTRAN代码,即
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dbwy/git_repo/chronusq/build
如果我尝试手动指定FORTRAN编译器,我会得到以下内容
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_Fortran_COMPILER
我的CMake中是否缺少一些与FORTRAN一起工作的功能?我使用的是cmake 3.0.2
答案 0 :(得分:1)
尝试将Fortran指定为cmake项目的语言。默认情况下,只启用C和C ++:
您可以选择指定项目支持的语言。示例语言是C,CXX(即C ++),Fortran等。默认情况下,如果没有给出语言选项,则启用C和CXX。指定语言NONE,或使用LANGUAGES关键字并列出无语言,以跳过启用任何语言。
http://www.cmake.org/cmake/help/v3.2/command/project.html
类似的东西:
project(foo C CXX Fortran)