mirror of
https://github.com/reactos/CMake.git
synced 2024-11-27 13:30:39 +00:00
Find{Java,JNI}: Use ENV{JAVA_HOME} first when set
Use list(APPEND) instead of set() to append to lists. When ENV{JAVA_HOME} is set explicitly place values based on it at the front their lists.
This commit is contained in:
parent
bbc82d85e5
commit
4b3614b25a
@ -91,22 +91,26 @@ macro(java_append_library_directories _var)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME)
|
||||
|
||||
set(JAVA_AWT_LIBRARY_DIRECTORIES)
|
||||
if(_JAVA_HOME)
|
||||
JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
|
||||
${_JAVA_HOME}/jre/lib/{libarch}
|
||||
${_JAVA_HOME}/jre/lib
|
||||
${_JAVA_HOME}/lib
|
||||
${_JAVA_HOME}
|
||||
)
|
||||
endif()
|
||||
get_filename_component(java_install_version
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
|
||||
|
||||
set(JAVA_AWT_LIBRARY_DIRECTORIES
|
||||
list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
|
||||
)
|
||||
|
||||
file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME)
|
||||
|
||||
JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
|
||||
${_JAVA_HOME}/jre/lib/{libarch}
|
||||
${_JAVA_HOME}/jre/lib
|
||||
${_JAVA_HOME}/lib
|
||||
${_JAVA_HOME}
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/usr/lib/jvm/java/lib
|
||||
@ -135,20 +139,21 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
|
||||
|
||||
set(JAVA_JVM_LIBRARY_DIRECTORIES)
|
||||
foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
|
||||
set(JAVA_JVM_LIBRARY_DIRECTORIES
|
||||
${JAVA_JVM_LIBRARY_DIRECTORIES}
|
||||
list(APPEND JAVA_JVM_LIBRARY_DIRECTORIES
|
||||
"${dir}"
|
||||
"${dir}/client"
|
||||
"${dir}/server"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
|
||||
set(JAVA_AWT_INCLUDE_DIRECTORIES
|
||||
set(JAVA_AWT_INCLUDE_DIRECTORIES)
|
||||
if(_JAVA_HOME)
|
||||
list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES ${_JAVA_HOME}/include)
|
||||
endif()
|
||||
list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
|
||||
${_JAVA_HOME}/include
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/usr/lib/java/include
|
||||
@ -173,7 +178,7 @@ foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
|
||||
get_filename_component(jpath "${JAVA_PROG}" PATH)
|
||||
foreach(JAVA_INC_PATH ../include ../java/include ../share/java/include)
|
||||
if(EXISTS ${jpath}/${JAVA_INC_PATH})
|
||||
set(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES} "${jpath}/${JAVA_INC_PATH}")
|
||||
list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES "${jpath}/${JAVA_INC_PATH}")
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(JAVA_LIB_PATH
|
||||
@ -181,7 +186,7 @@ foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
|
||||
../java/lib ../java/jre/lib ../java/jre/lib/i386
|
||||
../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386)
|
||||
if(EXISTS ${jpath}/${JAVA_LIB_PATH})
|
||||
set(JAVA_AWT_LIBRARY_DIRECTORIES ${JAVA_AWT_LIBRARY_DIRECTORIES} "${jpath}/${JAVA_LIB_PATH}")
|
||||
list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES "${jpath}/${JAVA_LIB_PATH}")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
@ -67,8 +67,14 @@
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME)
|
||||
|
||||
# The HINTS option should only be used for values computed from the system.
|
||||
set(_JAVA_HINTS
|
||||
set(_JAVA_HINTS)
|
||||
if(_JAVA_HOME)
|
||||
list(APPEND _JAVA_HINTS ${_JAVA_HOME}/bin)
|
||||
endif()
|
||||
list(APPEND _JAVA_HINTS
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\2.0;JavaHome]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/bin"
|
||||
@ -77,7 +83,6 @@ set(_JAVA_HINTS
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/bin"
|
||||
$ENV{JAVA_HOME}/bin
|
||||
)
|
||||
# Hard-coded guesses should still go in PATHS. This ensures that the user
|
||||
# environment can always override hard guesses.
|
||||
|
Loading…
Reference in New Issue
Block a user