Skip to content

Commit e0a7757

Browse files
authored
privat linking for "--embind"
1 parent 0213cb4 commit e0a7757

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

CMakeLists.txt

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ if (NOT DEFINED PY_VERSION)
1212
set(PY_VERSION 3.11)
1313
endif()
1414

15-
1615
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pycpp_includes)
1716

18-
19-
20-
2117
##########################################################
2218
# generate prejs and postjs
2319
##########################################################
@@ -70,9 +66,6 @@ add_custom_command(OUTPUT "pyjs_post.js"
7066
DEPENDS ${POSTJS_FILES})
7167

7268

73-
74-
75-
7669
##########################################################
7770
# headers to install
7871
##########################################################
@@ -117,21 +110,19 @@ add_library(pyjs STATIC
117110

118111
target_link_libraries(pyjs PRIVATE ${PYTHON_UTIL_LIBS} pybind11::embed)
119112

113+
target_compile_options(pyjs
114+
PUBLIC --std=c++17
115+
PUBLIC -Wno-deprecated
116+
PUBLIC "SHELL: -fexceptions"
117+
)
120118

121-
target_compile_options(pyjs
122-
PUBLIC --std=c++17
123-
PUBLIC -Wno-deprecated
124-
PUBLIC "SHELL: -fexceptions"
125-
)
126-
127-
target_link_options(pyjs
128-
PUBLIC -lembind
129-
PUBLIC -Wno-unused-command-line-argument
130-
PUBLIC "SHELL: -fexceptions"
131-
#PUBLIC "SHELL:-s EXPORT_EXCEPTION_HANDLING_HELPERS"
132-
#PUBLIC "SHELL:-s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules']"
133-
)
134-
119+
target_link_options(pyjs
120+
PRIVATE -lembind
121+
PUBLIC -Wno-unused-command-line-argument
122+
PUBLIC "SHELL: -fexceptions"
123+
#PUBLIC "SHELL:-s EXPORT_EXCEPTION_HANDLING_HELPERS"
124+
#PUBLIC "SHELL:-s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules']"
125+
)
135126

136127

137128
set_target_properties(pyjs PROPERTIES
@@ -144,10 +135,11 @@ add_dependencies(pyjs merge_pyjs)
144135
target_link_libraries(pyjs PRIVATE pybind11::pybind11)
145136
target_compile_options(pyjs PRIVATE -fPIC)
146137

138+
147139
target_include_directories(pyjs
148-
PUBLIC
149-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
150-
$<INSTALL_INTERFACE:include> # <prefix>/include
140+
PUBLIC
141+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
142+
$<INSTALL_INTERFACE:include>
151143
)
152144

153145
SET(PYTHON_UTIL_LIBS
@@ -180,16 +172,19 @@ target_compile_definitions(pyjs_runtime_browser PUBLIC -DPYTEST_DRIVER_WEB)
180172
target_include_directories(pyjs_runtime_browser
181173
PRIVATE
182174
${CMAKE_SOURCE_DIR}/include
183-
${CMAKE_CURRENT_BINARY_DIR}/pycpp_includes)
175+
${CMAKE_CURRENT_BINARY_DIR}/pycpp_includes
176+
${ZLIB_INCLUDE_DIRS}
177+
)
184178

185179
set_target_properties(pyjs_runtime_browser
186180
PROPERTIES
187181
CXX_STANDARD 17
188182
)
189183
target_compile_definitions(pyjs_runtime_browser PUBLIC -DPYJS_WEB)
190184
target_compile_options(pyjs_runtime_browser PRIVATE -fPIC)
191-
target_link_libraries(pyjs_runtime_browser PRIVATE pyjs)
192-
target_link_libraries(pyjs_runtime_browser PRIVATE ${PYTHON_UTIL_LIBS} pybind11::embed)
185+
target_link_libraries(pyjs_runtime_browser PRIVATE pyjs pybind11::embed ${PYTHON_UTIL_LIBS})
186+
187+
193188

194189
target_compile_options(pyjs_runtime_browser
195190
PUBLIC --std=c++17
@@ -204,6 +199,7 @@ target_compile_options(pyjs_runtime_browser
204199
)
205200

206201
target_link_options(pyjs_runtime_browser
202+
PRIVATE -lembind
207203
PUBLIC -Wno-unused-command-line-argument
208204
PUBLIC "SHELL: -s MODULARIZE=1"
209205
PUBLIC "SHELL: -s EXPORT_NAME=\"createModule\""

0 commit comments

Comments
 (0)