From 1d12e67d98d26f0d29788f013ea33dfb85135b2b Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 6 Feb 2026 10:50:46 +0100 Subject: [PATCH] fix ordering issue with downloaded pybind need to lookup opm-common before we call DownloadPybind11 --- CMakeLists.txt | 57 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 846f746777..395cd7f36e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,34 @@ elseif(CONVERT_CUDA_TO_HIP) message("To generate HIP code for AMD GPUs run CMake with version >= 3.21") endif() +if(SIBLING_SEARCH AND NOT opm-common_DIR) + # guess the sibling dir + get_filename_component(_leaf_dir_name ${PROJECT_BINARY_DIR} NAME) + get_filename_component(_parent_full_dir ${PROJECT_BINARY_DIR} DIRECTORY) + get_filename_component(_parent_dir_name ${_parent_full_dir} NAME) + #Try if / is used + get_filename_component(_modules_dir ${_parent_full_dir} DIRECTORY) + if(IS_DIRECTORY ${_modules_dir}/opm-common/${_leaf_dir_name}) + set(opm-common_DIR ${_modules_dir}/opm-common/${_leaf_dir_name}) + else() + string(REPLACE ${PROJECT_NAME} opm-common _opm_common_leaf ${_leaf_dir_name}) + if(NOT _leaf_dir_name STREQUAL _opm_common_leaf + AND IS_DIRECTORY ${_parent_full_dir}/${_opm_common_leaf}) + # We are using build directories named + set(opm-common_DIR ${_parent_full_dir}/${_opm_common_leaf}) + elseif(IS_DIRECTORY ${_parent_full_dir}/opm-common) + # All modules are in a common build dir + set(opm-common_DIR "${_parent_full_dir}/opm-common") + endif() + endif() +endif() +if(opm-common_DIR AND NOT IS_DIRECTORY ${opm-common_DIR}) + message(WARNING "Value ${opm-common_DIR} passed to variable" + " opm-common_DIR is not a directory") +endif() + +find_package(opm-common REQUIRED) + # The following was copied from CMakeLists.txt in opm-common. # TODO: factor out the common parts in opm-common and opm-simulator as a cmake module if (OPM_ENABLE_PYTHON) @@ -118,7 +146,6 @@ if (OPM_ENABLE_PYTHON) endif() find_package(pybind11 CONFIG) - if(NOT pybind11_FOUND) include(DownloadPyBind11) endif() @@ -128,34 +155,6 @@ if (OPM_ENABLE_PYTHON) set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) endif() -if(SIBLING_SEARCH AND NOT opm-common_DIR) - # guess the sibling dir - get_filename_component(_leaf_dir_name ${PROJECT_BINARY_DIR} NAME) - get_filename_component(_parent_full_dir ${PROJECT_BINARY_DIR} DIRECTORY) - get_filename_component(_parent_dir_name ${_parent_full_dir} NAME) - #Try if / is used - get_filename_component(_modules_dir ${_parent_full_dir} DIRECTORY) - if(IS_DIRECTORY ${_modules_dir}/opm-common/${_leaf_dir_name}) - set(opm-common_DIR ${_modules_dir}/opm-common/${_leaf_dir_name}) - else() - string(REPLACE ${PROJECT_NAME} opm-common _opm_common_leaf ${_leaf_dir_name}) - if(NOT _leaf_dir_name STREQUAL _opm_common_leaf - AND IS_DIRECTORY ${_parent_full_dir}/${_opm_common_leaf}) - # We are using build directories named - set(opm-common_DIR ${_parent_full_dir}/${_opm_common_leaf}) - elseif(IS_DIRECTORY ${_parent_full_dir}/opm-common) - # All modules are in a common build dir - set(opm-common_DIR "${_parent_full_dir}/opm-common") - endif() - endif() -endif() -if(opm-common_DIR AND NOT IS_DIRECTORY ${opm-common_DIR}) - message(WARNING "Value ${opm-common_DIR} passed to variable" - " opm-common_DIR is not a directory") -endif() - -find_package(opm-common REQUIRED) - include(OpmInit) OpmSetPolicies()