Index: CMakeLists.txt =================================================================== --- /dev/null +++ CMakeLists.txt @@ -0,0 +1,73 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +# The test-suite is designed to be built in release mode anyway and +# falls over unless -DNDEBUG is set. +if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "No build type selected, defaulting to Release") + set(CMAKE_BUILD_TYPE "Release") +endif() + +add_definitions(-DNDEBUG) + +# Let's make sure lit output is pretty. +if(CMAKE_VERSION VERSION_LESS 3.1.20141117) + set(cmake_3_2_USES_TERMINAL) +else() + set(cmake_3_2_USES_TERMINAL USES_TERMINAL) +endif() + +project(test-suite C CXX) + +# Add path for custom modules +set(CMAKE_MODULE_PATH + ${CMAKE_MODULE_PATH} + "${CMAKE_CURRENT_SOURCE_DIR}/cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" + ) + +# Sanity check our source directory to make sure that we are not trying to +# generate an in-tree build (unless on MSVC_IDE, where it is ok), and to make +# sure that we don't have any stray generated files lying around in the tree +# (which would end up getting picked up by header search, instead of the correct +# versions). +if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) + message(FATAL_ERROR "In-source builds are not allowed. +CMake would overwrite the makefiles distributed with LLVM. +Please create a directory and run cmake from there, passing the path +to this source directory as the last argument. +This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. +Please delete them.") +endif() + +include(MakefileFunctions) +include(SingleMultiSource) +find_package(YACC) +find_package(TCL) + +# FIXME: Detect host architecture, endianness and OS +if(NOT DEFINED TARGET_OS) + message(STATUS "Check target operating system - ${CMAKE_SYSTEM_NAME}") + set(TARGET_OS ${CMAKE_SYSTEM_NAME}) +endif() +if(NOT DEFINED ARCH) + include(DetectArchitecture) + detect_architecture(ARCH) +endif() +if(NOT DEFINED ENDIAN) + include(TestBigEndian) + test_big_endian(IS_BIGENDIAN) + if(IS_BIGENDIAN) + set(ENDIAN "big") + else() + set(ENDIAN "little") + endif() +endif() + +add_subdirectory(tools) + +# Now that the tools have been created, +set(CMAKE_C_COMPILE_OBJECT "${CMAKE_BINARY_DIR}/tools/timeit --summary .time ${CMAKE_C_COMPILE_OBJECT}") +set(CMAKE_CXX_COMPILE_OBJECT "${CMAKE_BINARY_DIR}/tools/timeit --summary .time ${CMAKE_CXX_COMPILE_OBJECT}") + +add_subdirectory(SingleSource) +add_subdirectory(MultiSource) Index: cmake/Makefile2CMakeLists.py =================================================================== --- /dev/null +++ cmake/Makefile2CMakeLists.py @@ -0,0 +1,337 @@ +##===- Makefile2CMakeLists.py ---------------------------------------------===## +# +# This script parses Makefiles in the SingleSource and MultiSource directories +# and generates equivalent CMakeLists.txt files. +# +# This script is intended to be run as a one-shot process, with its generated +# CMakeLists.txt checked in to the tree. Once this is done and dusted, this +# script can be deleted from the tree as it serves no more useful purpose. +# +# This script requires `pymake`: https://github.com/mozilla/pymake +# This is not available on PyPI so will need to be downloaded manually and +# `pip install -e`'d. +# +# Usage: cd $TEST_SUITE_ROOT; python Makefile2CMakeLists.py +# +# Improvements required before prime-time: +# * Copy across comments from the Makefiles into the generated CMakeLists. +##===----------------------------------------------------------------------===## + +import os, sys, fnmatch, re + +from pymake.parserdata import * +from pymake.parser import parsefile, parsemakesyntax, Data +import pymake.data as data +import pymake.functions as functions + +class Stream(object): + def __init__(self): + self.s = "" + self._indent = 0 + self.tmp = 0 + def writeLine(self, line): + self.s += ' ' * self._indent + self.s += line + "\n" + def indent(self, i): + self._indent += i + def str(self): + return self.s + def tempvar(self): + self.tmp += 1 + return "TMP%s" % self.tmp + +def _deref(s): + return "${%s}" % s + +def _deescape_in_string(s): + # This is particularly targetted at the escape in lua/Makefile :( + s = re.sub(r'"\\