Skip to content

Commit

Permalink
Initial merge with xeus-clang-repl
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-penev committed Oct 2, 2023
1 parent aba3401 commit 4dc43f7
Show file tree
Hide file tree
Showing 32 changed files with 686 additions and 63 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/**/*
build
86 changes: 73 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,50 @@ if (NOT DEFINED XEUS_CPP_KERNELSPEC_PATH)
set(XEUS_CPP_KERNELSPEC_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/")
endif ()

configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xcpp/kernel.json.in"
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xcpp/kernel.json"
)
set(CMAKE_CPLUS_INCLUDE_PATH "$ENV{CPLUS_INCLUDE_PATH}")
set(CMAKE_PATH "$ENV{PATH}")
set(CMAKE_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}")
set(CMAKE_PYTHONPATH "$ENV{PYTHONPATH}")
set(CMAKE_VENV_PATH "$ENV{VENV}")

message(STATUS "Debug: Replace in kernels")
message(STATUS "Debug: CMAKE_CPLUS_INCLUDE_PATH=${CMAKE_CPLUS_INCLUDE_PATH}")
message(STATUS "Debug: CMAKE_PATH=${CMAKE_PATH}")
message(STATUS "Debug: CMAKE_LD_LIBRARY_PATH=${CMAKE_LD_LIBRARY_PATH}")
message(STATUS "Debug: CMAKE_PYTHONPATH=${CMAKE_PYTHONPATH}")
message(STATUS "Debug: CMAKE_VENV_PATH=${CMAKE_VENV_PATH}")
message(STATUS "Debug: CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "Debug: CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}")


function(configure_kernel kernel)
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/kernel.json.in"
"${CMAKE_CURRENT_BINARY_DIR}/${kernel}/kernel.json"
)
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/*.png")
foreach(file ${files})
configure_file(
"${file}"
"${CMAKE_CURRENT_BINARY_DIR}/${kernel}/"
COPYONLY
)
endforeach()
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/*.svg")
foreach(file ${files})
configure_file(
"${file}"
"${CMAKE_CURRENT_BINARY_DIR}/${kernel}/"
COPYONLY
)
endforeach()
endfunction()

file(GLOB _kernels LIST_DIRECTORIES true RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "share/jupyter/kernels/*")
foreach(_kernel IN LISTS _kernels)
message("Configure kernel: ${_kernel}")
configure_kernel("${_kernel}")
endforeach()

# Build options
# =============
Expand Down Expand Up @@ -90,7 +130,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
if(NOT XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter -Wextra -Wreorder")
endif()


CHECK_CXX_COMPILER_FLAG("-std=c++17" HAS_CPP_17_FLAG)
if (HAS_CPP_17_FLAG)
Expand All @@ -105,9 +145,12 @@ if(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\"")
endif()

find_package(Clang REQUIRED)
#find_package(Clang REQUIRED)
find_package(CppInterOp REQUIRED CONFIG PATHS "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib")
find_package(argparse REQUIRED)
find_package(pugixml REQUIRED)
##set(Python_FIND_VIRTUALENV ONLY)
##find_package(Python COMPONENTS Interpreter Development)

# Source files
# ============
Expand Down Expand Up @@ -190,7 +233,6 @@ macro(xeus_cpp_set_kernel_options target_name)
find_package(Threads)
target_link_libraries(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif()

endmacro()

# Common macro for shared and static library
Expand Down Expand Up @@ -226,7 +268,8 @@ macro(xeus_cpp_create_target target_name linkage output_name)
set(XEUS_CPP_XEUS_TARGET xeus-static)
endif ()

target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangInterpreter pugixml argparse::argparse xtl)
## target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangInterpreter pugixml argparse::argparse xtl)
target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl)
if (WIN32 OR CYGWIN)
#
elseif (APPLE)
Expand All @@ -236,7 +279,7 @@ macro(xeus_cpp_create_target target_name linkage output_name)
find_package(Threads) # TODO: add Threads as a dependence of xeus-static?
target_link_libraries(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif()

endmacro()

# xeus-cpp-headers
Expand Down Expand Up @@ -283,6 +326,23 @@ if (XEUS_CPP_BUILD_EXECUTABLE)
xeus_cpp_set_common_options(xcpp)
xeus_cpp_set_kernel_options(xcpp)
target_link_libraries(xcpp PRIVATE xeus-zmq)

##set_target_properties(xcpp PROPERTIES
## ENABLE_EXPORTS 1
## CXX_STANDARD ${CMAKE_CXX_STANDARD}
##)
##target_link_libraries(xcpp PUBLIC xeus-cpp pthread Python::Python)
##
###TODO: We may be need sse RPATH
###set_target_properties(xcpp clangCppInterOp PROPERTIES
### INSTALL_RPATH_USE_LINK_PATH TRUE
###)
##if(APPLE)
## target_link_libraries(xcpp PUBLIC -Wl,-w -Wl,-bind_at_load -Wl,-undefined,dynamic_lookup)
##elseif(NOT MSVC)
## target_link_libraries(xcpp PUBLIC -Wl,--unresolved-symbols=ignore-in-object-files)
##endif()

endif()

if(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
Expand Down Expand Up @@ -318,18 +378,18 @@ endif ()
# Install xcpp
if (XEUS_CPP_BUILD_EXECUTABLE)
install(TARGETS xcpp
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
RUNTIME DESTINATION ${CMAKE_VENV_PATH}/bin)

# Configuration and data directories for jupyter and xeus-cpp
set(XJUPYTER_DATA_DIR "share/jupyter" CACHE STRING "Jupyter data directory")

# Install xcpp Jupyter kernelspec
set(KERNELSPEC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels)
set(KERNELSPEC_DIR ${CMAKE_CURRENT_BINARY_DIR}/share/jupyter/kernels)
install(DIRECTORY ${KERNELSPEC_DIR}
DESTINATION ${XJUPYTER_DATA_DIR}
# DESTINATION ${CMAKE_INSTALL_PREFIX}/${XJUPYTER_DATA_DIR}
PATTERN "*.in" EXCLUDE)


# Extra path for installing Jupyter kernelspec
if (XEXTRA_JUPYTER_DATA_DIR)
install(DIRECTORY ${KERNELSPEC_DIR}
Expand Down
Loading

0 comments on commit 4dc43f7

Please sign in to comment.