Skip to content

Commit

Permalink
Install nnvm lib and haders. Offer choice to build static or shared l…
Browse files Browse the repository at this point in the history
…ib. (dmlc#146)
  • Loading branch information
weijianwen authored and tqchen committed Oct 7, 2017
1 parent 5d56424 commit 3634676
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ set(nnvm_LINKER_LIBS "")

add_definitions(-DNNVM_EXPORTS)

# Build a shared lib (libnnvm.so) by default
option(BUILD_SHARED_NNVM "Build a shared nnvm lib" ON)
option(BUILD_STATIC_NNVM "Build a static nnvm lib" OFF)

# compile
if(MSVC)
add_definitions(-DDMLC_USE_CXX11)
Expand Down Expand Up @@ -64,8 +68,15 @@ elseif(DMLC_CORE_PATH)
include_directories(${DMLC_CORE_PATH}/include)
endif()

add_library(nnvm SHARED ${SOURCE})
target_link_libraries(nnvm ${nnvm_LINKER_LIBS})
if(BUILD_SHARED_NNVM)
add_library(nnvm SHARED ${SOURCE})
target_link_libraries(nnvm ${nnvm_LINKER_LIBS})
endif()
if(BUILD_STATIC_NNVM)
add_library(nnvm_static STATIC ${SOURCE})
target_link_libraries(nnvm_static ${nnvm_LINKER_LIBS})
set_target_properties(nnvm_static PROPERTIES OUTPUT_NAME "nnvm")
endif()

if(INSTALL_INCLUDE_DIR)
add_custom_command(TARGET nnvm POST_BUILD
Expand All @@ -74,6 +85,16 @@ if(INSTALL_INCLUDE_DIR)
)
endif()

# ---[ Install lib, header and docs
if(BUILD_SHARED_NNVM)
install(TARGETS nnvm LIBRARY DESTINATION lib)
endif()
if(BUILD_STATIC_NNVM)
install(TARGETS nnvm_static ARCHIVE DESTINATION lib)
endif()
install(DIRECTORY include DESTINATION .)
install(DIRECTORY docs DESTINATION .)

# ---[ Linter target
if(MSVC)
find_package(PythonInterp 2)
Expand Down

0 comments on commit 3634676

Please sign in to comment.