Home | History | Annotate | Download | only in cmake
      1 file(TO_CMAKE_PATH "$ENV{ANT_DIR}" ANT_DIR_ENV_PATH)
      2 file(TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH)
      3 
      4 if(CMAKE_HOST_WIN32)
      5   set(ANT_NAME ant.bat)
      6 else()
      7   set(ANT_NAME ant)
      8 endif()
      9 
     10 find_host_program(ANT_EXECUTABLE NAMES ${ANT_NAME}
     11   PATHS "${ANT_DIR_ENV_PATH}/bin" "${ProgramFiles_ENV_PATH}/apache-ant/bin"
     12   NO_DEFAULT_PATH
     13   )
     14 
     15 find_host_program(ANT_EXECUTABLE NAMES ${ANT_NAME})
     16 
     17 if(ANT_EXECUTABLE)
     18   execute_process(COMMAND ${ANT_EXECUTABLE} -version
     19     RESULT_VARIABLE ANT_ERROR_LEVEL
     20     OUTPUT_VARIABLE ANT_VERSION_FULL
     21     OUTPUT_STRIP_TRAILING_WHITESPACE)
     22   if (ANT_ERROR_LEVEL)
     23     unset(ANT_EXECUTABLE)
     24     unset(ANT_EXECUTABLE CACHE)
     25   else()
     26     string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" ANT_VERSION "${ANT_VERSION_FULL}")
     27     set(ANT_VERSION "${ANT_VERSION}" CACHE INTERNAL "Detected ant vesion")
     28 
     29     message(STATUS "Found apache ant ${ANT_VERSION}: ${ANT_EXECUTABLE}")
     30   endif()
     31 endif()
     32