cucumber / cucumber-cpp

Support for writing Cucumber step definitions in C++
MIT License
304 stars 131 forks source link

Compilation and Library Use #295

Open kreuzberger opened 4 months ago

kreuzberger commented 4 months ago

🤔 What's the problem you've observed?

Compilation

✨ Do you have a proposal for making it better?

📚 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 commented 4 months ago

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

loren-osborn commented 3 months ago

Thought my comment here might be relevant:

https://github.com/cucumber/cucumber-cpp/issues/297#issuecomment-2103434276