@@ -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" )
@@ -243,27 +250,23 @@ install(EXPORT ${PROJECT_NAME}_targets
243250 DESTINATION "${OSI_INSTALL_CMAKE_DIR} "
244251 COMPONENT dev)
245252
246- # add a target to generate API documentation with Doxygen
247- # Dependencies: Doxygen and proto2cpp.py
248- find_package (Doxygen)
249- if (Doxygen_FOUND)
253+ if (OSI_BUILD_DOCUMENTATION)
254+ # add a target to generate API documentation with Doxygen
255+ # Dependencies: Doxygen and proto2cpp.py
256+ find_package (Doxygen)
257+ if (Doxygen_FOUND)
250258 set (FILTER_PROTO2CPP_PY_PATH CACHE PATH "directory to the filter proto2cpp.py" )
251-
252259 if (NOT EXISTS ${FILTER_PROTO2CPP_PY_PATH} /proto2cpp.py)
253-
254- message (WARNING "${FILTER_PROTO2CPP_PY_PATH} /proto2cpp.py could not be found." )
255-
260+ message (WARNING "${FILTER_PROTO2CPP_PY_PATH} /proto2cpp.py could not be found." )
256261 else ()
262+ set (doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR} /doxygen_config.cmake.in)
263+ set (doxyfile ${CMAKE_CURRENT_BINARY_DIR} /Doxyfile)
257264
258- set (doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR} /doxygen_config.cmake.in)
259- set (doxyfile ${CMAKE_CURRENT_BINARY_DIR} /Doxyfile)
260-
261- configure_file (${doxyfile_in} ${doxyfile} @ONLY)
265+ configure_file (${doxyfile_in} ${doxyfile} @ONLY)
262266
263- ADD_CUSTOM_TARGET (api_doc ALL
267+ add_custom_target (api_doc ALL
264268 COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
265269 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
266-
267- endif (NOT EXISTS ${FILTER_PROTO2CPP_PY_PATH} /proto2cpp.py)
268-
270+ endif ()
271+ endif ()
269272endif ()
0 commit comments