Skip to content

Commit 251c668

Browse files
committed
Call opendds_export_header instead of manually set BUILD_DLL and HAS_DLL macros
1 parent 4a21c8b commit 251c668

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

cmake/opendds_target_sources.cmake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,11 @@ function(opendds_target_sources target)
253253
endif()
254254
else()
255255
# Assuming the custom export header is compatible with ones generated by generate_export_file.pl
256+
list(GET use_export 0 existing_header)
256257
list(GET use_export 1 existing_macro)
257258
string(FIND ${existing_macro} "_Export" index)
258259
string(SUBSTRING ${existing_macro} 0 ${index} macro_prefix)
259-
string(TOUPPER ${macro_prefix} macro_prefix)
260-
if(target_type STREQUAL "SHARED_LIBRARY")
261-
target_compile_definitions(${target} PRIVATE "${macro_prefix}_BUILD_DLL")
262-
target_compile_definitions(${target} PUBLIC "${macro_prefix}_HAS_DLL=1")
263-
elseif(target_type STREQUAL "STATIC_LIBRARY")
264-
target_compile_definitions(${target} PUBLIC "${macro_prefix}_HAS_DLL=0")
265-
endif()
260+
opendds_export_header(${target} EXISTING INCLUDE ${existing_header} MACRO_PREFIX ${macro_prefix})
266261
endif()
267262

268263
if(use_versioned_namespace)

docs/news.d/cmake-use-export.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. news-prs: 4964
2+
3+
.. news-start-section: Platform Support and Dependencies
4+
.. news-start-section: CMake
5+
- Fixed support for existing export header and macro in :cmake:func:`opendds_target_sources` with `USE_EXPORT`.
6+
7+
.. news-end-section
8+
.. news-end-section

0 commit comments

Comments
 (0)