From ac64f2bfa13879b355533f109440369e7ec5e805 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Mon, 22 Jan 2024 10:29:40 -0500 Subject: [PATCH 1/4] Fix mac builds with CMake. --- CMake/PythonSetup.cmake | 20 -------------------- gsd/CMakeLists.txt | 14 +++++++++++--- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/CMake/PythonSetup.cmake b/CMake/PythonSetup.cmake index 7ea49986..43b44860 100644 --- a/CMake/PythonSetup.cmake +++ b/CMake/PythonSetup.cmake @@ -83,23 +83,3 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(cython DEFAULT_MSG CYTHON_EXECUTABLE) if (NOT CYTHON_EXECUTABLE) message(ERROR "cython not found") endif() - -############################################################################################# -# Fixup conda linking, if this python appears to be a conda python -if (${CMAKE_MAJOR_VERSION} GREATER 2) -get_filename_component(_python_bin_dir ${PYTHON_EXECUTABLE} DIRECTORY) -if (EXISTS "${_python_bin_dir}/conda") - message("-- Detected conda python, activating workaround") - set(_using_conda On) -else() - set(_using_conda Off) -endif() -endif() - -macro(fix_conda_python target) -if (_using_conda) -get_filename_component(_python_lib_file ${PYTHON_LIBRARY} NAME) -add_custom_command(TARGET ${target} POST_BUILD - COMMAND install_name_tool ARGS -change ${_python_lib_file} ${PYTHON_LIBRARY} $) -endif () -endmacro() diff --git a/gsd/CMakeLists.txt b/gsd/CMakeLists.txt index 5290f268..d5e5ae62 100644 --- a/gsd/CMakeLists.txt +++ b/gsd/CMakeLists.txt @@ -23,15 +23,23 @@ target_compile_definitions(fl PRIVATE NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION) set_target_properties(fl PROPERTIES PREFIX "" OUTPUT_NAME "fl" MACOSX_RPATH "On") if(APPLE) set_target_properties(fl PROPERTIES SUFFIX ".so") - target_link_libraries(fl ${PYTHON_LIBRARY}) - fix_conda_python(fl) endif(APPLE) if (WIN32) - target_link_libraries(fl ${PYTHON_LIBRARY}) set_target_properties(fl PROPERTIES SUFFIX ".pyd") endif() +if(WIN32) + # Link to the Python libraries on windows + target_link_libraries(fl ${PYTHON_LIBRARIES}) +else() + # Do not link to the Python libraries on Mac/Linux - symbols are provided by + # the `python` executable. "-undefined dynamic_lookup" is needed on Mac + target_link_options( + fl PRIVATE + "$<$:LINKER:-undefined,dynamic_lookup>") +endif() + ################ Python only modules # copy python modules to the build directory to make it a working python package MACRO(copy_file file) From 8cca4b4745d0d02de277d1aa75454d51b6cc09e7 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Mon, 22 Jan 2024 10:30:58 -0500 Subject: [PATCH 2/4] Update change log. --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 548397ae..764bfded 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -19,6 +19,7 @@ Change Log and before `gsd_end_frame()` (`#319 `__). * Readthedocs builds with pandas 2.2.0 (`#322 `__). +* Import without seg fault when built with CMake on macOS. *Changed:* From 6c0d0950e3bf8a50bedc59c55c9d4855ba55739f Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Mon, 22 Jan 2024 10:40:54 -0500 Subject: [PATCH 3/4] Link to the correct lib on windows. --- gsd/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsd/CMakeLists.txt b/gsd/CMakeLists.txt index d5e5ae62..2dca238c 100644 --- a/gsd/CMakeLists.txt +++ b/gsd/CMakeLists.txt @@ -31,7 +31,7 @@ endif() if(WIN32) # Link to the Python libraries on windows - target_link_libraries(fl ${PYTHON_LIBRARIES}) + target_link_libraries(fl ${PYTHON_LIBRARY}) else() # Do not link to the Python libraries on Mac/Linux - symbols are provided by # the `python` executable. "-undefined dynamic_lookup" is needed on Mac From 0f00a34c00a92edf0f8ecbaf98c0e683c6d91bb5 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Mon, 22 Jan 2024 10:41:33 -0500 Subject: [PATCH 4/4] Add PR number to change log. --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 764bfded..1c9f69ff 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,7 @@ Change Log * Readthedocs builds with pandas 2.2.0 (`#322 `__). * Import without seg fault when built with CMake on macOS. + (`#323 `__). *Changed:*