terom@396: # terom@396: # CMake build script to determine project version number. terom@396: # terom@396: # this will set PROJECT_VERSION to a string terom@396: # terom@396: FUNCTION (FindProjectVersion project_path) terom@397: # Mercurial terom@397: if (EXISTS ${project_path}/.hg) terom@397: # first, determine tag terom@396: EXECUTE_PROCESS ( terom@397: COMMAND hg identify --tag terom@396: WORKING_DIRECTORY "${project_path}" terom@396: RESULT_VARIABLE hg_error_code terom@397: OUTPUT_VARIABLE hg_tag terom@396: OUTPUT_STRIP_TRAILING_WHITESPACE terom@396: ) terom@397: terom@396: if (hg_error_code) terom@397: MESSAGE (FATAL_ERROR "`hg identify --tag` failed") terom@396: endif (hg_error_code) terom@396: terom@397: # if tag is other than tip, use that terom@397: if ("${hg_tag}" STREQUAL "tip") terom@397: # use the revision hash terom@397: EXECUTE_PROCESS ( terom@397: COMMAND hg identify --id terom@397: WORKING_DIRECTORY "${project_path}" terom@397: RESULT_VARIABLE hg_error_code terom@397: OUTPUT_VARIABLE hg_id terom@397: OUTPUT_STRIP_TRAILING_WHITESPACE terom@397: ) terom@396: terom@397: if (hg_error_code) terom@397: MESSAGE (FATAL_ERROR "`hg identify --id` failed") terom@397: endif (hg_error_code) terom@396: terom@397: SET (PROJECT_VERSION "${hg_id}" PARENT_SCOPE) terom@397: MESSAGE (STATUS "Version: mercurial tip id: ${hg_id}") terom@396: terom@397: else ("${hg_tag}" STREQUAL "tip") terom@397: SET (PROJECT_VERSION "${hg_tag}" PARENT_SCOPE) terom@397: MESSAGE (STATUS "Version: mercurial tag: ${hg_tag}") terom@397: terom@397: endif ("${hg_tag}" STREQUAL "tip") terom@397: terom@397: else (EXISTS ${project_path}/.hg) terom@398: SET (PROJECT_VERSION "???" PARENT_SCOPE) terom@398: MESSAGE (STATUS "No version information available") terom@397: terom@397: endif (EXISTS ${project_path}/.hg) terom@396: ENDFUNCTION (FindProjectVersion)