Use target_link_options if available in CMake
authorCharles Giessen <charles@lunarg.com>
Sat, 19 Feb 2022 20:36:58 +0000 (13:36 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Wed, 9 Mar 2022 22:06:30 +0000 (15:06 -0700)
CMakeLists.txt
loader/CMakeLists.txt

index bac88773b027bb7f7413420ec0214f82cf2e3ae3..8fff3dd31f96b0fda696e07318ec157868ed5c3b 100644 (file)
@@ -307,8 +307,12 @@ if(MSVC)
     target_compile_options(loader_common_options INTERFACE /WX /GR- /w34456 /w34701 /w34703 /w34057 /w34245 /guard:cf)
 
     # Enable control flow guard
-    list(APPEND CMAKE_SHARED_LINKER_FLAGS /guard:cf)
-    list(APPEND CMAKE_EXE_LINKER_FLAGS /guard:cf)
+    if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0")
+        target_link_options(loader_common_options INTERFACE "LINKER:/guard:cf")
+    else()
+        set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /guard:cf")
+        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /guard:cf")
+    endif()
 
     # Prevent <windows.h> from polluting the code. guards against things like MIN and MAX
     target_compile_definitions(loader_common_options INTERFACE WIN32_LEAN_AND_MEAN)
index 167adf410fb9a45773da45bf6d5f7babb93ac759..6ebc30eb48d1ec3541a24ca110c50871867d77c1 100644 (file)
@@ -291,7 +291,7 @@ else()
         # Use GLOB_RECURSE to find all the header files and populate the vulkan.framework headers with them
         # Use CONFIGURE_DEPENDS to ensure that if the header files are updated, this list is also updated
         # Note: CONFIGURE_DEPENDS is a 3.12 feature - gate it for now and remove when CMake minimum version is higher
-        if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
+        if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
             file(GLOB_RECURSE CONFIGURE_DEPENDS FRAMEWORK_HEADERS ${VulkanHeaders_INCLUDE_DIRS})
         else()
             file(GLOB_RECURSE FRAMEWORK_HEADERS ${VulkanHeaders_INCLUDE_DIRS})