Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Remove cmake external project goo from cmake test.
Browse files Browse the repository at this point in the history
Fixes #54.
  • Loading branch information
Cap Petschulat committed Jun 27, 2014
1 parent 86ec3fb commit 786be96
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 39 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
53 changes: 22 additions & 31 deletions examples/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
7 changes: 1 addition & 6 deletions test_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 786be96

Please sign in to comment.