Use cpp as the preprocessor for headers.

This commit is contained in:
Ye Luo 2020-10-17 14:20:12 -05:00
parent d86dc2b81d
commit 419c89bcdf
3 changed files with 8 additions and 5 deletions

View File

@ -162,10 +162,12 @@ if(QE_ENABLE_OPENMP)
endif(QE_ENABLE_OPENMP)
############################################################
## Compiler specific options
## Compiler vendor specific options
############################################################
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
include(${PROJECT_CMAKE}/GNUFortranCompiler.cmake)
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI")
include(${PROJECT_CMAKE}/NVFortranCompiler.cmake)
endif()
############################################################

View File

@ -0,0 +1,2 @@
# set optimization specific flags
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mcache_align -Mlarge_arrays")

View File

@ -22,8 +22,8 @@ function(qe_get_global_compile_definitions OUTVAR)
endfunction(qe_get_global_compile_definitions)
function(qe_get_fortran_cpp_flag OUTVAR)
if(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")
set(${OUTVAR} "-Mpreprocess" PARENT_SCOPE) # :'(
if(DEFINED QE_Fortran_PREPROCESSOR_FLAGS)
set(${OUTVAR} "${QE_Fortran_PREPROCESSOR_FLAGS}" PARENT_SCOPE)
else()
# TODO actual flag check
set(${OUTVAR} "-cpp" PARENT_SCOPE)
@ -31,7 +31,6 @@ function(qe_get_fortran_cpp_flag OUTVAR)
endfunction(qe_get_fortran_cpp_flag)
function(qe_preprocess_source IN OUT)
qe_get_fortran_cpp_flag(f_cpp_flag)
qe_get_global_compile_definitions(global_defs)
foreach(DEF ${global_defs})
list(APPEND global_flags "-D${DEF}")
@ -42,7 +41,7 @@ function(qe_preprocess_source IN OUT)
endif()
add_custom_command(
OUTPUT ${OUT}
COMMAND "${CMAKE_Fortran_COMPILER}" ${f_cpp_flag} ${global_flags} -E ${IN} > ${OUT}
COMMAND cpp ${global_flags} -E ${IN} > ${OUT}
MAIN_DEPENDENCY ${IN}
COMMENT "Preprocessing ${IN}"
VERBATIM)