aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--third_party/CMakeLists.txt34
2 files changed, 31 insertions, 10 deletions
diff --git a/README.md b/README.md
index 7874038..49a91f0 100644
--- a/README.md
+++ b/README.md
@@ -140,8 +140,11 @@ git clone https://github.com/google/re2.git
cd $SOURCE_DIR/
```
-Note: You can set CMake variables to point to third party sources if they
-are located somewhere else. See the [Build options](#build-options) below.
+Note: There are two other ways to manage third party sources:
+- If you are building Effcee as part of a larger CMake-based project,
+ add the RE2 and `googletest` projects before adding Effcee.
+- Otherwise, you can set CMake variables to point to third party sources
+ if they are located somewhere else. See the [Build options](#build-options) below.
2) Ensure you have the requisite tools -- see the tools subsection below.
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index 9046573..4137510 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -1,25 +1,43 @@
# Suppress all warnings from third-party projects.
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -w)
+# Set alternate root directory for third party sources.
set(EFFCEE_THIRD_PARTY_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE STRING
"Root location of all third_party projects")
-set(EFFCEE_GOOGLETEST_DIR "${EFFCEE_THIRD_PARTY_ROOT_DIR}/googletest" CACHE STRING
- "Location of googletest source")
-set(EFFCEE_RE2_DIR "${EFFCEE_THIRD_PARTY_ROOT_DIR}/re2" CACHE STRING
- "Location of re2 source")
+
+# Find googletest and gmock
+if(${googletest-distribution_SOURCE_DIR})
+ set(EFFCEE_GOOGLETEST_DIR "${googletest-distribution_SOURCE_DIR}" CACHE STRING
+ "Location of googletest source")
+else()
+ set(EFFCEE_GOOGLETEST_DIR "${EFFCEE_THIRD_PARTY_ROOT_DIR}/googletest" CACHE STRING
+ "Location of googletest source")
+endif()
+
+# Find re2
+if(RE2_SOURCE_DIR)
+ set(EFFCEE_RE2_DIR "${RE2_SOURCE_DIR}" CACHE STRING "Location of re2 source" FORCE)
+else()
+ set(EFFCEE_RE2_DIR "${EFFCEE_THIRD_PARTY_ROOT_DIR}/re2" CACHE STRING
+ "Location of re2 source")
+endif()
# Configure third party projects.
if(EFFCEE_BUILD_TESTING)
- if (IS_DIRECTORY ${EFFCEE_GOOGLETEST_DIR})
- add_subdirectory(${EFFCEE_GOOGLETEST_DIR} googletest)
+ if (NOT TARGET gmock)
+ if (IS_DIRECTORY ${EFFCEE_GOOGLETEST_DIR})
+ add_subdirectory(${EFFCEE_GOOGLETEST_DIR} googletest)
+ endif()
endif()
if (NOT TARGET gmock)
message(FATAL_ERROR "gmock was not found - required for tests")
endif()
endif()
-if (IS_DIRECTORY ${EFFCEE_RE2_DIR})
- add_subdirectory(${EFFCEE_RE2_DIR} re2)
+if (NOT TARGET re2)
+ if (IS_DIRECTORY ${EFFCEE_RE2_DIR})
+ add_subdirectory(${EFFCEE_RE2_DIR} re2)
+ endif()
endif()
if (NOT TARGET re2)
message(FATAL_ERROR "re2 was not found - required for compilation")