[CMake] CMake can't find the JDK?

Eli Gottlieb eligottlieb at gmail.com
Tue Jul 3 17:17:27 EDT 2012


Sorry for being a bozo, I should have enclosed this before.  This is my 
CMakeLists.txt file.
On 07/03/2012 04:54 PM, Eli Gottlieb wrote:
> That indeed fixed that problem, but now I've got a rather bizarre new 
> one.  CMake never actually advances after finding Java and JNI. I get 
> the following as output:
>
>> eli at eli-netbook:~/Programs/jllvm/src/org/jllvm/bindings$ cmake .
>> -- The C compiler identification is GNU
>> -- The CXX compiler identification is GNU
>> -- Check for working C compiler: /usr/bin/gcc
>> -- Check for working C compiler: /usr/bin/gcc -- works
>> -- Detecting C compiler ABI info
>> -- Detecting C compiler ABI info - done
>> -- Check for working CXX compiler: /usr/bin/c++
>> -- Check for working CXX compiler: /usr/bin/c++ -- works
>> -- Detecting CXX compiler ABI info
>> -- Detecting CXX compiler ABI info - done
>> -- Found Java: /usr/lib/jvm/java-6-openjdk-amd64/bin/java (found 
>> version "1.6.0.24")
>> -- Found JNI: /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/libjawt.so
> And that's it.  CMake just sits there like that until I stop it with 
> CTRL-C.  It never actually finishes configuring my code, which it used 
> to do perfectly well.  Any notions?
> Rolf Eike Beer wrote:
>> Eli Gottlieb wrote:
>>> Applied the patch.  I still get the same error.
>> I guess you use the same build dir as before the upgrade? I think the 
>> java
>> executable location has changed during the upgrade. Wipe your build 
>> dir and
>> start again. This current error is caused by Java_JAVA_EXECUTABLE 
>> being wrong,
>> but there is probably more breakage that will hit you later, so 
>> better start
>> over.
>>
>> Eike


-------------- next part --------------
cmake_minimum_required (VERSION 2.6)
project (jllvm)
add_library(jllvm SHARED Analysis_wrap.c BitReader_wrap.c BitWriter_wrap.c Core_wrap.c EnhancedDisassembly_wrap.c ExecutionEngine_wrap.c LinkTimeOptimizer_wrap.c lto_wrap.c Target_wrap.c Transforms/IPO_wrap.c Transforms/Scalar_wrap.c)
install(TARGETS jllvm DESTINATION lib/)
add_definitions( -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS )

# A convenience variable:
set(LLVM_ROOT "/usr/" CACHE /usr/ "Root of LLVM install.")
set(CMAKE_INSTALL_PREFIX "/usr")
# A bit of a sanity check:
if( NOT EXISTS ${LLVM_ROOT}/include/llvm )
message(FATAL_ERROR "LLVM_ROOT (${LLVM_ROOT}) is not a valid LLVM install")
endif()
# We incorporate the CMake features provided by LLVM:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT}/share/llvm/cmake")
include(LLVMConfig)
# Now set the header and library paths:
include_directories( ${LLVM_ROOT}/include )
link_directories( ${LLVM_ROOT}/lib )
add_definitions( ${LLVM_DEFINITIONS} )
# Make sure to include the headers required for Java and JNI.
FIND_PACKAGE(Java REQUIRED)
FIND_PACKAGE(JNI REQUIRED)
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH2})
# Let's suppose we want to build a JIT compiler with support for
# binary code (no interpreter):
#llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native)
llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES all)
# Finally, we link the LLVM libraries to our executable:
target_link_libraries(jllvm ${REQ_LLVM_LIBRARIES})
# LLVM typically comes installed as static libraries, so make sure to link in the C++ runtimes.
set_target_properties(jllvm PROPERTIES LINKER_LANGUAGE CXX)


More information about the CMake mailing list