summaryrefslogtreecommitdiffstats
path: root/Modules/Platform
diff options
context:
space:
mode:
authorPeter Kuemmel <syntheticpp@gmx.net>2012-06-08 14:31:54 (GMT)
committerPeter Kuemmel <syntheticpp@gmx.net>2012-06-08 15:42:11 (GMT)
commit033a687acd828ad6667d154939ffdbc482ab047f (patch)
tree7e61efbc88da39b57810be42d502baaab0145136 /Modules/Platform
parent1d40729eaa35dd643efdf5e793e6a541e890f33a (diff)
downloadCMake-033a687acd828ad6667d154939ffdbc482ab047f.zip
CMake-033a687acd828ad6667d154939ffdbc482ab047f.tar.gz
CMake-033a687acd828ad6667d154939ffdbc482ab047f.tar.bz2
Ninja: add wrapper for cl to extract dependencies
cmcldeps wraps cl and adds /showInclude before calling cl. It parses the output of cl for used headers, drops system headers and writes them to a GCC like dependency file. cmcldeps uses ATM ninja code for process handling, but could be ported later to SystemTools. TODO: Why needs ninja multiple calls in the BuildDepends test?
Diffstat (limited to 'Modules/Platform')
-rw-r--r--Modules/Platform/Windows-cl.cmake18
1 files changed, 18 insertions, 0 deletions
diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake
index be6abb6..eed4e52 100644
--- a/Modules/Platform/Windows-cl.cmake
+++ b/Modules/Platform/Windows-cl.cmake
@@ -251,3 +251,21 @@ IF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake")
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXPlatform.cmake IMMEDIATE)
ENDIF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake")
+
+
+IF(CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPILER)
+ # TODO try_compile doesn't need cmcldeps, find a better solution
+ if(NOT EXISTS ${CMAKE_TRY_COMPILE_SOURCE_DIR}/../ShowIncludes)
+ SET(showdir ${CMAKE_BINARY_DIR}/CMakeFiles/ShowIncludes)
+ FILE(WRITE ${showdir}/foo.h "\n")
+ FILE(WRITE ${showdir}/main.c "#include \"foo.h\" \nint main(){}\n")
+ EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} /nologo /showIncludes ${showdir}/main.c
+ WORKING_DIRECTORY ${showdir} OUTPUT_VARIABLE showOut)
+ STRING(REPLACE main.c "" showOut1 ${showOut})
+ STRING(REPLACE "/" "\\" header1 ${showdir}/foo.h)
+ STRING(TOLOWER ${header1} header2)
+ STRING(REPLACE ${header2} "" showOut2 ${showOut1})
+ STRING(REPLACE "\n" "" showOut3 ${showOut2})
+ SET(CMAKE_CL_SHOWINCLUDE_PREFIX ${showOut3})
+ ENDIF()
+ENDIF()