Replace loader_cmake_config.h with definitions
authorCharles Giessen <charles@lunarg.com>
Wed, 3 Nov 2021 20:25:29 +0000 (14:25 -0600)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Wed, 9 Mar 2022 22:06:30 +0000 (15:06 -0700)
Use CMakes built in ability to define compiler definitions to targets so that
the loader_cmake_config.h file is made redundant. This simplifies the build
process by removing the configure_file and including it. Note that this
commit is a part of a series of commits and not intended to work by itself.

BUILD.gn
loader/CMakeLists.txt
loader/get_environment.c
loader/loader_cmake_config.h.in [deleted file]

index 08df4aef2ba7f3182638eb8944aa044a37fb56b0..dc1f8720ce3e6e78c7091e4c2ad274643d2c76a3 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -37,7 +37,6 @@ if (is_win) {
 
 config("vulkan_internal_config") {
   defines = [
-    "VULKAN_NON_CMAKE_BUILD",
     "VK_ENABLE_BETA_EXTENSIONS",
   ]
   if (is_clang || !is_win) {
index 6ab7813f381e6054d97a1688eeb568feeaa2272b..acea3da5e43153aee81aafe367d3a98434403e53 100644 (file)
@@ -30,10 +30,16 @@ include(CheckIncludeFile)
 
 check_function_exists(secure_getenv HAVE_SECURE_GETENV)
 check_function_exists(__secure_getenv HAVE___SECURE_GETENV)
-if(NOT (HAVE_SECURE_GETENV OR HAVE__SECURE_GETENV))
+
+if (HAVE_SECURE_GETENV)
+    target_compile_definitions(loader_specific_options INTERFACE HAVE_SECURE_GETENV)
+endif()
+if (HAVE___SECURE_GETENV)
+    target_compile_definitions(loader_specific_options INTERFACE HAVE___SECURE_GETENV)
+endif()
+if(NOT (HAVE_SECURE_GETENV OR HAVE___SECURE_GETENV))
     message(WARNING "Using non-secure environmental lookups. This loader will not properly disable environent variables when run with elevated permissions.")
 endif()
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/loader_cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/loader_cmake_config.h)
 
 if(WIN32)
     if(MSVC AND NOT MSVC_VERSION LESS 1900)
index bf878dab7bf206653ed8723de8ecbc35c041d14e..10a3ddf404315f6a76c1c413d41ca9d0187bd575 100644 (file)
 
 #include "log.h"
 
-// This is a CMake generated file with #defines for if secure_getenv and __secure_getenv
-// are present.
-#if !defined(VULKAN_NON_CMAKE_BUILD)
-#include "loader_cmake_config.h"
-#endif  // !defined(VULKAN_NON_CMAKE_BUILD)
-
 // Environment variables
 #if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__)
 
diff --git a/loader/loader_cmake_config.h.in b/loader/loader_cmake_config.h.in
deleted file mode 100644 (file)
index 3bbc461..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#cmakedefine HAVE_SECURE_GETENV
-#cmakedefine HAVE___SECURE_GETENV