llvm.org GIT mirror llvm / 3eb7322
CMake: build llvm-config on Windows. It was previously not being built on Windows because the cmake file relied on a sed script to generate a .in file that llvm-config needs. By using cmake's configure_file function, we can get rid off the sed hack, and also have this work on Windows. Differential Revision: http://llvm-reviews.chandlerc.com/D1481 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189125 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 6 years ago
2 changed file(s) with 12 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
11 # three small executables. This is done to minimize memory load in parallel
22 # builds. Please retain this ordering.
33
4 if( NOT WIN32 OR MSYS OR CYGWIN )
5 # We currently require 'sed' to build llvm-config, so don't try to build it
6 # on pure Win32.
7 add_llvm_tool_subdirectory(llvm-config)
8 else()
9 ignore_llvm_tool_subdirectory(llvm-config)
10 endif()
4 add_llvm_tool_subdirectory(llvm-config)
115
126 add_llvm_tool_subdirectory(opt)
137 add_llvm_tool_subdirectory(llvm-as)
0 set(LLVM_LINK_COMPONENTS support)
11
2 # We need to generate the BuildVariables.inc file containing values which are
3 # only defined when under certain build modes. Unfortunately, that precludes
4 # doing this inside CMake so we have to shell out to sed. For now, that means we
5 # can't expect to build llvm-config on Window.s
62 set(BUILDVARIABLES_SRCPATH ${CMAKE_CURRENT_SOURCE_DIR}/BuildVariables.inc.in)
73 set(BUILDVARIABLES_OBJPATH ${CMAKE_CURRENT_BINARY_DIR}/BuildVariables.inc)
8 set(SEDSCRIPT_OBJPATH ${CMAKE_CURRENT_BINARY_DIR}/BuildVariables.configure.sed)
94
105 # Compute the substitution values for various items.
116 get_system_libs(LLVM_SYSTEM_LIBS_LIST)
127 foreach(l ${LLVM_SYSTEM_LIBS_LIST})
138 set(SYSTEM_LIBS ${SYSTEM_LIBS} "-l${l}")
149 endforeach()
15 set(C_FLGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
16 set(CXX_FLGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
17 set(CPP_FLGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
1810
19 add_custom_command(OUTPUT ${BUILDVARIABLES_OBJPATH}
20 COMMAND echo s!@LLVM_SRC_ROOT@!${LLVM_MAIN_SRC_DIR}! > ${SEDSCRIPT_OBJPATH}
21 COMMAND echo s!@LLVM_OBJ_ROOT@!${LLVM_BINARY_DIR}! >> ${SEDSCRIPT_OBJPATH}
22 COMMAND echo s!@LLVM_CPPFLAGS@!${CPP_FLGS}! >> ${SEDSCRIPT_OBJPATH}
23 COMMAND echo s!@LLVM_CFLAGS@!${C_FLGS}! >> ${SEDSCRIPT_OBJPATH}
24 COMMAND echo s!@LLVM_CXXFLAGS@!${CXX_FLGS}! >> ${SEDSCRIPT_OBJPATH}
25 # TODO: Use general flags for linking! not just for shared libs:
26 COMMAND echo s!@LLVM_LDFLAGS@!${CMAKE_SHARED_LINKER_FLAGS}! >> ${SEDSCRIPT_OBJPATH}
27 COMMAND echo s!@LLVM_BUILDMODE@!${CMAKE_BUILD_TYPE}! >> ${SEDSCRIPT_OBJPATH}
28 COMMAND echo s!@LLVM_SYSTEM_LIBS@!${SYSTEM_LIBS}! >> ${SEDSCRIPT_OBJPATH}
29 COMMAND echo s!@LLVM_TARGETS_BUILT@!${LLVM_TARGETS_TO_BUILD}! >> ${SEDSCRIPT_OBJPATH}
30 COMMAND sed -f ${SEDSCRIPT_OBJPATH} < ${BUILDVARIABLES_SRCPATH} > ${BUILDVARIABLES_OBJPATH}
31 VERBATIM
32 COMMENT "Building BuildVariables.inc include."
33 )
11 # Use configure_file to create BuildVariables.inc.
12 set(LLVM_SRC_ROOT ${LLVM_MAIN_SRC_DIR})
13 set(LLVM_OBJ_ROOT ${LLVM_BINARY_DIR})
14 set(LLVM_CPPFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
15 set(LLVM_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
16 set(LLVM_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
17 set(LLVM_LDFLAGS ${CMAKE_SHARED_LINKER_FLAGS})
18 set(LLVM_BUILDMODE ${CMAKE_BUILD_TYPE})
19 set(LLVM_SYSTEM_LIBS ${SYSTEM_LIBS})
20 set(LLVM_TARGETS_BUILT ${LLVM_TARGETS_TO_BUILD})
21 configure_file(${BUILDVARIABLES_SRCPATH} ${BUILDVARIABLES_OBJPATH} @ONLY)
3422
3523 # Add the llvm-config tool.
3624 add_llvm_tool(llvm-config