Make sure HAVE_${MODULE} is always defined in all scopes.

1. Was a normal variable if no test program was compiled before.
  that meant HAVE_DUNE_FEM was not defined even if dune-fem was found.
2. The if-statement checking whether there is something to compile was
   wrong as this is macro and hence prog is not a variable. Resorted
   to comparison to empty string.
This commit is contained in:
Markus Blatt 2022-10-12 22:22:10 +02:00
parent 499663f048
commit 20e3202067

View File

@ -124,7 +124,7 @@ macro (find_opm_package module deps header lib defs prog conf)
# without config.h
config_cmd_line (${module}_CMD_CONFIG ${module}_CONFIG_VARS)
if(prog)
if(NOT "${prog}" STREQUAL "")
# check that we can compile a small test-program
include (CMakePushCheckState)
cmake_push_check_state ()
@ -138,13 +138,16 @@ macro (find_opm_package module deps header lib defs prog conf)
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG})
check_cxx_source_compiles ("${prog}" HAVE_${MODULE})
cmake_pop_check_state ()
else(prog)
else()
if(${module}_FOUND)
# No test code provided, mark compilation as successful
# if module was founf
set(HAVE_${MODULE} 1)
# if module was found
# Has to be cached because of scope. Otherwise it is not accessible
# where it is used.
set(HAVE_${MODULE} 1 CACHE BOOL "${module} found")
mark_as_advanced(HAVE_${MODULE})
endif(${module}_FOUND)
endif(prog)
endif()
# write status message in the same manner as everyone else
include (FindPackageHandleStandardArgs)