我正在尝试编译一个使用cmake
与几个库链接的fortran二进制文件。
add_executable(myexe
${CMAKE_SOURCE_DIR}/source/myexe.cpp
${CMAKE_CURRENT_SOURCE_DIR}/API/F90/mod.f
${CMAKE_CURRENT_SOURCE_DIR}/API/F90/main.f)
set_property(TARGET myexe PROPERTY LINKER_LANGUAGE Fortran)
target_link_libraries(myexe mylib1 mylib2)
install(TARGETS myexe DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
mylib1
和mylib2
是同一项目中的目标,可以毫无问题地进行编译。但是,链接器会为myexe
生成以下警告:
ifort: warning #10145: no action performed for file '/path/to/libmylib1.a'
ifort: warning #10145: no action performed for file '/path/to/libmylib2.a'
和make install
失败,并显示以下错误:
file INSTALL cannot find
"/path/to/myexe"
我调查了link.txt
以查看链接器命令,发现了这一点:
/usr/local/bin/ifort -c -lc++11 CMakeFiles/myexe.dir/__/source/myexe.cpp.o CMakeFiles/myexe.dir/API/F90/mod.f.o CMakeFiles/myexe.dir/API/F90/main.f.o -o myexe -Wl,-rpath,/path/to/lib/install/ ../LIB1/libmylib.a ../LIB2/libmylib2.a
我该怎么做才能更正此链接器命令并解决我的错误?
我的cmake版本是:
cmake version 3.14.1