summaryrefslogtreecommitdiff
path: root/indra/cmake/FindAutobuild.cmake
blob: 84ae41e8aa7f2ea9a18ee73cc17403efaaae089a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- cmake -*-
#
# Find the autobuild tool
#
# Output variables:
#
#   AUTOBUILD_EXECUTABLE - path to autobuild or pautobuild executable



IF (NOT AUTOBUILD_EXECUTABLE)

  # If cmake was executed by autobuild, autobuild will have set the AUTOBUILD env var
  IF (DEFINED ENV{AUTOBUILD})
    SET(AUTOBUILD_EXECUTABLE $ENV{AUTOBUILD})
    # In case $AUTOBUILD is a cygwin path, fix it back to Windows style
    STRING(REGEX REPLACE "^/cygdrive/(.)/" "\\1:/" AUTOBUILD_EXECUTABLE
           "${AUTOBUILD_EXECUTABLE}")
  ELSE (DEFINED ENV{AUTOBUILD})
    IF(WIN32)
      SET(AUTOBUILD_EXE_NAMES autobuild.cmd autobuild.exe)
    ELSE(WIN32)
      SET(AUTOBUILD_EXE_NAMES autobuild)
    ENDIF(WIN32)

    SET(AUTOBUILD_EXECUTABLE)
    FIND_PROGRAM(
      AUTOBUILD_EXECUTABLE 
      NAMES ${AUTOBUILD_EXE_NAMES}
      PATHS 
    ENV PATH
    ${CMAKE_SOURCE_DIR}/.. 
    ${CMAKE_SOURCE_DIR}/../..
    ${CMAKE_SOURCE_DIR}/../../..
      PATH_SUFFIXES "/autobuild/bin/"
    )
  ENDIF (DEFINED ENV{AUTOBUILD})

  IF (AUTOBUILD_EXECUTABLE)
    GET_FILENAME_COMPONENT(_autobuild_name ${AUTOBUILD_EXECUTABLE} NAME_WE)
  ELSE (AUTOBUILD_EXECUTABLE)
    IF (AUTOBUILD_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "Could not find autobuild executable")
    ENDIF (AUTOBUILD_FIND_REQUIRED)
  ENDIF (AUTOBUILD_EXECUTABLE)

  MARK_AS_ADVANCED(AUTOBUILD_EXECUTABLE)
ENDIF (NOT AUTOBUILD_EXECUTABLE)