Skip to content

Commit

Permalink
[FIX,CMAKE] Only compile runtime files once (#7417)
Browse files Browse the repository at this point in the history
* [FIX,CMAKE] Only compile runtime files once

* copy defines to tvm_runtime_objs
  • Loading branch information
tkonolige authored Feb 9, 2021
1 parent c789a29 commit 79b6ef7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ endif()

add_lib_info(${CMAKE_CURRENT_LIST_DIR}/src/support/libinfo.cc)

add_library(tvm_objs OBJECT ${COMPILER_SRCS} ${RUNTIME_SRCS})
add_library(tvm_objs OBJECT ${COMPILER_SRCS})
add_library(tvm_runtime_objs OBJECT ${RUNTIME_SRCS})

add_library(tvm SHARED $<TARGET_OBJECTS:tvm_objs>)
add_library(tvm SHARED $<TARGET_OBJECTS:tvm_objs> $<TARGET_OBJECTS:tvm_runtime_objs>)
set_property(TARGET tvm APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}")
add_library(tvm_runtime SHARED $<TARGET_OBJECTS:tvm_runtime_objs>)
set_property(TARGET tvm_runtime APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}")
Expand All @@ -394,16 +394,21 @@ if(USE_RELAY_DEBUG)
message(STATUS "Building Relay in debug mode...")
target_compile_definitions(tvm_objs PRIVATE "USE_RELAY_DEBUG")
target_compile_definitions(tvm_objs PRIVATE "DMLC_LOG_DEBUG")
target_compile_definitions(tvm_runtime_objs PRIVATE "USE_RELAY_DEBUG")
target_compile_definitions(tvm_runtime_objs PRIVATE "DMLC_LOG_DEBUG")
else()
target_compile_definitions(tvm_objs PRIVATE "NDEBUG")
target_compile_definitions(tvm_runtime_objs PRIVATE "NDEBUG")
endif(USE_RELAY_DEBUG)

if(USE_FALLBACK_STL_MAP)
message(STATUS "Building with STL Map...")
target_compile_definitions(tvm_objs PRIVATE "USE_FALLBACK_STL_MAP=1")
target_compile_definitions(tvm_runtime_objs PRIVATE "USE_FALLBACK_STL_MAP=1")
else()
message(STATUS "Building with TVM Map...")
target_compile_definitions(tvm_objs PRIVATE "USE_FALLBACK_STL_MAP=0")
target_compile_definitions(tvm_runtime_objs PRIVATE "USE_FALLBACK_STL_MAP=0")
endif(USE_FALLBACK_STL_MAP)

if(BUILD_FOR_HEXAGON)
Expand Down Expand Up @@ -447,7 +452,7 @@ target_include_directorieS(

set(TVM_TEST_LIBRARY_NAME tvm)
if (HIDE_PRIVATE_SYMBOLS AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_library(tvm_allvisible SHARED $<TARGET_OBJECTS:tvm_objs>)
add_library(tvm_allvisible SHARED $<TARGET_OBJECTS:tvm_objs> $<TARGET_OBJECTS:tvm_runtime_objs>)
target_include_directories(tvm_allvisible PUBLIC "$<TARGET_PROPERTY:tvm,INCLUDE_DIRECTORIES>")
target_link_libraries(tvm_allvisible PRIVATE "$<TARGET_PROPERTY:tvm,LINK_LIBRARIES>")
set(TVM_TEST_LIBRARY_NAME tvm_allvisible)
Expand Down

0 comments on commit 79b6ef7

Please sign in to comment.