cmake: add a dummy c++ file to force linkage

The hs dylib when built with Xcode wasn't being linked to C++ runtime
libs. Fixes #69
This commit is contained in:
Matthew Barr 2017-09-27 11:21:01 +10:00
parent 3fa1236f09
commit 3d235f4474

View File

@ -1271,25 +1271,42 @@ if (NOT BUILD_SHARED_LIBS)
endif()
if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
if (NOT FAT_RUNTIME)
add_library(hs_shared SHARED src/hs_version.c src/hs_valid_platform.c
$<TARGET_OBJECTS:hs_compile_shared> $<TARGET_OBJECTS:hs_exec_shared>)
else()
add_library(hs_shared SHARED src/hs_version.c src/hs_valid_platform.c
$<TARGET_OBJECTS:hs_compile_shared> $<TARGET_OBJECTS:hs_exec_common_shared>
${RUNTIME_SHLIBS})
set(hs_shared_SRCS
src/hs_version.c
src/hs_valid_platform.c
$<TARGET_OBJECTS:hs_compile_shared>)
if (XCODE)
# force this lib to use C++ linkage
add_custom_command(OUTPUT empty.cxx
COMMAND ${CMAKE_COMMAND} -E touch empty.cxx)
set (hs_shared_SRCS ${hs_shared_SRCS} empty.cxx)
endif (XCODE)
if (NOT FAT_RUNTIME)
set(hs_shared_SRCS
${hs_shared_SRCS}
$<TARGET_OBJECTS:hs_exec_shared>)
else ()
set(hs_shared_SRCS
${hs_shared_SRCS}
$<TARGET_OBJECTS:hs_exec_common_shared>
${RUNTIME_SHLIBS})
endif ()
add_library(hs_shared SHARED ${hs_shared_SRCS})
endif()
add_dependencies(hs_shared ragel_Parser)
set_target_properties(hs_shared PROPERTIES
OUTPUT_NAME hs
VERSION ${LIB_VERSION}
SOVERSION ${LIB_SOVERSION}
MACOSX_RPATH ON)
install(TARGETS hs_shared
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS hs_shared
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
# used by tools and other targets