Last active
April 11, 2018 19:22
-
-
Save JayKickliter/06d0e7c4f84ef7ccc7a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(JULIA_FOUND) | |
return() | |
endif() | |
# Find julia executable | |
find_program(JULIA_EXECUTABLE julia DOC "Julia executable") | |
if(NOT JULIA_EXECUTABLE) | |
return() | |
endif() | |
# | |
# Julia version | |
# | |
execute_process( | |
COMMAND ${JULIA_EXECUTABLE} --version | |
OUTPUT_VARIABLE JULIA_VERSION_STRING | |
RESULT_VARIABLE RESULT | |
) | |
if(RESULT EQUAL 0) | |
string(REGEX REPLACE ".*([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" | |
JULIA_VERSION_STRING ${JULIA_VERSION_STRING}) | |
endif() | |
# | |
# Julia includes | |
# | |
execute_process( | |
COMMAND ${JULIA_EXECUTABLE} -E "joinpath(match(r\"(.*)(bin)\",JULIA_HOME).captures[1],\"include\",\"julia\")" | |
OUTPUT_VARIABLE JULIA_INCLUDE_DIRS | |
# COMMAND ${JULIA_EXECUTABLE} -E "abspath(joinpath(JULIA_HOME, \"../..\", \"src\"))" | |
# OUTPUT_VARIABLE JULIA_INCLUDE_DIRS | |
RESULT_VARIABLE RESULT | |
) | |
if(RESULT EQUAL 0) | |
string(REGEX REPLACE "\"" "" JULIA_INCLUDE_DIRS ${JULIA_INCLUDE_DIRS}) | |
set(JULIA_INCLUDE_DIRS ${JULIA_INCLUDE_DIRS} | |
CACHE PATH "Location of Julia include files") | |
endif() | |
# | |
# Julia library location | |
# | |
execute_process( | |
COMMAND ${JULIA_EXECUTABLE} -E "abspath(dirname(Sys.dlpath(\"libjulia\")))" | |
OUTPUT_VARIABLE JULIA_LIBRARY_DIR | |
RESULT_VARIABLE RESULT | |
) | |
if(RESULT EQUAL 0) | |
string(REGEX REPLACE "\"" "" JULIA_LIBRARY_DIR ${JULIA_LIBRARY_DIR}) | |
string(STRIP ${JULIA_LIBRARY_DIR} JULIA_LIBRARY_DIR) | |
set(JULIA_LIBRARY_DIR ${JULIA_LIBRARY_DIR} | |
CACHE PATH "Julia library directory") | |
endif() | |
find_library( JULIA_LIBRARY | |
NAMES julia | |
PATHS ${JULIA_LIBRARY_DIR} | |
) | |
include(FindPackageHandleStandardArgs) | |
find_package_handle_standard_args( | |
Julia | |
REQUIRED_VARS JULIA_LIBRARY JULIA_LIBRARY_DIR JULIA_INCLUDE_DIRS | |
VERSION_VAR JULIA_VERSION_STRING | |
FAIL_MESSAGE "Julia not found" | |
) |
@filipesaraiva I somehow didn't get notified or didn't notice your comment. If you still want to know, you can use it however you want.
Hello,
For newer version of Julia, it seems that you need abspath(dirname(Libdl.dlpath("libjulia")))
instead of Sys
Hello.
Maybe add checking for existings of include path of Julia? Something like that:
IF (NOT EXISTS JULIA_INCLUDE_DIRS)
message(STATUS "Julia found, but include files are missing")
return()
endif()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Jay, we would like to use it in Cantor, a software of KDE Applications. Which license are you using for this code?