summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-09-26 22:40:15 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-09-26 22:40:15 +0000
commit173573736b9b0c2be3c69848dd918fd051db5d6f (patch)
tree2da4c4c17a2f5c8c6465616acebf1a3c77f2af32 /cmake
parent98a289923555a7c3a0c6840be31babc7fb6bd7a8 (diff)
Add LLVM_ENABLE_MODULES flag to CMake to enable building with C++ modules.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218551 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/AddLLVM.cmake12
-rw-r--r--cmake/modules/HandleLLVMOptions.cmake19
2 files changed, 31 insertions, 0 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 409a5d61e65..57e8955ccd9 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -310,6 +310,12 @@ function(llvm_add_library name)
endif()
if(ARG_MODULE OR ARG_SHARED)
+ # Do not add -Dname_EXPORTS to the command-line when building files in this
+ # target. Doing so is actively harmful for the modules build because it
+ # creates extra module variants, and not useful because we don't use these
+ # macros.
+ set_target_properties( ${name} PROPERTIES DEFINE_SYMBOL "" )
+
if (LLVM_EXPORTED_SYMBOL_FILE)
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
endif()
@@ -435,6 +441,12 @@ macro(add_llvm_executable name)
llvm_update_compile_flags(${name})
add_dead_strip( ${name} )
+ # Do not add -Dname_EXPORTS to the command-line when building files in this
+ # target. Doing so is actively harmful for the modules build because it
+ # creates extra module variants, and not useful because we don't use these
+ # macros.
+ set_target_properties( ${name} PROPERTIES DEFINE_SYMBOL "" )
+
if (LLVM_EXPORTED_SYMBOL_FILE)
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
endif(LLVM_EXPORTED_SYMBOL_FILE)
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index 0d39a07c522..5b9d554341a 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -332,6 +332,25 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
message(FATAL_ERROR "LLVM requires C++11 support but the '-std=c++11' flag isn't supported.")
endif()
endif()
+ if (LLVM_ENABLE_MODULES)
+ set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fmodules -fcxx-modules")
+ # Check that we can build code with modules enabled, and that repeatedly
+ # including <cassert> still manages to respect NDEBUG properly.
+ CHECK_CXX_SOURCE_COMPILES("#undef NDEBUG
+ #include <cassert>
+ #define NDEBUG
+ #include <cassert>
+ int main() { assert(this code is not compiled); }"
+ CXX_SUPPORTS_MODULES)
+ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
+ if (CXX_SUPPORTS_MODULES)
+ append_if(CXX_SUPPORTS_MODULES "-fmodules" CMAKE_C_FLAGS)
+ append_if(CXX_SUPPORTS_MODULES "-fmodules -fcxx-modules" CMAKE_CXX_FLAGS)
+ else()
+ message(FATAL_ERROR "LLVM_ENABLE_MODULES is not supported by this compiler")
+ endif()
+ endif(LLVM_ENABLE_MODULES)
endif( MSVC )
macro(append_common_sanitizer_flags)