Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

future-proof find_package(Python) again #1924

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,5 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()

find_package(Git REQUIRED)
find_package(Python COMPONENTS Interpreter REQUIRED)

add_subdirectory(src/Core)
add_subdirectory(Wrappers/Python)
32 changes: 6 additions & 26 deletions Wrappers/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,30 @@
option (BUILD_PYTHON_WRAPPER "Build Python Wrapper" ON)
find_package(Python COMPONENTS Interpreter REQUIRED)

if (BUILD_PYTHON_WRAPPER)
find_package(PythonInterp REQUIRED)

#set(PYTHON_DEST_DIR "" CACHE PATH "Directory of the Python wrappers")
if(PYTHON_DEST_DIR)
file(TO_CMAKE_PATH "${PYTHON_DEST_DIR}" TMP)
set(PYTHON_DEST "${TMP}")
unset(TMP)
file(TO_CMAKE_PATH "${PYTHON_DEST_DIR}" PYTHON_DEST)
endif()

message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")
if(NOT DEFINED)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()

find_package(PythonLibs)
if (PYTHONINTERP_FOUND)
message(STATUS "Found PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")
message(STATUS "Python version ${PYTHON_VERSION_STRING}")
endif()
if (PYTHONLIBS_FOUND)
message(STATUS "Found PYTHON_INCLUDE_DIRS=${PYTHON_INCLUDE_DIRS}")
message(STATUS "Found PYTHON_LIBRARIES=${PYTHON_LIBRARIES}")
endif()

if (PYTHONINTERP_FOUND)
message("Python found " ${PYTHON_EXECUTABLE})
# TODO: add to add_custom_command DEPENDS the list of python files of the project.
# file(GLOB_RECURSE DEPS ${CMAKE_CURRENT_SOURCE_DIR}/cil/*.py )
message("SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL: $ENV{SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL}")
message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
if(PYTHON_DEST_DIR)
message(STATUS "CIL install using ${PYTHON_EXECUTABLE} -m pip install -t ${PYTHON_DEST}")
message(STATUS "CIL install using ${Python_EXECUTABLE} -m pip install -t ${PYTHON_DEST}")
add_custom_target(pythonsetup ALL
COMMAND ${PYTHON_EXECUTABLE} -m pip install ${CMAKE_SOURCE_DIR} -t ${PYTHON_DEST} --upgrade
COMMAND ${Python_EXECUTABLE} -m pip install ${CMAKE_SOURCE_DIR} -t ${PYTHON_DEST} --upgrade
DEPENDS cilacc)
else()
message(STATUS "CIL install using ${PYTHON_EXECUTABLE} -m pip install")
message(STATUS "CIL install using ${Python_EXECUTABLE} -m pip install")
add_custom_target(pythonsetup ALL
COMMAND ${PYTHON_EXECUTABLE} -m pip install ${CMAKE_SOURCE_DIR} --upgrade
COMMAND ${Python_EXECUTABLE} -m pip install ${CMAKE_SOURCE_DIR} --upgrade
DEPENDS cilacc)
endif()
# install the data if not a conda build. With conda the data is in the dependency package cil-data
if (NOT CONDA_BUILD)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cil)
endif()
endif()
endif()
Loading