mirror of https://gitlab.com/QEF/q-e.git
Merge branch 'allow-alternative-CPP' into 'develop'
[CMake] Allow setting QE_CPP for an alternative C preprocessor. Closes #359 See merge request QEF/q-e!1513
This commit is contained in:
commit
9cd47e8d26
|
@ -215,7 +215,28 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI" OR CMAKE_Fortran_COMPILER_ID MATCHES
|
|||
endif()
|
||||
|
||||
############################################################
|
||||
## Compiler vendor specific options
|
||||
# C preprocessor
|
||||
# Note: reply on the compiler preprocessor whenever possible
|
||||
############################################################
|
||||
if(DEFINED ENV{CPP})
|
||||
set(QE_CPP_DEFAULT $ENV{CPP})
|
||||
else()
|
||||
set(QE_CPP_DEFAULT cpp)
|
||||
endif()
|
||||
# QE_CPP_DEFAULT is only effective when cached QE_CPP doesn't exist.
|
||||
set(QE_CPP ${QE_CPP_DEFAULT} CACHE
|
||||
STRING "C preprocessor for qe_preprocess_source in qeHelpers.cmake")
|
||||
find_program(QE_CPP_FULL_PATH NAMES ${QE_CPP} DOC "C preprocessor full path")
|
||||
if(QE_CPP_FULL_PATH)
|
||||
message(STATUS "C preprocessor used by qe_preprocess_source in qeHelpers.cmake: ${QE_CPP_FULL_PATH}")
|
||||
else()
|
||||
set(QE_CPP_SAVED ${QE_CPP})
|
||||
unset(QE_CPP CACHE)
|
||||
message(FATAL_ERROR "C preprocessor ${QE_CPP_SAVED} not found. Pass a working one to CMake via QE_CPP!")
|
||||
endif()
|
||||
|
||||
############################################################
|
||||
# Compiler vendor specific options
|
||||
############################################################
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
|
||||
include(${PROJECT_CMAKE}/GNUFortranCompiler.cmake)
|
||||
|
|
|
@ -41,7 +41,7 @@ function(qe_preprocess_source IN OUT)
|
|||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT ${OUT}
|
||||
COMMAND cpp -P ${global_flags} -E ${IN} > ${OUT}
|
||||
COMMAND ${QE_CPP_FULL_PATH} -P ${global_flags} -E ${IN} > ${OUT}
|
||||
MAIN_DEPENDENCY ${IN}
|
||||
COMMENT "Preprocessing ${IN}"
|
||||
VERBATIM)
|
||||
|
|
Loading…
Reference in New Issue