You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "cmcfarlen (via GitHub)" <gi...@apache.org> on 2023/02/14 19:00:20 UTC

[GitHub] [trafficserver] cmcfarlen commented on a diff in pull request #9409: update cmake for rpc and swoc

cmcfarlen commented on code in PR #9409:
URL: https://github.com/apache/trafficserver/pull/9409#discussion_r1106253386


##########
lib/swoc/CMakeLists.txt:
##########
@@ -0,0 +1,132 @@
+cmake_minimum_required(VERSION 3.11)
+
+project(Lib-SWOC CXX)
+set(LIBSWOC_VERSION "1.4.2")
+set(CMAKE_CXX_STANDARD 17)
+cmake_policy(SET CMP0087 NEW)
+# override "lib64" to be "lib" unless the user explicitly sets it.
+set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "directory for libraries" FORCE)
+include(GNUInstallDirs)
+
+cmake_dependent_option(LIBSWOC_INSTALL
+        "Enable generation of libswoc install targets" ON
+        "NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT" OFF)
+
+set(HEADER_FILES
+        include/swoc/swoc_version.h
+        include/swoc/ArenaWriter.h
+        include/swoc/BufferWriter.h
+        include/swoc/bwf_base.h
+        include/swoc/bwf_ex.h
+        include/swoc/bwf_ip.h
+        include/swoc/bwf_std.h
+        include/swoc/DiscreteRange.h
+        include/swoc/Errata.h
+        include/swoc/IntrusiveDList.h
+        include/swoc/IntrusiveHashMap.h
+        include/swoc/swoc_ip.h
+        include/swoc/IPEndpoint.h
+        include/swoc/IPAddr.h
+        include/swoc/IPSrv.h
+        include/swoc/IPRange.h
+        include/swoc/Lexicon.h
+        include/swoc/MemArena.h
+        include/swoc/MemSpan.h
+        include/swoc/Scalar.h
+        include/swoc/TextView.h
+        include/swoc/swoc_file.h
+        include/swoc/swoc_meta.h
+        include/swoc/string_view.h
+        include/swoc/Vectray.h
+        )
+
+# These are external but required.
+set(EXTERNAL_HEADER_FILES
+        include/swoc/ext/HashFNV.h
+        )
+
+set(CC_FILES
+        src/bw_format.cc
+        src/bw_ip_format.cc
+        src/ArenaWriter.cc
+        src/Errata.cc
+        src/swoc_ip.cc
+        src/MemArena.cc
+        src/RBTree.cc
+        src/swoc_file.cc
+        src/TextView.cc
+        src/string_view_util.cc
+        )
+
+add_library(libswoc SHARED ${CC_FILES})
+set_target_properties(libswoc PROPERTIES OUTPUT_NAME swoc-${LIBSWOC_VERSION})
+if (CMAKE_COMPILER_IS_GNUCXX)
+    target_compile_options(libswoc PRIVATE -fPIC -Wall -Wextra -Werror -Wnon-virtual-dtor -Wpedantic)
+endif()
+
+add_library(libswoc-static STATIC ${CC_FILES})
+set_target_properties(libswoc-static PROPERTIES OUTPUT_NAME swoc-static-${LIBSWOC_VERSION})
+if (CMAKE_COMPILER_IS_GNUCXX)
+    target_compile_options(libswoc-static PRIVATE -fPIC -Wall -Wextra -Werror -Wnon-virtual-dtor -Wpedantic)
+endif()
+
+# Not quite sure how this works, but I think it generates one of two paths depending on the context.
+# That is, the generator functions return non-empty strings only in the corresponding context.
+target_include_directories(libswoc-static
+        PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+        $<INSTALL_INTERFACE:include>
+        )
+
+target_include_directories(libswoc
+        PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+        $<INSTALL_INTERFACE:include>
+        )
+
+if (LIBSWOC_INSTALL)
+    # These install target variables are created by GNUInstallDirs.
+    install(TARGETS libswoc-static
+            EXPORT libswoc-static-config
+            ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # seems to have no effect.
+            )
+    install(TARGETS libswoc
+            EXPORT libswoc-config
+            ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # seems to have no effect.
+            )
+    install(DIRECTORY include/swoc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+
+    set(link-target libswoc.so)
+    set(link-src $<TARGET_FILE_NAME:libswoc>)
+    install(CODE
+            "execute_process(COMMAND bash -c \"echo Linking ${link-src} to ${link-target};cd ${CMAKE_INSTALL_FULL_LIBDIR} && (rm -f ${link-target};ln -s ${link-src} ${link-target})
+        \")"
+            )
+
+    install(EXPORT libswoc-static-config
+            NAMESPACE libswoc::
+            DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libswoc
+            )
+
+    install(EXPORT libswoc-config
+            NAMESPACE libswoc::
+            DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libswoc
+            )
+
+    #    set(PKG_CONFIG_FILE libswoc.pc)
+    #    set(PKG_STATIC_CONFIG_FILE libswoc-static.pc)
+    #    configure_file("libswoc.pc.cmake" ${PKG_CONFIG_FILE} @ONLY)
+    #
+    # configure_file("libswoc.pc.cmake" libswoc.pc @ONLY)
+    # configure_file("libswoc-static.pc.cmake" libswoc-static.pc @ONLY)

Review Comment:
   I had to comment these `configure_file` lines out since the source files are missing.  Otherwise this file is the same as swoc upstream.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org