Make CMakeLists.txt compatible with CMake 3.3 (#4420)

* Make CMakeLists.txt compatible with CMake 3.3; require CMake 3.11 for MSVC

* Use CMake 3.12 when sanitizer is enabled

* Disable funroll-loops for MSVC

* Use cmake version in container name

* Add missing arg

* Fix egrep use in ci_build.sh

* Display CMake version

* Do not set OpenMP_CXX_LIBRARIES for MSVC

* Use cmake_minimum_required()
This commit is contained in:
Philip Hyunsu Cho
2019-05-01 20:49:32 -07:00
committed by Jiaming Yuan
parent 17df5fd296
commit bfddc2c42c
6 changed files with 26 additions and 9 deletions

View File

@@ -77,7 +77,7 @@ target_include_directories(objxgboost
target_compile_options(objxgboost
PRIVATE
$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<COMPILE_LANGUAGE:CXX>>:/MP>
$<$<COMPILE_LANGUAGE:CXX>:-funroll-loops>)
$<$<AND:$<NOT:$<CXX_COMPILER_ID:MSVC>>,$<COMPILE_LANGUAGE:CXX>>:-funroll-loops>)
if (WIN32 AND MINGW)
target_compile_options(objxgboost PUBLIC -static-libstdc++)
endif (WIN32 AND MINGW)
@@ -106,6 +106,9 @@ if (USE_OPENMP)
find_package(OpenMP REQUIRED)
if (OpenMP_CXX_FOUND OR OPENMP_FOUND)
target_compile_options(objxgboost PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${OpenMP_CXX_FLAGS}>)
if ((NOT OpenMP_CXX_LIBRARIES) AND (NOT MSVC)) # old CMake doesn't define this variable
set(OpenMP_CXX_LIBRARIES "gomp;pthread")
endif ((NOT OpenMP_CXX_LIBRARIES) AND (NOT MSVC))
list(APPEND SRC_LIBS ${OpenMP_CXX_LIBRARIES})
set(LINKED_LIBRARIES_PRIVATE "${LINKED_LIBRARIES_PRIVATE};${SRC_LIBS}" PARENT_SCOPE)
endif (OpenMP_CXX_FOUND OR OPENMP_FOUND)