Fix a bug to handle Executable and Library with same name (xgboost) correctly. (#1669)

add_library(libxgboost SHARED ${SOURCES}) builds a library named
liblibxgboost.so; However, simply changing it to add_library(xgboost ...)
won't work, as add_executable(xgboost ...) and add_library(xgbboost ...)
will then have the same target name. This patch correctly handles the
same-name situation through SET_TARGET_PROPERTIES.
This commit is contained in:
Jiading Gai 2016-10-15 21:29:40 -04:00 committed by Tianqi Chen
parent f5c776f64f
commit be90deb9b6

View File

@ -74,8 +74,9 @@ add_subdirectory(dmlc-core)
add_library(rabit STATIC ${RABIT_SOURCES}) add_library(rabit STATIC ${RABIT_SOURCES})
add_executable(xgboost ${SOURCES}) add_executable(xgboost-bin ${SOURCES})
add_library(libxgboost SHARED ${SOURCES}) SET_TARGET_PROPERTIES(xgboost-bin PROPERTIES OUTPUT_NAME xgboost)
add_library(xgboost SHARED ${SOURCES})
target_link_libraries(xgboost-bin dmlccore rabit)
target_link_libraries(xgboost dmlccore rabit) target_link_libraries(xgboost dmlccore rabit)
target_link_libraries(libxgboost dmlccore rabit)