# (C) Copyright 2008 Andrew Sutton # Distributed under the Boost Software License, Version 1.0. # Contents: # gpld_add_executable # gpld_add_documentation set(GPLD_CXX_FLAGS --std=c++0x) # Dependend programs and libraries. find_package(Doxygen REQUIRED) # Enable testing when including the GPLD build enviornment. enable_testing() # Drop-in replacement for add_executable(). macro(gpld_add_executable name) add_executable(${name} ${ARGN}) set_target_properties(${name} PROPERTIES COMPILE_FLAGS ${GPLD_CXX_FLAGS}) endmacro(gpld_add_executable) # Drop-in replacement for add_library(). macro(gpld_add_library name) add_library(${name} ${ARGN}) set_target_properties(${name} PROPERTIES COMPILE_FLAGS ${GPLD_CXX_FLAGS}) endmacro(gpld_add_library) # Replacement for target_link_libraries(). macro(gpld_link_libraries name) target_link_libraries(${name} ${ARGN}) endmacro(gpld_link_libraries) # Replacement for add_test(). Note that this will ultimately become a synonym # for gpld_add_run_test(), which will no longer use the testing macros. macro(gpld_add_test) add_test(${ARGV}) endmacro(gpld_add_test) # Add a target to be run when executing 'make test'. # Should this defer compilation until 'make test' is run? macro(gpld_add_run_test) endmacro(gpld_add_run_test) # Add a target to try and compile when executing 'make test'. Note that this # will not try to compile the target until 'make test' is run. macro(gpld_add_compile_test) endmacro(gpld_add_compile_test) # The gpld_add_documentation macro will generate a build target name 'doc' that # will compile HTML doxygen documentation for your project into your top-level # doc directory. # # gpld_add_documentation(input1 [input2 input3...]) # # This will generate a Doxyfile that documents the given inputs and generates # a custom command name 'doc' for the build system. When running 'make doc', the # documents will be built in the CMAKE_SOURCE/doc directory, as per the GPLD # requirement. # # TODO: This is an extremely trivial implementation of generating doxygen docs # and kind of stupid to boot. There are many, many options that we could use # to alter how the documentation is generated. For example, we could pass header # paths, specific arguments that affect output and location, etc., etc. macro(gpld_add_documentation) # Define and generate the Doxyfile. We generate this every time just in # case the caller wants to change the parameters. No big deal. set(doxyfile ${CMAKE_BINARY_DIR}/Doxyfile) execute_process(COMMAND ${DOXYGEN_EXECUTABLE} -s -g ${doxyfile} OUTPUT_QUIET ERROR_QUIET) # Make sure that we only generate the format you want. This currently # disables latex, which is apparently enabled by the command above. file(APPEND ${doxyfile} "OUTPUT_DIRECTORY = ${CMAKE_SOURCE_DIR}/doc\n") file(APPEND ${doxyfile} "GENERATE_HTML = YES\n") file(APPEND ${doxyfile} "GENERATE_XML = NO\n") file(APPEND ${doxyfile} "GENERATE_LATEX = NO\n") file(APPEND ${doxyfile} "QUIET = YES\n") # Build an input string based on the values given to the macro. Note that # the input values should be listed /relative/ to the top-level project level # source directory. set(inputs "") foreach(input ${ARGV}) set(inputs "${inputs} ${input}") endforeach(input) file(APPEND ${doxyfile} "INPUT = ${inputs}\n") # Add a command for actually buildign the doxygen documentation. This will # not build by default, so docs should be updated from the build separately. add_custom_target(doc COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}) endmacro(gpld_add_documentation)