From 316f553538d2474c566e0b5460ce79d90e3028c0 Mon Sep 17 00:00:00 2001
From: Yuka Takahashi <yukatkh@gmail.com>
Date: Tue, 4 Sep 2018 13:35:08 +0200
Subject: [PATCH] [cxxmodule] Fix nightlies (#2577)

* Revert "[cmake] Narrow the list of included directories."

This reverts commit 88c16588108508eff66cc160d244c4a59eb157ed.

* Revert "[cxxmodules] Build cling runtime into module."

This reverts commit 76a9ce75d2c29c169812b0816163ac7ce27ffad5.
---
 cmake/modules/RootNewMacros.cmake             |  2 +-
 core/clingutils/CMakeLists.txt                | 27 ++++++++-----------
 core/dictgen/CMakeLists.txt                   | 25 +++++++++--------
 .../cling/include/cling/module.modulemap      | 21 ++++-----------
 .../include/cling/module.modulemap.build      | 15 -----------
 5 files changed, 29 insertions(+), 61 deletions(-)
 delete mode 100644 interpreter/cling/include/cling/module.modulemap.build

diff --git a/cmake/modules/RootNewMacros.cmake b/cmake/modules/RootNewMacros.cmake
index e675215422e..858233bf051 100644
--- a/cmake/modules/RootNewMacros.cmake
+++ b/cmake/modules/RootNewMacros.cmake
@@ -293,7 +293,7 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
 
   if(CMAKE_PROJECT_NAME STREQUAL ROOT)
     set(includedirs -I${CMAKE_SOURCE_DIR}
-                    -I${CMAKE_BINARY_DIR}/etc/cling/ # This is for the RuntimeUniverse
+                    -I${CMAKE_SOURCE_DIR}/interpreter/cling/include # This is for the RuntimeUniverse
                     -I${CMAKE_BINARY_DIR}/include)
     set(excludepaths ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
   elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc)
diff --git a/core/clingutils/CMakeLists.txt b/core/clingutils/CMakeLists.txt
index 4be71a05fb0..86fa10938cd 100644
--- a/core/clingutils/CMakeLists.txt
+++ b/core/clingutils/CMakeLists.txt
@@ -10,15 +10,13 @@ ROOT_GLOB_HEADERS(headers ${CMAKE_CURRENT_SOURCE_DIR}/inc/*.h)
 
 set(ClingUtils_dict_headers ${headers} PARENT_SCOPE)
 
-ROOT_OBJECT_LIBRARY(ClingUtils ${sources})
-add_dependencies(ClingUtils CLING)
 
-target_include_directories(ClingUtils PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/res ${CMAKE_CURRENT_SOURCE_DIR}/../foundation/res)
-target_include_directories(ClingUtils PRIVATE ${CLING_INCLUDE_DIRS})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/res ${CMAKE_CURRENT_SOURCE_DIR}/../foundation/res)
+include_directories(${CLING_INCLUDE_DIRS})
 # Register the llvm include directories after clangs. This instructs the compiler to resolve
 # headers from our builtin clang. That's an issue when we are building with bultin_llvm=Off
 # and we have installed clang headers, too.
-target_include_directories(ClingUtils PRIVATE SYSTEM ${CLANG_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
+include_directories(SYSTEM ${CLANG_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLING_CXXFLAGS}")
 
 # This is to avoid warnings coming from GCC 7 in llvm/src/include/llvm/ADT/DenseMap.h:1010
@@ -26,6 +24,10 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
   ROOT_ADD_CXX_FLAG(CMAKE_CXX_FLAGS -Wno-maybe-uninitialized)
 endif()
 
+ROOT_OBJECT_LIBRARY(ClingUtils ${sources})
+
+add_dependencies(ClingUtils CLING)
+
 ROOT_INSTALL_HEADERS()
 
 #### STL dictionary (replacement for cintdlls)##############################
@@ -85,8 +87,7 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/etc/cling/lib/clang/${CLANG_RESOURCE_DIR_V
 #---Install a bunch of files to /etc/cling------------------------------------
 set(clinginclude    ${CMAKE_SOURCE_DIR}/interpreter/cling/include)
 
-foreach(file module.modulemap.build
-        Interpreter/DynamicExprInfo.h
+foreach(file  Interpreter/DynamicExprInfo.h
         Interpreter/DynamicLookupRuntimeUniverse.h
         Interpreter/DynamicLookupLifetimeHandler.h
         Interpreter/Exception.h
@@ -94,16 +95,10 @@ foreach(file module.modulemap.build
         Interpreter/RuntimeUniverse.h
         Interpreter/Value.h)
   get_filename_component(path ${file} PATH)
-  set(dest_file ${file})
-  if (${file} STREQUAL "module.modulemap.build")
-    set(dest_file "module.modulemap")
-  else()
-    # We do not want our modulemap to be considered part of the PCH.
-    set_property(GLOBAL APPEND PROPERTY CLINGETCPCH etc/cling/${dest_file})
-  endif()
-  list(APPEND copy_commands COMMAND ${CMAKE_COMMAND} -E copy ${clinginclude}/cling/${file} ${CMAKE_BINARY_DIR}/etc/cling/${dest_file})
+  list(APPEND copy_commands COMMAND ${CMAKE_COMMAND} -E copy ${clinginclude}/cling/${file} ${CMAKE_BINARY_DIR}/etc/cling/${file})
   list(APPEND files_to_copy ${clinginclude}/cling/${file})
-  install(FILES ${CMAKE_BINARY_DIR}/etc/cling/${dest_file} DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cling/${path})
+  set_property(GLOBAL APPEND PROPERTY CLINGETCPCH etc/cling/${file})
+  install(FILES ${clinginclude}/cling/${file} DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cling/${path})
 endforeach()
 
 foreach(file  multimap  multiset)
diff --git a/core/dictgen/CMakeLists.txt b/core/dictgen/CMakeLists.txt
index 51643712494..8377edaaa17 100644
--- a/core/dictgen/CMakeLists.txt
+++ b/core/dictgen/CMakeLists.txt
@@ -10,22 +10,15 @@
 
 ROOT_GLOB_SOURCES(sources ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cxx)
 
-ROOT_OBJECT_LIBRARY(Dictgen
-  ${sources}
-)
-add_dependencies(Dictgen CLING)
-
-target_include_directories(Dictgen PRIVATE
-  ${CMAKE_CURRENT_SOURCE_DIR}/src
-  ${CMAKE_CURRENT_SOURCE_DIR}/res
-  ${CMAKE_CURRENT_SOURCE_DIR}/../foundation/res
-  ${CMAKE_CURRENT_SOURCE_DIR}/../clingutils/res
-)
-target_include_directories(Dictgen PRIVATE ${CLING_INCLUDE_DIRS})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src
+        ${CMAKE_CURRENT_SOURCE_DIR}/res
+        ${CMAKE_CURRENT_SOURCE_DIR}/../foundation/res
+        ${CMAKE_CURRENT_SOURCE_DIR}/../clingutils/res)
+include_directories(${CLING_INCLUDE_DIRS})
 # Register the llvm include directories after clangs. This instructs the compiler to resolve
 # headers from our builtin clang. That's an issue when we are building with bultin_llvm=Off
 # and we have installed clang headers, too.
-target_include_directories(Dictgen PRIVATE SYSTEM ${CLANG_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
+include_directories(SYSTEM ${CLANG_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
 
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLING_CXXFLAGS}")
 CHECK_CXX_COMPILER_FLAG("-fno-rtti" CXX_HAS_fno_rtti)
@@ -34,3 +27,9 @@ if(CXX_HAS_fno_rtti)
     set_source_files_properties(src/LinkdefReader.cxx    PROPERTIES COMPILE_FLAGS "-fno-rtti")
     set_source_files_properties(src/TModuleGenerator.cxx PROPERTIES COMPILE_FLAGS "-fno-rtti")
 endif()
+
+ROOT_OBJECT_LIBRARY(Dictgen
+  ${sources}
+)
+
+add_dependencies(Dictgen CLING)
diff --git a/interpreter/cling/include/cling/module.modulemap b/interpreter/cling/include/cling/module.modulemap
index 3851d2614ba..07d17a7af19 100644
--- a/interpreter/cling/include/cling/module.modulemap
+++ b/interpreter/cling/include/cling/module.modulemap
@@ -1,25 +1,14 @@
-// Only included at runtime.
-module Cling_Runtime {
-  module "RuntimeUniverse.h" { header "Interpreter/RuntimeUniverse.h" export * }
-  module "DynamicLookupRuntimeUniverse.h" { header "Interpreter/DynamicLookupRuntimeUniverse.h" export * }
-  module "RuntimePrintValue.h" { header "Interpreter/RuntimePrintValue.h" export * }
-  export *
-}
-
-// Included in both compile time and runtime.
-module Cling_Runtime_Extra {
-  module "DynamicExprInfo.h" { header "Interpreter/DynamicExprInfo.h" export * }
-  module "DynamicLookupLifetimeHandler.h" { header "Interpreter/DynamicLookupLifetimeHandler.h" export * }
-  module "Value.h" { header "Interpreter/Value.h" export * }
-  export *
-}
-
 module Cling_Interpreter {
   requires cplusplus
   umbrella "Interpreter"
 
   textual header "Interpreter/ClingOptions.inc"
 
+  // Only included at runtime.
+  exclude header "Interpreter/RuntimeUniverse.h"
+  exclude header "Interpreter/DynamicLookupRuntimeUniverse.h"
+  exclude header "Interpreter/RuntimePrintValue.h"
+
   module * { export * }
 }
 
diff --git a/interpreter/cling/include/cling/module.modulemap.build b/interpreter/cling/include/cling/module.modulemap.build
deleted file mode 100644
index 44d88cb0575..00000000000
--- a/interpreter/cling/include/cling/module.modulemap.build
+++ /dev/null
@@ -1,15 +0,0 @@
-// Only included at runtime.
-module Cling_Runtime {
-  module "RuntimeUniverse.h" { header "Interpreter/RuntimeUniverse.h" export * }
-  module "DynamicLookupRuntimeUniverse.h" { header "Interpreter/DynamicLookupRuntimeUniverse.h" export * }
-  module "RuntimePrintValue.h" { header "Interpreter/RuntimePrintValue.h" export * }
-  export *
-}
-
-// Included in both compile time and runtime.
-module Cling_Runtime_Extra {
-  module "DynamicExprInfo.h" { header "Interpreter/DynamicExprInfo.h" export * }
-  module "DynamicLookupLifetimeHandler.h" { header "Interpreter/DynamicLookupLifetimeHandler.h" export * }
-  module "Value.h" { header "Interpreter/Value.h" export * }
-  export *
-}
-- 
GitLab