speed-dreams-code/CMakeLists.txt
pouillot 86b0be8ede SD_INSTALL_TRACK now installs less .ac files + fixed main CMakeLists.txt svn:keywords (merged from 2.0.0-a2)
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3119 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 6dc4eec79c231bf381b0fa20a58ab621faf26726
Former-commit-id: b274d6611a777fa6850ef0bb2666195634383615
2010-11-11 10:51:10 +00:00

128 lines
4.3 KiB
CMake

CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
# Speed Dreams project
PROJECT(speed-dreams)
INCLUDE(cmake/macros.cmake)
INCLUDE(cmake/checks.cmake)
# 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}")
SET(NEED_SVN_REV TRUE)
ELSEIF(VERSION_IS_BUG_BRANCH)
STRING(REGEX REPLACE "${REGEX_BUG_BRANCH}" "\\1" TMP_VERSION "${HEAD_URL}")
SET(VERSION "${TMP_VERSION}.${NEXT_LESSER_VERSION}-dev")
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(VERSION "${VERSION}-dev")
SET(NEED_SVN_REV TRUE)
ELSE(VERSION_IS_TAG)
MESSAGE("Warning: Could not determine version name from HeadURL ${HEAD_URL}")
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)
MESSAGE(STATUS "Looking for current subversion revision (may be long) ...")
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)
SET(VERSION_LONG "${VERSION}")
IF(NOT SVN_FIND_REV_FAILED)
STRING(TOLOWER ${SVN_REV} SVN_REV)
SET(VERSION_LONG "${VERSION_LONG}-r${SVN_REV}")
ENDIF(NOT SVN_FIND_REV_FAILED)
MESSAGE(STATUS "Found '${VERSION_LONG}'")
ELSE(NEED_SVN_REV)
SET(VERSION_LONG "${VERSION}")
ENDIF(NEED_SVN_REV)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config.h)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/version.h)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/doxygen_config.cmake
${CMAKE_CURRENT_BINARY_DIR}/doxygen_config @ONLY)
SD_INSTALL_FILES(DATA "/" FILES credits.xml)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(data)
ADD_SUBDIRECTORY(cmake)
INSTALL_SD_CMAKE()
# Generate a 'make clobber'-like clobber.sh/.bat script in case of an in-source build.
SD_GENERATE_CLOBBER_SCRIPT()
# Add an unistall target.
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" IMMEDIATE @ONLY)
IF(WIN32)
ADD_CUSTOM_TARGET(UNINSTALL "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" )
ELSE(WIN32)
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" )
ENDIF(WIN32)
# Configure CPack.
INCLUDE(cmake/packagemaker.cmake)