From 5845e633962845424ff38571ab80f04857667b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=2E=20Neuh=C3=A4u=C3=9Fer?= Date: Tue, 14 Jun 2016 14:13:44 +0200 Subject: [PATCH] Make cmake not emit -fPIC to mingw64 for Windows builds. This patch detects a mingw64 build of the shared library and does not emit -fPIC to the compiler. This is necessary to avoid a warning message, as Windows native code DLLs are generally relocatable and not position independent. --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee0810295..c9a01daed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -304,7 +304,10 @@ endif() # library. If not building a shared library ``-fPIC`` isn't needed and would add # unnecessary overhead. if (BUILD_LIBZ3_SHARED) - if (NOT MSVC) + # Avoid adding -fPIC compiler switch if we compile with MSVC (which does not + # support the flag) or if we target Windows, which generally does not use + # position independent code for native code shared libraries (DLLs). + if (NOT (MSVC OR MINGW OR WIN32)) z3_add_cxx_flag("-fPIC" REQUIRED) endif() endif() @@ -387,4 +390,3 @@ option(ENABLE_EXAMPLE_TARGETS "Build Z3 api examples" ON) if (ENABLE_EXAMPLE_TARGETS) add_subdirectory(examples) endif() -