Open
Description
🤔 What's the problem you've observed?
Compilation
- Compilation without
.git
(e.g. from downloaded Source Archive) leads to error causeCUKE_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}"