forked from OSchip/llvm-project
				
			Add LLVM_ENABLE_MODULES flag to CMake to enable building with C++ modules.
llvm-svn: 218551
This commit is contained in:
		
							parent
							
								
									601327c4b9
								
							
						
					
					
						commit
						2b91a7f80f
					
				| 
						 | 
				
			
			@ -208,6 +208,7 @@ else()
 | 
			
		|||
  option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF)
 | 
			
		||||
option(LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF)
 | 
			
		||||
option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
 | 
			
		||||
option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue