Skip to content

Commit

Permalink
Fix CMakeLists for clang.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nong Li committed Oct 17, 2013
1 parent f953519 commit 627adf9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ set(LIBRARY_OUTPUT_PATH "build")
# where to put generated binaries
set(EXECUTABLE_OUTPUT_PATH "build")

find_program(CLANG_EXECUTABLE clang++)

# Function to generate rule to cross compile a source file to an IR module.
# This should be called with the .cc src file and it will generate a
# src-file-ir target that can be built.
# e.g. COMPILE_TO_IR(test.cc) generates the "test-ir" make target.
set(IR_COMPILE_FLAGS "-emit-llvm" "-O3" "-c" "-I../")
set(IR_COMPILE_FLAGS "-emit-llvm" "-O3" "-c")
function(COMPILE_TO_IR SRC_FILE)
get_filename_component(BASE_NAME ${SRC_FILE} NAME_WE)
set(OUTPUT_FILE "${LIBRARY_OUTPUT_PATH}/${BASE_NAME}.ll")
set(OUTPUT_FILE "build/${BASE_NAME}.ll")
add_custom_command(
OUTPUT ${OUTPUT_FILE}
COMMAND ${LLVM_CLANG_EXECUTABLE} ${IR_COMPILE_FLAGS} ${SRC_FILE} -o ${OUTPUT_FILE}
COMMAND ${CLANG_EXECUTABLE} ${IR_COMPILE_FLAGS} ${SRC_FILE} -o ${OUTPUT_FILE}
DEPENDS ${SRC_FILE})
add_custom_target(${BASE_NAME}-ir ALL DEPENDS ${OUTPUT_FILE})
endfunction(COMPILE_TO_IR)
Expand All @@ -39,8 +41,10 @@ add_library(udfsample SHARED udf-sample.cc)
add_library(udasample SHARED uda-sample.cc hyperloglog-uda.cc)

# Custom targest to cross compile UDA/UDF to ir
COMPILE_TO_IR(udf-sample.cc )
COMPILE_TO_IR(uda-sample.cc )
if (CLANG_EXECUTABLE)
COMPILE_TO_IR(udf-sample.cc )
COMPILE_TO_IR(uda-sample.cc )
endif(CLANG_EXECUTABLE)

# This is an example of how to use the test harness to help develop UDF and UDAs.
add_executable(udf-sample-test udf-sample-test.cc)
Expand Down

0 comments on commit 627adf9

Please sign in to comment.