Warning, /education/cantor/cmake/FindJulia.cmake is written in an unsupported language. File is not indexed.

0001 if(JULIA_FOUND)
0002     return()
0003 endif()
0004 
0005 # Find julia executable
0006 find_program(JULIA_EXECUTABLE julia DOC "Julia executable")
0007 
0008 if(NOT JULIA_EXECUTABLE)
0009     return()
0010 endif()
0011 
0012 
0013 
0014 
0015 #
0016 # Julia version
0017 #
0018 execute_process(
0019     COMMAND ${JULIA_EXECUTABLE} --version
0020     OUTPUT_VARIABLE JULIA_VERSION_STRING
0021     RESULT_VARIABLE RESULT
0022 )
0023 if(RESULT EQUAL 0)
0024   string(REGEX REPLACE ".*([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1"
0025       JULIA_VERSION_STRING ${JULIA_VERSION_STRING})
0026 endif()
0027 
0028 
0029 
0030 
0031 #
0032 # Julia includes
0033 #
0034 if(${JULIA_VERSION_STRING} VERSION_LESS 0.7.0)
0035     set(JULIA_BINDIR "JULIA_HOME")
0036 else()
0037     set(JULIA_BINDIR "Sys.BINDIR")
0038 endif()
0039 
0040 execute_process(
0041     COMMAND ${JULIA_EXECUTABLE} -E "joinpath(match(r\"(.*)(bin)\",${JULIA_BINDIR}).captures[1],\"include\",\"julia\")"
0042     OUTPUT_VARIABLE JULIA_INCLUDE_DIRS
0043     # COMMAND ${JULIA_EXECUTABLE} -E "abspath(joinpath(JULIA_HOME, \"../..\", \"src\"))"
0044     # OUTPUT_VARIABLE JULIA_INCLUDE_DIRS
0045     RESULT_VARIABLE RESULT
0046 )
0047 if(RESULT EQUAL 0)
0048     string(REGEX REPLACE "\"" "" JULIA_INCLUDE_DIRS ${JULIA_INCLUDE_DIRS})
0049     set(JULIA_INCLUDE_DIRS ${JULIA_INCLUDE_DIRS}
0050         CACHE PATH "Location of Julia include files")
0051 endif()
0052 
0053 string(CONCAT JULIA_INCLUDE_TEST_FILE ${JULIA_INCLUDE_DIRS} "/julia_version.h")
0054 string(REGEX REPLACE "\n" "" JULIA_INCLUDE_TEST_FILE ${JULIA_INCLUDE_TEST_FILE})
0055 IF (NOT EXISTS ${JULIA_INCLUDE_TEST_FILE})
0056     message(STATUS "Julia found, but include files are missing")
0057     return()
0058 endif()
0059 
0060 
0061 #
0062 # Julia library location
0063 #
0064 if(${JULIA_VERSION_STRING} VERSION_LESS 0.7.0)
0065     set(JULIA_LIBDL_COMMAND "abspath(dirname(Libdl.dlpath(\"libjulia\")))")
0066 else()
0067     set(JULIA_LIBDL_COMMAND "using Libdl\; abspath(dirname(Libdl.dlpath(\"libjulia\")))")
0068 endif()
0069 
0070 execute_process(
0071     COMMAND ${JULIA_EXECUTABLE} -E ${JULIA_LIBDL_COMMAND}
0072     OUTPUT_VARIABLE JULIA_LIBRARY_DIR
0073     RESULT_VARIABLE RESULT
0074 )
0075 
0076 if(RESULT EQUAL 0)
0077     string(REGEX REPLACE "\"" "" JULIA_LIBRARY_DIR ${JULIA_LIBRARY_DIR})
0078     string(STRIP ${JULIA_LIBRARY_DIR} JULIA_LIBRARY_DIR)
0079     set(JULIA_LIBRARY_DIR ${JULIA_LIBRARY_DIR}
0080         CACHE PATH "Julia library directory")
0081 endif()
0082 
0083 if(NOT ${JULIA_VERSION_STRING} VERSION_LESS 1.6.0)
0084     set(JULIA_INTERNAL_LIBDL_COMMAND "using Libdl\; abspath(dirname(Libdl.dlpath(\"libjulia-internal\")))")
0085     execute_process(
0086         COMMAND ${JULIA_EXECUTABLE} -E ${JULIA_INTERNAL_LIBDL_COMMAND}
0087         OUTPUT_VARIABLE JULIA_INTERNAL_LIBRARY_DIR
0088         RESULT_VARIABLE RESULT
0089     )
0090 
0091     if(RESULT EQUAL 0)
0092         string(REGEX REPLACE "\"" "" JULIA_INTERNAL_LIBRARY_DIR ${JULIA_INTERNAL_LIBRARY_DIR})
0093         string(STRIP ${JULIA_INTERNAL_LIBRARY_DIR} JULIA_INTERNAL_LIBRARY_DIR)
0094         set(JULIA_INTERNAL_LIBRARY_DIR ${JULIA_INTERNAL_LIBRARY_DIR}
0095             CACHE PATH "Julia internal library directory")
0096     endif()
0097 endif()
0098 
0099 find_library( JULIA_LIBRARY
0100     NAMES julia
0101     PATHS ${JULIA_LIBRARY_DIR}
0102 )
0103 
0104 if(NOT ${JULIA_VERSION_STRING} VERSION_LESS 1.6.0)
0105     find_library( JULIA_INTERNAL_LIBRARY
0106         NAMES julia-internal
0107         PATHS ${JULIA_INTERNAL_LIBRARY_DIR}
0108     )
0109 endif()
0110 
0111 if(${JULIA_VERSION_STRING} VERSION_LESS 1.6.0)
0112     find_package_handle_standard_args(
0113         Julia
0114         REQUIRED_VARS   JULIA_LIBRARY JULIA_INCLUDE_DIRS
0115         VERSION_VAR     JULIA_VERSION_STRING
0116         FAIL_MESSAGE    "Julia not found"
0117     )
0118 else()
0119     find_package_handle_standard_args(
0120         Julia
0121         REQUIRED_VARS   JULIA_LIBRARY JULIA_INTERNAL_LIBRARY JULIA_INCLUDE_DIRS
0122         VERSION_VAR     JULIA_VERSION_STRING
0123         FAIL_MESSAGE    "Julia not found"
0124     )
0125 endif()