mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Fixed: revision.h error when hg executable not found
This commit is contained in:
parent
bced63993b
commit
2e6361ebfe
2 changed files with 53 additions and 21 deletions
|
@ -3,20 +3,24 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3)
|
||||||
# ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory)
|
# ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory)
|
||||||
# SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt)
|
# SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt)
|
||||||
|
|
||||||
# Replace spaces by semi-columns
|
IF(SOURCE_DIR)
|
||||||
IF(CMAKE_MODULE_PATH)
|
# Replace spaces by semi-columns
|
||||||
STRING(REPLACE " " ";" CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
|
IF(CMAKE_MODULE_PATH)
|
||||||
ENDIF(CMAKE_MODULE_PATH)
|
STRING(REPLACE " " ";" CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
|
||||||
|
ENDIF(CMAKE_MODULE_PATH)
|
||||||
|
|
||||||
SET(CMAKE_MODULE_PATH ${SOURCE_DIR}/CMakeModules ${CMAKE_MODULE_PATH})
|
SET(CMAKE_MODULE_PATH ${SOURCE_DIR}/CMakeModules ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
IF(NOT ROOT_DIR AND SOURCE_DIR)
|
IF(NOT ROOT_DIR AND SOURCE_DIR)
|
||||||
SET(ROOT_DIR ${SOURCE_DIR})
|
SET(ROOT_DIR ${SOURCE_DIR})
|
||||||
ENDIF(NOT ROOT_DIR AND SOURCE_DIR)
|
ENDIF(NOT ROOT_DIR AND SOURCE_DIR)
|
||||||
|
|
||||||
IF(NOT SOURCE_DIR AND ROOT_DIR)
|
IF(NOT SOURCE_DIR AND ROOT_DIR)
|
||||||
SET(SOURCE_DIR ${ROOT_DIR})
|
SET(SOURCE_DIR ${ROOT_DIR})
|
||||||
ENDIF(NOT SOURCE_DIR AND ROOT_DIR)
|
ENDIF(NOT SOURCE_DIR AND ROOT_DIR)
|
||||||
|
ELSE(SOURCE_DIR)
|
||||||
|
SET(ROOT_DIR ${CMAKE_SOURCE_DIR})
|
||||||
|
ENDIF(SOURCE_DIR)
|
||||||
|
|
||||||
MACRO(NOW RESULT)
|
MACRO(NOW RESULT)
|
||||||
IF (WIN32)
|
IF (WIN32)
|
||||||
|
@ -53,10 +57,11 @@ IF(EXISTS "${ROOT_DIR}/.hg/")
|
||||||
ENDIF(MERCURIAL_FOUND)
|
ENDIF(MERCURIAL_FOUND)
|
||||||
ENDIF(EXISTS "${ROOT_DIR}/.hg/")
|
ENDIF(EXISTS "${ROOT_DIR}/.hg/")
|
||||||
|
|
||||||
IF(DEFINED REVISION)
|
IF(SOURCE_DIR AND DEFINED REVISION)
|
||||||
IF(EXISTS ${SOURCE_DIR}/revision.h.in)
|
IF(EXISTS ${SOURCE_DIR}/revision.h.in)
|
||||||
|
MESSAGE(STATUS "Revision: ${REVISION}")
|
||||||
NOW(BUILD_DATE)
|
NOW(BUILD_DATE)
|
||||||
CONFIGURE_FILE(${SOURCE_DIR}/revision.h.in revision.h.txt)
|
CONFIGURE_FILE(${SOURCE_DIR}/revision.h.in revision.h.txt)
|
||||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy revision.h.txt revision.h) # copy_if_different
|
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy revision.h.txt revision.h) # copy_if_different
|
||||||
ENDIF(EXISTS ${SOURCE_DIR}/revision.h.in)
|
ENDIF(EXISTS ${SOURCE_DIR}/revision.h.in)
|
||||||
ENDIF(DEFINED REVISION)
|
ENDIF(SOURCE_DIR AND DEFINED REVISION)
|
||||||
|
|
|
@ -22,22 +22,39 @@ ENDMACRO(NL_GEN_PC)
|
||||||
###
|
###
|
||||||
MACRO(NL_GEN_REVISION_H)
|
MACRO(NL_GEN_REVISION_H)
|
||||||
IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
|
IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
|
SET(TOOL_FOUND OFF)
|
||||||
ADD_DEFINITIONS(-DHAVE_REVISION_H)
|
|
||||||
SET(HAVE_REVISION_H ON)
|
IF(EXISTS "${CMAKE_SOURCE_DIR}/../.svn/")
|
||||||
|
FIND_PACKAGE(Subversion)
|
||||||
|
|
||||||
|
IF(SUBVERSION_FOUND)
|
||||||
|
SET(TOOL_FOUND ON)
|
||||||
|
ENDIF(SUBVERSION_FOUND)
|
||||||
|
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/../.svn/")
|
||||||
|
|
||||||
|
IF(EXISTS "${CMAKE_SOURCE_DIR}/../.hg/")
|
||||||
|
FIND_PACKAGE(Mercurial)
|
||||||
|
|
||||||
|
IF(MERCURIAL_FOUND)
|
||||||
|
SET(TOOL_FOUND ON)
|
||||||
|
ENDIF(MERCURIAL_FOUND)
|
||||||
|
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/../.hg/")
|
||||||
|
|
||||||
# if already generated
|
# if already generated
|
||||||
IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h)
|
IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h)
|
||||||
# copy it
|
# copy it
|
||||||
MESSAGE(STATUS "Copying provided revision.h...")
|
MESSAGE(STATUS "Copying provided revision.h...")
|
||||||
FILE(COPY ${CMAKE_SOURCE_DIR}/revision.h DESTINATION ${CMAKE_BINARY_DIR})
|
FILE(COPY ${CMAKE_SOURCE_DIR}/revision.h DESTINATION ${CMAKE_BINARY_DIR})
|
||||||
ELSE(EXISTS ${CMAKE_SOURCE_DIR}/revision.h)
|
SET(HAVE_REVISION_H ON)
|
||||||
|
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h)
|
||||||
|
|
||||||
|
IF(TOOL_FOUND)
|
||||||
# a custom target that is always built
|
# a custom target that is always built
|
||||||
ADD_CUSTOM_TARGET(revision ALL
|
ADD_CUSTOM_TARGET(revision ALL)
|
||||||
DEPENDS ${CMAKE_BINARY_DIR}/revision.h)
|
|
||||||
|
|
||||||
# creates revision.h using cmake script
|
# creates revision.h using cmake script
|
||||||
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/revision.h
|
ADD_CUSTOM_COMMAND(TARGET revision
|
||||||
|
PRE_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
|
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
|
||||||
-DROOT_DIR=${CMAKE_SOURCE_DIR}/..
|
-DROOT_DIR=${CMAKE_SOURCE_DIR}/..
|
||||||
|
@ -47,7 +64,13 @@ MACRO(NL_GEN_REVISION_H)
|
||||||
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/revision.h
|
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/revision.h
|
||||||
PROPERTIES GENERATED TRUE
|
PROPERTIES GENERATED TRUE
|
||||||
HEADER_FILE_ONLY TRUE)
|
HEADER_FILE_ONLY TRUE)
|
||||||
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h)
|
SET(HAVE_REVISION_H ON)
|
||||||
|
ENDIF(TOOL_FOUND)
|
||||||
|
|
||||||
|
IF(HAVE_REVISION_H)
|
||||||
|
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
|
||||||
|
ADD_DEFINITIONS(-DHAVE_REVISION_H)
|
||||||
|
ENDIF(HAVE_REVISION_H)
|
||||||
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
|
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
|
||||||
ENDMACRO(NL_GEN_REVISION_H)
|
ENDMACRO(NL_GEN_REVISION_H)
|
||||||
|
|
||||||
|
@ -922,6 +945,10 @@ MACRO(SETUP_EXTERNAL)
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
FIND_PACKAGE(External REQUIRED)
|
FIND_PACKAGE(External REQUIRED)
|
||||||
|
|
||||||
|
IF(NOT VC_DIR)
|
||||||
|
SET(VC_DIR $ENV{VC_DIR})
|
||||||
|
ENDIF(NOT VC_DIR)
|
||||||
|
|
||||||
IF(MSVC10)
|
IF(MSVC10)
|
||||||
IF(NOT MSVC10_REDIST_DIR)
|
IF(NOT MSVC10_REDIST_DIR)
|
||||||
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
||||||
|
|
Loading…
Reference in a new issue