diff --git a/cmake/Modules/OpmCompile.cmake b/cmake/Modules/OpmCompile.cmake index 821c936e6..899e91f12 100644 --- a/cmake/Modules/OpmCompile.cmake +++ b/cmake/Modules/OpmCompile.cmake @@ -29,7 +29,11 @@ macro (opm_compile opm) # create this library, if there are any compilation units link_directories (${${opm}_LIBRARY_DIRS}) - add_definitions (${${opm}_DEFINITIONS}) + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.12") + add_compile_definitions (${${opm}_DEFINITIONS}) + else() + add_definitions(${${opm}_DEFINITIONS}) + endif() set (${opm}_VERSION "${${opm}_VERSION_MAJOR}.${${opm}_VERSION_MINOR}") if (${opm}_SOURCES) add_library (${${opm}_TARGET} ${${opm}_LIBRARY_TYPE} ${${opm}_SOURCES}) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 6459dd63b..0306b62ab 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -96,9 +96,13 @@ macro (find_opm_package module deps header lib defs prog conf) # compile with this option to avoid avalanche of warnings set (${module}_DEFINITIONS "${${module}_DEFINITIONS}") foreach (_def IN ITEMS ${defs}) - list (APPEND ${module}_DEFINITIONS "-D${_def}") + if(_def MATCHES "^[A-Za-z].*") + list (APPEND ${module}_DEFINITIONS "-D${_def}") + endif() endforeach (_def) + list (APPEND ${module}_DEFINITIONS ${defs}) + # tidy the lists before returning them remove_dup_deps (${module})