如何在设置-DCMAKE_BUILD_TYPE=Release时禁用cmake中的Fortran选项-DNDEBUG?

z2acfund  于 2022-12-04  发布在  其他
关注(0)|答案(1)|浏览(158)

使用英特尔Fortran编译器时,我的子例程在变量中包含NDEBUG。如果我使用-DCMAKE_BUILD_TYPE=Release发行版的cmake,则会自动出现错误,因为它的var值将更改为1。

error #5082: Syntax error, found INTEGER_CONSTANT '1' when expecting one of: %FILL <IDENTIFIER>
      INTEGER(LONG), PARAMETER        :: 1        =  250   ! Size of DEBUG array
-----------------------------------------^

它是

INTEGER(LONG), PARAMETER        :: NDEBUG        =  250

有线索吗?

unftdfkk

unftdfkk1#

我知道了。
删除CMAKE_Fortran_FLAGS_RELEASE_INIT中的/DNDEBUG任何任何发行版。如intel.cmake中所示

if (${__WINDOWS_INTEL} MATCHES 1)
set(CMAKE_Fortran_FLAGS_MINSIZEREL "/O1")
set(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "/O1")
set(CMAKE_Fortran_FLAGS_RELEASE "/O2")
set(CMAKE_Fortran_FLAGS_RELEASE_INIT "/O2")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "/O2 /debug:full")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "/O2 /debug:full")
set(CMAKE_CXX_FLAGS_RELEASE= /O3 /Ob2)
set(CMAKE_CXX_FLAGS_RELEASE_INIT= /O3 /Ob2)
endif()

相关问题