Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation and Library Use #295

Open
kreuzberger opened this issue Apr 9, 2024 · 2 comments
Open

Compilation and Library Use #295

kreuzberger opened this issue Apr 9, 2024 · 2 comments
Labels

Comments

@kreuzberger
Copy link

🤔 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}"

@ursfassler ursfassler added the bug label Apr 9, 2024
@ursfassler
Copy link
Contributor

@kreuzberger thanks for the report. This indeed looks like bugs.

@loren-osborn
Copy link

Thought my comment here might be relevant:

#297 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants