[Cmake-commits] CMake branch, next, updated. v2.8.11-2373-g250810d

Stephen Kelly steveire at gmail.com
Fri May 31 03:22:22 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  250810daf6842b1620e41fd1dba5ddd6b997be64 (commit)
       via  82a30a7e2b9c21eb159a723db21340bac27f4c29 (commit)
      from  0036b8afa955fffe431d4184eb5f0e85493d08ed (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=250810daf6842b1620e41fd1dba5ddd6b997be64
commit 250810daf6842b1620e41fd1dba5ddd6b997be64
Merge: 0036b8a 82a30a7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri May 31 03:22:21 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri May 31 03:22:21 2013 -0400

    Merge topic 'VISIBILITY_PRESET-property' into next
    
    82a30a7 Add a COMPILE_OPTION for a VISIBILITY_INLINES_HIDDEN target property.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=82a30a7e2b9c21eb159a723db21340bac27f4c29
commit 82a30a7e2b9c21eb159a723db21340bac27f4c29
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu May 23 15:32:17 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Fri May 31 09:22:09 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..33d6093 100644
--- a/Modules/Compiler/GNU-CXX.cmake
+++ b/Modules/Compiler/GNU-CXX.cmake
@@ -1,2 +1,12 @@
 include(Compiler/GNU)
 __compiler_gnu(CXX)
+
+if (WIN32)
+  if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
+    set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fno-keep-inline-dllexport")
+  endif()
+else()
+  if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2)
+    set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
+  endif()
+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/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)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 260a87c..30be228 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -65,7 +65,22 @@ add_RunCMake_test(Languages)
 add_RunCMake_test(ObjectLibrary)
 if(NOT WIN32)
   add_RunCMake_test(PositionIndependentCode)
-  add_RunCMake_test(VisibilityPreset)
+  set(SKIP_VISIBILITY 0)
+  if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.2)
+    set(SKIP_VISIBILITY 1)
+  endif()
+
+  if (CMAKE_CXX_COMPILER_ID MATCHES Watcom
+      OR CMAKE_SYSTEM_NAME MATCHES IRIX64
+      OR CMAKE_CXX_COMPILER_ID MATCHES HP
+      OR CMAKE_CXX_COMPILER_ID MATCHES XL
+      OR CMAKE_CXX_COMPILER_ID MATCHES SunPro)
+    set(SKIP_VISIBILITY 1)
+  endif()
+
+  if (NOT SKIP_VISIBILITY)
+    add_RunCMake_test(VisibilityPreset)
+  endif()
 endif()
 add_RunCMake_test(CompatibleInterface)
 
diff --git a/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake b/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake
index f7d6599..2d78832 100644
--- a/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake
@@ -1,17 +1,3 @@
 include(RunCMake)
 
-set(SKIP_TESTS 0)
-if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.2)
-  set(SKIP_TESTS 1)
-endif()
-if (CMAKE_CXX_COMPILER_ID MATCHES Watcom
-    OR CMAKE_SYSTEM_NAME MATCHES IRIX64
-    OR CMAKE_CXX_COMPILER_ID MATCHES HP
-    OR CMAKE_CXX_COMPILER_ID MATCHES XL
-    OR CMAKE_CXX_COMPILER_ID MATCHES SunPro)
-  set(SKIP_TESTS 1)
-endif()
-
-if (NOT SKIP_TESTS)
-  run_cmake(PropertyTypo)
-endif()
+run_cmake(PropertyTypo)

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list