[Please CC the mailing list] Eli Gottlieb <eligottlieb at gmail.com> writes:> OK, I'm just going to paste in my CMakeLists.txt file. Like I said, > I'm building an LLVM install myself by untarring llvm, mkdir build in > the root dir of the source, cd build/, cmake .., make. > >> cmake_minimum_required (VERSION 2.6) >> project (libjllvm) >> add_library(jllvm 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) >> >> # A convenience variable: >> set(LLVM_ROOT "/usr" CACHE /usr/ "Root of LLVM install.") >> # 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(LLVM) >> # Now set the header and library paths: >> include_directories( ${LLVM_ROOT}/include ) >> link_directories( ${LLVM_ROOT}/lib ) >> # 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 core) >> # Finally, we link the LLVM libraries to our executable: >> target_link_libraries(jllvm ${REQ_LLVM_LIBRARIES})Where is the failure? On the "if( NOT EXISTS ${LLVM_ROOT}/include/llvm )" ? If that's the problem, is LLVM installed on /usr ? On my Kubuntu machine CMAKE_INSTALL_PREFIX defaults to /usr/local. Please describe exactly the problem, pasting error messages if necessary.
I compiled and installed it to the prefix /usr, but that's not the issue. Once I actually compile and install LLVM with CMake by hand, I get the share/llvm/cmake stuff installed correctly (can those files be included in "normal" builds, or will LLVM switch to CMake as its primary build system?). Now I'm running into the problem of cflags or includes or something not being set properly. CMakeLists.txt:> cmake_minimum_required (VERSION 2.6) > project (libjllvm) > add_library(jllvm 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) > > # A convenience variable: > set(LLVM_ROOT "/usr" CACHE /usr/ "Root of LLVM install.") > # 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(LLVM) > # Now set the header and library paths: > include_directories( ${LLVM_ROOT}/include ) > link_directories( ${LLVM_ROOT}/lib ) > # 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 core) > # Finally, we link the LLVM libraries to our executable: > target_link_libraries(jllvm ${REQ_LLVM_LIBRARIES})I run "cmake ." where I've got my source and then make. This results in:> eli at eli-netbook:~/Programs/decac/src/jllvm/llvm$ make > Scanning dependencies of target jllvm > [ 9%] Building C object CMakeFiles/jllvm.dir/Analysis_wrap.c.o > In file included from /usr/include/llvm-c/Core.h:36, > from /usr/include/llvm-c/Analysis.h:22, > from > /home/eli/Programs/decac/src/jllvm/llvm/Analysis_wrap.c:190: > /usr/include/llvm/System/DataTypes.h:46: error: #error "Must #define > __STDC_LIMIT_MACROS before #including System/DataTypes.h" > /usr/include/llvm/System/DataTypes.h:50: error: #error "Must #define > __STDC_CONSTANT_MACROS before " "#including System/DataTypes.h" > make[2]: *** [CMakeFiles/jllvm.dir/Analysis_wrap.c.o] Error 1 > make[1]: *** [CMakeFiles/jllvm.dir/all] Error 2 > make: *** [all] Error 2Thanks for all your help, Eli
Eli Gottlieb <eligottlieb at gmail.com> writes:> I compiled and installed it to the prefix /usr, but that's not the > issue. Once I actually compile and install LLVM with CMake by hand, I > get the share/llvm/cmake stuff installed correctly (can those files be > included in "normal" builds, or will LLVM switch to CMake as its > primary build system?). Now I'm running into the problem of cflags or > includes or something not being set properly.[snip]>> [ 9%] Building C object CMakeFiles/jllvm.dir/Analysis_wrap.c.o >> In file included from /usr/include/llvm-c/Core.h:36, >> from /usr/include/llvm-c/Analysis.h:22, >> from >> /home/eli/Programs/decac/src/jllvm/llvm/Analysis_wrap.c:190: >> /usr/include/llvm/System/DataTypes.h:46: error: #error "Must #define >> __STDC_LIMIT_MACROS before #including System/DataTypes.h" >> /usr/include/llvm/System/DataTypes.h:50: error: #error "Must #define >> __STDC_CONSTANT_MACROS before " "#including System/DataTypes.h" >> make[2]: *** [CMakeFiles/jllvm.dir/Analysis_wrap.c.o] Error 1 >> make[1]: *** [CMakeFiles/jllvm.dir/all] Error 2 >> make: *** [all] Error 2Yes, you must define __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS on your CMakeLists.txt. Put this before any add_executable/add_library that contains source files that uses LLVM stuff: add_definitions( -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS )