summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/BuildDepends/CompilerDependencies.cmake
blob: 8a9e6008bc3b5b69633a4d4519ee2a8a97bf3f91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
enable_language(C)

add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.c)

file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
set(check_pairs
  \"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/main.c\"
  \"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/main.h\"
  )
set(check_exes
  \"$<TARGET_FILE:main>\"
  )

if (check_step EQUAL 2)
  include(\"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Makefile.cmake\")
  if (NOT CMAKE_DEPEND_INFO_FILES)
    set(RunCMake_TEST_FAILED \"Variable CMAKE_DEPEND_INFO_FILES not found.\")
  else()
    include(\"${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_DEPEND_INFO_FILES}\")
    if (NOT CMAKE_DEPENDS_DEPENDENCY_FILES)
      set(RunCMake_TEST_FAILED \"Variable CMAKE_DEPENDS_DEPENDENCY_FILES not found.\")
    else()
      list(GET CMAKE_DEPENDS_DEPENDENCY_FILES 1 OBJECT_FILE)
      list(GET CMAKE_DEPENDS_DEPENDENCY_FILES 3 DEP_FILE)
      if (NOT EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/\${DEP_FILE}\")
        set(RunCMake_TEST_FAILED \"File \${DEP_FILE} not found.\")
      else()
        set (TARGET_DEP_FILE \"${CMAKE_CURRENT_BINARY_DIR}/\${DEP_FILE}\")
        cmake_path(REPLACE_FILENAME TARGET_DEP_FILE \"compiler_depend.make\")
        file(READ \"\${TARGET_DEP_FILE}\" DEPENDS_CONTENT)
        if (WIN32)
          string (REPLACE \"\\\\\" \"/\" DEPENDS_CONTENT \"\${DEPENDS_CONTENT}\")
          string (TOLOWER \"\${DEPENDS_CONTENT}\" DEPENDS_CONTENT)
          string (TOLOWER \"\${OBJECT_FILE}\" OBJECT_FILE)
        else()
          string(REPLACE \"\\\\ \" \" \" DEPENDS_CONTENT \"\${DEPENDS_CONTENT}\")
        endif()
        if(NOT DEPENDS_CONTENT MATCHES \"\${OBJECT_FILE} *:.+main.c\"
            OR NOT DEPENDS_CONTENT MATCHES \"main.h\")
          set(RunCMake_TEST_FAILED \"Dependency file '\${TARGET_DEP_FILE}' badly generated.\")
        endif()
      endif()
    endif()
  endif()
endif()
")