Adding the cmake subdir
[kdeedu-porting.git] / cmake / modules / FindOCaml.cmake
blob09b8bdcbfe5f80e6f131d2e6125b622c99450dc4
1 # - Try to find OCaml
2 # Once done this will define
4 #  OCAML_FOUND - system has OCaml
5 #  OCAML_OCAMLC_EXECUTABLE - the Libfacile include directory
6 #  OCAML_OCAMLDEP_EXECUTABLE - Link these to use Libfacile
7 #  OCAML_OCAMLOPT_EXECUTABLE - Compiler switches required for using Libfacile
8 #  OCAMLC_DIR
10 # Copyright (c) 2006, Carsten Niehaus, <cniehaus@gmx.de>
11 # Copyright (c) 2006, Montel Laurent, <montel@kde.org>
12 # Redistribution and use is allowed according to the terms of the BSD license.
13 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
15 if ( OCAML_OCAMLC_EXECUTABLE AND OCAML_OCAMLDEP_EXECUTABLE AND OCAML_OCAMLOPT_EXECUTABLE)
17   # in cache already
18   set(OCAML_FOUND TRUE)
20 else ( OCAML_OCAMLC_EXECUTABLE AND OCAML_OCAMLDEP_EXECUTABLE AND OCAML_OCAMLOPT_EXECUTABLE)
22 FIND_PROGRAM(OCAML_OCAMLC_EXECUTABLE NAMES ocamlc)
23 FIND_PROGRAM(OCAML_OCAMLDEP_EXECUTABLE NAMES ocamldep)
24 FIND_PROGRAM(OCAML_OCAMLOPT_EXECUTABLE NAMES ocamlopt)
26 if( OCAML_OCAMLC_EXECUTABLE AND OCAML_OCAMLDEP_EXECUTABLE AND OCAML_OCAMLOPT_EXECUTABLE)
27    EXECUTE_PROCESS(COMMAND ${OCAML_OCAMLC_EXECUTABLE} -where OUTPUT_VARIABLE OCAMLC_DIR)
28    STRING(REPLACE "\n" "" OCAMLC_DIR "${OCAMLC_DIR}")
29    #MESSAGE(STATUS "ocamlc directory <${OCAMLC_DIR}>")
31      # show the LIBFACILE_INCLUDE_DIR and LIBFACILE_LIBRARIES variables only in the advanced view
32      MARK_AS_ADVANCED(LIBFACILE_INCLUDE_DIR LIBFACILE_LIBRARIES )
34    set(OCAML_FOUND TRUE)
35 else( OCAML_OCAMLC_EXECUTABLE AND OCAML_OCAMLDEP_EXECUTABLE AND OCAML_OCAMLOPT_EXECUTABLE)
37    if(NOT OCAML_OCAMLC_EXECUTABLE)
38       message(STATUS "ocamlc not found.")
39    endif(NOT OCAML_OCAMLC_EXECUTABLE)
40    if(NOT OCAML_OCAMLDEP_EXECUTABLE)
41       message(STATUS "ocamldep not found.")
42    endif(NOT OCAML_OCAMLDEP_EXECUTABLE)
43    if(NOT OCAML_OCAMLOPT_EXECUTABLE)
44       message(STATUS "ocamlopt not found.")
45    endif(NOT OCAML_OCAMLOPT_EXECUTABLE)
46    set(OCAML_FOUND FALSE)
47 endif( OCAML_OCAMLC_EXECUTABLE AND OCAML_OCAMLDEP_EXECUTABLE AND OCAML_OCAMLOPT_EXECUTABLE)
50 IF(OCAML_FOUND)
51    IF(NOT OCaml_FIND_QUIETLY)
52       MESSAGE(STATUS "Found OCaml: ${OCAML_OCAMLC_EXECUTABLE}")
53    ENDIF(NOT OCaml_FIND_QUIETLY)
54 ELSE(OCAML_FOUND)
55    IF(OCaml_FIND_REQUIRED)
56       MESSAGE(FATAL_ERROR "Could not find OCaml")
57    ENDIF(OCaml_FIND_REQUIRED)
58 ENDIF(OCAML_FOUND)
60 endif ( OCAML_OCAMLC_EXECUTABLE AND OCAML_OCAMLDEP_EXECUTABLE AND OCAML_OCAMLOPT_EXECUTABLE)