From 935cd91ab9deb98b72757b562803074ebfd58b6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 21 Jun 2011 23:58:22 +0100 Subject: [PATCH] Always use bundled zlib and libpng sources. Dynamically linking against them can cause conflicts when tracing applications that dynamically link against different versions. --- CMakeLists.txt | 34 +++++++++++++--------------------- libpng/CMakeLists.txt | 4 ++-- zlib/CMakeLists.txt | 4 ++-- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd32044..f388991 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,13 +15,6 @@ find_package (OpenGL REQUIRED) find_package (Qt4 4.7 COMPONENTS QtCore QtGui QtWebKit) find_package (QJSON) -if (NOT WIN32) - # Always use the bundled zlib and libpng sources on Windows to make it easy - # to deploy the wrappers DLLs - find_package (ZLIB) - find_package (PNG) -endif (NOT WIN32) - if (NOT WIN32) find_package (X11 REQUIRED) @@ -119,25 +112,24 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}) ############################################################################## # Bundled dependencies +# +# We always use the bundled zlib and libpng sources: +# - on Windows to make it easy to deploy the wrappers DLLs +# - on unices to prevent symbol collisions when tracing applications that link +# against other versions of these libraries -# Use bundled ZLIB if system one can't be found -if (NOT ZLIB_FOUND) - set (ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/zlib) - set (ZLIB_LIBRARIES zlib) - add_subdirectory (zlib EXCLUDE_FROM_ALL) -endif (NOT ZLIB_FOUND) +set (ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/zlib) +set (ZLIB_LIBRARIES z_bundled) +add_subdirectory (zlib EXCLUDE_FROM_ALL) include_directories (${ZLIB_INCLUDE_DIRS}) link_libraries (${ZLIB_LIBRARIES}) -# Use bundled LIBPNG if system one can't be found -if (PNG_FOUND) -else (PNG_FOUND) - set (PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libpng) - set (PNG_DEFINITIONS "") - set (PNG_LIBRARIES png) - add_subdirectory (libpng EXCLUDE_FROM_ALL) -endif (PNG_FOUND) +set (PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libpng) +set (PNG_DEFINITIONS "") +set (PNG_LIBRARIES png_bundled) + +add_subdirectory (libpng EXCLUDE_FROM_ALL) include_directories (${PNG_INCLUDE_DIR}) add_definitions (${PNG_DEFINITIONS}) link_libraries (${PNG_LIBRARIES}) diff --git a/libpng/CMakeLists.txt b/libpng/CMakeLists.txt index def8c5b..7775f91 100644 --- a/libpng/CMakeLists.txt +++ b/libpng/CMakeLists.txt @@ -1,6 +1,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -add_library (png STATIC +add_library (png_bundled STATIC png.c pngerror.c pngget.c @@ -18,6 +18,6 @@ add_library (png STATIC pngwutil.c ) -set_target_properties (png PROPERTIES +set_target_properties (png_bundled PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}" ) diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index 24a97a6..42caa7b 100644 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt @@ -1,6 +1,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -add_library (zlib STATIC +add_library (z_bundled STATIC adler32.c compress.c crc32.c @@ -15,6 +15,6 @@ add_library (zlib STATIC inffast.c ) -set_target_properties (zlib PROPERTIES +set_target_properties (z_bundled PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}" ) -- 2.43.0