Skip to content

Commit 9d0363c

Browse files
committed
Disable export symbols for BSD based systems
1 parent 3806387 commit 9d0363c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,12 @@ target_link_libraries( picode_example PRIVATE ${PROJECT_NAME} ${MATH_LIBRARY} )
254254
set_target_properties( picode_example PROPERTIES EXCLUDE_FROM_ALL TRUE )
255255

256256
# Add executable export symbols for loadable modules to prevent policy CMP0065 warning
257-
set_property(TARGET picode_example PROPERTY ENABLE_EXPORTS 1)
257+
# Basic check for BSD based systems, like as FreeBSD, NetBSD, OpenBSD, etc.
258+
string( TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME_UPPER )
259+
if(NOT CMAKE_SYSTEM_NAME_UPPER MATCHES "BSD")
260+
# If not a BSD system, add executable export symbols for loadable modules. Add linker flag "-Wl,--export-dynamic"
261+
set_target_properties( picode_example PROPERTIES ENABLE_EXPORTS TRUE )
262+
endif()
258263

259264
# If git info available adds to picode_example executable as environment var
260265
if(DEFINED BUILD_VERSION)
@@ -272,7 +277,12 @@ target_link_libraries( cpicode_example PRIVATE c${PROJECT_NAME} ${MATH_LIBRARY}
272277
set_target_properties( cpicode_example PROPERTIES EXCLUDE_FROM_ALL TRUE )
273278

274279
# Add executable export symbols for loadable modules to prevent policy CMP0065 warning
275-
set_property(TARGET cpicode_example PROPERTY ENABLE_EXPORTS 1)
280+
# Basic check for BSD based systems, like as FreeBSD, NetBSD, OpenBSD, etc.
281+
string( TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME_UPPER )
282+
if(NOT CMAKE_SYSTEM_NAME_UPPER MATCHES "BSD")
283+
# If not a BSD system, add executable export symbols for loadable modules. Add linker flag "-Wl,--export-dynamic"
284+
set_target_properties( cpicode_example PROPERTIES ENABLE_EXPORTS TRUE )
285+
endif()
276286

277287
# If git info available adds to cpicode_example executable as environment var
278288
if(DEFINED BUILD_VERSION)

0 commit comments

Comments
 (0)