cmake_export_symbol: Darwin compatibility

The Darwin platform prefixes all C symbols with an underscore.  At
link-time of a shared library, libressl generates a list of symbols to
export, but does not prefix each symbol with an underscore.

This commit addresses that issue.
This commit is contained in:
Masud Rahman 2017-06-25 18:19:20 -04:00
parent 8b80bcdad8
commit 73e51e012f

View File

@ -10,7 +10,13 @@ macro(export_symbol TARGET FILENAME)
target_sources(${TARGET} PRIVATE ${DEF_FILENAME}) target_sources(${TARGET} PRIVATE ${DEF_FILENAME})
elseif(APPLE) elseif(APPLE)
set(FLAG "-exported_symbols_list ${FILENAME}") file(READ ${FILENAME} SYMBOLS)
string(REGEX REPLACE "\n$" "" SYMBOLS ${SYMBOLS})
string(REPLACE "\n" "\n_" SYMBOLS ${SYMBOLS})
string(REGEX REPLACE "(.)$" "\\1\\n" SYMBOLS ${SYMBOLS})
string(REPLACE ".sym" ".exp" EXP_FILENAME ${FILENAME})
file(WRITE ${EXP_FILENAME} "_${SYMBOLS}")
set(FLAG "-exported_symbols_list ${EXP_FILENAME}")
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS ${FLAG}) set_target_properties(${TARGET} PROPERTIES LINK_FLAGS ${FLAG})
elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX") elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX")