mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-17 09:47:34 +03:00
Merged PR 15561: Properly compile FBGEMM in CMake MSVC build
This fixes compilation of FBGEMM on Windows using CMake: 1. Compiling FBGEMM and cpuinfo statically 2. Forcing USE_STATIC_LIBS if USE_FBGEMM is set
This commit is contained in:
parent
244cfaa07e
commit
ae866af035
@ -98,13 +98,22 @@ if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /MTd /Od /Ob0 ${INTRINSICS} /RTC1 /Zi /D_DEBUG")
|
||||
|
||||
# ignores warning LNK4049: locally defined symbol free imported - this comes from zlib
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /LTCG:incremental /INCREMENTAL:NO /ignore:4049")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /LTCG:incremental /INCREMENTAL:NO /ignore:4049")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRTD")
|
||||
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /LTCG:incremental")
|
||||
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /LTCG:incremental")
|
||||
|
||||
find_library(SHLWAPI Shlwapi.lib)
|
||||
set(EXT_LIBS ${EXT_LIBS} SHLWAPI)
|
||||
|
||||
if(USE_FBGEMM)
|
||||
if(NOT USE_STATIC_LIBS) # FBGEMM on Windows can be compiled only statically via CMake
|
||||
message(FATAL_ERROR "FATAL ERROR: FBGEMM must be compiled statically on Windows, \
|
||||
add -DUSE_STATIC_LIBS=on to the cmake command")
|
||||
endif()
|
||||
set(EXT_LIBS ${EXT_LIBS} fbgemm)
|
||||
add_definitions(-DUSE_FBGEMM=1 -DFBGEMM_STATIC=1)
|
||||
endif(USE_FBGEMM)
|
||||
else(MSVC)
|
||||
|
||||
# Check we are using at least g++ 5.0
|
||||
|
9
src/3rd_party/CMakeLists.txt
vendored
9
src/3rd_party/CMakeLists.txt
vendored
@ -23,6 +23,15 @@ if(USE_FBGEMM)
|
||||
|
||||
# Do not compile cpuinfo executables due to a linker error, and they are not needed
|
||||
set(CPUINFO_BUILD_TOOLS OFF CACHE BOOL "Build command-line tools")
|
||||
# Do not build cpuinfo tests and benchmarks
|
||||
set(CPUINFO_BUILD_UNIT_TESTS OFF CACHE BOOL "Do not build cpuinfo unit tests")
|
||||
set(CPUINFO_BUILD_MOCK_TESTS OFF CACHE BOOL "Do not build cpuinfo mock tests")
|
||||
set(CPUINFO_BUILD_BENCHMARKS OFF CACHE BOOL "Do not build cpuinfo benchmarks")
|
||||
if(MSVC)
|
||||
# Force static compilation of cpuinfo on Windows
|
||||
SET(CPUINFO_LIBRARY_TYPE "static" CACHE STRING "Type of cpuinfo library (shared, static, or default) to build")
|
||||
SET(CPUINFO_RUNTIME_TYPE "static" CACHE STRING "Type of runtime library (shared, static, or default) to use")
|
||||
endif(MSVC)
|
||||
|
||||
set(FBGEMM_BUILD_TESTS OFF CACHE BOOL "Disable fbgemm tests")
|
||||
set(FBGEMM_BUILD_BENCHMARKS OFF CACHE BOOL "Disable fbgemm benchmark")
|
||||
|
Loading…
Reference in New Issue
Block a user