[llvm] r245782 - [CMake] Make LLVM_EXTERNAL_*_SOURCE_DIR consistent against older buildsites.
NAKAMURA Takumi via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 21:53:54 PDT 2015
Author: chapuni
Date: Fri Aug 21 23:53:52 2015
New Revision: 245782
URL: http://llvm.org/viewvc/llvm-project?rev=245782&view=rev
Log:
[CMake] Make LLVM_EXTERNAL_*_SOURCE_DIR consistent against older buildsites.
If corresponding in-tree subdirectory exists, just ignore LLVM_EXTERNAL* stuff.
Otherwise, set LLVM_TOOL_*_BUILD ON/OFF properly according to LLVM_EXTERNAL_*.
This makes easier to walk among old revisions *without* deleteing CMakeCache.txt.
Before r242059, LLVM_EXTERNAL_* was working like;
if(EXISTS ${*_SOURCE_DIR}/CMakeLists.txt)
set(*_BUILD ON CACHE)
if(*_BUILD is ON)
add_subdirectory(*_SOURCE_DIR)
endif()
endif()
Modified:
llvm/trunk/cmake/modules/AddLLVM.cmake
Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=245782&r1=245781&r2=245782&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Fri Aug 21 23:53:52 2015
@@ -694,20 +694,33 @@ macro(add_llvm_external_project name)
set(add_llvm_external_dir ${name})
endif()
canonicalize_tool_name(${name} nameUPPER)
- if(NOT DEFINED LLVM_TOOL_${nameUPPER}_BUILD)
+ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir}/CMakeLists.txt)
+ # Treat it as in-tree subproject.
option(LLVM_TOOL_${nameUPPER}_BUILD
"Whether to build ${name} as part of LLVM" On)
- endif()
- if (LLVM_TOOL_${nameUPPER}_BUILD)
- if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir}/CMakeLists.txt)
- add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir} ${add_llvm_external_dir})
- set(LLVM_TOOL_${nameUPPER}_BUILD Off)
- elseif(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR)
- set(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR
- "${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR}"
- CACHE PATH "Path to ${name} source directory")
- mark_as_advanced(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR)
+ mark_as_advanced(LLVM_TOOL_${name}_BUILD)
+ if(LLVM_TOOL_${nameUPPER}_BUILD)
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir} ${add_llvm_external_dir})
+ # Don't process it in add_llvm_implicit_projects().
+ set(LLVM_TOOL_${nameUPPER}_BUILD OFF)
+ endif()
+ else()
+ set(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR
+ "${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR}"
+ CACHE PATH "Path to ${name} source directory")
+ set(LLVM_TOOL_${nameUPPER}_BUILD_DEFAULT ON)
+ if(NOT LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR OR NOT EXISTS ${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR})
+ set(LLVM_TOOL_${nameUPPER}_BUILD_DEFAULT OFF)
+ endif()
+ if("${LLVM_EXTERNAL_${nameUPPER}_BUILD}" STREQUAL "OFF")
+ set(LLVM_TOOL_${nameUPPER}_BUILD_DEFAULT OFF)
+ endif()
+ option(LLVM_TOOL_${nameUPPER}_BUILD
+ "Whether to build ${name} as part of LLVM"
+ ${LLVM_TOOL_${nameUPPER}_BUILD_DEFAULT})
+ if (LLVM_TOOL_${nameUPPER}_BUILD)
add_subdirectory(${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR} ${add_llvm_external_dir})
+ # FIXME: It'd be redundant.
set(LLVM_TOOL_${nameUPPER}_BUILD Off)
endif()
endif()
@@ -736,15 +749,6 @@ function(create_llvm_tool_options)
"Whether to build ${name} as part of LLVM" On)
mark_as_advanced(LLVM_TOOL_${name}_BUILD)
endif()
- endforeach()
- get_cmake_property(variableNames VARIABLES)
- foreach (variableName ${variableNames})
- get_project_name_from_src_var(${variableName} projectName)
- if(projectName)
- option(LLVM_TOOL_${projectName}_BUILD
- "Whether to build ${name} as part of LLVM" On)
- mark_as_advanced(LLVM_TOOL_${name}_BUILD)
- endif()
endforeach()
endfunction(create_llvm_tool_options)
More information about the llvm-commits
mailing list