cmake: fix static build on windows

On Windows, we can make a static build by setting the triple to
x64-windows-static, but due to some issues with cmake we also need to
modify the linker flags and Python definitions.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2019-08-15 12:59:00 +08:00
parent 6e932f5a2d
commit 0b5c0bd94e

View File

@ -15,7 +15,14 @@ option(SERIALIZE_CHIPDB "Never build chipdb in parallel to reduce peak memory us
set(link_param "")
if (STATIC_BUILD)
set(Boost_USE_STATIC_LIBS ON)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CMAKE_CXX_FLAGS_RELEASE "/MT")
set(CMAKE_CXX_FLAGS_DEBUG "/MTd")
if (BUILD_PYTHON)
add_definitions(-DBOOST_PYTHON_STATIC_LIB)
endif()
else()
set(link_param "-static")
endif()
endif()