speed-dreams-code/CMakeLists.txt
pouillot 512c02157a Re #313 (Improve Windows binary installer) Multi-plateform speed-dreams-2 install / user settings folder prefix, executable name, and sd2-prefixed tools executables names to enable cohabitation with 1.4.x
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3261 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 47fb2bf5a83e7f44c489be6620bee6f1982b2208
Former-commit-id: 8a24125280d7cc601d83687a869b0d0065cbb90f
2011-01-12 19:32:40 +00:00

141 lines
4.8 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
CHANGES.txt COPYING.txt INSTALL.txt README.txt TODO.txt)
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)
# Ensure system run-time libs are installed under Windows (MSVC*80.dll and co.).
# We do it ourselves, but use InstallRequiredSystemLibraries to figure out what they are
IF(WIN32)
SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
INCLUDE(InstallRequiredSystemLibraries)
IF(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
INSTALL(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
DESTINATION ${SD_BINDIR_ABS})
ENDIF(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
ENDIF(WIN32)
# Configure CPack.
INCLUDE(cmake/packagemaker.cmake)