Skip to content

Commit

Permalink
[cmake] Restore CMAKE_MODULE_PATH after temporary modification
Browse files Browse the repository at this point in the history
As this ends up in e.g. opm-common_config.cmake, calling
find_package(opm-common) will modify the CMAKE_MODULE_PATH
in a downstream module if not restored. Since we only need
this modification locally it is nice to restore the variable.
  • Loading branch information
timokoch committed Nov 30, 2024
1 parent a1a08cc commit 32aec17
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmake/Templates/opm-project-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,16 @@ if(NOT @opm-project_NAME@_FOUND)
find_package(opm-common CONFIG)
endif()
# This is required to include OpmPackage /opm-common-prereq.cmake
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" @PREREQ_LOCATION@)
list(PREPEND CMAKE_MODULE_PATH @PREREQ_LOCATION@)

# extra code from variable OPM_PROJECT_EXTRA_CODE
@OPM_PROJECT_EXTRA_CODE@
# end extra code

include(OpmPackage)
include(@opm-project_NAME@-prereqs)

# remove the temporarily added path again to not pollute downstream modules
list(POP_FRONT CMAKE_MODULE_PATH)
endif()
endif()

0 comments on commit 32aec17

Please sign in to comment.