From: Julien Schueller Date: Wed, 10 Apr 2024 13:28:36 +0000 (+0200) Subject: CMake: Avoid linking to Python libs X-Git-Tag: V9_14_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fe1a8ca2f9f6da382879f9b692efdc360f3f851c;p=tools%2Fmedcoupling.git CMake: Avoid linking to Python libs --- diff --git a/src/MEDCoupling_Swig/CMakeLists.txt b/src/MEDCoupling_Swig/CMakeLists.txt index cd8a4fefe..273cb03fb 100644 --- a/src/MEDCoupling_Swig/CMakeLists.txt +++ b/src/MEDCoupling_Swig/CMakeLists.txt @@ -121,13 +121,12 @@ ELSE() SWIG_ADD_LIBRARY(${MEDCouling_target_name} LANGUAGE python SOURCES MEDCoupling.i) ENDIF() +SWIG_LINK_LIBRARIES(${MEDCouling_target_name} ${PLATFORM_LIBS} medcouplingcpp) IF(WIN32 OR CYGWIN) - SWIG_LINK_LIBRARIES(${MEDCouling_target_name} ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} medcouplingcpp) -ELSE(WIN32 OR CYGWIN) - # ${PYTHON_LIBRARIES} not needed see https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1 - SWIG_LINK_LIBRARIES(${MEDCouling_target_name} ${PLATFORM_LIBS} medcouplingcpp) -ENDIF(WIN32 OR CYGWIN) -# ${PYTHON_LIBRARIES} not needed + # PYTHON_LIBRARIES only needed on win32 see https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1 + SWIG_LINK_LIBRARIES(${MEDCouling_target_name} ${PYTHON_LIBRARIES}) +ENDIF() + SWIG_CHECK_GENERATION(${MEDCouling_target_name}) SET_SOURCE_FILES_PROPERTIES(MEDCouplingRemapper.i PROPERTIES CPLUSPLUS ON) IF(WIN32) @@ -155,12 +154,11 @@ ELSE() SWIG_ADD_LIBRARY(MEDCouplingRemapper LANGUAGE python SOURCES MEDCouplingRemapper.i) ENDIF() +SWIG_LINK_LIBRARIES(MEDCouplingRemapper medcouplingremapper) IF(WIN32 OR CYGWIN) - SWIG_LINK_LIBRARIES(MEDCouplingRemapper ${PYTHON_LIBRARIES} medcouplingremapper) -ELSE(WIN32 OR CYGWIN) - # ${PYTHON_LIBRARIES} not needed see https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1 - SWIG_LINK_LIBRARIES(MEDCouplingRemapper medcouplingremapper) -ENDIF(WIN32 OR CYGWIN) + # PYTHON_LIBRARIES only needed on win32 see https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1 + SWIG_LINK_LIBRARIES(MEDCouplingRemapper ${PYTHON_LIBRARIES}) +ENDIF() IF(WIN32) SET_TARGET_PROPERTIES(_MEDCouplingRemapper PROPERTIES DEBUG_OUTPUT_NAME _MEDCouplingRemapper_d) diff --git a/src/MEDLoader/Swig/CMakeLists.txt b/src/MEDLoader/Swig/CMakeLists.txt index bc13f294c..86029b1bc 100644 --- a/src/MEDLoader/Swig/CMakeLists.txt +++ b/src/MEDLoader/Swig/CMakeLists.txt @@ -83,7 +83,12 @@ ELSE() SWIG_ADD_LIBRARY(MEDLoader LANGUAGE python SOURCES MEDLoader.i) ENDIF() -SWIG_LINK_LIBRARIES(MEDLoader ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} medloader medcouplingcpp ) +SWIG_LINK_LIBRARIES(MEDLoader ${PLATFORM_LIBS} medloader medcouplingcpp) +IF (WIN32 OR CYGWIN) + # PYTHON_LIBRARIES only needed on win32 see https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1 + SWIG_LINK_LIBRARIES(MEDLoader ${PYTHON_LIBRARIES}) +ENDIF() + SWIG_CHECK_GENERATION(MEDLoader) IF(WIN32) SET_TARGET_PROPERTIES(_MEDLoader PROPERTIES DEBUG_OUTPUT_NAME _MEDLoader_d) diff --git a/src/MEDPartitioner_Swig/CMakeLists.txt b/src/MEDPartitioner_Swig/CMakeLists.txt index 2227bace2..f8fcc324d 100644 --- a/src/MEDPartitioner_Swig/CMakeLists.txt +++ b/src/MEDPartitioner_Swig/CMakeLists.txt @@ -62,7 +62,11 @@ ELSE() SWIG_ADD_LIBRARY(MEDPartitioner LANGUAGE python SOURCES MEDPartitioner.i) ENDIF() -SWIG_LINK_LIBRARIES(MEDPartitioner ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} medpartitionercpp) +SWIG_LINK_LIBRARIES(MEDPartitioner ${PLATFORM_LIBS} medpartitionercpp) +IF (WIN32) + # PYTHON_LIBRARIES only needed on win32 see https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1 + SWIG_LINK_LIBRARIES(MEDPartitioner ${PYTHON_LIBRARIES}) +ENDIF() SWIG_CHECK_GENERATION(MEDPartitioner) IF(WIN32) diff --git a/src/ParaMEDMEM_Swig/CMakeLists.txt b/src/ParaMEDMEM_Swig/CMakeLists.txt index e1fdb6f07..b26b45b42 100644 --- a/src/ParaMEDMEM_Swig/CMakeLists.txt +++ b/src/ParaMEDMEM_Swig/CMakeLists.txt @@ -64,7 +64,11 @@ ELSE() SWIG_ADD_LIBRARY(ParaMEDMEM LANGUAGE python SOURCES ParaMEDMEM.i) ENDIF() -SWIG_LINK_LIBRARIES(ParaMEDMEM ${PYTHON_LIBRARIES} paramedmem) +SWIG_LINK_LIBRARIES(ParaMEDMEM paramedmem) +IF (WIN32) + # PYTHON_LIBRARIES only needed on win32 see https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1 + SWIG_LINK_LIBRARIES(ParaMEDMEM ${PYTHON_LIBRARIES}) +ENDIF () SWIG_CHECK_GENERATION(ParaMEDMEM) # diff --git a/src/PyWrapping/CMakeLists.txt b/src/PyWrapping/CMakeLists.txt index 9c8039d9a..fc9857635 100644 --- a/src/PyWrapping/CMakeLists.txt +++ b/src/PyWrapping/CMakeLists.txt @@ -67,14 +67,14 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../ShapeRecogn/Swig ${PROJECT_BINARY_DIR}/doc ) - - IF(WIN32 OR CYGWIN) - SET(medcoupling_LIB_dependancies ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} medcouplingremapper medicoco) - ELSE(WIN32 OR CYGWIN) - # ${PYTHON_LIBRARIES} not needed see https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1 + + SET(medcoupling_LIB_dependancies ${PLATFORM_LIBS} medcouplingremapper medicoco) - ENDIF(WIN32 OR CYGWIN) - + IF(WIN32 OR CYGWIN) + # PYTHON_LIBRARIES only needed on win32 see https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1 + LIST(APPEND medcoupling_LIB_dependancies ${PYTHON_LIBRARIES}) + ENDIF() + IF(MEDCOUPLING_ENABLE_SHAPERECOGN) LIST(APPEND SWIG_MODULE_medcoupling_EXTRA_FLAGS -DWITH_SHAPE_RECOGN) LIST(APPEND medcoupling_LIB_dependancies shaperecogn) diff --git a/src/RENUMBER_Swig/CMakeLists.txt b/src/RENUMBER_Swig/CMakeLists.txt index a927ed365..55314f6c8 100644 --- a/src/RENUMBER_Swig/CMakeLists.txt +++ b/src/RENUMBER_Swig/CMakeLists.txt @@ -65,7 +65,11 @@ ELSE() SWIG_ADD_LIBRARY(MEDRenumber LANGUAGE python SOURCES MEDRenumber.i) ENDIF() -SWIG_LINK_LIBRARIES(MEDRenumber ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} renumbercpp) +SWIG_LINK_LIBRARIES(MEDRenumber ${PLATFORM_LIBS} renumbercpp) +IF (WIN32) + # PYTHON_LIBRARIES only needed on win32 see https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1 + SWIG_LINK_LIBRARIES(MEDRenumber ${PYTHON_LIBRARIES}) +ENDIF() SWIG_CHECK_GENERATION(MEDRenumber) IF(WIN32)