Use temp file for config vars to avoid rebuild
When generating the config.h configuration file, write to a temporary first and then rename afterward to avoid touching the file and thus triggering a complete rebuild (of everything that includes config.h) unnecessarily.
This commit is contained in:
parent
234be65229
commit
4942763ddd
@ -187,7 +187,10 @@ endif (NOT HAVE_ERT)
|
||||
# includes the necessary defines by the dependencies
|
||||
include (ConfigVars)
|
||||
list (APPEND ${project}_CONFIG_VARS ${${project}_CONFIG_VAR})
|
||||
set (CONFIG_H "${PROJECT_BINARY_DIR}/config.h")
|
||||
|
||||
# write configuration variables to this file. note that it is a temporary.
|
||||
message (STATUS "Writing config file \"${PROJECT_BINARY_DIR}/config.h\"...")
|
||||
set (CONFIG_H "${PROJECT_BINARY_DIR}/config.h.tmp")
|
||||
configure_vars (
|
||||
FILE CXX ${CONFIG_H}
|
||||
WRITE ${${project}_CONFIG_VARS}
|
||||
@ -199,6 +202,13 @@ define_fc_func (
|
||||
IF HAVE_AGMG # HAVE_BLAS HAVE_LAPACK
|
||||
)
|
||||
|
||||
# overwrite the config.h that is used by the code only if we have some
|
||||
# real changes. thus, we don't have to recompile if a reconfigure is run
|
||||
# due to some files being added, for instance
|
||||
execute_process (COMMAND
|
||||
${CMAKE_COMMAND} -E copy_if_different ${CONFIG_H} ${PROJECT_BINARY_DIR}/config.h
|
||||
)
|
||||
|
||||
# compile main library; pull in all required includes and libraries
|
||||
include (OpmCompile)
|
||||
opm_compile (${project})
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
function (configure_vars obj syntax filename verb)
|
||||
# this is just to make the syntax look like the build-in commands
|
||||
message (STATUS "Writing config file \"${filename}\"...")
|
||||
if (NOT ("${obj}" STREQUAL "FILE" AND
|
||||
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
|
||||
message (FATAL_ERROR "Syntax error in argument list")
|
||||
@ -47,10 +46,10 @@ function (configure_vars obj syntax filename verb)
|
||||
# to avoid confusion from other configuration files.
|
||||
get_filename_component (_config_path "${filename}" PATH)
|
||||
get_filename_component (_config_file "${filename}" NAME)
|
||||
if ("${_config_file}" STREQUAL "config.h")
|
||||
if ("${_config_file}" MATCHES "config\\.h(\\..+)?")
|
||||
add_definitions (-DHAVE_CONFIG_H=1)
|
||||
include_directories (BEFORE "${_config_path}")
|
||||
endif ("${_config_file}" STREQUAL "config.h")
|
||||
endif ("${_config_file}" MATCHES "config\\.h(\\..+)?")
|
||||
|
||||
# only write the current value of each variable once
|
||||
set (_args ${ARGN})
|
||||
|
Loading…
Reference in New Issue
Block a user