aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Poletti <poletti.marco@gmail.com>2020-03-08 10:25:16 -0700
committerMarco Poletti <poletti.marco@gmail.com>2020-03-08 10:25:16 -0700
commit4eb421d3352f44f054b2221a0200253f1ca8092a (patch)
tree81f3a96df96d6deed1d11eca21b9e8fe713f9af5
parent7d72dce02a7236b42811ec986086df109522f1c3 (diff)
parentc1d802a4a054438614fa90bb5d419c110d4324e2 (diff)
downloadgoogle-fruit-4eb421d3352f44f054b2221a0200253f1ca8092a.tar.gz
Merge branch 'find-package-boost' of https://github.com/tt4g/fruit into tt4g-find-package-boost
-rw-r--r--CMakeLists.txt17
-rw-r--r--CONTRIBUTING.md10
-rw-r--r--appveyor.yml4
-rw-r--r--conanfile.py26
-rw-r--r--tests/CMakeLists.txt2
5 files changed, 34 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b357c1c..6f2c5a5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,12 +64,19 @@ set(FRUIT_USES_BOOST TRUE CACHE BOOL
"Whether to use Boost (specifically, boost::unordered_set and boost::unordered_map).
If this is false, Fruit will use std::unordered_set and std::unordered_map instead (however this causes injection to be a bit slower).")
-if("${WIN32}" AND "${FRUIT_USES_BOOST}" AND NOT "${FRUIT_IS_BEING_BUILT_BY_CONAN}")
- set(BOOST_DIR "" CACHE PATH "The directory where the boost library is installed, e.g. C:\\boost\\boost_1_62_0.")
- if("${BOOST_DIR}" STREQUAL "")
- message(FATAL_ERROR "Please re-run CMake, specifying the boost library path as BOOST_DIR, e.g. -DBOOST_DIR=C:\\boost\\boost_1_62_0, or specify -DFRUIT_USES_BOOST=False to not use boost.")
+if(${FRUIT_USES_BOOST})
+
+ if(DEFINED BOOST_DIR)
+ message(DEPRECATION "BOOST_DIR is deprecated. Use Boost_INCLUDE_DIR instead.")
+ set(Boost_INCLUDE_DIR "${BOOST_DIR}" CACHE PATH "")
+ endif()
+
+ find_package(Boost)
+ if(Boost_FOUND)
+ include_directories(${Boost_INCLUDE_DIRS})
+ else()
+ message(FATAL_ERROR "Please re-run CMake, specifying the boost library path as Boost_INCLUDE_DIR, e.g. -DBoost_INCLUDE_DIR=C:\\boost\\boost_1_62_0, or specify -DFRUIT_USES_BOOST=False to not use boost.")
endif()
- include_directories("${BOOST_DIR}")
endif()
set(RUN_TESTS_UNDER_VALGRIND FALSE CACHE BOOL "Whether to run Fruit tests under valgrind")
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 89a3fca..8d9170f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -108,7 +108,7 @@ For example, if you installed Boost in `C:\boost\boost_1_62_0`, you can put this
"generator": "Visual Studio 15 2017",
"configurationType": "Debug",
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
- "cmakeCommandArgs": "-DBOOST_DIR=C:\\boost\\boost_1_62_0 -DCMAKE_BUILD_TYPE=Debug -DFRUIT_ADDITIONAL_CXX_FLAGS=/Z7",
+ "cmakeCommandArgs": "-DBoost_INCLUDE_DIR=C:\\boost\\boost_1_62_0 -DCMAKE_BUILD_TYPE=Debug -DFRUIT_ADDITIONAL_CXX_FLAGS=/Z7",
"buildCommandArgs": "-m -v:minimal"
},
{
@@ -116,7 +116,7 @@ For example, if you installed Boost in `C:\boost\boost_1_62_0`, you can put this
"generator": "Visual Studio 15 2017",
"configurationType": "Release",
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
- "cmakeCommandArgs": "-DBOOST_DIR=C:\\boost\\boost_1_62_0 -DCMAKE_BUILD_TYPE=Release",
+ "cmakeCommandArgs": "-DBoost_INCLUDE_DIR=C:\\boost\\boost_1_62_0 -DCMAKE_BUILD_TYPE=Release",
"buildCommandArgs": "-m -v:minimal"
},
{
@@ -124,7 +124,7 @@ For example, if you installed Boost in `C:\boost\boost_1_62_0`, you can put this
"generator": "Visual Studio 15 2017 Win64",
"configurationType": "Debug",
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
- "cmakeCommandArgs": "-DBOOST_DIR=C:\\boost\\boost_1_62_0 -DCMAKE_BUILD_TYPE=Debug -DFRUIT_ADDITIONAL_CXX_FLAGS=/Z7",
+ "cmakeCommandArgs": "-DBoost_INCLUDE_DIR=C:\\boost\\boost_1_62_0 -DCMAKE_BUILD_TYPE=Debug -DFRUIT_ADDITIONAL_CXX_FLAGS=/Z7",
"buildCommandArgs": "-m -v:minimal"
},
{
@@ -132,7 +132,7 @@ For example, if you installed Boost in `C:\boost\boost_1_62_0`, you can put this
"generator": "Visual Studio 15 2017 Win64",
"configurationType": "Release",
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
- "cmakeCommandArgs": "-DBOOST_DIR=C:\\boost\\boost_1_62_0 -DCMAKE_BUILD_TYPE=Release",
+ "cmakeCommandArgs": "-DBoost_INCLUDE_DIR=C:\\boost\\boost_1_62_0 -DCMAKE_BUILD_TYPE=Release",
"buildCommandArgs": "-m -v:minimal"
}
]
@@ -140,7 +140,7 @@ For example, if you installed Boost in `C:\boost\boost_1_62_0`, you can put this
The `/Z7` flag instructs Visual Studio to use the C7 format for debugging information, which allows Fruit's tests to run in parallel without interfering with each other.
-If you don't want to use Boost, you can replace the `-DBOOST_DIR=...` flags above with `-DFRUIT_USES_BOOST=False`.
+If you don't want to use Boost, you can replace the `-DBoost_INCLUDE_DIR=...` flags above with `-DFRUIT_USES_BOOST=False`.
You can now run CMake within Visual Studio (from the menu: CMake -> Cache -> Generate -> CMakeLists.txt) and build Fruit (from the menu: CMake -> Build All).
diff --git a/appveyor.yml b/appveyor.yml
index bc9a449..10aa397 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -30,7 +30,7 @@ environment:
MINGW_PATH: 'C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin'
CMAKE_GENERATOR: 'MinGW Makefiles'
VCVARSALL_DIR: ''
- ADDITIONAL_CMAKE_ARGS: '-DBOOST_DIR=C:\Libraries\boost_1_64_0 -DCMAKE_CXX_FLAGS="-Werror"'
+ ADDITIONAL_CMAKE_ARGS: '-DBoost_INCLUDE_DIR=C:\Libraries\boost_1_64_0 -DCMAKE_CXX_FLAGS="-Werror"'
CONFIGURATION: Release
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_GENERATOR: 'Visual Studio 15 2017 Win64'
@@ -46,7 +46,7 @@ environment:
MINGW_PATH: 'C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin'
CMAKE_GENERATOR: 'MinGW Makefiles'
VCVARSALL_DIR: ''
- ADDITIONAL_CMAKE_ARGS: '-DBOOST_DIR=C:\Libraries\boost_1_64_0 -DBUILD_SHARED_LIBS=False -DCMAKE_CXX_FLAGS="-Werror"'
+ ADDITIONAL_CMAKE_ARGS: '-DBoost_INCLUDE_DIR=C:\Libraries\boost_1_64_0 -DBUILD_SHARED_LIBS=False -DCMAKE_CXX_FLAGS="-Werror"'
CONFIGURATION: Release
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_GENERATOR: 'Visual Studio 15 2017 Win64'
diff --git a/conanfile.py b/conanfile.py
index d5ebdaf..9d2c664 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -16,6 +16,7 @@ class FruitConan(ConanFile):
generators = "cmake"
exports = "COPYING"
_source_subfolder = "source_subfolder"
+ _cmake = None
def configure(self):
min_version = {
@@ -42,19 +43,20 @@ class FruitConan(ConanFile):
os.rename(extracted_dir, self._source_subfolder)
def _configure_cmake(self):
- cmake = CMake(self)
- cmake.definitions["FRUIT_IS_BEING_BUILT_BY_CONAN"] = "YES"
- cmake.definitions["BUILD_SHARED_LIBS"] = "YES" if self.options.shared else "NO"
- if self.options.use_boost:
+ if not self._cmake:
+ self._cmake = CMake(self)
+ self._cmake.definitions["FRUIT_IS_BEING_BUILT_BY_CONAN"] = "YES"
+ self._cmake.definitions["BUILD_SHARED_LIBS"] = "YES" if self.options.shared else "NO"
+ self._cmake.definitions["FRUIT_USES_BOOST"] = self.options.use_boost
+ if self.options.use_boost:
+ self._cmake.definitions["Boost_INCLUDE_DIR"] = os.path.join(
+ self.deps_cpp_info["boost"].rootpath, "include")
if self.settings.os == "Windows":
- cmake.definitions["BOOST_DIR"] = "."
- else:
- cmake.definitions["FRUIT_USES_BOOST"] = "NO"
- if self.settings.os == "Windows":
- cmake.definitions["FRUIT_TESTS_USE_PRECOMPILED_HEADERS"] = "NO"
- cmake.definitions["CMAKE_BUILD_TYPE"] = self.settings.build_type
- cmake.configure(source_folder=self._source_subfolder)
- return cmake
+ self._cmake.definitions["FRUIT_TESTS_USE_PRECOMPILED_HEADERS"] = "NO"
+ self._cmake.definitions["CMAKE_BUILD_TYPE"] = self.settings.build_type
+ self._cmake.configure(source_folder=self._source_subfolder)
+
+ return self._cmake
def build(self):
cmake = self._configure_cmake()
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index d543dca..6444023 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -87,7 +87,7 @@ CXX='${CMAKE_CXX_COMPILER}'
CXX_COMPILER_NAME='${CMAKE_CXX_COMPILER_ID}'
CXX_COMPILER_VERSION='${CMAKE_CXX_COMPILER_VERSION}'
FRUIT_COMPILE_FLAGS='${FRUIT_COMPILE_FLAGS} ${FRUIT_TESTONLY_CXXFLAGS}'
-ADDITIONAL_INCLUDE_DIRS='${BOOST_DIR}'
+ADDITIONAL_INCLUDE_DIRS='${Boost_INCLUDE_DIRS}'
ADDITIONAL_LINKER_FLAGS='${CMAKE_EXE_LINKER_FLAGS}'
RUN_TESTS_UNDER_VALGRIND='${RUN_TESTS_UNDER_VALGRIND_FLAG}'
VALGRIND_FLAGS='${VALGRIND_FLAGS_STR}'