Commit 741c005c authored by Christian Convey's avatar Christian Convey

Fixes several CMake problems.

parent 4dac3a18
...@@ -14,12 +14,20 @@ ...@@ -14,12 +14,20 @@
# We require version 2.8.12 only because that's the lowest version of CMake on which # We require version 2.8.12 only because that's the lowest version of CMake on which
# we've validate this repository. # we've validate this repository.
cmake_minimum_required (VERSION 2.8.12) cmake_minimum_required (VERSION 2.8.12)
cmake_policy(VERSION 2.8.12)
project (ngraph # Suppress an OS X-specific warning.
LANGUAGES CXX if (POLICY CMP0042)
) cmake_policy(SET CMP0042 OLD)
endif()
# Suppress a warning about not using the `project` command's `VERSION` argument.
# Once we bump `cmake_minimum_required` to something >= 3.0, we can remove this
# suppression and change how we specify the project's version number.
if (POLICY CMP0048)
cmake_policy(SET CMP0048 OLD)
endif()
project (ngraph CXX)
set(NGRAPH_VERSION 0.1) set(NGRAPH_VERSION 0.1)
# These variables are undocumented but useful. # These variables are undocumented but useful.
...@@ -29,6 +37,29 @@ set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) ...@@ -29,6 +37,29 @@ set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
# set directory where the custom finders live # set directory where the custom finders live
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
#-----------------------------------------------------------------------------------------------
# Compiler-specific logic...
#-----------------------------------------------------------------------------------------------
# Default values...
set(NGRAPH_CXX_WARNING_FLAGS "")
# Compiler-specific logic...
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
include( cmake/clang_4_0_flags.cmake )
else()
message(WARNING "CMAKE_CXX_COMPILER_ID='${CMAKE_CXX_COMPILER_ID}'. CMAKE_CXX_COMPILER='${CMAKE_CXX_COMPILER}'. The only supported compiler is 'clang', but the selected compiler is '${CMAKE_CXX_COMPILER}'.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
FOREACH(F IN LISTS NGRAPH_CXX_WARNING_FLAGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${F}")
ENDFOREACH()
#-----------------------------------------------------------------------------------------------
# The following 'add_subdirectory' call: # The following 'add_subdirectory' call:
# - defines the 'libgtest' target. # - defines the 'libgtest' target.
# - defines the 'GTEST_INCLUDE_DIR' cmake variable. # - defines the 'GTEST_INCLUDE_DIR' cmake variable.
......
...@@ -14,17 +14,38 @@ ...@@ -14,17 +14,38 @@
# Enable ExternalProject CMake module # Enable ExternalProject CMake module
include(ExternalProject) include(ExternalProject)
# Download and install GoogleTest #----------------------------------------------------------------------------------------------------------
ExternalProject_Add( # Download and install GoogleTest ...
gtest #----------------------------------------------------------------------------------------------------------
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.0 SET(GTEST_GIT_REPO_URL https://github.com/google/googletest.git)
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest SET(GTEST_GIT_LABEL release-1.8.0)
# Disable install step
INSTALL_COMMAND "" # The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
UPDATE_COMMAND "" if (${CMAKE_VERSION} VERSION_LESS 3.2)
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build/googlemock/gtest/libgtest.a" ExternalProject_Add(
) gtest
GIT_REPOSITORY ${GTEST_GIT_REPO_URL}
GIT_TAG ${GTEST_GIT_LABEL}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
)
else()
ExternalProject_Add(
gtest
GIT_REPOSITORY ${GTEST_GIT_REPO_URL}
GIT_TAG ${GTEST_GIT_LABEL}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build/googlemock/gtest/libgtest.a"
)
endif()
#----------------------------------------------------------------------------------------------------------
# Get GTest source and binary directories from CMake project # Get GTest source and binary directories from CMake project
ExternalProject_Get_Property(gtest source_dir binary_dir) ExternalProject_Get_Property(gtest source_dir binary_dir)
......
...@@ -11,29 +11,6 @@ ...@@ -11,29 +11,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
#-----------------------------------------------------------------------------------------------
# Compiler-specific logic...
#-----------------------------------------------------------------------------------------------
# Default values...
set(NGRAPH_CXX_WARNING_FLAGS "")
# Compiler-specific logic...
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
include( ../cmake/clang_4_0_flags.cmake )
else()
message(WARNING "CMAKE_CXX_COMPILER_ID='${CMAKE_CXX_COMPILER_ID}'. CMAKE_CXX_COMPILER='${CMAKE_CXX_COMPILER}'. The only supported compiler is 'clang', but the selected compiler is '${CMAKE_CXX_COMPILER}'.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
FOREACH(F IN LISTS NGRAPH_CXX_WARNING_FLAGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${F}")
ENDFOREACH()
#-----------------------------------------------------------------------------------------------
get_filename_component( NGRAPH_INCLUDE_DIR . ABSOLUTE) get_filename_component( NGRAPH_INCLUDE_DIR . ABSOLUTE)
set(NGRAPH_INCLUDE_DIR "${NGRAPH_INCLUDE_DIR}" PARENT_SCOPE) set(NGRAPH_INCLUDE_DIR "${NGRAPH_INCLUDE_DIR}" PARENT_SCOPE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment