Compilation and Library Use

未关闭
#295 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
cmake, cpp
领域
build-system

调研方向

从 CMakeLists.txt 和 src/CMakeLists 开始,然后从下载的源代码归档中重现报告的构建,并针对 Unix 共享库进行重现。检查 issue 中描述的警告、版本检测和位置无关代码路径;当这些编译场景能够在没有报告的错误的情况下正常工作时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

bug
🤔 What's the problem you've observed?
Compilation
  • Compilation without .git (e.g. from downloaded Source Archive) leads to error cause CUKE_VERSION could not be determined
  • Use Library in a Shared Library requires compilation with -fPIC on Unix
  • Compilation error due to -Werror:
include/asio/impl/error.ipp:34:15: error: ‘virtual const char* asio::error::detail::netdb_category::name() const’ can be marked override [-Werror=suggest-override]
✨ Do you have a proposal for making it better?
  • If compiled from source archive the used CUKE_VERSION must be SET via Configure OR the source archive should contain a version file from which CMake could read the CUKE_VERSION
  • Compile with flag -fPIC in Unix cases
  • Remove -Werror, No warnings goal should be checked via github actions on merge / build
📚 Any additional context?

Below suggestion to remove the issues without greater changes

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cc98353..7b92ff4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,7 +98,7 @@ endif()
 #
 
 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Werror -Wall -Wextra -Wsuggest-override ${CMAKE_CXX_FLAGS}")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Wall -Wextra -Wsuggest-override ${CMAKE_CXX_FLAGS}")
     # TODO: A better fix should handle ld's --as-needed flag
     if(UNIX AND NOT APPLE)
         set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker '--no-as-needed'")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 466c37c..cda2006 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -127,7 +127,18 @@ foreach(TARGET
     endif(MINGW)
 endforeach()
 
-git_get_version(CUKE_VERSION)
+if(UNIX)
+    foreach(TARGET
+        cucumber-cpp-internal
+        cucumber-cpp-nomain
+    )
+        target_compile_options(${TARGET} PRIVATE -fPIC)
+    endforeach()
+endif()
+
+if("${CUKE_VERSION}" STREQUAL "")
+    git_get_version(CUKE_VERSION)
+endif()
 message(STATUS "Version: ${CUKE_VERSION}")
 target_compile_definitions(cucumber-cpp PRIVATE
     CUKE_VERSION="${CUKE_VERSION}"

主要语言
C++
星标
330
派生
142
平均合并
2 天 8 小时
30 天内合并 PR
2

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cucumber/cucumber-cpp 的其他 Issue

查看 cucumber/cucumber-cpp 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。