From 6a0953ab94a35e150a212d2b709b5bf569b6cce8 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Tue, 6 Mar 2012 19:42:59 +0000 Subject: [PATCH] cmake: sparsehash moves header file in newer version! Detect the 2 include pathes and add a define. Fix issue 1222 git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5117 96395faa-99c1-11dd-bbfe-3dabce05a288 --- cmake/FindSparseHash_NEW.cmake | 18 ++++++++++++++++++ cmake/SearchForStuff.cmake | 6 ++++++ common/include/Utilities/HashMap.h | 8 ++++++++ common/src/Utilities/CMakeLists.txt | 4 ++++ pcsx2/CMakeLists.txt | 4 ++++ 5 files changed, 40 insertions(+) create mode 100644 cmake/FindSparseHash_NEW.cmake diff --git a/cmake/FindSparseHash_NEW.cmake b/cmake/FindSparseHash_NEW.cmake new file mode 100644 index 0000000000..070999f7d2 --- /dev/null +++ b/cmake/FindSparseHash_NEW.cmake @@ -0,0 +1,18 @@ +# Try to find SparseHash +# Once done, this will define +# +# SPARSEHASE_NEW_FOUND - system has SparseHash +# SPARSEHASE_NEW_INCLUDE_DIR - the SparseHash include directories + +if(SPARSEHASE_NEW_INCLUDE_DIR) + set(SPARSEHASE_NEW_FIND_QUIETLY TRUE) +endif(SPARSEHASE_NEW_INCLUDE_DIR) + +find_path(SPARSEHASE_NEW_INCLUDE_DIR sparsehash/internal/densehashtable.h) + +# handle the QUIETLY and REQUIRED arguments and set SPARSEHASE_NEW_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(SparseHash_new DEFAULT_MSG SPARSEHASE_NEW_INCLUDE_DIR) + +mark_as_advanced(SPARSEHASE_NEW_INCLUDE_DIR) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 0527299649..6c776f100d 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -61,6 +61,7 @@ if(NOT FORCE_INTERNAL_SOUNDTOUCH) include(FindSoundTouch) endif(NOT FORCE_INTERNAL_SOUNDTOUCH) include(FindSparseHash) +include(FindSparseHash_NEW) # Note for include_directory: The order is important to avoid a mess between include file from your system and the one of pcsx2 # If you include first 3rdparty, all 3rdpary include will have a higer priority... @@ -166,6 +167,11 @@ endif(SOUNDTOUCH_FOUND AND NOT projectSoundTouch) if(SPARSEHASH_FOUND) include_directories(${SPARSEHASH_INCLUDE_DIR}) endif(SPARSEHASH_FOUND) +if(SPARSEHASH_NEW_FOUND) + include_directories(${SPARSEHASH_NEW_INCLUDE_DIR}) + # allow to build parts that depend on sparsehash + set(SPARSEHASH_FOUND TRUE) +endif(SPARSEHASH_NEW_FOUND) # Wx if(wxWidgets_FOUND) diff --git a/common/include/Utilities/HashMap.h b/common/include/Utilities/HashMap.h index 91500026e9..44da83fbdb 100644 --- a/common/include/Utilities/HashMap.h +++ b/common/include/Utilities/HashMap.h @@ -15,10 +15,18 @@ #pragma once +// They move include file in version 2.0.2 of google sparsehash... +#ifdef SPARSEHASH_NEW_INCLUDE_DIR +#include +#include +#include +#include +#else #include #include #include #include +#endif #include diff --git a/common/src/Utilities/CMakeLists.txt b/common/src/Utilities/CMakeLists.txt index b5d9040d30..68fb33fc5a 100644 --- a/common/src/Utilities/CMakeLists.txt +++ b/common/src/Utilities/CMakeLists.txt @@ -20,6 +20,10 @@ set(CommonFlags -pipe -Wunused-variable) +if (SPARSEHASH_NEW_FOUND) + set(CommonFlags "${CommonFlags} -DSPARSEHASH_NEW_INCLUDE_DIR ") +endif (SPARSEHASH_NEW_FOUND) + # set warning flags set(DebugFlags -g diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index c87ab6fa9e..9bef3c82d7 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -22,6 +22,10 @@ set(CommonFlags -Wstrict-aliasing # Allow to track strict aliasing issue. -pipe) +if (SPARSEHASH_NEW_FOUND) + set(CommonFlags "${CommonFlags} -DSPARSEHASH_NEW_INCLUDE_DIR ") +endif (SPARSEHASH_NEW_FOUND) + # set warning flags set(DebugFlags -W