Skip to content

Commit

Permalink
Add install and debug options.
Browse files Browse the repository at this point in the history
make install now installs all targets to ${TRACER_HOME}/install,
and cmake -DDEBUG=ON will build in debug mode.

NOTE: the AST pass can only be built through CMake, so if you are
building without CMake, make install will not install the AST pass
binary.

Change-Id: Iec021102fdac94e922f5b2fbec17fd74c54204a2
  • Loading branch information
xyzsam committed Sep 6, 2016
1 parent cc08729 commit 680baa2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ cmake_minimum_required(VERSION 2.8.12)
project(LLVM_TRACER CXX)
enable_testing()

set(CMAKE_INSTALL_PREFIX $ENV{TRACER_HOME}/install)
set(SCRIPT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake-scripts")
include("${SCRIPT_DIR}/TracerConfig.cmake")
include("${SCRIPT_DIR}/findAndSetLLVM.cmake")

set(CMAKE_CXX_COMPILER ${CLANGXX})
option(DEBUG "Build in debugging mode (-O0, -g)" OFF)

add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/full-trace")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/profile-func")
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
.PHONY: all
.PHONY: all install clean

all:
$(MAKE) -C full-trace
$(MAKE) -C profile-func

install: all
mkdir -p ${TRACER_HOME}/install/bin
mkdir -p ${TRACER_HOME}/install/lib
cp ${TRACER_HOME}/full-trace/full_trace.so ${TRACER_HOME}/install/lib
cp ${TRACER_HOME}/profile-func/trace_logger.llvm ${TRACER_HOME}/install/lib

clean:
$(MAKE) -C full-trace clean
$(MAKE) -C profile-func clean
7 changes: 7 additions & 0 deletions ast-pass/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ add_definitions(
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -std=c++11")
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")
else (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif (DEBUG)

set(SOURCE_FILES GetLabeledStmts.cpp)
add_executable(get-labeled-stmts ${SOURCE_FILES})
install(TARGETS get-labeled-stmts RUNTIME DESTINATION bin)

target_link_libraries(get-labeled-stmts
clangFrontend
Expand Down Expand Up @@ -60,3 +66,4 @@ target_link_libraries(get-labeled-stmts
dl
${CURSES_LIBRARIES}
)

8 changes: 7 additions & 1 deletion full-trace/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")
else (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif (DEBUG)

file(GLOB SRC "*.cpp")
add_library(full_trace SHARED ${SRC})
install(TARGETS full_trace LIBRARY DESTINATION lib)

# remove name prefix in order not to generate libxxxxxx name
set_target_properties(full_trace PROPERTIES PREFIX "")
Expand Down
1 change: 1 addition & 0 deletions profile-func/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ else()
endif()

add_custom_target(PROFILE_FUNC ALL DEPENDS ${FCTS})
install(FILES ${FCTS}.llvm DESTINATION lib)

0 comments on commit 680baa2

Please sign in to comment.