Skip to content

Commit 29ccf2c

Browse files
committed
ZGW-3429: libzwaveip: build: Remove cmake generated files
It is a good practice to change sources on build, this will create ambiguity, since it is easy to rebuild version related files will be generated on the fly. Origin: #23 Signed-off-by: Philippe Coval <[email protected]>
1 parent ee22272 commit 29ccf2c

File tree

3 files changed

+20
-39
lines changed

3 files changed

+20
-39
lines changed

libzwaveip/CMakeLists.txt

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 2.9)
44
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
55

66
#TODO better versioning here when releasing
7-
set(VERSION_SHORT "latest")
7+
88

99
# Enforce build type
1010
if(NOT CMAKE_BUILD_TYPE)
@@ -51,23 +51,25 @@ find_package(LibXml2)
5151

5252
message (STATUS "openssl libraries: ${OPENSSL_LIBRARIES}")
5353

54-
# Figure out a proper versioning for the build
55-
if(NOT GIT_FOUND)
56-
find_package(Git QUIET)
57-
endif()
58-
59-
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --match "ver*"
60-
OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
61-
62-
if(VERSION MATCHES "^ver")
63-
MESSAGE(STATUS "log: found git tag: ${VERSION}")
54+
if(NOT PROJECT_IS_TOP_LEVEL)
55+
set(VERSION_SHORT "latest")
56+
set(CMAKE_PROJECT_NAME "libzwaveip")
6457
else()
65-
if(NOT DEFINED VERSION)
66-
set(VERSION ver0_0.0)
58+
59+
# Figure out a proper versioning for the build
60+
if(NOT GIT_FOUND)
61+
find_package(Git QUIET)
6762
endif()
63+
64+
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --match "ver*"
65+
OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
66+
endif()
67+
68+
if(NOT VERSION MATCHES "^ver")
69+
set(VERSION ver0_0.00)
6870
endif()
6971

70-
#parse the version information into pieces.
72+
message(STATUS "log: parse the version information into pieces: ${VERSION}")
7173
string(REGEX REPLACE "^ver([0-9]+)_.*" "\\1" VERSION_MAJOR "${VERSION}")
7274
string(REGEX REPLACE "^ver[0-9]+_([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
7375
string(REGEX REPLACE "^ver[0-9]+_[0-9]+.[0-9]+[0-9,R,C,_]*-.[0-9]*-(.*)" "\\1" VERSION_SHA1 "${VERSION}")
@@ -83,14 +85,15 @@ set(VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${PATCH_LEVEL}")
8385
if (DEFINED VERSION_SHA1)
8486
set(VERSION_SHORT "${VERSION_SHORT}-${VERSION_SHA1}")
8587
endif()
88+
8689
message(STATUS "VERSION_MAJOR: " ${VERSION_MAJOR})
8790
message(STATUS "VERSION_MINOR: " ${VERSION_MINOR})
8891
message(STATUS "PATCH_LEVEL: " ${PATCH_LEVEL})
8992
message(STATUS "VERSION_TWEAK: " ${VERSION_TWEAK})
9093
message(STATUS "VERSION_SHA1: " ${VERSION_SHA1})
9194
message(STATUS "VERSION_SHORT: " ${VERSION_SHORT})
9295

93-
configure_file(pkgconfig.h.cmake.in ${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig.h)
96+
configure_file(pkgconfig.h.cmake.in pkgconfig.h)
9497

9598
add_subdirectory( libzwaveip )
9699
add_subdirectory( xml )

libzwaveip/examples/reference_apps/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ target_include_directories(reference_client
2020
../..
2121
../../libedit
2222
${LIBXML2_INCLUDE_DIR}
23+
${CMAKE_CURRENT_BINARY_DIR}/../..
2324
)
2425

2526
target_include_directories(reference_listener
2627
PUBLIC
2728
listener
2829
../..
30+
${CMAKE_CURRENT_BINARY_DIR}/../..
2931
)
3032

3133
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")

libzwaveip/pkgconfig.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)