From 786be9604df9229117a72f8911ecad5c0ebea941 Mon Sep 17 00:00:00 2001 From: Cap Petschulat Date: Fri, 27 Jun 2014 16:19:13 +0000 Subject: [PATCH] Remove cmake external project goo from cmake test. Fixes #54. --- CMakeLists.txt | 6 ++-- examples/cmake/CMakeLists.txt | 53 +++++++++++++++-------------------- test_cmake.sh | 7 +---- 3 files changed, 27 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 692be3b..d4bb1a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,8 +52,10 @@ endif() if (DEFINED ENV{DISTRIBUTIONS_USE_PROTOBUF}) find_package(Protobuf) -endif() -if(PROTOBUF_FOUND) + if(NOT PROTOBUF_FOUND) + message(FATAL_ERROR + "DISTRIBUTIONS_USE_PROTOBUF specified but protobuf not found") + endif() message(STATUS "Using Google Protocol Buffers") set(DISTRIBUTIONS_SHARED_LIBS ${DISTRIBUTIONS_SHARED_LIBS} protobuf) set(DISTRIBUTIONS_STATIC_LIBS ${DISTRIBUTIONS_STATIC_LIBS} protobuf) diff --git a/examples/cmake/CMakeLists.txt b/examples/cmake/CMakeLists.txt index 0ce139e..a924c0b 100644 --- a/examples/cmake/CMakeLists.txt +++ b/examples/cmake/CMakeLists.txt @@ -5,45 +5,36 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++0x") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare") - #----------------------------------------------------------------------------- # BEGIN generic section -# -# To build with local copy of distributions, first build distributions, and -# then set the environment variable -# export DISTRIBUTIONS_PATH=/path/to/distributions -# for example in ~/.bashrc or $VIRTUAL_ENV/bin/postactivate - -include(ExternalProject) -if(DEFINED ENV{DISTRIBUTIONS_PATH}) - ExternalProject_Add(distributions - PREFIX distributions - DOWNLOAD_COMMAND "" - SOURCE_DIR $ENV{DISTRIBUTIONS_PATH} - BINARY_DIR $ENV{DISTRIBUTIONS_PATH}/build - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - ) +# germ of a future FindDistributions.cmake +find_path(DISTRIBUTIONS_INCLUDE_DIR distributions/random.hpp) +if(NOT DISTRIBUTIONS_INCLUDE_DIR) + message(FATAL_ERROR + "distributions include dir not found, try setting CMAKE_PREFIX_PATH") else() - ExternalProject_Add(distributions - PREFIX distributions - GIT_REPOSITORY https://github.com/forcedotcom/distributions.git - INSTALL_COMMAND "" - ) + message(STATUS + "using distributions include dir ${DISTRIBUTIONS_INCLUDE_DIR}") +endif() +find_library(DISTRIBUTIONS_LIBRARIES distributions_shared) +if(NOT DISTRIBUTIONS_LIBRARIES) + message(FATAL_ERROR + "distributions libraries not found, try setting CMAKE_PREFIX_PATH") +endif() +if(DEFINED ENV{DISTRIBUTIONS_USE_PROTOBUF}) + find_package(Protobuf) + if(NOT PROTOBUF_FOUND) + message(FATAL_ERROR + "DISTRIBUTIONS_USE_PROTOBUF specified but protobuf not found") + endif() + set(DISTRIBUTIONS_LIBRARIES ${DISTRIBUTIONS_LIBRARIES} protobuf) endif() -ExternalProject_Get_Property(distributions SOURCE_DIR) -ExternalProject_Get_Property(distributions BINARY_DIR) -include_directories("${SOURCE_DIR}/include") -link_directories("${BINARY_DIR}/src") - # END generic section #----------------------------------------------------------------------------- - add_executable(foo foo.cc) - +include_directories(${DISTRIBUTIONS_INCLUDE_DIR}) target_link_libraries(foo - distributions_shared + ${DISTRIBUTIONS_LIBRARIES} ) diff --git a/test_cmake.sh b/test_cmake.sh index f41715b..2b2508f 100755 --- a/test_cmake.sh +++ b/test_cmake.sh @@ -6,10 +6,5 @@ ROOT=$PWD mkdir -p $BUILD cd $BUILD -echo '------------' -echo 'REMOTE BUILD' +export CMAKE_PREFIX_PATH=$VIRTUAL_ENV cmake .. && make && ./foo - -echo '-----------' -echo 'LOCAL BUILD' -DISTRIBUTIONS_PATH=$ROOT cmake .. && make && ./foo