From 2e4f9f22ab5d4c18fe09132eabb535feee2e661e Mon Sep 17 00:00:00 2001
From: Fan Hu <fan_hu@pku.edu.cn>
Date: Fri, 9 Apr 2021 17:10:42 +0200
Subject: [PATCH] Resolve "linker error in clang 12"

---
 CMakeLists.txt                                |  2 +-
 cmake/corsikaConfig.cmake.in                  |  6 ++++++
 .../framework/geometry/QuantityVector.inl     |  4 ++--
 modules/qgsjetII/CMakeLists.txt               | 20 -------------------
 modules/sibyll/CMakeLists.txt                 | 20 -------------------
 modules/urqmd/CMakeLists.txt                  | 18 -----------------
 6 files changed, 9 insertions(+), 61 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f5ee1a4f2..3cd6f0ba0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -239,8 +239,8 @@ target_link_libraries (
   CONAN_PKG::spdlog
   CONAN_PKG::boost
   cnpy # for SaveBoostHistogram
-  stdc++fs # experimental::filesystem
   )
+
 # "src" is needed, since some headers (namely GeneratedParticleProperties.inc ec.) are produced by python script from e.g. ParticleData.xml
 add_subdirectory (src)
 add_subdirectory (documentation)
diff --git a/cmake/corsikaConfig.cmake.in b/cmake/corsikaConfig.cmake.in
index 81a499c04..546d5141d 100644
--- a/cmake/corsikaConfig.cmake.in
+++ b/cmake/corsikaConfig.cmake.in
@@ -25,6 +25,12 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
     STRING "Choose the type of build." FORCE)
 endif (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
   
+#+++++++++++++++++++++++++++++
+# as long as there still are modules using it:
+#
+enable_language (Fortran)
+set (CMAKE_Fortran_FLAGS "-std=legacy -Wfunction-elimination")
+
 
 #++++++++++++++++++++++++++++
 # General config and flags
diff --git a/corsika/detail/framework/geometry/QuantityVector.inl b/corsika/detail/framework/geometry/QuantityVector.inl
index c7f9457b9..a932e4de8 100644
--- a/corsika/detail/framework/geometry/QuantityVector.inl
+++ b/corsika/detail/framework/geometry/QuantityVector.inl
@@ -17,8 +17,8 @@
 namespace corsika {
 
   template <typename TDimension>
-  inline typename QuantityVector<TDimension>::quantity_type
-  QuantityVector<TDimension>::operator[](size_t const index) const {
+  inline typename QuantityVector<TDimension>::quantity_type QuantityVector<TDimension>::
+  operator[](size_t const index) const {
     return quantity_type(phys::units::detail::magnitude_tag, eigenVector_[index]);
   }
 
diff --git a/modules/qgsjetII/CMakeLists.txt b/modules/qgsjetII/CMakeLists.txt
index bef449e65..c566ea2eb 100644
--- a/modules/qgsjetII/CMakeLists.txt
+++ b/modules/qgsjetII/CMakeLists.txt
@@ -10,20 +10,6 @@ set (
   )
 
 enable_language (Fortran)
-add_library (QGSJetII SHARED ${MODEL_SOURCES})
-set_target_properties (
-  QGSJetII
-  PROPERTIES
-  POSITION_INDEPENDENT_CODE 1
-  )
-
-target_include_directories (
-  QGSJetII
-  PUBLIC
-  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
-  $<INSTALL_INTERFACE:include/corsika_modules/qgsjetII>
-  )
-target_link_libraries (QGSJetII CorsikaData)
 
 add_library (QGSJetII_static STATIC ${MODEL_SOURCES})
 set_target_properties (
@@ -46,12 +32,6 @@ install (
   DESTINATION include/corsika_modules/qgsjetII
   )
 
-install (
-  TARGETS QGSJetII
-  EXPORT CORSIKA8PublicTargets
-  DESTINATION lib/corsika
-  )
-
 install (
   TARGETS QGSJetII_static
   EXPORT CORSIKA8PublicTargets
diff --git a/modules/sibyll/CMakeLists.txt b/modules/sibyll/CMakeLists.txt
index c974237be..7f03881a4 100644
--- a/modules/sibyll/CMakeLists.txt
+++ b/modules/sibyll/CMakeLists.txt
@@ -14,28 +14,14 @@ set (
   )
 
 enable_language (Fortran)
-add_library (Sibyll SHARED ${MODEL_SOURCES})
 add_library (Sibyll_static STATIC ${MODEL_SOURCES})
 
-set_target_properties (
-  Sibyll
-  PROPERTIES
-  POSITION_INDEPENDENT_CODE 1
-  )
-
 set_target_properties (
   Sibyll_static
   PROPERTIES
   POSITION_INDEPENDENT_CODE 1
   )
 
-target_include_directories (
-  Sibyll
-  PUBLIC
-  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
-  $<INSTALL_INTERFACE:include/corsika_modules/sibyll>
-  )
-
 target_include_directories (
   Sibyll_static
   PUBLIC
@@ -55,12 +41,6 @@ install (
   DESTINATION include/corsika_modules/sibyll
   )
 
-install (
-  TARGETS Sibyll
-  EXPORT CORSIKA8PublicTargets
-  LIBRARY DESTINATION lib/corsika
-  )
-
 install (
   TARGETS Sibyll_static
   EXPORT CORSIKA8PublicTargets
diff --git a/modules/urqmd/CMakeLists.txt b/modules/urqmd/CMakeLists.txt
index b60484848..77bb20787 100644
--- a/modules/urqmd/CMakeLists.txt
+++ b/modules/urqmd/CMakeLists.txt
@@ -41,17 +41,6 @@ set (
 
 enable_language (Fortran)
 
-add_library (UrQMD SHARED ${MODEL_SOURCES})
-target_include_directories (UrQMD PUBLIC
-  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
-  $<INSTALL_INTERFACE:include/corsika_modules/urqmd>
-  )
-set_target_properties (
-  UrQMD
-  PROPERTIES
-  POSITION_INDEPENDENT_CODE 1
-  )
-
 add_library (UrQMD_static STATIC ${MODEL_SOURCES})
 target_include_directories (UrQMD_static PUBLIC
   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
@@ -69,13 +58,6 @@ install (
   DESTINATION include/corsika_modules/urqmd
   )
 
-install (
-  TARGETS UrQMD
-  EXPORT CORSIKA8PublicTargets
-  LIBRARY DESTINATION lib/corsika
-  INCLUDES DESTINATION include/corsika_modules/urqmd
-  )
-
 install (
   TARGETS UrQMD_static
   EXPORT CORSIKA8PublicTargets
-- 
GitLab