CMake doesn't handle convenience libraries as nicely as autotools does. We
need to be explicit with -fPIC here as we use these in libvnc.so.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4645 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/Xregion/CMakeLists.txt b/common/Xregion/CMakeLists.txt
index 40ca97e..a7788eb 100644
--- a/common/Xregion/CMakeLists.txt
+++ b/common/Xregion/CMakeLists.txt
@@ -1,6 +1,14 @@
add_library(Xregion STATIC
Region.c)
+# This code goes into libvnc.so, so it needs to be PIC on x86_64.
+# (It should be on archs as well, but we prefer performance over memory
+# efficiency. Win64 is excluded because PIC is always on there and it
+# complains when you give it the explicit flag.)
+if(CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_SIZEOF_VOID_P MATCHES 8) AND NOT WIN32)
+ set_target_properties(Xregion PROPERTIES COMPILE_FLAGS -fPIC)
+endif()
+
if(UNIX)
libtool_create_control_file(Xregion)
endif()
diff --git a/common/network/CMakeLists.txt b/common/network/CMakeLists.txt
index ddde574..681d291 100644
--- a/common/network/CMakeLists.txt
+++ b/common/network/CMakeLists.txt
@@ -3,6 +3,14 @@
add_library(network STATIC
TcpSocket.cxx)
+# This code goes into libvnc.so, so it needs to be PIC on x86_64.
+# (It should be on archs as well, but we prefer performance over memory
+# efficiency. Win64 is excluded because PIC is always on there and it
+# complains when you give it the explicit flag.)
+if(CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_SIZEOF_VOID_P MATCHES 8) AND NOT WIN32)
+ set_target_properties(network PROPERTIES COMPILE_FLAGS -fPIC)
+endif()
+
if(UNIX)
libtool_create_control_file(network)
endif()
diff --git a/common/os/CMakeLists.txt b/common/os/CMakeLists.txt
index 82f1165..623a32f 100644
--- a/common/os/CMakeLists.txt
+++ b/common/os/CMakeLists.txt
@@ -5,3 +5,11 @@
net.c
os.cxx
tls.cxx)
+
+# This code goes into libvnc.so, so it needs to be PIC on x86_64.
+# (It should be on archs as well, but we prefer performance over memory
+# efficiency. Win64 is excluded because PIC is always on there and it
+# complains when you give it the explicit flag.)
+if(CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_SIZEOF_VOID_P MATCHES 8) AND NOT WIN32)
+ set_target_properties(os PROPERTIES COMPILE_FLAGS -fPIC)
+endif()
diff --git a/common/rdr/CMakeLists.txt b/common/rdr/CMakeLists.txt
index ee71a9b..6d3ec1d 100644
--- a/common/rdr/CMakeLists.txt
+++ b/common/rdr/CMakeLists.txt
@@ -24,6 +24,14 @@
target_link_libraries(rdr ${RDR_LIBRARIES})
+# This code goes into libvnc.so, so it needs to be PIC on x86_64.
+# (It should be on archs as well, but we prefer performance over memory
+# efficiency. Win64 is excluded because PIC is always on there and it
+# complains when you give it the explicit flag.)
+if(CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_SIZEOF_VOID_P MATCHES 8) AND NOT WIN32)
+ set_target_properties(rdr PROPERTIES COMPILE_FLAGS -fPIC)
+endif()
+
if(UNIX)
libtool_create_control_file(rdr)
endif()
diff --git a/common/rfb/CMakeLists.txt b/common/rfb/CMakeLists.txt
index be03c64..f8c1a43 100644
--- a/common/rfb/CMakeLists.txt
+++ b/common/rfb/CMakeLists.txt
@@ -95,6 +95,14 @@
target_link_libraries(rfb ${RFB_LIBRARIES})
+# This code goes into libvnc.so, so it needs to be PIC on x86_64.
+# (It should be on archs as well, but we prefer performance over memory
+# efficiency. Win64 is excluded because PIC is always on there and it
+# complains when you give it the explicit flag.)
+if(CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_SIZEOF_VOID_P MATCHES 8) AND NOT WIN32)
+ set_target_properties(rfb PROPERTIES COMPILE_FLAGS -fPIC)
+endif()
+
if(UNIX)
libtool_create_control_file(rfb)
endif()
diff --git a/common/zlib/CMakeLists.txt b/common/zlib/CMakeLists.txt
index 69f1c9f..ecee0eb 100644
--- a/common/zlib/CMakeLists.txt
+++ b/common/zlib/CMakeLists.txt
@@ -20,3 +20,11 @@
trees.c
uncompr.c
zutil.c)
+
+# This code goes into libvnc.so, so it needs to be PIC on x86_64.
+# (It should be on other archs as well, but we prefer performance over memory
+# efficiency. Win64 is excluded because PIC is always on there and it
+# complains when you give it the explicit flag.)
+if(CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_SIZEOF_VOID_P MATCHES 8) AND NOT WIN32)
+ set_target_properties(zlib PROPERTIES COMPILE_FLAGS -fPIC)
+endif()