1 # check if the user wants to build ddocs
3 # Copyright (c) 2007 Tim Burrell <tim.burrell@gmail.com>
7 # See Copyright.txt for details.
10 # Do not build documentation by default
11 if (NOT CMAKE_D_BUILD_DOCS)
12 set(CMAKE_D_BUILD_DOCS False CACHE BOOLEAN TRUE FORCE)
13 else (NOT CMAKE_D_BUILD_DOCS)
14 # check for specified ddoc files
15 # default to the candydoc usual
16 set(CMAKE_D_BUILD_DOCS True CACHE BOOLEAN FALSE FORCE)
17 if (NOT CMAKE_D_DDOC_FILES)
18 set(CMAKE_D_DDOC_FILES "documentation/candydoc/candy.ddoc;documentation/candydoc/modules.ddoc" CACHE STRING FALSE FORCE)
19 else (NOT CMAKE_D_DDOC_FILES)
20 set(CMAKE_D_DDOC_FILES "${CMAKE_D_DDOC_FILES}" CACHE STRING FALSE FORCE)
21 endif (NOT CMAKE_D_DDOC_FILES)
23 # copy the candydoc files
24 file(GLOB_RECURSE CANDY_DOC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/candydoc/*")
25 foreach(item ${CANDY_DOC_FILES})
26 string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" item ${item})
27 configure_file(${item} ${CMAKE_CURRENT_BINARY_DIR}/documentation/${item} COPYONLY)
31 file(GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/*.d")
33 foreach(item ${sources})
34 # first make sure we're not config.d
35 string(REGEX MATCH "config\\.d" ignore ${item})
36 if (NOT ${ignore} MATCHES "")
38 string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" item ${item})
39 string(REGEX REPLACE "\\.d" ".html" htmlFile ${item})
40 string(REGEX REPLACE "^.*/" "" htmlFile ${htmlFile})
41 string(REGEX REPLACE "\\.d" "" item ${item})
42 string(REGEX REPLACE "/" "." item ${item})
44 set(modules "${item}")
46 set(CMAKE_D_DDOC_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/documentation/${htmlFile}" CACHE STRING FALSE FORCE)
48 set(modules "${modules};${item}")
49 set(CMAKE_D_DDOC_CLEAN_FILES "${CMAKE_D_DDOC_CLEAN_FILES}" "${CMAKE_CURRENT_BINARY_DIR}/documentation/${htmlFile}" CACHE STRING FALSE FORCE)
51 endif (NOT ${ignore} MATCHES "")
54 # create formatted modules string
55 set(modString "MODULES = \n")
56 foreach(item ${modules})
57 set(modString "${modString}\t$(MODULE ${item})\n")
59 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/documentation/candydoc/modules.ddoc" ${modString})
60 endif (NOT CMAKE_D_BUILD_DOCS)