summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-06-21 09:51:26 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-06-21 09:51:26 +0000
commit7c888eee47a5ba925ddc91c837302a7c2a435e5c (patch)
treebac47cfa5fed2f636a55853b7586f4154616a030 /cmake
parent7060221ae256ded2b7bbfec60a2c9bdc71426ff2 (diff)
downloadllvm-7c888eee47a5ba925ddc91c837302a7c2a435e5c.tar.gz
llvm-7c888eee47a5ba925ddc91c837302a7c2a435e5c.tar.bz2
llvm-7c888eee47a5ba925ddc91c837302a7c2a435e5c.tar.xz
Completely refactor the structuring of unittest CMake files to match the
Makefiles, the CMake files in every other part of the LLVM tree, and sanity. This should also restore the output tree structure of all the unit tests, sorry for breaking that, and thanks for letting me know. The fundamental change is to put a CMakeLists.txt file in the unittest directory, with a single test binary produced from it. This has several advantages: - No more weird directory stripping in the unittest macro, allowing it to be used more readily in other projects. - No more directory prefixes on all the source files. - Allows correct and precise use of LLVM's per-directory dependency system. - Allows use of the checking logic for source files that have not been added to the CMake build. This uncovered a file being skipped with CMake in LLVM and one in Clang's unit tests. - Makes Specifying conditional compilation or other custom logic for JIT tests easier. It did require adding the concept of an explicit 'optional' source file to the CMake build so that the missing-file check can skip cases where the file is *supposed* to be missing. =] This is another chunk of refactoring the CMake build in order to make it usable for other clients like CompilerRT / ASan / TSan. Note that this is interdependent with a Clang CMake change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158909 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rwxr-xr-xcmake/modules/AddLLVM.cmake8
-rw-r--r--cmake/modules/LLVMProcessSources.cmake7
2 files changed, 8 insertions, 7 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index f32a6d3c87..96246fafe4 100755
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -149,14 +149,12 @@ macro(add_llvm_external_project name)
endmacro(add_llvm_external_project)
# Generic support for adding a unittest.
-function(add_unittest test_suite test_dirname)
- string(REGEX MATCH "([^/]+)$" test_name ${test_dirname})
+function(add_unittest test_suite test_name)
if (CMAKE_BUILD_TYPE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
- ${CMAKE_CURRENT_BINARY_DIR}/${test_dirname}/${CMAKE_BUILD_TYPE})
+ ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
else()
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
- ${CMAKE_CURRENT_BINARY_DIR}/${test_dirname})
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
if( NOT LLVM_BUILD_TESTS )
set(EXCLUDE_FROM_ALL ON)
diff --git a/cmake/modules/LLVMProcessSources.cmake b/cmake/modules/LLVMProcessSources.cmake
index 641f1b33e1..bb11e9cad6 100644
--- a/cmake/modules/LLVMProcessSources.cmake
+++ b/cmake/modules/LLVMProcessSources.cmake
@@ -81,10 +81,13 @@ function(llvm_check_source_file_list)
file(GLOB globbed *.cpp)
foreach(g ${globbed})
get_filename_component(fn ${g} NAME)
- list(FIND listed ${fn} idx)
+ list(FIND LLVM_OPTIONAL_SOURCES ${fn} idx)
if( idx LESS 0 )
- message(SEND_ERROR "Found unknown source file ${g}
+ list(FIND listed ${fn} idx)
+ if( idx LESS 0 )
+ message(SEND_ERROR "Found unknown source file ${g}
Please update ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt\n")
+ endif()
endif()
endforeach()
endfunction(llvm_check_source_file_list)