mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-17 06:30:41 +08:00
[cmake]: add svn version script
CMakeLists.txt will generate version.h for mpp include git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@7 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -138,6 +138,73 @@ if(GCC)
|
|||||||
endif()
|
endif()
|
||||||
endif(GCC)
|
endif(GCC)
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Create svn version information
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
set(HAVE_SVN 0)
|
||||||
|
if(EXISTS "${PROJECT_SOURCE_DIR}/.svn/")
|
||||||
|
find_package(Subversion)
|
||||||
|
if(Subversion_FOUND)
|
||||||
|
set(HAVE_SVN 1)
|
||||||
|
else()
|
||||||
|
if(WIN32)
|
||||||
|
# The official subversion client is not available, so fall back to
|
||||||
|
# tortoise if it is installed.
|
||||||
|
find_program(TORTOISE_WCREV_EXECUTABLE
|
||||||
|
NAMES SubWCRev.exe
|
||||||
|
PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\TortoiseSVN;Directory]/bin"
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT TORTOISE_WCREV_EXECUTABLE)
|
||||||
|
message(STATUS "TortoiseSVN was not found.")
|
||||||
|
else(NOT TORTOISE_WCREV_EXECUTABLE)
|
||||||
|
message(STATUS "TortoiseSVN was Found.")
|
||||||
|
set(HAVE_SVN 1)
|
||||||
|
|
||||||
|
macro(Subversion_WC_INFO dir prefix)
|
||||||
|
# the subversion commands should be executed with the C locale, otherwise
|
||||||
|
# the message (which are parsed) may be translated, Alex
|
||||||
|
set(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}")
|
||||||
|
set(ENV{LC_ALL} C)
|
||||||
|
|
||||||
|
execute_process(COMMAND ${TORTOISE_WCREV_EXECUTABLE} ${dir}
|
||||||
|
OUTPUT_VARIABLE ${prefix}_WC_INFO
|
||||||
|
ERROR_VARIABLE Subversion_svn_info_error
|
||||||
|
RESULT_VARIABLE Subversion_svn_info_result
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
if(NOT ${Subversion_svn_info_result} EQUAL 0)
|
||||||
|
message(SEND_ERROR "Command \"${TORTOISE_WCREV_EXECUTABLE} ${dir}\" failed with output:\n${Subversion_svn_info_error}")
|
||||||
|
else()
|
||||||
|
string(REGEX REPLACE "^(.*\n)?Last committed at revision ([0-9]*)\n.*"
|
||||||
|
"\\2" ${prefix}_WC_REVISION "${${prefix}_WC_INFO}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# restore the previous LC_ALL
|
||||||
|
set(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL})
|
||||||
|
endmacro()
|
||||||
|
endif (NOT TORTOISE_WCREV_EXECUTABLE)
|
||||||
|
endif(WIN32)
|
||||||
|
endif(Subversion_FOUND)
|
||||||
|
|
||||||
|
endif(EXISTS "${PROJECT_SOURCE_DIR}/.svn/")
|
||||||
|
|
||||||
|
if(${HAVE_SVN})
|
||||||
|
Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project)
|
||||||
|
|
||||||
|
message(STATUS "Current svn revision is ${Project_WC_REVISION}")
|
||||||
|
set(VERSION_REVISION ${Project_WC_REVISION})
|
||||||
|
else()
|
||||||
|
set(VERSION_REVISION -1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
"${PROJECT_SOURCE_DIR}/build/cmake/version.h.in"
|
||||||
|
"${PROJECT_SOURCE_DIR}/inc/version.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# Build options
|
# Build options
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
24
build/cmake/version.h.in
Normal file
24
build/cmake/version.h.in
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010 Rockchip Electronics S.LSI Co. LTD
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __VERSION_H__
|
||||||
|
#define __VERSION_H__
|
||||||
|
|
||||||
|
#define SVN_VERSION "@VERSION_REVISION@"
|
||||||
|
#define SVN_LAST_LOG "@VERSION_LAST_LOG@"
|
||||||
|
|
||||||
|
#endif /*__VERSION_H__*/
|
||||||
|
|
@@ -20,7 +20,7 @@ add_library(osal STATIC
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(WIN32_PTHREAD_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/window/pthread/inc")
|
set(WIN32_PTHREAD_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/window/pthread/inc")
|
||||||
include_directories(${WIN32_PTHREAD_INCLUDE_DIRS})
|
include_directories(${WIN32_PTHREAD_INCLUDE_DIRS})
|
||||||
add_library(pthread STATIC IMPORTED)
|
add_library(pthread SHARED IMPORTED)
|
||||||
message(STATUS "platform X86 ${X86} X64 ${X64}")
|
message(STATUS "platform X86 ${X86} X64 ${X64}")
|
||||||
set(WIN32_PTHREAD_LIB_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/window/pthread/lib")
|
set(WIN32_PTHREAD_LIB_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/window/pthread/lib")
|
||||||
set(WIN32_PTHREAD_DLL_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/window/pthread/dll")
|
set(WIN32_PTHREAD_DLL_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/window/pthread/dll")
|
||||||
@@ -36,6 +36,9 @@ if(MSVC)
|
|||||||
include_directories("${WIN32_PTHREAD_DLL_DIRS}/${WIN32_ARCH}")
|
include_directories("${WIN32_PTHREAD_DLL_DIRS}/${WIN32_ARCH}")
|
||||||
set_target_properties(pthread PROPERTIES
|
set_target_properties(pthread PROPERTIES
|
||||||
IMPORTED_LOCATION
|
IMPORTED_LOCATION
|
||||||
|
"${WIN32_PTHREAD_LIB_DIRS}/${WIN32_ARCH}/pthreadVC2.dll")
|
||||||
|
set_target_properties(pthread PROPERTIES
|
||||||
|
IMPORTED_IMPLIB
|
||||||
"${WIN32_PTHREAD_LIB_DIRS}/${WIN32_ARCH}/pthreadVC2.lib")
|
"${WIN32_PTHREAD_LIB_DIRS}/${WIN32_ARCH}/pthreadVC2.lib")
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(osal pthread)
|
target_link_libraries(osal pthread)
|
||||||
|
Reference in New Issue
Block a user