From f76515a4a05dbfc68f717210bb3b7164cc8d13b8 Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Tue, 6 Oct 2020 10:52:17 +0200 Subject: [PATCH] [CMake] Split PreFind to GitSetup and PythonSetup. --- CMakeLists.txt | 3 +- .../cmake/{PreFind.cmake => GitSetup.cmake} | 36 ------------------- scripts/cmake/PythonSetup.cmake | 34 ++++++++++++++++++ 3 files changed, 36 insertions(+), 37 deletions(-) rename scripts/cmake/{PreFind.cmake => GitSetup.cmake} (70%) create mode 100644 scripts/cmake/PythonSetup.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 13b429b2fb7..1d305b072d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,8 @@ option(OGS_USE_CVODE "Use the Sundials CVODE module?" OFF) # ---- CMake includes ---- include(Versions) -include(PreFind) +include(GitSetup) +include(PythonSetup) include(SubmoduleSetup) include(ProcessesSetup) include(ProjectSetup) diff --git a/scripts/cmake/PreFind.cmake b/scripts/cmake/GitSetup.cmake similarity index 70% rename from scripts/cmake/PreFind.cmake rename to scripts/cmake/GitSetup.cmake index 783387ea358..6ec1497b2ab 100644 --- a/scripts/cmake/PreFind.cmake +++ b/scripts/cmake/GitSetup.cmake @@ -88,39 +88,3 @@ endif() if(MSVC) set(CMD_COMMAND "cmd" "/c" CACHE INTERNAL "") endif() - -### Python setup ### -find_program(POETRY poetry) -if(POETRY) - configure_file(${PROJECT_SOURCE_DIR}/scripts/python/poetry.in.toml - ${PROJECT_BINARY_DIR}/poetry.toml COPYONLY) - if(NOT EXISTS ${PROJECT_BINARY_DIR}/pyproject.toml) - configure_file(${PROJECT_SOURCE_DIR}/scripts/python/pyproject.in.toml - ${PROJECT_BINARY_DIR}/pyproject.toml) - endif() - if(NOT EXISTS ${PROJECT_BINARY_DIR}/.venv) - execute_process(COMMAND ${CMD_COMMAND} poetry install) - endif() - set(Python3_ROOT_DIR ${PROJECT_BINARY_DIR}/.venv) - set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/bin/python) - if(MSVC) - set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/Scripts/python.exe) - endif() -endif() - -if(OGS_USE_PYTHON) - find_package(Python3 ${ogs.minimum_version.python} COMPONENTS Interpreter Development REQUIRED) -else() - find_package(Python3 ${ogs.minimum_version.python} COMPONENTS Interpreter) -endif() -if(POETRY) - if(MSVC) - file(TO_NATIVE_PATH "${Python3_ROOT_DIR}/Lib/site-packages" - Python3_VIRTUALENV_SITEPACKAGES) - string(REPLACE "\\" "\\\\" Python3_VIRTUALENV_SITEPACKAGES - ${Python3_VIRTUALENV_SITEPACKAGES}) - else() - set(Python3_VIRTUALENV_SITEPACKAGES - ${Python3_ROOT_DIR}/lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages) - endif() -endif() diff --git a/scripts/cmake/PythonSetup.cmake b/scripts/cmake/PythonSetup.cmake new file mode 100644 index 00000000000..17e68293486 --- /dev/null +++ b/scripts/cmake/PythonSetup.cmake @@ -0,0 +1,34 @@ +find_program(POETRY poetry) +if(POETRY) + configure_file(${PROJECT_SOURCE_DIR}/scripts/python/poetry.in.toml + ${PROJECT_BINARY_DIR}/poetry.toml COPYONLY) + if(NOT EXISTS ${PROJECT_BINARY_DIR}/pyproject.toml) + configure_file(${PROJECT_SOURCE_DIR}/scripts/python/pyproject.in.toml + ${PROJECT_BINARY_DIR}/pyproject.toml) + endif() + if(NOT EXISTS ${PROJECT_BINARY_DIR}/.venv) + execute_process(COMMAND ${CMD_COMMAND} poetry install) + endif() + set(Python3_ROOT_DIR ${PROJECT_BINARY_DIR}/.venv) + set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/bin/python) + if(MSVC) + set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/Scripts/python.exe) + endif() +endif() + +if(OGS_USE_PYTHON) + find_package(Python3 ${ogs.minimum_version.python} COMPONENTS Interpreter Development REQUIRED) +else() + find_package(Python3 ${ogs.minimum_version.python} COMPONENTS Interpreter) +endif() +if(POETRY) + if(MSVC) + file(TO_NATIVE_PATH "${Python3_ROOT_DIR}/Lib/site-packages" + Python3_VIRTUALENV_SITEPACKAGES) + string(REPLACE "\\" "\\\\" Python3_VIRTUALENV_SITEPACKAGES + ${Python3_VIRTUALENV_SITEPACKAGES}) + else() + set(Python3_VIRTUALENV_SITEPACKAGES + ${Python3_ROOT_DIR}/lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages) + endif() +endif() -- GitLab