diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b8012476..bdaaa6661 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,6 @@ if (MSVC) endif (MSVC) set_default_configuration_release() -msvc_use_static_runtime() #-- Options option(BUILD_C_DOC "Build documentation for C APIs using Doxygen." OFF) @@ -67,6 +66,7 @@ if (USE_CUDA) endif (USE_CUDA) # dmlc-core +msvc_use_static_runtime() add_subdirectory(${PROJECT_SOURCE_DIR}/dmlc-core) set_target_properties(dmlc PROPERTIES CXX_STANDARD 11 @@ -139,6 +139,8 @@ set_target_properties( set_output_directory(runxgboost ${PROJECT_SOURCE_DIR}) set_output_directory(xgboost ${PROJECT_SOURCE_DIR}/lib) +# Ensure these two targets do not build simultaneously, as they produce outputs with conflicting names +add_dependencies(xgboost runxgboost) #-- Installing XGBoost if (R_LIB) @@ -214,3 +216,8 @@ if (GOOGLE_TEST) PROPERTIES PASS_REGULAR_EXPRESSION ".*test-rmse:0.087.*") endif (GOOGLE_TEST) + +# For MSVC: Call msvc_use_static_runtime() once again to completely +# replace /MD with /MT. See https://github.com/dmlc/xgboost/issues/4462 +# for issues caused by mixing of /MD and /MT flags +msvc_use_static_runtime() diff --git a/Jenkinsfile b/Jenkinsfile index d1ce168ec..0fbbcd3db 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,7 +25,7 @@ pipeline { // Build stages stages { - stage('Get sources') { + stage('Jenkins Linux: Get sources') { agent { label 'linux && cpu' } steps { script { @@ -35,7 +35,7 @@ pipeline { milestone ordinal: 1 } } - stage('Formatting Check') { + stage('Jenkins Linux: Formatting Check') { agent none steps { script { @@ -49,7 +49,7 @@ pipeline { milestone ordinal: 2 } } - stage('Build') { + stage('Jenkins Linux: Build') { agent none steps { script { @@ -65,7 +65,7 @@ pipeline { milestone ordinal: 3 } } - stage('Test') { + stage('Jenkins Linux: Test') { agent none steps { script { diff --git a/Jenkinsfile-win64 b/Jenkinsfile-win64 new file mode 100644 index 000000000..831f9154c --- /dev/null +++ b/Jenkinsfile-win64 @@ -0,0 +1,70 @@ +#!/usr/bin/groovy +// -*- mode: groovy -*- + +/* Jenkins pipeline for Windows AMD64 target */ + +pipeline { + agent none + // Build stages + stages { + stage('Jenkins Win64: Get sources') { + agent { label 'win64' } + steps { + script { + checkoutSrcs() + } + stash name: 'srcs' + milestone ordinal: 1 + } + } + stage('Jenkins Win64: Build') { + agent none + steps { + script { + parallel ([ + 'build-win64': { BuildWin64() } + ]) + } + milestone ordinal: 2 + } + } + } +} + +// check out source code from git +def checkoutSrcs() { + retry(5) { + try { + timeout(time: 2, unit: 'MINUTES') { + checkout scm + sh 'git submodule update --init' + } + } catch (exc) { + deleteDir() + error "Failed to fetch source codes" + } + } +} + +def BuildWin64() { + node('win64') { + unstash name: 'srcs' + echo "Building XGBoost for Windows AMD64 target..." + bat """ + mkdir build + cd build + cmake .. -G"Visual Studio 15 2017 Win64" -DUSE_CUDA=ON -DCMAKE_VERBOSE_MAKEFILE=ON + """ + bat """ + cd build + "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\MSBuild.exe" xgboost.sln /m /p:Configuration=Release + """ + bat """ + cd python-package + conda activate && python setup.py bdist_wheel --universal + """ + stash name: 'xgboost_win_whl', includes: 'python-package/dist/*.whl' + archiveArtifacts artifacts: "python-package/dist/*.whl", allowEmptyArchive: true + deleteDir() + } +} diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake index d9b38dc8a..8922fd0f0 100644 --- a/cmake/Utils.cmake +++ b/cmake/Utils.cmake @@ -17,6 +17,10 @@ endfunction(auto_source_group) function(msvc_use_static_runtime) if(MSVC) set(variables + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_MINSIZEREL + CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE @@ -29,6 +33,7 @@ function(msvc_use_static_runtime) endif() endforeach() set(variables + CMAKE_CUDA_FLAGS CMAKE_CUDA_FLAGS_DEBUG CMAKE_CUDA_FLAGS_MINSIZEREL CMAKE_CUDA_FLAGS_RELEASE @@ -39,6 +44,10 @@ function(msvc_use_static_runtime) string(REGEX REPLACE "-MD" "-MT" ${variable} "${${variable}}") set(${variable} "${${variable}}" PARENT_SCOPE) endif() + if(${variable} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}") + set(${variable} "${${variable}}" PARENT_SCOPE) + endif() endforeach() endif() endfunction(msvc_use_static_runtime) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2886706d2..c053321b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,7 +42,7 @@ if (USE_CUDA) $<$:--expt-extended-lambda> $<$:--expt-relaxed-constexpr> $<$:-lineinfo> - $<$:--std=c++11> + $<$>,$>:--std=c++11> $<$:${GEN_CODE}>) if (USE_NCCL) @@ -113,4 +113,10 @@ if (USE_OPENMP) set(LINKED_LIBRARIES_PRIVATE "${LINKED_LIBRARIES_PRIVATE};${SRC_LIBS}" PARENT_SCOPE) endif (OpenMP_CXX_FOUND OR OPENMP_FOUND) endif (USE_OPENMP) + +# For MSVC: Call msvc_use_static_runtime() once again to completely +# replace /MD with /MT. See https://github.com/dmlc/xgboost/issues/4462 +# for issues caused by mixing of /MD and /MT flags +msvc_use_static_runtime() + #-- End object library