From be90deb9b60759313a1a6e6e121209a929744c8e Mon Sep 17 00:00:00 2001 From: Jiading Gai Date: Sat, 15 Oct 2016 21:29:40 -0400 Subject: [PATCH] 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. --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab1dec833..ddb38f82b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,9 @@ add_subdirectory(dmlc-core) add_library(rabit STATIC ${RABIT_SOURCES}) -add_executable(xgboost ${SOURCES}) -add_library(libxgboost SHARED ${SOURCES}) +add_executable(xgboost-bin ${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(libxgboost dmlccore rabit)