Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ if (WIN32 AND (NOT MINGW) AND (NOT CYGWIN))
set(CMAKE_CXX_FLAGS_MINSIZEREL "/MT")
endif ()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
find_package(JNI11)
find_package(Java 11 REQUIRED COMPONENTS Development)
include(${CMAKE_CURRENT_LIST_DIR}/SetJavaHomeFromJavaExecutable.cmake)
find_package(JNI REQUIRED)

include_directories(${JNI_INCLUDE_DIRS})

add_library(memory_agent SHARED
Expand Down
8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Contributing guide for debugger memory agent

## Prerequisites
To build the project you should have CMake 3.1 or higher installed, and JDK 11 or higher is installed.

## Building
To build the project you should have Cmake 3.1 or higher installed, and `JDK_11`
environmental variable should be set to jdk 11 or higher. Once you've downloaded the project,
you can build it using the following commands in the root project directory:
Once you've downloaded the project, you can build it using the following commands in the root project directory:
```
cmake .
cmake --build .
Expand Down
18 changes: 0 additions & 18 deletions FindJNI11.cmake

This file was deleted.

20 changes: 20 additions & 0 deletions SetJavaHomeFromJavaExecutable.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
if(NOT Java_JAVA_EXECUTABLE)
message(FATAL_ERROR "java executable not found")
endif()
execute_process(COMMAND "${Java_JAVA_EXECUTABLE}" -XshowSettings:properties -version
RESULT_VARIABLE res
OUTPUT_VARIABLE var
ERROR_VARIABLE var
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
if(res)
message(FATAL_ERROR "Error executing java -version")
else()
set(_java_version_regex "java\\.home = ([^\n]+)")
if(var MATCHES "${_java_version_regex}")
set(JAVA_HOME "${CMAKE_MATCH_1}")
else()
string(REPLACE "\n" "\n " ver_msg "\n${var}")
message(FATAL_ERROR "Java output not recognized:${ver_msg}\nPlease report.")
endif()
endif()