CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) INCLUDE(cmake/macros.cmake) INCLUDE(cmake/checks.cmake) # Speed Dreams project project (speed-dreams) # 3rd Party Dependency Stuff IF(WIN32) INCLUDE(Find3rdPartyDependencies) ENDIF(WIN32) CHECK_HEADERS_H() CHECK_FUNCTIONS() CHECK_LIBRARIES() CHECK_PLIB_LIBRARIES() CHECK_PACKAGES() #Calculate version #Set version which doesn't follow from HeadURL SET(HEAD_URL "$HeadURL$") SET(NEXT_LESSER_VERSION 0) # The next lesser version SET(NEXT_MAJOR_MINOR_VERSION "2.0") # Next major.minor version #Define regular expressions SET(REGEX_TAG "^\\$HeadURL:.*speed-dreams/tags/([^/\\$ ]*).*\\$$") SET(REGEX_BUG_BRANCH "^\\$HeadURL:.*speed-dreams/branches/([0-9]+\\.[0-9]+)(\\.[xX])?/.*\\$$") SET(REGEX_TRUNK "^\\$HeadURL:.*speed-dreams/trunk/.*\\$$") SET(REGEX_BRANCH "^\\$HeadURL:.*speed-dreams/branches/([^/\\$ ]*).*\\$$") #Check regular expressions STRING(REGEX MATCH "${REGEX_TAG}" VERSION_IS_TAG "${HEAD_URL}") STRING(REGEX MATCH "${REGEX_BUG_BRANCH}" VERSION_IS_BUG_BRANCH "${HEAD_URL}") STRING(REGEX MATCH "${REGEX_TRUNK}" VERSION_IS_TRUNK "${HEAD_URL}") STRING(REGEX MATCH "${REGEX_BRANCH}" VERSION_IS_BRANCH "${HEAD_URL}") #Look in which case we are and set the version according to that SET(NEED_SVN_REV FALSE) IF(VERSION_IS_TAG) STRING(REGEX REPLACE "${REGEX_TAG}" "\\1" VERSION "${HEAD_URL}") ELSEIF(VERSION_IS_BUG_BRANCH) STRING(REGEX REPLACE "${REGEX_BUG_BRANCH}" "\\1" TMP_VERSION "${HEAD_URL}") SET(VERSION "${TMP_VERSION}.${NEXT_LESSER_VERSION}") SET(NEED_SVN_REV TRUE) ELSEIF(VERSION_IS_TRUNK) SET(VERSION "${NEXT_MAJOR_MINOR_VERSION}-dev") SET(NEED_SVN_REV TRUE) ELSEIF(VERSION_IS_BRANCH) STRING(REGEX REPLACE "${REGEX_BRANCH}" "\\1" VERSION "${HEAD_URL}") SET(NEED_SVN_REV TRUE) ELSE(VERSION_IS_TAG) MESSAGE("Warning: unknown version through unexpected HeadURL") ENDIF(VERSION_IS_TAG) #Try to get current revision IF(NEED_SVN_REV) SET(SVN_FIND_REV_FAILED FALSE) FIND_PROGRAM(SVNVERSION_EXEC svnversion PATHS /usr/local/bin /usr/bin) IF(NOT SVNVERSION_EXEC) SET(SVN_FIND_REV_FAILED TRUE) ENDIF(NOT SVNVERSION_EXEC) IF(NOT SVN_FIND_REV_FAILED) EXECUTE_PROCESS(COMMAND ${SVNVERSION_EXEC} ${CMAKE_CURRENT_SOURCE_DIR} --no-newline RESULT_VARIABLE SVNVERSION_RESULT OUTPUT_VARIABLE SVN_REV_LONG) IF(NOT ${SVNVERSION_RESULT} EQUAL 0) SET(SVN_FIND_REV_FAILED TRUE) ENDIF(NOT ${SVNVERSION_RESULT} EQUAL 0) ENDIF(NOT SVN_FIND_REV_FAILED) IF(NOT SVN_FIND_REV_FAILED) IF("${SVN_REV_LONG}" MATCHES ":") STRING(REGEX REPLACE "^[^:]*:(.*)$" "\\1" SVN_REV "${SVN_REV_LONG}") ELSE("${SVN_REV_LONG}" MATCHES ":") SET(SVN_REV "${SVN_REV_LONG}") ENDIF("${SVN_REV_LONG}" MATCHES ":") IF(NOT SVN_REV) SET(SVN_FIND_REV_FAILED TRUE) ENDIF(NOT SVN_REV) ENDIF(NOT SVN_FIND_REV_FAILED) STRING(TOLOWER ${SVN_REV} SVN_REV) SET(VERSION_LONG "${VERSION}") IF(NOT SVN_FIND_REV_FAILED) SET(VERSION_LONG "${VERSION_LONG}-r${SVN_REV}") ENDIF(NOT SVN_FIND_REV_FAILED) MESSAGE(STATUS "Looking for current subversion revision : found '${VERSION_LONG}'") ELSE(NEED_SVN_REV) SET(VERSION_LONG "${VERSION}") ENDIF(NEED_SVN_REV) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doxygen_config.cmake ${CMAKE_CURRENT_BINARY_DIR}/doxygen_config @ONLY) TORCS_INSTALL_FILES(DATA . FILES credits.xml) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(data) ADD_SUBDIRECTORY(cmake) INSTALL_TORCSNG_CMAKE() INCLUDE(cmake/packagemaker.cmake)