Skip to content

Commit 00c074a

Browse files
committed
Link to CMake Python3::Module target (#98)
Since ecflow is built as a `module` (i.e. a shared library, dynamically loaded by the Python interpreter), the linkage in macOs requires passing flags `-undefined` and `-dynamic_lookup`. This is handled directly by CMake which, since CMake 3.15, defines a specific target `Python3::Module` to be used when building Python modules. Re ECFLOW-1950
1 parent 1cafe6c commit 00c074a

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ option( ENABLE_UI_BACKTRACE "Print a UI debug backtrace" OFF )
5858
option( ENABLE_UI_USAGE_LOG "Enable UI usage logging" OFF )
5959
option( ENABLE_SSL "Enable SSL encrypted communication" ON )
6060
option( ENABLE_PYTHON_PTR_REGISTER "Some compilers/boost versions do not register shared ptr automatically" OFF )
61-
option( ENABLE_PYTHON_UNDEF_LOOKUP "Some boost/python versions are too closely linked" OFF )
6261
option( ENABLE_HTTP "Enable HTTP server (experimental)" ON )
6362
option( ENABLE_HTTP_COMPRESSION "Enable compression support by HTTP server" ON )
6463
option( ENABLE_UDP "Enable UDP server (experimental)" ON )
@@ -192,7 +191,6 @@ endif()
192191
ecbuild_info( "ENABLE_SERVER : ${ENABLE_SERVER}" )
193192
ecbuild_info( "ENABLE_PYTHON : ${ENABLE_PYTHON}" )
194193
ecbuild_info( "ENABLE_PYTHON_PTR_REGISTER : ${ENABLE_PYTHON_PTR_REGISTER}" )
195-
ecbuild_info( "ENABLE_PYTHON_UNDEF_LOOKUP : ${ENABLE_PYTHON_UNDEF_LOOKUP}" )
196194
ecbuild_info( "ENABLE_UI : ${ENABLE_UI}" )
197195
ecbuild_info( "ENABLE_TESTS : ${ENABLE_TESTS} *if* disabled no need for boost test libs" )
198196
ecbuild_info( "ENABLE_ALL_TESTS : ${ENABLE_ALL_TESTS}" )

Pyext/python3/CMakeLists.txt

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
# nor does it submit to any jurisdiction.
99
#
1010

11-
# ENABLE_PYTHON_UNDEF_LOOKUP
12-
# on some systems (e.g. conda on macOS) the boost Python libraries seem to be too
13-
# closely linked with the exact version of the Python development libraries,
14-
# meaning that we get segfaults when we try to run a Python example. By removing
15-
# the Python libraries from the link line and adding -undefined dynamic_lookup
16-
# we can make our ecflow shared library more movable bewteen systems
17-
18-
if (ENABLE_PYTHON_UNDEF_LOOKUP)
19-
add_link_options(-undefined dynamic_lookup)
20-
endif()
11+
#
12+
# Important!
13+
#
14+
# Notice that ecflow Python module is linked with `Python3::Module` CMake imported target,
15+
# to enable a loose linkage with Python development libraries -- this is necessary in some
16+
# platforms, such as conda-forge+macOS.
17+
#
18+
# In practice, this implies that `-undefined` and `-dynamic_lookup` linkage flags are used
19+
# and the Python development libraries are not linked directly into the ecflow Python module.
20+
#
2121

2222
ecbuild_add_library(
2323
TARGET
@@ -35,7 +35,7 @@ ecbuild_add_library(
3535
node
3636
attributes
3737
core
38-
Python3::Python
38+
Python3::Module
3939
Boost::${ECFLOW_BOOST_PYTHON_COMPONENT}
4040
$<$<BOOL:${OPENSSL_FOUND}>:OpenSSL::SSL>
4141
CXXFLAGS

0 commit comments

Comments
 (0)