summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/release/dev/GenerateExportHeader-include-guard.rst8
-rw-r--r--Modules/GenerateExportHeader.cmake9
-rw-r--r--Modules/exportheader.cmake.in2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/GEH.cmake1
-rw-r--r--Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/includeguard/CMakeLists.txt19
-rw-r--r--Tests/RunCMake/GenerateExportHeader/includeguard/libincludeguard.cpp0
-rw-r--r--Tests/RunCMake/GenerateExportHeader/includeguard/main.cpp.in10
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h2
22 files changed, 62 insertions, 17 deletions
diff --git a/Help/release/dev/GenerateExportHeader-include-guard.rst b/Help/release/dev/GenerateExportHeader-include-guard.rst
new file mode 100644
index 0000000..fa2be42
--- /dev/null
+++ b/Help/release/dev/GenerateExportHeader-include-guard.rst
@@ -0,0 +1,8 @@
+GenerateExportHeader-include-guard
+----------------------------------
+
+* The :module:`GenerateExportHeader` module learned an optional
+ ``INCLUDE_GUARD_NAME`` parameter to change the name of the include guard
+ symbol written to the generated export header.
+ Additionally, it now adds a comment after the closing ``#endif`` on the
+ generated export header's include guard.
diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake
index 4573c2e..17a3357 100644
--- a/Modules/GenerateExportHeader.cmake
+++ b/Modules/GenerateExportHeader.cmake
@@ -19,6 +19,7 @@
# [EXPORT_FILE_NAME <export_file_name>]
# [DEPRECATED_MACRO_NAME <deprecated_macro_name>]
# [NO_EXPORT_MACRO_NAME <no_export_macro_name>]
+# [INCLUDE_GUARD_NAME <include_guard_name>]
# [STATIC_DEFINE <static_define>]
# [NO_DEPRECATED_MACRO_NAME <no_deprecated_macro_name>]
# [DEFINE_NO_DEPRECATED]
@@ -277,7 +278,7 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY)
set(options DEFINE_NO_DEPRECATED)
set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME
DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE
- NO_DEPRECATED_MACRO_NAME CUSTOM_CONTENT_FROM_VARIABLE)
+ NO_DEPRECATED_MACRO_NAME CUSTOM_CONTENT_FROM_VARIABLE INCLUDE_GUARD_NAME)
set(multiValueArgs)
cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}"
@@ -341,7 +342,11 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY)
endif()
string(MAKE_C_IDENTIFIER ${NO_DEPRECATED_MACRO_NAME} NO_DEPRECATED_MACRO_NAME)
- set(INCLUDE_GUARD_NAME "${EXPORT_MACRO_NAME}_H")
+ if(_GEH_INCLUDE_GUARD_NAME)
+ set(INCLUDE_GUARD_NAME ${_GEH_INCLUDE_GUARD_NAME})
+ else()
+ set(INCLUDE_GUARD_NAME "${EXPORT_MACRO_NAME}_H")
+ endif()
get_target_property(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY} DEFINE_SYMBOL)
diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in
index 9dd75bf..c518b3d 100644
--- a/Modules/exportheader.cmake.in
+++ b/Modules/exportheader.cmake.in
@@ -39,4 +39,4 @@
# endif
#endif
@CUSTOM_CONTENT@
-#endif
+#endif /* @INCLUDE_GUARD_NAME@ */
diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake
index cf81f36..ae9a84c 100644
--- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake
+++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake
@@ -85,6 +85,7 @@ macro_add_test_library(libshared)
macro_add_test_library(libstatic)
add_subdirectory(nodeprecated)
+add_subdirectory(includeguard)
if(NOT BORLAND)
add_subdirectory(c_identifier)
endif()
diff --git a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake
index 55625a8..18c3340 100644
--- a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake
@@ -12,6 +12,8 @@ function(run_GEH)
run_cmake(GEH)
run_cmake_command(GEH-build ${CMAKE_COMMAND} --build . --config Debug)
run_cmake_command(GEH-run ${RunCMake_TEST_BINARY_DIR}/GenerateExportHeader)
+ run_cmake_command(GEH-incguard-macro-run ${RunCMake_TEST_BINARY_DIR}/test_includeguard_macro)
+ run_cmake_command(GEH-incguard-custom-run ${RunCMake_TEST_BINARY_DIR}/test_includeguard_custom)
file(STRINGS "${RunCMake_TEST_BINARY_DIR}/failure_test_targets"
failure_test_targets)
diff --git a/Tests/RunCMake/GenerateExportHeader/includeguard/CMakeLists.txt b/Tests/RunCMake/GenerateExportHeader/includeguard/CMakeLists.txt
new file mode 100644
index 0000000..514d27b
--- /dev/null
+++ b/Tests/RunCMake/GenerateExportHeader/includeguard/CMakeLists.txt
@@ -0,0 +1,19 @@
+set(libincludeguard_SRC libincludeguard.cpp)
+
+add_library(includeguard_macro ${libincludeguard_SRC})
+generate_export_header(includeguard_macro)
+
+set(EXPORT_HEADER includeguard_macro_export.h)
+set(DEF_SYMBOL INCLUDEGUARD_MACRO_EXPORT_H)
+set(NDEF_SYMBOL CUSTOM_GUARD)
+configure_file(main.cpp.in main_macro.cpp)
+add_executable(test_includeguard_macro ${CMAKE_CURRENT_BINARY_DIR}/main_macro.cpp)
+
+add_library(includeguard_custom ${libincludeguard_SRC})
+generate_export_header(includeguard_custom INCLUDE_GUARD_NAME CUSTOM_GUARD)
+
+set(EXPORT_HEADER includeguard_custom_export.h)
+set(DEF_SYMBOL CUSTOM_GUARD)
+set(NDEF_SYMBOL INCLUDEGUARD_CUSTOM_EXPORT_H)
+configure_file(main.cpp.in main_custom.cpp)
+add_executable(test_includeguard_custom ${CMAKE_CURRENT_BINARY_DIR}/main_custom.cpp)
diff --git a/Tests/RunCMake/GenerateExportHeader/includeguard/libincludeguard.cpp b/Tests/RunCMake/GenerateExportHeader/includeguard/libincludeguard.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/GenerateExportHeader/includeguard/libincludeguard.cpp
diff --git a/Tests/RunCMake/GenerateExportHeader/includeguard/main.cpp.in b/Tests/RunCMake/GenerateExportHeader/includeguard/main.cpp.in
new file mode 100644
index 0000000..51bd5d9
--- /dev/null
+++ b/Tests/RunCMake/GenerateExportHeader/includeguard/main.cpp.in
@@ -0,0 +1,10 @@
+#include "@EXPORT_HEADER@"
+
+int main()
+{
+#if defined(@DEF_SYMBOL@) && !defined(@NDEF_SYMBOL@)
+ return 0;
+#else
+ return 1;
+#endif
+}
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h
index e8af0a5..0b1dcba 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h
index 598bd71..5e3ac9f 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h
index cc20e09..dac4fda 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h
index 4aaa848..b6e2a4a 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h
index 053ad18..11f8042 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h
index 4aaa848..b6e2a4a 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h
index 808ff01..1481acd 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h
index 4aaa848..b6e2a4a 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h
index cc20e09..dac4fda 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h
index 4aaa848..b6e2a4a 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h
index 4e675af..3ba2d2e 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h
index 4d5ed4e..3c7e093 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h
index 84340e3..bf9163e 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h
index 598bd71..5e3ac9f 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */