Debian Codegraph @

cmake/tribits/core/utils/GenerateNinjaMakefiles.cmake

raw
1 set(_GenerateNinjaMakefiles_DIR ${CMAKE_CURRENT_LIST_DIR})
2 function(generate_ninja_makefiles srcdir)
3 # Recurse into subdirectories.
4 get_property(dirs DIRECTORY ${srcdir} PROPERTY SUBDIRECTORIES)
5 foreach(d IN LISTS dirs)
6 generate_ninja_makefiles(${d})
7 endforeach()
8
9 # Get the targets from this directory.
10 get_property(targets DIRECTORY ${srcdir} PROPERTY BUILDSYSTEM_TARGETS)
11
12 # Accumulate a global list of all targets.
13 set_property(GLOBAL APPEND PROPERTY _GenerateNinjaMakefiles_TARGETS ${targets})
14
15 # Compute paths to/from this directory and the top.
16 get_property(bindir DIRECTORY ${srcdir} PROPERTY BINARY_DIR)
17 if("${bindir}" STREQUAL "${CMAKE_BINARY_DIR}")
18 set(topdir ".")
19 set(subdir ".")
20 # The top level provides all targets.
21 get_property(targets GLOBAL PROPERTY _GenerateNinjaMakefiles_TARGETS)
22 else()
23 file(RELATIVE_PATH subdir ${CMAKE_BINARY_DIR} ${bindir})
24 string(REGEX REPLACE "[^/]+" ".." topdir "${subdir}")
25 endif()
26
27 # Write the Makefile for this directory.
28 string(REPLACE ";" " " NINJA_MAKEFILE_TARGETS "${targets}")
29 file(TO_NATIVE_PATH "${topdir}" NINJA_MAKEFILE_TOPDIR)
30 file(TO_NATIVE_PATH "${subdir}" NINJA_MAKEFILE_SUBDIR)
31 file(TO_NATIVE_PATH "${_GenerateNinjaMakefiles_DIR}/NinjaMakefileCommon.make" NINJA_MAKEFILE_COMMON)
32 configure_file(${_GenerateNinjaMakefiles_DIR}/NinjaMakefile.in ${bindir}/Makefile)
33 endfunction()