diff options
author | Oscar Fuentes <ofv@wanadoo.es> | 2008-09-22 01:08:49 +0000 |
---|---|---|
committer | Oscar Fuentes <ofv@wanadoo.es> | 2008-09-22 01:08:49 +0000 |
commit | 3d01fc7de86c75926e4e5ac7cc49f0116018893d (patch) | |
tree | 2ea49e2f904dd479a4b941454b776dee762921dd /tools/llvm-config | |
parent | cd4c73aa708d9ecf5d7e0a711dbf359d22b6dd3a (diff) |
Initial support for the CMake build system.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56419 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-config')
-rw-r--r-- | tools/llvm-config/CMakeLists.txt | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/tools/llvm-config/CMakeLists.txt b/tools/llvm-config/CMakeLists.txt new file mode 100644 index 0000000000..2d6898c2db --- /dev/null +++ b/tools/llvm-config/CMakeLists.txt @@ -0,0 +1,102 @@ +include(TestBigEndian) + +if( NOT PERL_FOUND ) + message(FATAL_ERROR "Perl required but not found!") +endif( NOT PERL_FOUND ) + +set(PERL ${PERL_EXECUTABLE}) +set(VERSION PACKAGE_VERSION) +set(PREFIX ${LLVM_BINARY_DIR}) # TODO: Root for `make install'. +execute_process(COMMAND date + OUTPUT_VARIABLE LLVM_CONFIGTIME + OUTPUT_STRIP_TRAILING_WHITESPACE) +set(abs_top_srcdir ${LLVM_MAIN_SRC_DIR}) +set(abs_top_builddir ${LLVM_BINARY_DIR}) +# LLVM_ON_UNIX and LLVM_ON_WIN32 already set. +# those are set to blank by `autoconf' on MinGW, so it seems they are not required: +#set(LLVMGCCDIR "") +#set(LLVMGCC "") +#set(LLVMGXX "") +#set(LLVMGCC_VERSION "") +#set(LLVMGCC_MAJVERS "") +test_big_endian(IS_BIG_ENDIAN) +if( IS_BIG_ENDIAN ) + set(ENDIAN "big") +else( IS_BIG_ENDIAN ) + set(ENDIAN "little") +endif( IS_BIG_ENDIAN ) +set(SHLIBEXT ${LTDL_SHLIB_EXT}) +#EXEEXT already set. +set(OS "${CMAKE_SYSTEM}") +set(ARCH "X86") # TODO: This gives "i686" in Linux: "${CMAKE_SYSTEM_PROCESSOR}") +# TODO: avoid using autoconf: +set(config_guess ${LLVM_MAIN_SRC_DIR}/autoconf/config.guess) +execute_process(COMMAND sh ${config_guess} + RESULT_VARIABLE TT_RV + OUTPUT_VARIABLE LLVM_TARGET_TRIPLET + OUTPUT_STRIP_TRAILING_WHITESPACE) +message(STATUS "Target triplet: ${LLVM_TARGET_TRIPLET}") +if( NOT TT_RV EQUAL 0 ) + message(FATAL_ERROR "Failed to execute ${config_guess}") +endif( NOT TT_RV EQUAL 0 ) +set(target ${LLVM_TARGET_TRIPLET}) +set(TARGETS_TO_BUILD "X86") # TODO +set(TARGET_HAS_JIT "1") # TODO + +# Avoids replacement at config-time: +set(LLVM_CPPFLAGS "@LLVM_CPPFLAGS@") +set(LLVM_CFLAGS "@LLVM_CFLAGS@") +set(LLVM_CXXFLAGS "@LLVM_CXXFLAGS@") +set(LLVM_LDFLAGS "@LLVM_LDFLAGS@") +set(LIBS "@LIBS@") +set(LLVM_BUILDMODE "@LLVM_BUILDMODE@") + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.in.in + ${CMAKE_CURRENT_BINARY_DIR}/llvm-config.in + @ONLY +) + +set(LIBDEPS ${CMAKE_CURRENT_BINARY_DIR}/LibDeps.txt) +set(LIBDEPS_TMP ${CMAKE_CURRENT_BINARY_DIR}/LibDeps.txt.tmp) +set(FINAL_LIBDEPS ${CMAKE_CURRENT_BINARY_DIR}/FinalLibDeps.txt) +set(LLVM_CONFIG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/llvm-config) +set(LLVM_CONFIG_IN ${CMAKE_CURRENT_BINARY_DIR}/llvm-config.in) + +# set(LIBDEPS LibDeps.txt) +# set(LIBDEPS_TMP LibDeps.txt.tmp) +# set(FINAL_LIBDEPS FinalLibDeps.txt) + +add_custom_command(OUTPUT ${LIBDEPS_TMP} + COMMAND ${PERL_EXECUTABLE} ${LLVM_MAIN_SRC_DIR}/utils/GenLibDeps.pl -flat ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} > ${LIBDEPS_TMP} + DEPENDS ${llvm_libs} + COMMENT "Regenerating ${LIBDEPS_TMP}") + +add_custom_command(OUTPUT ${LIBDEPS} + COMMAND cmp -s ${LIBDEPS_TMP} ${LIBDEPS} || \( cp ${LIBDEPS_TMP} ${LIBDEPS} && echo "Updated ${LIBDEPS} because dependencies changed" \) + DEPENDS ${LIBDEPS_TMP}) + +add_custom_command(OUTPUT ${FINAL_LIBDEPS} + COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/find-cycles.pl < ${LIBDEPS} > ${FINAL_LIBDEPS} || rm -f ${FINAL_LIBDEPS} + DEPENDS ${LIBDEPS} + COMMENT "Checking for cyclic dependencies between LLVM libraries.") + +add_custom_command(OUTPUT ${LLVM_CONFIG} + COMMAND echo 's,@LLVM_CPPFLAGS@,${CMAKE_CPP_FLAGS},' > temp.sed + COMMAND echo 's,@LLVM_CFLAGS@,${CMAKE_C_FLAGS},' >> temp.sed + COMMAND echo 's,@LLVM_CXXFLAGS@,${CMAKE_CXX_FLAGS},' >> temp.sed + # TODO: Use general flags for linking, not just for shared libs: + COMMAND echo 's,@LLVM_LDFLAGS@,${CMAKE_SHARED_LINKER_FLAGS},' >> temp.sed + COMMAND echo 's,@LIBS@,,' >> temp.sed # TODO: System libs + COMMAND echo 's,@LLVM_BUILDMODE@,${CMAKE_BUILD_TYPE},' >> temp.sed + COMMAND sed -f temp.sed < ${LLVM_CONFIG_IN} > ${LLVM_CONFIG} + COMMAND rm temp.sed + COMMAND cat ${FINAL_LIBDEPS} >> ${LLVM_CONFIG} + COMMAND chmod +x ${LLVM_CONFIG} + COMMAND cd ${LLVM_BINARY_DIR} && ${CMAKE_COMMAND} -U HAVE_LLVM_CONFIG ${LLVM_MAIN_SRC_DIR} + DEPENDS ${FINAL_LIBDEPS} ${LLVM_CONFIG_IN} + COMMENT "Building llvm-config script." + ) + +add_custom_target(llvm-config.target ALL + DEPENDS ${LLVM_CONFIG})
\ No newline at end of file |