[Cmake-commits] CMake branch, next, updated. v2.8.11-2240-g07908cf

Stephen Kelly steveire at gmail.com
Tue May 28 04:17:02 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  07908cfc7e1625c3b5c12209bc1db2170a2a47ed (commit)
       via  0663226c5e1907e8f2b1a4753b5ea70a4de7782c (commit)
      from  5d1334e2699f8eaf0b63a78efb261252e39533e0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=07908cfc7e1625c3b5c12209bc1db2170a2a47ed
commit 07908cfc7e1625c3b5c12209bc1db2170a2a47ed
Merge: 5d1334e 0663226
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue May 28 04:17:00 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue May 28 04:17:00 2013 -0400

    Merge topic 'VISIBILITY_PREFIX-property' into next
    
    0663226 Add a COMPILE_OPTION for a VISIBILITY_INLINES_HIDDEN target property.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0663226c5e1907e8f2b1a4753b5ea70a4de7782c
commit 0663226c5e1907e8f2b1a4753b5ea70a4de7782c
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu May 23 15:32:17 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Tue May 28 10:15:58 2013 +0200

    Add a COMPILE_OPTION for a VISIBILITY_INLINES_HIDDEN target property.
    
    This corresponds to the g++ and clang++
    option -fvisibility-inlines-hidden on linux. On Windows with MinGW,
    this corresponds to -fno-keep-inline-dllexport. That option is
    not supported by clang currently.

diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake
index 486e2af..972d889 100644
--- a/Modules/Compiler/Clang-CXX.cmake
+++ b/Modules/Compiler/Clang-CXX.cmake
@@ -1,2 +1,4 @@
 include(Compiler/Clang)
 __compiler_clang(CXX)
+
+set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake
index 879ab8f..9bee962 100644
--- a/Modules/Compiler/GNU-CXX.cmake
+++ b/Modules/Compiler/GNU-CXX.cmake
@@ -1,2 +1,8 @@
 include(Compiler/GNU)
 __compiler_gnu(CXX)
+
+if (WIN32)
+  set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fno-keep-inline-dllexport")
+else()
+  set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
+endif()
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 71dd3e9..dce1838 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1992,28 +1992,12 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags,
     }
 }
 
-//----------------------------------------------------------------------------
-void cmLocalGenerator
-::AddVisibilityPresetFlags(std::string &flags, cmTarget* target,
-                            const char *lang)
+static void AddVisibilityCompileOption(std::string &flags, cmTarget* target,
+                                       cmLocalGenerator *lg, const char *lang)
 {
-  int targetType = target->GetType();
-  bool suitableTarget = ((targetType == cmTarget::SHARED_LIBRARY)
-                      || (targetType == cmTarget::MODULE_LIBRARY)
-                      || (target->IsExecutableWithExports()));
-
-  if (!suitableTarget)
-    {
-    return;
-    }
-
-  if (!lang)
-    {
-    return;
-    }
   std::string l(lang);
   std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY";
-  const char *opt = this->Makefile->GetDefinition(compileOption.c_str());
+  const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str());
   if (!opt)
     {
     return;
@@ -2037,7 +2021,50 @@ void cmLocalGenerator
     return;
     }
   std::string option = std::string(opt) + prop;
-  this->AppendFlags(flags, option.c_str());
+  lg->AppendFlags(flags, option.c_str());
+}
+
+static void AddInlineVisibilityCompileOption(std::string &flags,
+                                       cmTarget* target,
+                                       cmLocalGenerator *lg)
+{
+  std::string compileOption
+                = "CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN";
+  const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str());
+  if (!opt)
+    {
+    return;
+    }
+
+  bool prop = target->GetPropertyAsBool("VISIBILITY_INLINES_HIDDEN");
+  if (!prop)
+    {
+    return;
+    }
+  lg->AppendFlags(flags, opt);
+}
+
+//----------------------------------------------------------------------------
+void cmLocalGenerator
+::AddVisibilityPresetFlags(std::string &flags, cmTarget* target,
+                            const char *lang)
+{
+  int targetType = target->GetType();
+  bool suitableTarget = ((targetType == cmTarget::SHARED_LIBRARY)
+                      || (targetType == cmTarget::MODULE_LIBRARY)
+                      || (target->IsExecutableWithExports()));
+
+  if (!suitableTarget)
+    {
+    return;
+    }
+
+  if (!lang)
+    {
+    return;
+    }
+  AddVisibilityCompileOption(flags, target, this, lang);
+  AddInlineVisibilityCompileOption(flags, target, this);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 7712a58..84fd58c 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -144,7 +144,7 @@ public:
   void AddCMP0018Flags(std::string &flags, cmTarget* target,
                        std::string const& lang, const char *config);
   void AddVisibilityPresetFlags(std::string &flags, cmTarget* target,
-                                 const char *lang);
+                                const char *lang);
   void AddConfigVariableFlags(std::string& flags, const char* var,
                               const char* config);
   ///! Append flags to a string.
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index c34c3ab..47e36fd 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -942,6 +942,17 @@ void cmTarget::DefineProperties(cmake *cm)
      "CMAKE_CXX_VISIBILITY_PRESET if it is set when a target is created.");
 
   cm->DefineProperty
+    ("VISIBILITY_INLINES_HIDDEN", cmProperty::TARGET,
+     "Whether to add a compile flag to hide symbols of inline functions",
+     "The VISIBILITY_INLINES_HIDDEN property determines whether a flag for "
+     "hiding symbols for inline functions. the value passed used in "
+     "a visibility related compile option, such as -fvisibility=.  This "
+     "property only has an affect for libraries and executables with "
+     "exports.  This property is initialized by the value of the variable "
+     "CMAKE_VISIBILITY_INLINES_HIDDEN if it is set when a target is "
+     "created.");
+
+  cm->DefineProperty
     ("POSITION_INDEPENDENT_CODE", cmProperty::TARGET,
      "Whether to create a position-independent target",
      "The POSITION_INDEPENDENT_CODE property determines whether position "
@@ -1580,6 +1591,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
 
   this->SetPropertyDefault("C_VISIBILITY_PRESET", 0);
   this->SetPropertyDefault("CXX_VISIBILITY_PRESET", 0);
+  this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", 0);
 
   if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY
       || this->TargetTypeValue == cmTarget::MODULE_LIBRARY)
diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt b/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt
index ffa9380..2571d22 100644
--- a/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt
+++ b/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt
@@ -1,9 +1,13 @@
 
 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
 
 if (CMAKE_CXX_FLAGS MATCHES "-fvisibility=hidden")
   message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory")
 endif()
+if (CMAKE_CXX_FLAGS MATCHES "-fvisibility-inlines-hidden")
+  message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory")
+endif()
 
 add_library(visibility_preset SHARED visibility_preset.cpp)
 generate_export_header(visibility_preset)

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list