Make _GNU_SOURCE a common target property
authorCharles Giessen <charles@lunarg.com>
Thu, 17 Feb 2022 23:15:05 +0000 (16:15 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Wed, 9 Mar 2022 22:06:30 +0000 (15:06 -0700)
Rather than set it per target that needs it, make it available on the
loader_specific_options target for consistency.

loader/CMakeLists.txt

index 98379f5dc573ba85f8ee27992bed61074098c53d..34e02ba3a94e1b0373b3eee591b79be4185e000d 100644 (file)
@@ -106,6 +106,12 @@ if(WIN32)
     # Configure the file to include the versioning info
     # Place it in the current directory for check-in - so the GN build has up to date info
     configure_file(loader.rc.in ${CMAKE_CURRENT_LIST_DIR}/loader.rc)
+else()
+    # Used to make alloca() and secure_getenv() available
+    target_compile_definitions(loader_specific_options INTERFACE _GNU_SOURCE)
+    if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+        target_compile_definitions(loader_specific_options INTERFACE __BSD_VISIBLE=1)
+    endif()
 endif()
 
 set(NORMAL_LOADER_SRCS
@@ -276,12 +282,7 @@ else()
     if (NOT ANDROID)
         target_link_libraries(vulkan Threads::Threads)
     endif()
-    # Used to make alloca() and secure_getenv() available
-    target_compile_definitions(vulkan PRIVATE _GNU_SOURCE)
-    if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
-        target_compile_definitions(vulkan PRIVATE __BSD_VISIBLE=1)
-        target_compile_definitions(asm_offset PRIVATE __BSD_VISIBLE=1)
-    endif()
+
     if(APPLE)
         find_library(COREFOUNDATION_LIBRARY NAMES CoreFoundation)
         target_link_libraries(vulkan "-framework CoreFoundation")