Warning, /graphics/glaxnimate/cmake/misc.cmake is written in an unsupported language. File is not indexed.
0001 #
0002 # Copyright (C) 2015-2017 Mattia Basaglia
0003 #
0004 # This program is free software: you can redistribute it and/or modify
0005 # it under the terms of the GNU General Public License as published by
0006 # the Free Software Foundation, either version 3 of the License, or
0007 # (at your option) any later version.
0008 #
0009 # This program is distributed in the hope that it will be useful,
0010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0012 # GNU General Public License for more details.
0013 #
0014 # You should have received a copy of the GNU General Public License
0015 # along with this program. If not, see <http://www.gnu.org/licenses/>.
0016 #
0017
0018 # Sets C++ standard version and disables extensions
0019 # Synopsis: use_cxx_standard(version)
0020 function(use_cxx_standard version)
0021 set(CMAKE_CXX_STANDARD ${version} PARENT_SCOPE)
0022 set(CMAKE_CXX_EXTENSIONS OFF PARENT_SCOPE)
0023 set(CMAKE_CXX_STANDARD_REQUIRED ON PARENT_SCOPE)
0024 message(STATUS "Using C++${version}")
0025
0026 if(${CMAKE_VERSION} LESS 3.2)
0027 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
0028 include(CheckCXXCompilerFlag)
0029 check_cxx_compiler_flag(--std=c++${version} STD_CXX)
0030 if(STD_CXX)
0031 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++${version}" PARENT_SCOPE)
0032 else()
0033 message(SEND_ERROR "Requires C++${version} or better")
0034 endif()
0035 else()
0036 message(WARNING "Unrecognized compiler: ${CMAKE_CXX_COMPILER_ID}, make sure it supports C++${version}")
0037 endif()
0038 endif()
0039 endfunction()
0040
0041 # Searches all sources matching a some glob patterns
0042 # Synopsis:
0043 # find_sources(
0044 # OUTPUT output_variable # Variable to populate
0045 # PATTERNS pattern... # Glob patterns for matching files
0046 # SOURCES directory... # Directories to scan
0047 # )
0048 function(find_sources)
0049 set(options)
0050 set(one_value OUTPUT)
0051 set(multi_value PATTERNS SOURCES)
0052 cmake_parse_arguments(PARSE_ARGV 0 FIND_SOURCES "${options}" "${one_value}" "${multi_value}")
0053
0054 set(all_files)
0055 foreach(dir ${FIND_SOURCES_SOURCES})
0056 foreach(pattern ${FIND_SOURCES_PATTERNS})
0057 file(GLOB_RECURSE files "${dir}/${pattern}")
0058 list(APPEND all_files ${files})
0059 endforeach()
0060 endforeach()
0061 set(${FIND_SOURCES_OUTPUT} ${all_files} PARENT_SCOPE)
0062 endfunction()
0063
0064
0065 # Creates targets to generate Doxygen documentation
0066 # Synopsis: create_doxygen_target(name)
0067 function(create_doxygen_target name)
0068 set(DOXYGEN_OUTPUT "\"${CMAKE_BINARY_DIR}/${name}\"")
0069
0070 set(DOXYGEN_INPUT "")
0071 find_sources(DOXYGEN_INPUT_FILES "*.dox")
0072 set(DOXYGEN_INPUT_FILES ${DOXYGEN_INPUT_FILES} ${ALL_SOURCES})
0073 foreach(source ${DOXYGEN_INPUT_FILES})
0074 set(DOXYGEN_INPUT "${DOXYGEN_INPUT} \"${source}\"")
0075 endforeach()
0076
0077 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile)
0078 add_custom_target(${name}
0079 ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
0080 DEPENDS ${PROJECT_BINARY_DIR}/Doxyfile ${DOXYGEN_INPUT_FILES}
0081 WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
0082 COMMENT "Generating Doxygen Documentation" VERBATIM
0083 )
0084 add_custom_target(${name}-view
0085 xdg-open ${DOXYGEN_OUTPUT}/html/index.html
0086 COMMENT "Showing Doxygen documentation"
0087 )
0088 endfunction()
0089
0090
0091 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/modules")