From 0b5c0bd94e19bbd268d9af956c51e804d4661ddf Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 15 Aug 2019 12:59:00 +0800 Subject: [PATCH] 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 --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c58104de..c808572d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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()