@@ -59,7 +59,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
59
59
# Check for Link Time Optimization support
60
60
# (GCC/Clang)
61
61
CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG)
62
- if (HAS_LTO_FLAG)
62
+ if (HAS_LTO_FLAG AND NOT CYGWIN )
63
63
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto" )
64
64
endif ()
65
65
@@ -149,6 +149,9 @@ add_library(example SHARED
149
149
${PYBIND11_EXAMPLES}
150
150
)
151
151
152
+ # Link against the Python shared library
153
+ target_link_libraries (example ${PYTHON_LIBRARY} )
154
+
152
155
# Don't add a 'lib' prefix to the shared library
153
156
set_target_properties (example PROPERTIES PREFIX "" )
154
157
@@ -182,9 +185,6 @@ if (WIN32)
182
185
183
186
# .PYD file extension on Windows
184
187
set_target_properties (example PROPERTIES SUFFIX ".pyd" )
185
-
186
- # Link against the Python shared library
187
- target_link_libraries (example ${PYTHON_LIBRARY} )
188
188
elseif (UNIX )
189
189
# It's quite common to have multiple copies of the same Python version
190
190
# installed on one's system. E.g.: one copy from the OS and another copy
@@ -200,8 +200,13 @@ elseif (UNIX)
200
200
# missing symbols, but that's perfectly fine -- they will be resolved at
201
201
# import time.
202
202
203
- # .SO file extension on Linux/Mac OS
204
- set_target_properties (example PROPERTIES SUFFIX ".so" )
203
+ # .DLL file extension on Cygwin, .SO file extension on Linux/Mac OS
204
+ if (CYGWIN )
205
+ set (SUFFIX ".dll" )
206
+ else ()
207
+ set (SUFFIX ".so" )
208
+ endif ()
209
+ set_target_properties (example PROPERTIES SUFFIX ${SUFFIX} )
205
210
206
211
# Optimize for a small binary size
207
212
if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
@@ -213,11 +218,11 @@ elseif (UNIX)
213
218
set_target_properties (example PROPERTIES MACOSX_RPATH "." )
214
219
set_target_properties (example PROPERTIES LINK_FLAGS "-undefined dynamic_lookup " )
215
220
if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
216
- add_custom_command (TARGET example POST_BUILD COMMAND strip -u -r ${PROJECT_SOURCE_DIR} /example/example.so )
221
+ add_custom_command (TARGET example POST_BUILD COMMAND strip -u -r ${PROJECT_SOURCE_DIR} /example/example${SUFFIX} )
217
222
endif ()
218
223
else ()
219
224
if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
220
- add_custom_command (TARGET example POST_BUILD COMMAND strip ${PROJECT_SOURCE_DIR} /example/example.so )
225
+ add_custom_command (TARGET example POST_BUILD COMMAND strip ${PROJECT_SOURCE_DIR} /example/example${SUFFIX} )
221
226
endif ()
222
227
endif ()
223
228
endif ()
0 commit comments