Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Commit

Permalink
Adding proper version label to build output folder
Browse files Browse the repository at this point in the history
* Made all version constants have same prefix
* Parse ProtocolVersion.h in top level CMakeLists.txt to generate a project label
* Dump all outputs to version label folder
  • Loading branch information
HipsterSloth committed Mar 29, 2017
1 parent f4971d4 commit 0924b92
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 47 deletions.
41 changes: 41 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,47 @@ else()
endif()
endif()

#------------------------
# Project Version
#------------------------

# Retrieve version from header file
set(PSM_VERSION_HEADER_FILE "${ROOT_DIR}/src/psmoveprotocol/ProtocolVersion.h")

file(STRINGS ${PSM_VERSION_HEADER_FILE} PSM_VERSION_PARTS
REGEX "^#define[ \t]+PSM_VERSION_(PRODUCT|MAJOR|PHASE|MINOR|RELEASE|HOTFIX)[ \t]+[0-9a-z]+$")

# Verify version parts
string(REGEX MATCH "PSM_VERSION_PRODUCT[ \t]+[0-9a-z]+" PSM_VERSION_PRODUCT ${PSM_VERSION_PARTS})
string(REGEX MATCH "PSM_VERSION_MAJOR[ \t]+[0-9a-z]+" PSM_VERSION_MAJOR ${PSM_VERSION_PARTS})
string(REGEX MATCH "PSM_VERSION_PHASE[ \t]+[0-9a-z]+" PSM_VERSION_PHASE ${PSM_VERSION_PARTS})
string(REGEX MATCH "PSM_VERSION_MINOR[ \t]+[0-9a-z]+" PSM_VERSION_MINOR ${PSM_VERSION_PARTS})
string(REGEX MATCH "PSM_VERSION_RELEASE[ \t]+[0-9a-z]+" PSM_VERSION_RELEASE ${PSM_VERSION_PARTS})
string(REGEX MATCH "PSM_VERSION_HOTFIX[ \t]+[0-9a-z]+" PSM_VERSION_HOTFIX ${PSM_VERSION_PARTS})

if(NOT PSM_VERSION_PRODUCT
OR NOT PSM_VERSION_MAJOR
OR NOT PSM_VERSION_PHASE
OR NOT PSM_VERSION_MINOR
OR NOT PSM_VERSION_RELEASE
OR NOT PSM_VERSION_HOTFIX)
message(FATAL_ERROR "Unable to retrieve project version from ${PSM_VERSION_HEADER_FILE}")
endif()

# Extract version numbers
string(REGEX REPLACE "PSM_VERSION_PRODUCT[ \t]+([0-9a-z]+)" "\\1" PSM_VERSION_PRODUCT ${PSM_VERSION_PRODUCT})
string(REGEX REPLACE "PSM_VERSION_MAJOR[ \t]+([0-9a-z]+)" "\\1" PSM_VERSION_MAJOR ${PSM_VERSION_MAJOR})
string(REGEX REPLACE "PSM_VERSION_PHASE[ \t]+([0-9a-z]+)" "\\1" PSM_VERSION_PHASE ${PSM_VERSION_PHASE})
string(REGEX REPLACE "PSM_VERSION_MINOR[ \t]+([0-9a-z]+)" "\\1" PSM_VERSION_MINOR ${PSM_VERSION_MINOR})
string(REGEX REPLACE "PSM_VERSION_RELEASE[ \t]+([0-9a-z]+)" "\\1" PSM_VERSION_RELEASE ${PSM_VERSION_RELEASE})
string(REGEX REPLACE "PSM_VERSION_HOTFIX[ \t]+([0-9a-z]+)" "\\1" PSM_VERSION_HOTFIX ${PSM_VERSION_HOTFIX})

set(PSM_VERSION_STRING "${PSM_VERSION_PRODUCT}.${PSM_VERSION_MAJOR}_${PSM_VERSION_PHASE}${PSM_VERSION_MINOR}.${PSM_VERSION_RELEASE}.${PSM_VERSION_HOTFIX}")

message(STATUS "Project version: ${PSM_VERSION_STRING}")

set(PSM_PROJECT_NAME "PSMoveService_${PSM_VERSION_STRING}")

# When not using MSVC, we recommend using system-wide libraries
# (installed via homebrew on Mac or apt-get in Linux/Ubuntu)
# In MSVC, we auto-download the source and make it an external_project
Expand Down
8 changes: 4 additions & 4 deletions src/psmoveclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ set_target_properties(PSMoveClient_CAPI PROPERTIES C_VISIBILITY_PRESET hidden)
# Install
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
install(TARGETS PSMoveClient_CAPI
RUNTIME DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
PUBLIC_HEADER DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/include)
RUNTIME DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
PUBLIC_HEADER DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/include)
ELSE() #Linux/Darwin
install(TARGETS PSMoveClient_CAPI
RUNTIME DESTINATION bin
Expand Down
10 changes: 5 additions & 5 deletions src/psmoveconfigtool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ add_custom_command(TARGET PSMoveConfigTool POST_BUILD
# Install
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
install(TARGETS PSMoveConfigTool
RUNTIME DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib)
RUNTIME DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/assets/
DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin/assets
DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin/assets
FILES_MATCHING PATTERN "*.ttf" PATTERN "*.jpg")
install(DIRECTORY ${OPENVR_BINARIES_DIR}/
DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
FILES_MATCHING PATTERN "*.dll" PATTERN "*.pdb")
ELSE() #Linux/Darwin
ENDIF()
20 changes: 10 additions & 10 deletions src/psmoveprotocol/ProtocolVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
#define PSM_STRINGIZE(x) PSM_STRINGIZEIMPL(x)
#endif

#define PSM_PRODUCT_VERSION 0
#define PSM_MAJOR_VERSION 9
#define PSM_PHASE alpha
#define PSM_MINOR_VERSION 8
#define PSM_RELEASE_VERSION 1
#define PSM_HOTFIX_NUMBER 0
#define PSM_VERSION_PRODUCT 0
#define PSM_VERSION_MAJOR 9
#define PSM_VERSION_PHASE alpha
#define PSM_VERSION_MINOR 8
#define PSM_VERSION_RELEASE 1
#define PSM_VERSION_HOTFIX 0

/// "Product.Major-Phase Minor.Patch.Hotfix"
/// "Product.Major-Phase Minor.Release"
#if !defined(PSM_VERSION_STRING)
#define PSM_VERSION_STRING PSM_STRINGIZE(PSM_PRODUCT_VERSION.PSM_MAJOR_VERSION-PSM_PHASE PSM_MINOR_VERSION.PSM_RELEASE_VERSION)
#define PSM_VERSION_STRING PSM_STRINGIZE(PSM_PRODUCT_VERSION.PSM_MAJOR_VERSION-PSM_PHASE PSM_MINOR_VERSION.PSM_VERSION_RELEASE)
#endif

/// "Product.Major-Phase Minor.Patch.Hotfix"
/// "Product.Major-Phase Minor.Release.Hotfix"
#if !defined(PSM_DETAILED_VERSION_STRING)
#define PSM_DETAILED_VERSION_STRING PSM_STRINGIZE(PSM_PRODUCT_VERSION.PSM_MAJOR_VERSION-PSM_PHASE PSM_MINOR_VERSION.PSM_RELEASE_VERSION.PSM_HOTFIX_NUMBER)
#define PSM_DETAILED_VERSION_STRING PSM_STRINGIZE(PSM_PRODUCT_VERSION.PSM_MAJOR_VERSION-PSM_PHASE PSM_MINOR_VERSION.PSM_VERSION_RELEASE.PSM_VERSION_HOTFIX)
#endif

#endif // PROTOCOL_VERSION_H
8 changes: 4 additions & 4 deletions src/psmoveservice/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ ENDIF()
# Install
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
install(TARGETS PSMoveService
RUNTIME DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib)
RUNTIME DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib)
IF(${ISWIN32})
install(DIRECTORY "${ROOT_DIR}/thirdparty/CLEYE/x86/bin/"
DESTINATION ${ROOT_DIR}/Win32/bin
DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}//Win32/bin
FILES_MATCHING PATTERN "*.dll")
ENDIF()#ISWIN32
ELSE() #Linux/Darwin
Expand Down
48 changes: 24 additions & 24 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ ENDIF()#ISWIN32
# Install
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
install(TARGETS test_camera
RUNTIME DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib)
RUNTIME DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib)
install(TARGETS test_camera_parallel
RUNTIME DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib)
RUNTIME DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib)
ELSE() #Linux/Darwin
ENDIF()

Expand Down Expand Up @@ -274,9 +274,9 @@ SET_TARGET_PROPERTIES(test_psmove_controller PROPERTIES FOLDER Test)
# Install
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
install(TARGETS test_psmove_controller
RUNTIME DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib)
RUNTIME DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib)
ELSE() #Linux/Darwin
ENDIF()

Expand Down Expand Up @@ -389,9 +389,9 @@ SET_TARGET_PROPERTIES(test_navi_controller PROPERTIES FOLDER Test)
# Install
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
install(TARGETS test_navi_controller
RUNTIME DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib)
RUNTIME DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib)
ELSE() #Linux/Darwin
ENDIF()

Expand Down Expand Up @@ -513,9 +513,9 @@ SET_TARGET_PROPERTIES(test_ds4_controller PROPERTIES FOLDER Test)
# Install
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
install(TARGETS test_ds4_controller
RUNTIME DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib)
RUNTIME DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib)
ELSE() #Linux/Darwin
ENDIF()

Expand All @@ -529,9 +529,9 @@ SET_TARGET_PROPERTIES(test_console_CAPI PROPERTIES FOLDER Test)
# Install
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
install(TARGETS test_console_CAPI
RUNTIME DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib)
RUNTIME DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib)
ELSE() #Linux/Darwin
ENDIF()

Expand Down Expand Up @@ -580,9 +580,9 @@ SET_TARGET_PROPERTIES(test_kalman_filter PROPERTIES FOLDER Test)
# Install
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
install(TARGETS test_kalman_filter
RUNTIME DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib)
RUNTIME DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib)
ELSE() #Linux/Darwin
ENDIF()

Expand Down Expand Up @@ -615,9 +615,9 @@ SET_TARGET_PROPERTIES(unit_test_suite PROPERTIES FOLDER Test)
# Install
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
install(TARGETS unit_test_suite
RUNTIME DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${ARCH_LABEL}/lib)
RUNTIME DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/bin
LIBRARY DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib
ARCHIVE DESTINATION ${ROOT_DIR}/${PSM_PROJECT_NAME}/${ARCH_LABEL}/lib)
ELSE() #Linux/Darwin
ENDIF()

Expand Down

0 comments on commit 0924b92

Please sign in to comment.