Skip to content
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
19 changes: 1 addition & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ include(CMakePrintHelpers)
include(F2Py)
find_package(pybind11 CONFIG)

# cannot use find_package(Python), we need PythonLibsNew from pybind11
find_package(PythonLibsNew REQUIRED)
find_package(Python REQUIRED COMPONENTS Interpreter Development)

# in Numpy-1.22+, this becomes easier: import numpy.f2py; print(numpy.f2py.get_include())
if (NOT F2PY_INCLUDE_DIR)
Expand All @@ -54,22 +53,6 @@ if (NOT NUMPY_INCLUDE_DIRS)
set(NUMPY_INCLUDE_DIRS "${_numpy_directory}" CACHE STRING "NumPy source directory location" FORCE)
endif()

macro(use_alternate_linker_if_available linker)
find_program(LINKER_EXECUTABLE ld.${linker})
if(LINKER_EXECUTABLE)
message(STATUS "Linker detected: ${linker} (${LINKER_EXECUTABLE})")
if(CLANG AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 12.0.0)
message(STATUS "Clang links with ${LINKER_EXECUTABLE}")
add_link_options(-ld-path=${linker})
elseif(GCC AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 12.0.0)
message(STATUS "GCC links with ${LINKER_EXECUTABLE}")
add_link_options(-ld-path=${linker})
endif()
endif()
endmacro()

use_alternate_linker_if_available(mold)

# Print out the discovered paths
cmake_print_variables(CMAKE_BUILD_TYPE)
cmake_print_variables(PYTHON_EXECUTABLE)
Expand Down
11 changes: 1 addition & 10 deletions F2Py.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
# This function expects the following variables to be set:
#
# PYTHON_EXECUTABLE
# PYTHON_LIBRARIES
# F2PY_INCLUDE_DIR
# PYTHON_MODULE_EXTENSION
# PYTHON_MODULE_PREFIX
# f2py_source
# f2py_dir
#
Expand Down Expand Up @@ -157,16 +154,13 @@ function (f2py_add_module target_name)

endif()

add_library(${target_name} MODULE
Python_add_library(${target_name} MODULE WITH_SOABI
${f2py_source}
${modulec_file}
${f2pywrap_file}
${F2PY_ADD_MODULE_SOURCES}
)

if (PYTHON_LIBRARIES) # may not be available (e.g. on manylinux)
target_link_libraries(${target_name} PRIVATE ${PYTHON_LIBRARIES})
endif()
if (F2PY_ADD_MODULE_INCLUDE_DIRS)
target_include_directories(${target_name}
PRIVATE ${F2PY_ADD_MODULE_INCLUDE_DIRS})
Expand All @@ -184,8 +178,5 @@ function (f2py_add_module target_name)
if (WIN32)
target_link_libraries(${target_name} PUBLIC "-static")
endif()
set_property(TARGET ${target_name} PROPERTY SUFFIX ${PYTHON_MODULE_EXTENSION})
# must be a string, so that empty string works correcty
set_property(TARGET ${target_name} PROPERTY PREFIX "${PYTHON_MODULE_PREFIX}")

endfunction()