diff --git a/CMakeLists.txt b/CMakeLists.txt index ea6ab36..a1f286d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,10 +8,22 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # N2n release information set(N2N_OSNAME ${CMAKE_SYSTEM_NAME}) execute_process( - COMMAND scripts/version.sh - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE PACKAGE_VERSION + COMMAND scripts/version.sh + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE PACKAGE_VERSION + RESULT_VARIABLE GIT_ERROR_CODE ) +if (NOT GIT_ERROR_CODE EQUAL 0) + # - if we can run version.sh and it exits with an error that is signaling + # a build failure. + # - if we are on windows with no MSYS or Cygwin, we cannot run version.sh + # which is the fallback case handled below + # TODO: Distinguish between these two cases + + # Fallback to just using the non dynamic short version string + file(STRINGS VERSION PACKAGE_VERSION) +endif (NOT GIT_ERROR_CODE EQUAL 0) + string(STRIP "${PACKAGE_VERSION}" PACKAGE_VERSION) MESSAGE(STATUS "Build for version: ${PACKAGE_VERSION}") diff --git a/Makefile.in b/Makefile.in index de86f47..ae6e68b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -148,7 +148,14 @@ COVERAGEDIR?=coverage .PHONY: steps build push all clean distclean install test cover gcov build-dep .PHONY: lint lint.python lint.ccode lint.shell lint.yaml -all: $(APPS) $(DOCS) $(SUBDIRS) +all: version $(APPS) $(DOCS) $(SUBDIRS) + +# This allows breaking the build if the version.sh script discovers +# any inconsistancies +.PHONY: version +version: + @echo -n "Build for version: " + @scripts/version.sh tools: $(N2N_LIB) $(MAKE) -C $@