Improve build: parse out the version
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
# Full-featured Build System Sample
|
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu>
|
||||||
# CMake cross-platform build system recipe
|
|
||||||
# 2009 Ryan Pavlik <rpavlik@iastate.edu>
|
|
||||||
# http://academic.cleardefinition.com/
|
# http://academic.cleardefinition.com/
|
||||||
# Iowa State University HCI Graduate Program/VRAC
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 2.6.2)
|
||||||
|
|
||||||
# Set package properties
|
# Set package properties
|
||||||
project(WiiUse)
|
project(WiiUse)
|
||||||
@@ -13,6 +11,9 @@ project(WiiUse)
|
|||||||
# Set up options
|
# Set up options
|
||||||
###
|
###
|
||||||
|
|
||||||
|
include("./ParseVersion.cmake")
|
||||||
|
message(STATUS "Configuring WiiUse version ${CPACK_PACKAGE_VERSION}")
|
||||||
|
|
||||||
option(BUILD_EXAMPLE "Should we build the example app?" YES)
|
option(BUILD_EXAMPLE "Should we build the example app?" YES)
|
||||||
option(BUILD_EXAMPLE_SDL "Should we build the SDL-based example app?" YES)
|
option(BUILD_EXAMPLE_SDL "Should we build the SDL-based example app?" YES)
|
||||||
option(INSTALL_EXAMPLES "Should we install the example apps?" YES)
|
option(INSTALL_EXAMPLES "Should we install the example apps?" YES)
|
||||||
@@ -64,6 +65,24 @@ endif()
|
|||||||
# Set packaging options (for CPack)
|
# Set packaging options (for CPack)
|
||||||
###
|
###
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(DOC_DIR .)
|
||||||
|
else()
|
||||||
|
set(DOC_DIR share/doc/wiiuse)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
CHANGELOG
|
||||||
|
LICENSE
|
||||||
|
LICENSE_noncommercial
|
||||||
|
README
|
||||||
|
DESTINATION ${DOC_DIR})
|
||||||
|
|
||||||
|
include(GetCompilerInfoString)
|
||||||
|
get_compiler_info_string(_compiler)
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${_compiler}")
|
||||||
|
|
||||||
# Include the packaging system now that we have it all set up
|
# Include the packaging system now that we have it all set up
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|
||||||
|
|||||||
28
ParseVersion.cmake
Normal file
28
ParseVersion.cmake
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
set(_version_file "${CMAKE_CURRENT_SOURCE_DIR}/src/wiiuse.h")
|
||||||
|
if(EXISTS "${_version_file}")
|
||||||
|
file(READ "${_version_file}" _version_contents)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${_version_contents}" MATCHES "WIIUSE_MAJOR ([0-9]+)")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||||
|
else()
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||||
|
message("Could not parse major version from wiiuse.h")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${_version_contents}" MATCHES "WIIUSE_MINOR ([0-9]+)")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR "${CMAKE_MATCH_1}")
|
||||||
|
else()
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR "13")
|
||||||
|
message("Could not parse minor version from wiiuse.h")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${_version_contents}" MATCHES "WIIUSE_MICRO ([0-9]+)")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MICRO "${CMAKE_MATCH_1}")
|
||||||
|
else()
|
||||||
|
set(CPACK_PACKAGE_VERSION_MICRO "0")
|
||||||
|
message("Could not parse micro version from wiiuse.h")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_VERSION
|
||||||
|
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_MICRO}")
|
||||||
Reference in New Issue
Block a user