diff --git a/README.md b/README.md index 80fddc1..ec75401 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,4 @@ Usage ``` cmake -DCMAKE_MODULE_PATH:PATH=/cmake-d ``` -
- ---- -*Notes:* - - *use absolute path for CMAKE_MODULE_PATH* - - *Because internally cmake uses relative paths, on Windows, \ and cmake installation directory need to be on the same drive.* diff --git a/cmake-d/CMakeDetermineDCompiler.cmake b/cmake-d/CMakeDetermineDCompiler.cmake index 647f401..66657ed 100644 --- a/cmake-d/CMakeDetermineDCompiler.cmake +++ b/cmake-d/CMakeDetermineDCompiler.cmake @@ -115,12 +115,24 @@ IF(NOT CMAKE_D_COMPILER_ID_RUN) FIND_FILE(CMAKE_PLATFORM_ID_CONTENT_FILE CMakePlatformId.di.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH}) FILE(READ ${CMAKE_PLATFORM_ID_CONTENT_FILE} CMAKE_D_COMPILER_ID_PLATFORM_CONTENT) - INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) - # Workaround for bug http://public.kitware.com/Bug/view.php?id=14481 FIND_FILE(CMAKE_D_COMPILER_ID_FILE_IN CMakeDCompilerId.d.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH}) - FILE(RELATIVE_PATH CMAKE_D_COMPILER_ID_FILE_IN_RELATIVE ${CMAKE_ROOT}/Modules ${CMAKE_D_COMPILER_ID_FILE_IN}) - STRING(REGEX REPLACE "[.]in$" "" CMAKE_COMPILER_ID_FILE_RELATIVE ${CMAKE_D_COMPILER_ID_FILE_IN_RELATIVE}) - CMAKE_DETERMINE_COMPILER_ID(D DFLAGS ${CMAKE_COMPILER_ID_FILE_RELATIVE}) + # Workaround for bug http://public.kitware.com/Bug/view.php?id=14481 + # if CMAKE_MODULE_PATH is used, then patch ${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake + GET_FILENAME_COMPONENT(CMAKE_D_COMPILER_ID_FILE_IN_PATH ${CMAKE_D_COMPILER_ID_FILE_IN} PATH) + IF(CMAKE_D_COMPILER_ID_FILE_IN_PATH STREQUAL ${CMAKE_ROOT}/Modules) + INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) + ELSE(CMAKE_D_COMPILER_ID_FILE_IN_PATH STREQUAL ${CMAKE_ROOT}/Modules) + FILE(READ ${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake CMAKE_DETERMINE_COMPILER_ID_CMAKE_CONTENT) + STRING(REPLACE "file(READ \${CMAKE_ROOT}/Modules/\${src}.in ID_CONTENT_IN)" + "find_file(src_in \${src}.in PATHS \${CMAKE_ROOT}/Modules \${CMAKE_MODULE_PATH}) + file(READ \${src_in} ID_CONTENT_IN) + unset(src_in CACHE)" + CMAKE_DETERMINE_COMPILER_ID_CMAKE_CONTENT_PATCHED ${CMAKE_DETERMINE_COMPILER_ID_CMAKE_CONTENT}) + FILE(WRITE ${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCompilerId.cmake + ${CMAKE_DETERMINE_COMPILER_ID_CMAKE_CONTENT_PATCHED}) + INCLUDE(${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCompilerId.cmake) + ENDIF(CMAKE_D_COMPILER_ID_FILE_IN_PATH STREQUAL ${CMAKE_ROOT}/Modules) + CMAKE_DETERMINE_COMPILER_ID(D DFLAGS CMakeDCompilerId.d) UNSET(CMAKE_D_COMPILER_ID_FILE_IN CACHE) UNSET(CMAKE_PLATFORM_ID_CONTENT_FILE CACHE)