From 44627458ac98803fc1813c3055a3cdf770fe404a Mon Sep 17 00:00:00 2001 From: Riccardo Bertossa Date: Wed, 26 Apr 2023 15:50:30 +0200 Subject: [PATCH] fixed nopython build, try to fix the macos conda-forge build --- .github/workflows/cmake.yml | 5 +++++ CMakeLists.txt | 14 ++++++++++++-- lib/src/basetrajectory.cpp | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index f1401265c..e3e114773 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -62,6 +62,11 @@ jobs: SOURCE_DIR: ${{github.workspace}} BUILD_DIR: ${{github.workspace}}/build PYTHONPATH: /usr/lib/python${{ matrix.python-version }}/dist-packages + - name: Build_nopython + run: | + cmake -B ${{github.workspace}}/build_nopython -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPYTHON_INTERFACE:BOOL=OFF + cmake --build ${{github.workspace}}/build_nopython --config ${{env.BUILD_TYPE}} + ctest -C ${{env.BUILD_TYPE}} build_windows: # The CMake configure and build commands are platform agnostic and should work equally # well on Windows or Mac. You can convert this to a matrix build if you need diff --git a/CMakeLists.txt b/CMakeLists.txt index 30291748c..67cc95ff2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,7 +253,12 @@ set(BOOST_LIB boost) endif() add_executable(all_tests tests/src/all_tests.cpp) -target_link_libraries(all_tests ${PROJECT_NAME}_lib ${BOOST_LIB} test_fixtures ${LRT} ) +target_link_libraries(all_tests PRIVATE ${PROJECT_NAME}_lib ${BOOST_LIB} test_fixtures ${LRT} ) +if(PYTHON_INTERFACE) +if (${PYTHONLIBS_FOUND}) +target_link_libraries(all_tests PUBLIC pybind11::embed) +endif() +endif() set_property(TARGET all_tests PROPERTY CXX_STANDARD 17) @@ -275,6 +280,7 @@ pybind11_add_module(pyanalisi ) target_link_libraries(pyanalisi PRIVATE ${PROJECT_NAME}_lib ${LTR} ) set_property(TARGET pyanalisi PROPERTY CXX_STANDARD 17) +install(TARGETS pyanalisi DESTINATION ${PYTHON_SITE_PACKAGES} COMPONENT python ) endif() endif() @@ -291,6 +297,11 @@ endif() if (BUILD_MMAP) target_link_libraries(${PROJECT_NAME} PUBLIC boost_program_options "${FFTW}" "${FFTW_MT}" "${XDR_FILE}" ${LTR}) +if(PYTHON_INTERFACE) +if (${PYTHONLIBS_FOUND}) +target_link_libraries(${PROJECT_NAME} PUBLIC pybind11::embed) +endif() +endif() endif() target_link_libraries(${PROJECT_NAME}_lib PRIVATE "${FFTW}" "${FFTW_MT}" "${XDR_FILE}") add_definitions(-DANALISI -DDEBUG) @@ -350,5 +361,4 @@ CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_D include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) message(STATUS "python install library = ${PYTHON_SITE_PACKAGES}" ) -install(TARGETS pyanalisi DESTINATION ${PYTHON_SITE_PACKAGES} COMPONENT python ) diff --git a/lib/src/basetrajectory.cpp b/lib/src/basetrajectory.cpp index d829b0dce..b8e8a4d85 100644 --- a/lib/src/basetrajectory.cpp +++ b/lib/src/basetrajectory.cpp @@ -1,6 +1,4 @@ #include "testtraiettoria.h" -#include "trajectory.h" -#include "trajectory_numpy.h" #include "config.h" template @@ -91,9 +89,11 @@ size_t BaseTrajectory::get_ntypes (){ } #ifdef PYTHON_SUPPORT +#include "trajectory_numpy.h" template class BaseTrajectory; #endif #ifdef BUILD_MMAP +#include "trajectory.h" template class BaseTrajectory; #endif