]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
cmake: add a dummy c++ file to force linkage
authorMatthew Barr <matthew.barr@intel.com>
Wed, 27 Sep 2017 01:21:01 +0000 (11:21 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 29 Sep 2017 04:52:11 +0000 (14:52 +1000)
The hs dylib when built with Xcode wasn't being linked to C++ runtime
libs. Fixes #69

CMakeLists.txt

index 59a3292b8335f6060fd471262cab526848b6b535..f81cd7eb8a914f893d4bcca8fb77a30c15868d96 100644 (file)
@@ -1271,25 +1271,42 @@ if (NOT BUILD_SHARED_LIBS)
 endif()
 
 if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
+    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)
-        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>
+        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