Skip to content

Commit

Permalink
disabling cookbook by default and make cmake fail when dependencies f…
Browse files Browse the repository at this point in the history
…or meta examples are not met
  • Loading branch information
karlnapf authored and vigsterkr committed Mar 10, 2016
1 parent 960b614 commit b0a4dbc
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 57 deletions.
37 changes: 22 additions & 15 deletions CMakeLists.txt
Expand Up @@ -661,28 +661,35 @@ ENDIF()
FIND_PACKAGE(PythonInterp REQUIRED)

OPTION(BUILD_META_EXAMPLES "Generate API examples from meta-examples" ON)
find_package(PLY)
find_package(PYPARSING)
IF(NOT PLY_FOUND AND NOT PYPARSING_FOUND)
message("-- Python module PYPARSING or PLY required for meta examples. Disabling.")
SET(BUILD_META_EXAMPLES 0)
include(FindPythonModule)
find_python_module(ply REQUIRED)
IF(NOT PY_PLY)
find_python_module(pyparsing REQUIRED)
IF(NOT PY_PYPARSING)
message(FATAL_ERROR "Python modules pyparsing or ply required for meta examples.")
ELSE()
message(WARNING "Python module ply was not found. Falling back to pyparsing. This may cause meta example parsing to be very slow.")
ENDIF()
ENDIF()

IF(BUILD_META_EXAMPLES)
# allow meta examples without adding examples dir
# allow meta examples without adding examples dir itself
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples/meta)
ENDIF()

OPTION(BUILD_COOKBOOK "Build Shogun API cookbook" ON)
IF(NOT BUILD_META_EXAMPLES)
message("-- Meta examples are required for building cookbook. Disabling.")
SET(BUILD_COOKBOOK 0)
OPTION(BUILD_COOKBOOK "Build Shogun API cookbook" OFF)
IF(BUILD_COOKBOOK)
IF(NOT BUILD_META_EXAMPLES)
message(FATAL_ERROR
"Meta examples need to be enabled to build cookbook.")
ENDIF()

find_package(Sphinx)
IF(NOT SPHINX_FOUND)
message(FATAL_ERROR "Sphinx is required to build cookbook.")
ENDIF()
ENDIF()

find_package(Sphinx)
IF(NOT SPHINX_FOUND)
message("-- Sphinx is required for building cookbook. Disabling.")
SET(ENABLE_COOKBOOK 0)
ENDIF()

# JSON
OPTION(BUNDLE_JSON "Bundle JSON" OFF)
Expand Down
18 changes: 0 additions & 18 deletions cmake/FindPLY.cmake

This file was deleted.

18 changes: 0 additions & 18 deletions cmake/FindPYPARSING.cmake

This file was deleted.

20 changes: 20 additions & 0 deletions cmake/FindPythonModule.cmake
@@ -0,0 +1,20 @@
function(find_python_module module)
string(TOUPPER ${module} module_upper)
if(NOT PY_${module_upper})
if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED")
set(${module}_FIND_REQUIRED TRUE)
endif()
# A module's location is usually a directory, but for binary modules
# it's a .so file.
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import re, ${module}; print re.compile('/__init__.py.*').sub('',${module}.__file__)"
RESULT_VARIABLE _${module}_status
OUTPUT_VARIABLE _${module}_location
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT _${module}_status)
set(PY_${module_upper} ${_${module}_location} CACHE STRING
"Location of Python module ${module}")
endif(NOT _${module}_status)
endif(NOT PY_${module_upper})
find_package_handle_standard_args(PY_${module} DEFAULT_MSG PY_${module_upper})
endfunction(find_python_module)
6 changes: 0 additions & 6 deletions examples/meta/CMakeLists.txt
Expand Up @@ -3,12 +3,6 @@
# Check which interfaces are turned on
# Add CMakeLists file for each turned on interface


# Check if PLY is installed, warn if not. Check if pyparsing is installed otherwise. Throws error if not.
IF(NOT PLY_FOUND)
message(WARNING "Python module PLY was not found. This may cause Shogun's meta example generation to be very slow.")
ENDIF()

# Disabled (temporary) as non-portable solution. This is replaced by allowing any [a-zA-Z_][a-zA-Z0-9_]* as shogun keyword
# Generate type list
# execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/generator/types/get_type_list.sh > ${CMAKE_CURRENT_SOURCE_DIR}/generator/types/typelist)
Expand Down

0 comments on commit b0a4dbc

Please sign in to comment.