Permalink
Browse files

Improved handing of external rabbitmq-codegen

- By default look in the CMAKE_SOURCE_DIR/rabbitmq-codegen, then
CMAKE_SOURCE_DIR/../rabbitmq-codegen unless RABBITMQ_CODEGEN_DIR is set
- If FETCH_CODEGEN_FROM_GIT use the CMake ExternalProject to do it
  • Loading branch information...
1 parent c817cb2 commit 6738de940bb901f81671c3851b92bca297f5c571 @alanxz alanxz committed Oct 31, 2011
Showing with 38 additions and 14 deletions.
  1. +38 −14 CMakeLists.txt
View
52 CMakeLists.txt
@@ -19,23 +19,47 @@ if (CHECK_PYTHON_JSON_FAILED)
endif (CHECK_PYTHON_SIMPLEJSON_FAILED)
endif (CHECK_PYTHON_JSON_FAILED)
-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
include(TestCInline)
-include(ExternalProject)
-ExternalProject_Add(
- amqp_codegen
- GIT_REPOSITORY https://github.com/rabbitmq/rabbitmq-codegen.git
- GIT_TAG rabbitmq_v2_5_1
- SOURCE_DIR amqp_codegen
- CONFIGURE_COMMAND ""
- BUILD_COMMAND ""
- INSTALL_COMMAND ""
- TEST_COMMAND "")
-
-ExternalProject_Get_Property(amqp_codegen SOURCE_DIR)
-set(AMQP_CODEGEN_DIR ${SOURCE_DIR})
+option(FETCH_CODEGEN_FROM_GIT "Fetch codegen directly from the git repository" OFF)
+
+set(CODEGEN_GIT_TAG rabbitmq_v2_5_1 CACHE STRING "Git tag in rabbitmq-codegen to fetch with FETCH_CODEGEN_FROM_GIT")
+if (FETCH_CODEGEN_FROM_GIT)
+ include(ExternalProject)
+ ExternalProject_Add(
+ amqp_codegen
+ GIT_REPOSITORY https://github.com/rabbitmq/rabbitmq-codegen.git
+ GIT_TAG ${CODEGEN_GIT_TAG}
+ SOURCE_DIR amqp_codegen
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+ TEST_COMMAND "")
+
+ ExternalProject_Get_Property(amqp_codegen SOURCE_DIR)
+ set(AMQP_CODEGEN_DIR ${SOURCE_DIR} CACHE PATH "Path to rabbitmq-codegen" FORCE)
+ message(STATUS "Using amqp_codegen.py in ${AMQP_CODEGEN_DIR}")
+else (FETCH_CODEGEN_FROM_GIT)
+ find_path(RABBITMQ_CODEGEN_DIR
+ amqp_codegen.py
+ PATHS ${CMAKE_SOURCE_DIR}/rabbitmq-codegen
+ ${CMAKE_SOURCE_DIR}/../rabbitmq-codegen
+ DOC "Path to directory containing amqp_codegen.py (rabbitmq-codegen)"
+ NO_DEFAULT_PATH
+ )
+
+ if (RABBITMQ_CODEGEN_DIR STREQUAL "RABBITMQ_CODEGEN_DIR-NOTFOUND")
+ message(SEND_ERROR "Cannot find rabbitmq-codegen, set RABBITMQ_CODEGEN_DIR to a rabbitmq-codegen checkout, or set FETCH_CODEGEN_FROM_GIT to download it from git automatically")
+ else ()
+ message(STATUS "Using amqp_codegen.py in ${RABBITMQ_CODEGEN_DIR}")
+ endif()
+
+ set(AMQP_CODEGEN_DIR ${RABBITMQ_CODEGEN_DIR} CACHE PATH "Path to rabbitmq-codegen" FORCE)
+endif (FETCH_CODEGEN_FROM_GIT)
+
+mark_as_advanced(AMQP_CODEGEN_DIR)
+
add_subdirectory(librabbitmq)
add_subdirectory(examples)

0 comments on commit 6738de9

Please sign in to comment.