summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-06-04 19:53:37 +0000
committerDouglas Gregor <dgregor@apple.com>2009-06-04 19:53:37 +0000
commit8eeb96d2d56f05fe6cf95a835f66c72410215be2 (patch)
tree019512dcfbf14306615922d944b429afbf3f5481
parentd8b4711a16a38f446f2d0e902d13790e03196dee (diff)
downloadllvm-8eeb96d2d56f05fe6cf95a835f66c72410215be2.tar.gz
llvm-8eeb96d2d56f05fe6cf95a835f66c72410215be2.tar.bz2
llvm-8eeb96d2d56f05fe6cf95a835f66c72410215be2.tar.xz
CMake: Use explicit dependencies for Xcode (as well as MSVC), to make
the CMake-generated Xcode project build properly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72883 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--CMakeLists.txt18
-rwxr-xr-xcmake/modules/AddLLVM.cmake6
-rwxr-xr-xcmake/modules/AddPartiallyLinkedObject.cmake12
-rwxr-xr-xcmake/modules/LLVMConfig.cmake54
-rw-r--r--tools/CMakeLists.txt6
5 files changed, 59 insertions, 37 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a846eaeb2a..0de1e08cf7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -90,6 +90,24 @@ endforeach(c)
set(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm)
+# The USE_EXPLICIT_DEPENDENCIES variable will be TRUE to indicate that
+# we should use the library dependencies explicitly specified in the
+# CMakeLists.txt files rather than those determined by
+# llvm-config. This value must be true for non-make and IDE
+# generators.
+if (MSVC_IDE)
+ set(DEFAULT_USE_EXPLICIT_DEPENDENCIES ON)
+elseif (XCODE)
+ set(DEFAULT_USE_EXPLICIT_DEPENDENCIES ON)
+else ()
+ set(DEFAULT_USE_EXPLICIT_DEPENDENCIES OFF)
+endif ()
+
+option(USE_EXPLICIT_DEPENDENCIES
+ "Use explicit dependencies instead of llvm-config"
+ ${DEFAULT_USE_EXPLICIT_DEPENDENCIES})
+mark_as_advanced(USE_EXPLICIT_DEPENDENCIES)
+
# Add path for custom modules
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index c531298a30..a21ed20d3b 100755
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -26,11 +26,11 @@ macro(add_llvm_executable name)
if( LLVM_LINK_COMPONENTS )
llvm_config(${name} ${LLVM_LINK_COMPONENTS})
endif( LLVM_LINK_COMPONENTS )
- if( MSVC )
+ if( USE_EXPLICIT_DEPENDENCIES )
target_link_libraries(${name} ${llvm_libs})
- else( MSVC )
+ else( )
add_dependencies(${name} llvm-config.target)
- endif( MSVC )
+ endif( )
get_system_libs(llvm_system_libs)
if( llvm_system_libs )
target_link_libraries(${name} ${llvm_system_libs})
diff --git a/cmake/modules/AddPartiallyLinkedObject.cmake b/cmake/modules/AddPartiallyLinkedObject.cmake
index c9d96de1b9..d20666dd79 100755
--- a/cmake/modules/AddPartiallyLinkedObject.cmake
+++ b/cmake/modules/AddPartiallyLinkedObject.cmake
@@ -1,18 +1,18 @@
include(LLVMProcessSources)
macro(target_name_of_partially_linked_object lib var)
- if( MSVC )
+ if( USE_EXPLICIT_DEPENDENCIES )
set(${var} ${lib})
- else( MSVC )
+ else( )
set(${var} ${lib}_pll)
- endif( MSVC )
+ endif( )
endmacro(target_name_of_partially_linked_object lib var)
macro(add_partially_linked_object lib)
- if( MSVC )
+ if( USE_EXPLICIT_DEPENDENCIES )
add_llvm_library( ${lib} ${ARGN})
- else( MSVC )
+ else( )
set(pll ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${lib}.o)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib)
@@ -36,7 +36,7 @@ macro(add_partially_linked_object lib)
add_custom_target(${tnplo} ALL DEPENDS ${pll})
set( llvm_libs ${llvm_libs} ${pll} PARENT_SCOPE)
set( llvm_lib_targets ${llvm_lib_targets} ${tnplo} PARENT_SCOPE )
- endif( MSVC )
+ endif( )
install(FILES ${pll}
DESTINATION lib)
endmacro(add_partially_linked_object lib)
diff --git a/cmake/modules/LLVMConfig.cmake b/cmake/modules/LLVMConfig.cmake
index 9776fb05d2..fd92495187 100755
--- a/cmake/modules/LLVMConfig.cmake
+++ b/cmake/modules/LLVMConfig.cmake
@@ -21,36 +21,40 @@ endfunction(get_system_libs)
macro(llvm_config executable)
# extra args is the list of link components.
- if( MSVC )
- msvc_llvm_config(${executable} ${ARGN})
- else( MSVC )
+ if( USE_EXPLICIT_DEPENDENCIES )
+ explicit_llvm_config(${executable} ${ARGN})
+ else( )
nix_llvm_config(${executable} ${ARGN})
- endif( MSVC )
+ endif( )
endmacro(llvm_config)
-function(msvc_llvm_config executable)
+function(explicit_llvm_config executable)
set( link_components ${ARGN} )
- if( CMAKE_CL_64 )
- set(include_lflag "/INCLUDE:")
- else( CMAKE_CL_64 )
- set(include_lflag "/INCLUDE:_")
- endif()
- foreach(c ${link_components})
- if( c STREQUAL "jit" )
- set(lfgs "${lfgs} ${include_lflag}X86TargetMachineModule")
- endif( c STREQUAL "jit" )
- list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
- if( NOT idx LESS 0 )
- set(lfgs "${lfgs} ${include_lflag}${c}TargetMachineModule")
- list(FIND LLVM_ASMPRINTERS_FORCE_LINK ${c} idx)
+
+ set(lfgs)
+ if (MSVC)
+ if( CMAKE_CL_64 )
+ set(include_lflag "/INCLUDE:")
+ else( CMAKE_CL_64 )
+ set(include_lflag "/INCLUDE:_")
+ endif()
+ foreach(c ${link_components})
+ if( c STREQUAL "jit" )
+ set(lfgs "${lfgs} ${include_lflag}X86TargetMachineModule")
+ endif( c STREQUAL "jit" )
+ list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
if( NOT idx LESS 0 )
- set(lfgs "${lfgs} ${include_lflag}${c}AsmPrinterForceLink")
+ set(lfgs "${lfgs} ${include_lflag}${c}TargetMachineModule")
+ list(FIND LLVM_ASMPRINTERS_FORCE_LINK ${c} idx)
+ if( NOT idx LESS 0 )
+ set(lfgs "${lfgs} ${include_lflag}${c}AsmPrinterForceLink")
+ endif()
endif()
- endif()
- endforeach(c)
+ endforeach(c)
+ endif ()
- msvc_map_components_to_libraries(LIBRARIES ${link_components})
+ explicit_map_components_to_libraries(LIBRARIES ${link_components})
target_link_libraries(${executable} ${LIBRARIES})
if( lfgs )
@@ -58,10 +62,10 @@ function(msvc_llvm_config executable)
PROPERTIES
LINK_FLAGS ${lfgs})
endif()
-endfunction(msvc_llvm_config)
+endfunction(explicit_llvm_config)
-function(msvc_map_components_to_libraries out_libs)
+function(explicit_map_components_to_libraries out_libs)
set( link_components ${ARGN} )
foreach(c ${link_components})
# add codegen/asmprinter
@@ -121,7 +125,7 @@ function(msvc_map_components_to_libraries out_libs)
endwhile( ${curr_idx} LESS ${lst_size} )
list(REMOVE_DUPLICATES result)
set(${out_libs} ${result} PARENT_SCOPE)
-endfunction(msvc_map_components_to_libraries)
+endfunction(explicit_map_components_to_libraries)
macro(nix_llvm_config executable)
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 113d98743c..5c1ee351a2 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -2,9 +2,9 @@
# large and three small executables. This is done to minimize memory load
# in parallel builds. Please retain this ordering.
-if( NOT MSVC )
- add_subdirectory(llvm-config)
-endif( NOT MSVC )
+if (NOT USE_EXPLICIT_DEPENDENCIES)
+ add_subdirectory(llvm-config)
+endif()
add_subdirectory(opt)
add_subdirectory(llvm-as)