@@ -2,12 +2,19 @@ cmake_minimum_required(VERSION 3.5)
22
33project (open_simulation_interface)
44
5+ # Toplevel check
6+ set (OSI_IS_TOP_LEVEL OFF )
7+ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR )
8+ set (OSI_IS_TOP_LEVEL ON )
9+ endif ()
10+
511# Set the C++ standard
612set (CMAKE_CXX_STANDARD 11)
713set (CMAKE_CXX_STANDARD_REQUIRED ON )
814
915# Optional Flatbuffer support
1016option (OSI_BUILD_FLATBUFFER "Build flatbuffer versions of libraries" OFF )
17+ option (OSI_BUILD_DOCUMENTATION "Build flatbuffer versions of libraries" ${OSI_IS_TOP_LEVEL} )
1118
1219# Set a default build type if none was specified
1320set (default_build_type "Release" )
@@ -241,27 +248,23 @@ install(EXPORT ${PROJECT_NAME}_targets
241248 DESTINATION "${OSI_INSTALL_CMAKE_DIR} "
242249 COMPONENT dev)
243250
244- # add a target to generate API documentation with Doxygen
245- # Dependencies: Doxygen and proto2cpp.py
246- find_package (Doxygen)
247- if (Doxygen_FOUND)
251+ if (OSI_BUILD_DOCUMENTATION)
252+ # add a target to generate API documentation with Doxygen
253+ # Dependencies: Doxygen and proto2cpp.py
254+ find_package (Doxygen)
255+ if (Doxygen_FOUND)
248256 set (FILTER_PROTO2CPP_PY_PATH CACHE PATH "directory to the filter proto2cpp.py" )
249-
250257 if (NOT EXISTS ${FILTER_PROTO2CPP_PY_PATH} /proto2cpp.py)
251-
252- message (WARNING "${FILTER_PROTO2CPP_PY_PATH} /proto2cpp.py could not be found." )
253-
258+ message (WARNING "${FILTER_PROTO2CPP_PY_PATH} /proto2cpp.py could not be found." )
254259 else ()
260+ set (doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR} /doxygen_config.cmake.in)
261+ set (doxyfile ${CMAKE_CURRENT_BINARY_DIR} /Doxyfile)
255262
256- set (doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR} /doxygen_config.cmake.in)
257- set (doxyfile ${CMAKE_CURRENT_BINARY_DIR} /Doxyfile)
258-
259- configure_file (${doxyfile_in} ${doxyfile} @ONLY)
263+ configure_file (${doxyfile_in} ${doxyfile} @ONLY)
260264
261- ADD_CUSTOM_TARGET (api_doc ALL
265+ add_custom_target (api_doc ALL
262266 COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
263267 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
264-
265- endif (NOT EXISTS ${FILTER_PROTO2CPP_PY_PATH} /proto2cpp.py)
266-
268+ endif ()
269+ endif ()
267270endif ()
0 commit comments