llvm.org GIT mirror llvm / 0350314
[CMake] Introduce a LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY flag. On Darwin it is currently impossible to build LLVM with modules because the Darwin system module map is not compatible with -fmodules-local-submodule-visibility at this point in time. This patch makes the flag optional and off by default on Darwin so it becomes possible to build LLVM with modules again. http://reviews.llvm.org/D21827 rdar://problem/27019000 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274196 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 4 years ago
2 changed file(s) with 16 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
282282 option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
283283 option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
284284 option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF)
285 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
286 option(LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." OFF)
287 else()
288 option(LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." ON)
289 endif()
285290 option(LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF)
286291 option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
287292 option(LLVM_ENABLE_LIBCXXABI "Use libc++abi when using libc++." OFF)
464464 endif()
465465 if (LLVM_ENABLE_MODULES)
466466 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
467 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fmodules -Xclang -fmodules-local-submodule-visibility -fmodules-cache-path=module.cache")
467 set(module_flags "-fmodules -Xclang -fmodules-cache-path=module.cache")
468 if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
469 # On Darwin -fmodules does not imply -fcxx-modules.
470 set(module_flags "${module_flags} -fcxx-modules")
471 endif()
472 if (LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY)
473 set(module_flags "${module_flags} -fmodules-local-submodule-visibility")
474 endif()
475 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${module_flags}")
476
468477 # Check that we can build code with modules enabled, and that repeatedly
469478 # including still manages to respect NDEBUG properly.
470479 CHECK_CXX_SOURCE_COMPILES("#undef NDEBUG
475484 CXX_SUPPORTS_MODULES)
476485 set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
477486 if (CXX_SUPPORTS_MODULES)
478 append_if(CXX_SUPPORTS_MODULES "-fmodules -Xclang -fmodules-local-submodule-visibility -fmodules-cache-path=module.cache" CMAKE_CXX_FLAGS)
487 append("${module_flags}" CMAKE_CXX_FLAGS)
479488 else()
480489 message(FATAL_ERROR "LLVM_ENABLE_MODULES is not supported by this compiler")
481490 endif()