Browse Source

Merge topic 'ghs-link-flags'

36ad8dd4 GHS: Implement link flags and dirs for non-target groups (#16029)
230d50ed GHS: Factor out compiler information shared among languages
Brad King 9 years ago
parent
commit
2ab344a1dc

+ 2 - 2
Modules/Compiler/GHS-C.cmake

@@ -1,3 +1,5 @@
+include(Compiler/GHS)
+
 set(CMAKE_C_VERBOSE_FLAG "-v")
 set(CMAKE_C_VERBOSE_FLAG "-v")
 
 
 set(CMAKE_C_FLAGS_INIT "")
 set(CMAKE_C_FLAGS_INIT "")
@@ -12,8 +14,6 @@ set(CMAKE_C_GHS_KERNEL_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT}")
 set(CMAKE_C_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT
 set(CMAKE_C_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT
   "-ldebug ${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}")
   "-ldebug ${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}")
 
 
-set(CMAKE_EXECUTABLE_SUFFIX ".as")
-
 if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
 if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
   set (CMAKE_C_GHS_KERNEL_FLAGS_DEBUG "${CMAKE_C_GHS_KERNEL_FLAGS_DEBUG_INIT}"
   set (CMAKE_C_GHS_KERNEL_FLAGS_DEBUG "${CMAKE_C_GHS_KERNEL_FLAGS_DEBUG_INIT}"
     CACHE STRING "Kernel flags used by the compiler during debug builds.")
     CACHE STRING "Kernel flags used by the compiler during debug builds.")

+ 2 - 2
Modules/Compiler/GHS-CXX.cmake

@@ -1,3 +1,5 @@
+include(Compiler/GHS)
+
 set(CMAKE_CXX_VERBOSE_FLAG "-v")
 set(CMAKE_CXX_VERBOSE_FLAG "-v")
 
 
 set(CMAKE_CXX_FLAGS_INIT "")
 set(CMAKE_CXX_FLAGS_INIT "")
@@ -15,8 +17,6 @@ set(CMAKE_CXX_GHS_KERNEL_FLAGS_RELEASE_INIT
 set(CMAKE_CXX_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT
 set(CMAKE_CXX_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT
   "-ldebug ${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}")
   "-ldebug ${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}")
 
 
-set(CMAKE_EXECUTABLE_SUFFIX ".as")
-
 if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
 if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
   set (CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG
   set (CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG
     "${CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG_INIT}"
     "${CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG_INIT}"

+ 8 - 0
Modules/Compiler/GHS.cmake

@@ -0,0 +1,8 @@
+if(__COMPILER_GHS)
+  return()
+endif()
+set(__COMPILER_GHS 1)
+
+set(CMAKE_EXECUTABLE_SUFFIX ".as")
+set(CMAKE_LIBRARY_PATH_TERMINATOR "\n")
+set(CMAKE_LIBRARY_PATH_FLAG "  -L")

+ 32 - 2
Source/cmGhsMultiTargetGenerator.cxx

@@ -149,7 +149,7 @@ void cmGhsMultiTargetGenerator::Generate()
     this->WriteIncludes(config, language);
     this->WriteIncludes(config, language);
     if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
     if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
       {
       {
-      this->WriteTargetLinkLibraries();
+      this->WriteTargetLinkLibraries(config, language);
       }
       }
     this->WriteCustomCommands();
     this->WriteCustomCommands();
 
 
@@ -365,7 +365,8 @@ void cmGhsMultiTargetGenerator::WriteIncludes(const std::string &config,
     }
     }
 }
 }
 
 
-void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries()
+void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries(
+  std::string const& config, std::string const& language)
 {
 {
   // library directories
   // library directories
   cmTargetDependSet tds =
   cmTargetDependSet tds =
@@ -393,6 +394,35 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries()
     *this->GetFolderBuildStreams() << "    -l\"" << libName << "\""
     *this->GetFolderBuildStreams() << "    -l\"" << libName << "\""
                                    << std::endl;
                                    << std::endl;
     }
     }
+
+  if (!this->TargetGroup)
+    {
+    std::string linkLibraries;
+    std::string flags;
+    std::string linkFlags;
+    std::string frameworkPath;
+    std::string linkPath;
+    std::string createRule =
+        this->GeneratorTarget->GetCreateRuleVariable(language, config);
+    bool useWatcomQuote =
+        this->Makefile->IsOn(createRule + "_USE_WATCOM_QUOTE");
+    this->LocalGenerator->GetTargetFlags(
+      linkLibraries, flags, linkFlags,
+      frameworkPath, linkPath,
+      this->GeneratorTarget, useWatcomQuote);
+    linkFlags = cmSystemTools::TrimWhitespace(linkFlags);
+
+    if (!linkPath.empty())
+      {
+      linkPath = " " + linkPath.substr(0U, linkPath.size() - 1U);
+      *this->GetFolderBuildStreams() << linkPath;
+      }
+
+    if (!linkFlags.empty())
+      {
+      *this->GetFolderBuildStreams() << "    " << linkFlags << std::endl;
+      }
+    }
 }
 }
 
 
 void cmGhsMultiTargetGenerator::WriteCustomCommands()
 void cmGhsMultiTargetGenerator::WriteCustomCommands()

+ 2 - 1
Source/cmGhsMultiTargetGenerator.h

@@ -81,7 +81,8 @@ private:
                          std::string const &config);
                          std::string const &config);
 
 
   void WriteIncludes(const std::string &config, const std::string &language);
   void WriteIncludes(const std::string &config, const std::string &language);
-  void WriteTargetLinkLibraries();
+  void WriteTargetLinkLibraries(std::string const& config,
+                                std::string const& language);
   void WriteCustomCommands();
   void WriteCustomCommands();
   void
   void
   WriteCustomCommandsHelper(std::vector<cmCustomCommand> const &commandsSet,
   WriteCustomCommandsHelper(std::vector<cmCustomCommand> const &commandsSet,