我正试图使我的CMake项目只能与Intel编译器一起使用。我已经开始from this thread,现在我有了这个CMakeLists.txt
半可用的cmake_minimum_required(VERSION 3.14)
project(oo Fortran)
enable_language(Fortran)
enable_language(C)
find_program(CMAKE_Fortran_COMPILER NAMES ifort)
find_program(CMAKE_C_COMPILER NAMES icc)
find_program(CMAKE_CXX_COMPILER NAMES icpc)
find_program(CMAKE_AR NAMES xiar)
find_program(CMAKE_LINKER NAMES xild)
if (CMAKE_Fortran_COMPILER MATCHES CMAKE_Fortran_COMPILER-NOTFOUND OR
CMAKE_C_COMPILER MATCHES CMAKE_C_COMPILER-NOTFOUND OR
CMAKE_CXX_COMPILER MATCHES CMAKE_CXX_COMPILER-NOTFOUND OR
CMAKE_AR MATCHES CMAKE_AR-NOTFOUND OR
CMAKE_LINKER MATCHES CMAKE_LINKER-NOTFOUND)
message(FATAL_ERROR "Cannot find Intel compiler. You may need to run `. /opt/intel/bin/compilervars.sh intel64'")
endif ()
message(">>>>> ${CMAKE_C_COMPILER}")
message(">>>>> ${CMAKE_CXX_COMPILER}")
message(">>>>> ${CMAKE_Fortran_COMPILER}")
message(">>>>> ${CMAKE_AR}")
message(">>>>> ${CMAKE_LINKER}")
set(dialect "-w -qopenmp -stand f18 -free -u -qopenmp-simd -qopt-report=5 -mavx -arch AVX")
set(bounds "-w -qopenmp -check bounds")
set(symbols "-debug full")
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${dialect} ${bounds} ${symbols}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
add_executable(oo animal_module.f90 cat_module.f90 main.f90)
set_property(TARGET oo PROPERTY LINKER_LANGUAGE Fortran)
文件:
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/sensei/Documents/Projects/oo
-- The Fortran compiler identification is Intel 19.0.4.20190416
-- Check for working Fortran compiler: /usr/local/bin/ifort
-- Check for working Fortran compiler: /usr/local/bin/ifort -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/local/bin/ifort supports Fortran 90
-- Checking whether /usr/local/bin/ifort supports Fortran 90 -- yes
-- The C compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
>>>>> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
>>>>> /usr/local/bin/icpc
>>>>> /usr/local/bin/ifort
>>>>> /usr/bin/ar
>>>>> /usr/bin/ld
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/sensei/Documents/Projects/oo/cmake-build-debug
[Finished]
问题在于它可以正确找到Intel的C ++编译器,Fortran编译器,但没有找到我所要求的其他选项(C,链接器,汇编器),并且将其设置为Apple的。您可以从输出中看到:
CMAKE_FORCE_C_COMPILER
这当然是来自命令行和CLion,我也读过httptest.NewRecorder()
和类似内容,但they are deprecated也是如此。
关于为什么发生这种情况的任何线索吗?