summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-06-05 13:38:59 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-06-05 13:38:59 (GMT)
commitff8917fdd2e8739a46c84ab03911258c23779744 (patch)
tree501e695d25bd0256e932d090eb1b70dc71bd8f8b /Tests
parent4d15c0b7c6f11c7486da7e760c59a1e7daabacab (diff)
parentcd1fa537a03377974a4d0a27e592785f931a41e5 (diff)
downloadCMake-ff8917fdd2e8739a46c84ab03911258c23779744.zip
CMake-ff8917fdd2e8739a46c84ab03911258c23779744.tar.gz
CMake-ff8917fdd2e8739a46c84ab03911258c23779744.tar.bz2
Merge topic 'VISIBILITY_PRESET-property'
cd1fa53 Add a COMPILE_OPTION for a VISIBILITY_INLINES_HIDDEN target property. 0e9f4bc Introduce target property <LANG>_VISIBILITY_PRESET
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Module/GenerateExportHeader/CMakeLists.txt2
-rw-r--r--Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt17
-rw-r--r--Tests/Module/GenerateExportHeader/visibility_preset/main.cpp9
-rw-r--r--Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp7
-rw-r--r--Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h13
-rw-r--r--Tests/RunCMake/CMakeLists.txt16
-rw-r--r--Tests/RunCMake/VisibilityPreset/CMakeLists.txt8
-rw-r--r--Tests/RunCMake/VisibilityPreset/PropertyTypo-result.txt1
-rw-r--r--Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt1
-rw-r--r--Tests/RunCMake/VisibilityPreset/PropertyTypo.cmake3
-rw-r--r--Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/VisibilityPreset/lib.cpp5
12 files changed, 85 insertions, 0 deletions
diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt
index 45334a4..09f1881 100644
--- a/Tests/Module/GenerateExportHeader/CMakeLists.txt
+++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt
@@ -141,6 +141,8 @@ endmacro()
include(GenerateExportHeader)
+add_subdirectory(visibility_preset)
+
add_compiler_export_flags()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt b/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt
new file mode 100644
index 0000000..2571d22
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+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)
+
+add_executable(visibility_preset_exe main.cpp)
+
+target_link_libraries(visibility_preset_exe visibility_preset)
diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp b/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp
new file mode 100644
index 0000000..89c3977
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp
@@ -0,0 +1,9 @@
+
+#include "visibility_preset.h"
+
+int main()
+{
+ VisibilityPreset vp;
+ vp.someMethod();
+ return 0;
+}
diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp b/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp
new file mode 100644
index 0000000..c97dec6
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp
@@ -0,0 +1,7 @@
+
+#include "visibility_preset.h"
+
+void VisibilityPreset::someMethod()
+{
+
+}
diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h b/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h
new file mode 100644
index 0000000..8becbe1
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h
@@ -0,0 +1,13 @@
+
+#ifndef VISIBILITY_PRESET_H
+#define VISIBILITY_PRESET_H
+
+#include "visibility_preset_export.h"
+
+class VISIBILITY_PRESET_EXPORT VisibilityPreset
+{
+public:
+ void someMethod();
+};
+
+#endif
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 86c9725..c1a08d2 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -65,6 +65,22 @@ add_RunCMake_test(Languages)
add_RunCMake_test(ObjectLibrary)
if(NOT WIN32)
add_RunCMake_test(PositionIndependentCode)
+ 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/CMakeLists.txt b/Tests/RunCMake/VisibilityPreset/CMakeLists.txt
new file mode 100644
index 0000000..22577da
--- /dev/null
+++ b/Tests/RunCMake/VisibilityPreset/CMakeLists.txt
@@ -0,0 +1,8 @@
+
+cmake_minimum_required(VERSION 2.8)
+project(${RunCMake_TEST} CXX)
+
+# MSVC creates extra targets which pollute the stderr unless we set this.
+set(CMAKE_SUPPRESS_REGENERATION TRUE)
+
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/VisibilityPreset/PropertyTypo-result.txt b/Tests/RunCMake/VisibilityPreset/PropertyTypo-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/VisibilityPreset/PropertyTypo-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt b/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt
new file mode 100644
index 0000000..ca8c33f
--- /dev/null
+++ b/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt
@@ -0,0 +1 @@
+CMake Error: Target visibility_preset uses unsupported value \"hiden\" for CXX_VISIBILITY_PRESET
diff --git a/Tests/RunCMake/VisibilityPreset/PropertyTypo.cmake b/Tests/RunCMake/VisibilityPreset/PropertyTypo.cmake
new file mode 100644
index 0000000..03c0ed9
--- /dev/null
+++ b/Tests/RunCMake/VisibilityPreset/PropertyTypo.cmake
@@ -0,0 +1,3 @@
+
+add_library(visibility_preset SHARED lib.cpp)
+set_property(TARGET visibility_preset PROPERTY CXX_VISIBILITY_PRESET hiden)
diff --git a/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake b/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake
new file mode 100644
index 0000000..2d78832
--- /dev/null
+++ b/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(PropertyTypo)
diff --git a/Tests/RunCMake/VisibilityPreset/lib.cpp b/Tests/RunCMake/VisibilityPreset/lib.cpp
new file mode 100644
index 0000000..06b3472
--- /dev/null
+++ b/Tests/RunCMake/VisibilityPreset/lib.cpp
@@ -0,0 +1,5 @@
+
+int foo(void)
+{
+ return 42;
+}