build: Beautify cmake files
authorMike Weiblen <mikew@lunarg.com>
Sat, 30 Jun 2018 18:07:29 +0000 (12:07 -0600)
committerMike Weiblen <mikew@lunarg.com>
Sun, 1 Jul 2018 04:55:12 +0000 (22:55 -0600)
Add .cmake-format.py
Add cmake-format docs to CONTRIBUTING.md
Minor edits to existing files

Due to a bug in cmake-format, use this script to reformat:

for i in CMakeLists.txt external/CMakeLists.txt loader/CMakeLists.txt tests/CMakeLists.txt tests/layers/CMakeLists.txt
do
    sed --in-place='' 's/^  *#/#/' $i
    cmake-format --in-place $i
done

Change-Id: I8e59c77ae184c88485a97a015ac81d4f71ac4897

.cmake-format.py [new file with mode: 0644]
CMakeLists.txt
CONTRIBUTING.md
external/CMakeLists.txt
loader/CMakeLists.txt
tests/CMakeLists.txt
tests/layers/CMakeLists.txt

diff --git a/.cmake-format.py b/.cmake-format.py
new file mode 100644 (file)
index 0000000..9c173ac
--- /dev/null
@@ -0,0 +1,34 @@
+# Configuration for cmake-format (v0.3.6, circa Apr 2018)
+# https://github.com/cheshirekow/cmake_format
+
+# How wide to allow formatted cmake files
+line_width = 132
+
+# How many spaces to tab for indent
+tab_size = 4
+
+# If arglists are longer than this, break them always
+max_subargs_per_line = 3
+
+# If true, separate flow control names from their parentheses with a space
+separate_ctrl_name_with_space = False
+
+# If true, separate function names from parentheses with a space
+separate_fn_name_with_space = False
+
+# If a statement is wrapped to more than one line, than dangle the closing
+# parenthesis on it's own line
+dangle_parens = False
+
+# What character to use for bulleted lists
+bullet_char = u'*'
+
+# What character to use as punctuation after numerals in an enumerated list
+enum_char = u'.'
+
+# What style line endings to use in the output.
+line_ending = u'unix'
+
+# Format command names consistently as 'lower' or 'upper' case
+command_case = u'lower'
+
index 868b58f99656a069883362daeb304d8f38fa7c4b..b942bd47cdfd623b145934ce51ad08d6a0b55547 100644 (file)
@@ -21,19 +21,19 @@ cmake_minimum_required(VERSION 2.8.11)
 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
 
 project(Vulkan-Loader)
-set (CMAKE_VERBOSE_MAKEFILE 0)
+set(CMAKE_VERBOSE_MAKEFILE 0)
 
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 find_package(PythonInterp 3 REQUIRED)
 
 find_package(VulkanHeaders)
-if (NOT ${VulkanHeaders_FOUND})
+if(NOT ${VulkanHeaders_FOUND})
     message(FATAL_ERROR "Could not find Vulkan headers path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
-        "installation of the Vulkan-Headers repository.")
+                        "installation of the Vulkan-Headers repository.")
 endif()
 
 option(USE_CCACHE "Use ccache" OFF)
-if (USE_CCACHE)
+if(USE_CCACHE)
     find_program(CCACHE_FOUND ccache)
     if(CCACHE_FOUND)
         set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
@@ -43,13 +43,12 @@ endif()
 
 include(GNUInstallDirs)
 # Set a better default install location for Windows only if the user did not provide one.
-if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
-    set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE )
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
+    set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE)
 endif()
 
 if(APPLE)
-    # CMake versions 3 or later need CMAKE_MACOSX_RPATH defined.
-    # This avoids the CMP0042 policy message.
+    # CMake versions 3 or later need CMAKE_MACOSX_RPATH defined. This avoids the CMP0042 policy message.
     set(CMAKE_MACOSX_RPATH 1)
     # The "install" target for MacOS fixes up bundles in place.
     set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
@@ -61,10 +60,18 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 set(LOADER_HELPER_FOLDER "Helper Targets")
 
 if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-    set(FALLBACK_CONFIG_DIRS "/etc/xdg" CACHE STRING
-        "Search path to use when XDG_CONFIG_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant.")
-    set(FALLBACK_DATA_DIRS "/usr/local/share:/usr/share" CACHE STRING
-        "Search path to use when XDG_DATA_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant.")
+    set(
+        FALLBACK_CONFIG_DIRS "/etc/xdg"
+        CACHE
+            STRING
+            "Search path to use when XDG_CONFIG_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant."
+        )
+    set(
+        FALLBACK_DATA_DIRS "/usr/local/share:/usr/share"
+        CACHE
+            STRING
+            "Search path to use when XDG_DATA_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant."
+        )
 endif()
 
 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
@@ -74,20 +81,20 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
     option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" ON)
     option(BUILD_WSI_MIR_SUPPORT "Build Mir WSI support" OFF)
 
-    if (BUILD_WSI_XCB_SUPPORT)
+    if(BUILD_WSI_XCB_SUPPORT)
         find_package(XCB REQUIRED)
     endif()
 
-    if (BUILD_WSI_XLIB_SUPPORT)
+    if(BUILD_WSI_XLIB_SUPPORT)
         find_package(X11 REQUIRED)
     endif()
 
-    if (BUILD_WSI_WAYLAND_SUPPORT)
+    if(BUILD_WSI_WAYLAND_SUPPORT)
         find_package(Wayland REQUIRED)
         include_directories(${WAYLAND_CLIENT_INCLUDE_DIR})
     endif()
 
-    if (BUILD_WSI_MIR_SUPPORT)
+    if(BUILD_WSI_MIR_SUPPORT)
         find_package(Mir REQUIRED)
     endif()
 endif()
@@ -102,23 +109,23 @@ set(SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
 # Add location of Vulkan header files to include search path
 include_directories(${VulkanHeaders_INCLUDE_DIRS})
 
-if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
+if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
     set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
     set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
 
-    # For GCC version 7.1 or greater, we need to disable the implicit fallthrough warning since
-    # there's no consistent way to satisfy all compilers until they all accept the C++17 standard
-    if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_CXX_COMPILER_VERSION LESS 7.1))
+    # For GCC version 7.1 or greater, we need to disable the implicit fallthrough warning since there's no consistent way to satisfy
+    # all compilers until they all accept the C++17 standard
+    if(CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_CXX_COMPILER_VERSION LESS 7.1))
         set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -Wimplicit-fallthrough=0")
     endif()
 
-    if (APPLE)
+    if(APPLE)
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILE_FLAGS}")
     else()
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}")
     endif()
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11 -fno-rtti")
-    if (UNIX)
+    if(UNIX)
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
     endif()
@@ -147,27 +154,30 @@ else()
     option(BUILD_TESTS "Build Tests" OFF)
 endif()
 
-set (PYTHON_CMD ${PYTHON_EXECUTABLE})
+set(PYTHON_CMD ${PYTHON_EXECUTABLE})
 
 # Define macro used for building vkxml generated files
 macro(run_vk_xml_generate dependency output)
     add_custom_command(OUTPUT ${output}
-    COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/loader_genvk.py -registry ${VulkanRegistry_DIR}/vk.xml -scripts ${VulkanRegistry_DIR} ${output}
-    DEPENDS ${VulkanRegistry_DIR}/vk.xml ${VulkanRegistry_DIR}/generator.py ${SCRIPTS_DIR}/${dependency} ${SCRIPTS_DIR}/loader_genvk.py ${VulkanRegistry_DIR}/reg.py
-    )
+                       COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/loader_genvk.py -registry ${VulkanRegistry_DIR}/vk.xml -scripts
+                               ${VulkanRegistry_DIR} ${output}
+                       DEPENDS ${VulkanRegistry_DIR}/vk.xml
+                               ${VulkanRegistry_DIR}/generator.py
+                               ${SCRIPTS_DIR}/${dependency}
+                               ${SCRIPTS_DIR}/loader_genvk.py
+                               ${VulkanRegistry_DIR}/reg.py)
 endmacro()
 
 # Custom target for generated vulkan helper file dependencies
-add_custom_target(generate_helper_files DEPENDS
-    vk_enum_string_helper.h
-    vk_safe_struct.h
-    vk_safe_struct.cpp
-    vk_object_types.h
-    vk_layer_dispatch_table.h
-    vk_dispatch_table_helper.h
-    vk_extension_helper.h
-    vk_typemap_helper.h
-    )
+add_custom_target(generate_helper_files
+                  DEPENDS vk_enum_string_helper.h
+                          vk_safe_struct.h
+                          vk_safe_struct.cpp
+                          vk_object_types.h
+                          vk_layer_dispatch_table.h
+                          vk_dispatch_table_helper.h
+                          vk_extension_helper.h
+                          vk_typemap_helper.h)
 set_target_properties(generate_helper_files PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
 
 # Rules to build generated helper files
@@ -195,12 +205,10 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/vk_layer_dispatch_table.h" DESTINATIO
 
 # uninstall target
 if(NOT TARGET uninstall)
-    configure_file(
-        "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
-        "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
-        IMMEDIATE @ONLY)
-    add_custom_target(uninstall
-        COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
+    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+                   IMMEDIATE
+                   @ONLY)
+    add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
     set_target_properties(uninstall PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
 endif()
 
index 111e5e40465e4aaccb01e303a536ffc1177ad4b6..34fcdeca3e1277fe2f176005f25eaee96e24b772 100644 (file)
@@ -63,7 +63,7 @@ current assignee.
     but it improves type safety."
 
 * Run **clang-format** on your changes to maintain consistent formatting
-  * There are `.clang-format files` present in the repository to define
+  * There are `.clang-format` files present in the repository to define
     clang-format settings which are found and used automatically by clang-format.
   * **clang-format** binaries are available from the LLVM orginization, here:
     [LLVM](https://clang.llvm.org/).
@@ -113,6 +113,29 @@ will assist in enforcing this requirement.
 * Run tests that explicitly exercise your changes.
 * Feel free to subject your code changes to other tests as well!
 
+#### Coding Conventions for [CMake](http://cmake.org) files
+
+* When editing configuration files for CMake, follow the style conventions of the surrounding code.
+  * The column limit is 132.
+  * The indent is 4 spaces.
+  * CMake functions are lower-case.
+  * Variable and keyword names are upper-case.
+* The format is defined by
+  [cmake-format](https://github.com/cheshirekow/cmake_format)
+  using the `.cmake-format.py` file in the repository to define the settings.
+  See the cmake-format page for information about its simple markup for comments.
+* Disable reformatting of a block of comment lines by inserting
+  a `# ~~~` comment line before and after that block.
+* Disable any formatting of a block of lines by surrounding that block with
+  `# cmake-format: off` and `# cmake-format: on` comment lines.
+* To install: `sudo pip install cmake_format`
+* To run: `cmake-format --in-place $FILENAME`
+* **IMPORTANT (June 2018)** cmake-format v0.3.6 has a
+  [bug]( https://github.com/cheshirekow/cmake_format/issues/50)
+  that can corrupt the formatting of comment lines in CMake files.
+  A workaround is to use the following command _before_ running cmake-format:
+  `sed --in-place='' 's/^  *#/#/' $FILENAME`
+
 ### Contributor License Agreement (CLA)
 
 You will be prompted with a one-time "click-through" CLA dialog as part of
index 34940952d8e5f94eee75aca5dd84f4a288c0f1a4..058fd7f842d5b398d7465a86f678c2350dc88acc 100644 (file)
 # limitations under the License.
 # ~~~
 
-# Add all optional dependencies
-# Currently, the only optional project is googletest
+# Add all optional dependencies. Currently, the only optional project is googletest.
 
 if(BUILD_TESTS)
-    # googletest is an external dependency for the tests in the ValidationLayers
-    # repo. Add googletest to the project if present and not already defined.
+    # googletest is an external dependency for the tests in the ValidationLayers repo. Add googletest to the project if present and
+    # not already defined.
     if(TARGET gtest_main)
         # It is possible that a project enclosing this one has defined the gtest target
-        message(STATUS "Vulkan-Loader/external: "
-            "Google Test (googletest) already configured - use it")
+        message(STATUS "Vulkan-Loader/external: " "Google Test (googletest) already configured - use it")
     elseif(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/googletest")
-        message(STATUS "Vulkan-Loader/external: "
-            "googletests found - configuring it for tests")
+        message(STATUS "Vulkan-Loader/external: " "googletests found - configuring it for tests")
         set(BUILD_GTEST ON CACHE BOOL "Builds the googletest subproject")
         set(BUILD_GMOCK OFF CACHE BOOL "Builds the googlemock subproject")
         set(gtest_force_shared_crt ON CACHE BOOL "Link gtest runtimes dynamically")
@@ -35,8 +32,7 @@ if(BUILD_TESTS)
         # EXCLUDE_FROM_ALL keeps the install target from installing GTEST files.
         add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/googletest" EXCLUDE_FROM_ALL)
     else()
-        message(SEND_ERROR
-            "Vulkan-Loader/external: Google Test was not found.  "
-            "Provide Google Test in external/googletest or set BUILD_TESTS=OFF")
+        message(SEND_ERROR "Vulkan-Loader/external: Google Test was not found.  "
+                           "Provide Google Test in external/googletest or set BUILD_TESTS=OFF")
     endif()
 endif()
index d6a10ea2e1382d9d7a77c1da638e0839c4dd0f72..a5bbc1d0b01fbab6d074d884e8527694110e2073 100644 (file)
 
 if(NOT ${VulkanRegistry_FOUND})
     message(FATAL_ERROR "Could not find Vulkan registry path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
-        "installation of the Vulkan-Headers repository.")
+                        "installation of the Vulkan-Headers repository.")
 endif()
 
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}
-    ${CMAKE_CURRENT_BINARY_DIR}
-    ${PROJECT_BINARY_DIR}
-    ${CMAKE_BINARY_DIR}
-)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_BINARY_DIR} ${CMAKE_BINARY_DIR})
 
 # Check for the existance of the secure_getenv or __secure_getenv commands
 include(CheckFunctionExists)
-CHECK_FUNCTION_EXISTS(secure_getenv HAVE_SECURE_GETENV)
-CHECK_FUNCTION_EXISTS(__secure_getenv HAVE___SECURE_GETENV)
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/loader_cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/loader_cmake_config.h)
+check_function_exists(secure_getenv HAVE_SECURE_GETENV)
+check_function_exists(__secure_getenv HAVE___SECURE_GETENV)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/loader_cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/loader_cmake_config.h)
 
 # Fetch header version from vulkan_core.h
 file(STRINGS "${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_core.h" lines REGEX "^#define VK_HEADER_VERSION [0-9]+")
@@ -39,13 +34,13 @@ list(LENGTH lines len)
 if(${len} EQUAL 1)
     string(REGEX MATCHALL "[0-9]+" vk_header_version ${lines})
 else()
-    MESSAGE(FATAL_ERROR "Unable to fetch version from vulkan.h")
+    message(FATAL_ERROR "Unable to fetch version from vulkan.h")
 endif()
 
 if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
     add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN)
     set(DisplayServer Win32)
-    if (NOT MSVC_VERSION LESS 1900)
+    if(NOT MSVC_VERSION LESS 1900)
         # Enable control flow guard
         message(STATUS "Building loader with control flow guard")
         add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/guard:cf>")
@@ -55,19 +50,19 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
 elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
     add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
 elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
-    if (BUILD_WSI_XCB_SUPPORT)
+    if(BUILD_WSI_XCB_SUPPORT)
         add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
     endif()
 
-    if (BUILD_WSI_XLIB_SUPPORT)
-       add_definitions(-DVK_USE_PLATFORM_XLIB_KHR -DVK_USE_PLATFORM_XLIB_XRANDR_EXT)
+    if(BUILD_WSI_XLIB_SUPPORT)
+        add_definitions(-DVK_USE_PLATFORM_XLIB_KHR -DVK_USE_PLATFORM_XLIB_XRANDR_EXT)
     endif()
 
-    if (BUILD_WSI_WAYLAND_SUPPORT)
-       add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
+    if(BUILD_WSI_WAYLAND_SUPPORT)
+        add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
     endif()
 
-    if (BUILD_WSI_MIR_SUPPORT)
+    if(BUILD_WSI_MIR_SUPPORT)
         add_definitions(-DVK_USE_PLATFORM_MIR_KHR)
         include_directories(${MIR_INCLUDE_DIR})
     endif()
@@ -96,23 +91,19 @@ set(NORMAL_LOADER_SRCS
     cJSON.c
     cJSON.h
     murmurhash.c
-    murmurhash.h
-)
+    murmurhash.h)
 
-set(OPT_LOADER_SRCS
-    dev_ext_trampoline.c
-    phys_dev_ext.c
-)
+set(OPT_LOADER_SRCS dev_ext_trampoline.c phys_dev_ext.c)
 
 # Check for assembler support
 set(ASM_FAILURE_MSG "The build will fall back on building with C code\n")
 set(ASM_FAILURE_MSG "${ASM_FAILURE_MSG}Note that this may be unsafe, as the C code requires tail-call optimizations to remove")
 set(ASM_FAILURE_MSG "${ASM_FAILURE_MSG} the stack frame for certain calls. If the compiler does not do this, then unknown device")
 set(ASM_FAILURE_MSG "${ASM_FAILURE_MSG} extensions will suffer from a corrupted stack.")
-if (WIN32)
+if(WIN32)
     enable_language(ASM_MASM)
-    if (CMAKE_ASM_MASM_COMPILER_WORKS)
-        if (NOT CMAKE_CL_64)
+    if(CMAKE_ASM_MASM_COMPILER_WORKS)
+        if(NOT CMAKE_CL_64)
             set(CMAKE_ASM_MASM_FLAGS ${CMAKE_ASM_MASM_FLAGS} /safeseh)
         endif()
         set(OPT_LOADER_SRCS ${OPT_LOADER_SRCS} unknown_ext_chain_masm.asm)
@@ -137,10 +128,11 @@ else()
     set(CMAKE_ASM-ATT_COMPILE_FLAGS "${CMAKE_ASM-ATT_COMPILE_FLAGS} $ENV{ASFLAGS}")
     set(CMAKE_ASM-ATT_COMPILE_FLAGS "${CMAKE_ASM-ATT_COMPILE_FLAGS} -I\"${CMAKE_CURRENT_BINARY_DIR}\"")
 
-    file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/asm_test.asm ".intel_syntax noprefix\n.text\n.global sample\nsample:\nmov ecx, [eax + 16]\n")
+    file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/asm_test.asm
+               ".intel_syntax noprefix\n.text\n.global sample\nsample:\nmov ecx, [eax + 16]\n")
     try_compile(ASSEMBLER_WORKS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/asm_test.asm)
     file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/asm_test.asm)
-    if (ASSEMBLER_WORKS)
+    if(ASSEMBLER_WORKS)
         set(CMAKE_ASM-ATT_FLAGS "$ENV{ASFLAGS} -I\"${CMAKE_CURRENT_BINARY_DIR}\"")
         set(OPT_LOADER_SRCS ${OPT_LOADER_SRCS} unknown_ext_chain_gas.asm)
         add_executable(asm_offset asm_offset.c)
@@ -156,31 +148,39 @@ endif()
 
 run_vk_xml_generate(loader_extension_generator.py vk_loader_extensions.h)
 run_vk_xml_generate(loader_extension_generator.py vk_loader_extensions.c)
-add_custom_target(loader_gen_files DEPENDS
-        vk_loader_extensions.h
-        vk_loader_extensions.c
-    )
+add_custom_target(loader_gen_files DEPENDS vk_loader_extensions.h vk_loader_extensions.c)
 set_target_properties(loader_gen_files PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
 
-if (WIN32)
+if(WIN32)
     # Use static MSVCRT libraries
-    foreach(configuration in CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
-                             CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+    foreach(configuration
+            in
+            CMAKE_C_FLAGS_DEBUG
+            CMAKE_C_FLAGS_MINSIZEREL
+            CMAKE_C_FLAGS_RELEASE
+            CMAKE_C_FLAGS_RELWITHDEBINFO
+            CMAKE_CXX_FLAGS_DEBUG
+            CMAKE_CXX_FLAGS_MINSIZEREL
+            CMAKE_CXX_FLAGS_RELEASE
+            CMAKE_CXX_FLAGS_RELWITHDEBINFO)
         if(${configuration} MATCHES "/MD")
             string(REGEX REPLACE "/MD" "/MT" ${configuration} "${${configuration}}")
         endif()
     endforeach()
 
-    if (ENABLE_WIN10_ONECORE)
-    # Note  When linking your app or driver to OneCore.lib, be sure to remove any links to non-umbrella libs (such as kernel32.lib).
+    if(ENABLE_WIN10_ONECORE)
+        # Note: When linking your app or driver to OneCore.lib, be sure to remove any links to non-umbrella libs (such as
+        # kernel32.lib).
         set(CMAKE_CXX_STANDARD_LIBRARIES " ") # space is intentional
         set(CMAKE_C_STANDARD_LIBRARIES ${CMAKE_CXX_STANDARD_LIBRARIES})
     endif()
 
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
+    # ~~~
     # Build dev_ext_trampoline.c with -O2 to allow tail-call optimization.
-    # Build other C files with normal options
-    # setup two Cmake targets (loader-norm and loader-opt) for the different compilation flags
+    # Build other C files with normal options.
+    # Setup two CMake targets (loader-norm and loader-opt) for the different compilation flags.
+    # ~~~
     separate_arguments(LOCAL_C_FLAGS_DBG WINDOWS_COMMAND ${CMAKE_C_FLAGS_DEBUG})
     set(CMAKE_C_FLAGS_DEBUG " ")
     separate_arguments(LOCAL_C_FLAGS_REL WINDOWS_COMMAND ${CMAKE_C_FLAGS_RELEASE})
@@ -197,16 +197,21 @@ if (WIN32)
         target_compile_definitions(loader-norm PUBLIC LOADER_DYNAMIC_LIB)
         target_compile_definitions(loader-opt PUBLIC LOADER_DYNAMIC_LIB)
 
-        add_library(vulkan SHARED $<TARGET_OBJECTS:loader-opt> $<TARGET_OBJECTS:loader-norm> ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-1.def ${CMAKE_CURRENT_SOURCE_DIR}/loader.rc)
+        add_library(vulkan
+                    SHARED
+                    $<TARGET_OBJECTS:loader-opt>
+                    $<TARGET_OBJECTS:loader-norm>
+                    ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-1.def
+                    ${CMAKE_CURRENT_SOURCE_DIR}/loader.rc)
         set_target_properties(vulkan PROPERTIES LINK_FLAGS_DEBUG "/ignore:4098" OUTPUT_NAME vulkan-1)
     else()
         add_library(vulkan STATIC $<TARGET_OBJECTS:loader-opt> $<TARGET_OBJECTS:loader-norm>)
         set_target_properties(vulkan PROPERTIES OUTPUT_NAME VKstatic.1)
     endif()
 
-    if (ENABLE_WIN10_ONECORE)
+    if(ENABLE_WIN10_ONECORE)
         target_link_libraries(vulkan OneCoreUAP.lib LIBCMT.LIB LIBCMTD.LIB LIBVCRUNTIME.LIB LIBUCRT.LIB)
-        set_target_properties(vulkan PROPERTIES LINK_FLAGS   "/NODEFAULTLIB")
+        set_target_properties(vulkan PROPERTIES LINK_FLAGS "/NODEFAULTLIB")
     else()
         target_link_libraries(vulkan Cfgmgr32)
     endif()
@@ -217,9 +222,9 @@ else()
     # Linux and MacOS
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith")
 
-    # Clang (and not gcc) warns about redefining a typedef with the same types, so disable that warning.
-    # Note that it will still throw an error if a typedef is redefined with a different type.
-    if (CMAKE_C_COMPILER_ID MATCHES "Clang")
+    # Clang (and not gcc) warns about redefining a typedef with the same types, so disable that warning. Note that it will still
+    # throw an error if a typedef is redefined with a different type.
+    if(CMAKE_C_COMPILER_ID MATCHES "Clang")
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-typedef-redefinition")
     endif()
 
@@ -251,19 +256,18 @@ else()
             ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_xlib.h
             ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan_xlib_xrandr.h
             ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan.h
-            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan.hpp
-        )
+            ${VulkanHeaders_INCLUDE_DIRS}/vulkan/vulkan.hpp)
         add_library(vulkan-framework SHARED ${NORMAL_LOADER_SRCS} ${OPT_LOADER_SRCS} ${FRAMEWORK_HEADERS})
         add_dependencies(vulkan-framework generate_helper_files loader_gen_files loader_asm_gen_files)
         target_compile_definitions(vulkan-framework PUBLIC -DLOADER_DYNAMIC_LIB)
         target_link_libraries(vulkan-framework -ldl -lpthread -lm "-framework CoreFoundation")
 
-        # The FRAMEWORK_VERSION needs to be "A" here so that Xcode code-signing works when
-        # a user adds their framework to an Xcode project and does "Sign on Copy".
-        # It would have been nicer to use "1" to denote Vulkan 1.
-        # Although Apple docs say that a framework version does not have to be "A",
-        # this part of the Apple toolchain expects it.
+        # The FRAMEWORK_VERSION needs to be "A" here so that Xcode code-signing works when a user adds their framework to an Xcode
+        # project and does "Sign on Copy". It would have been nicer to use "1" to denote Vulkan 1. Although Apple docs say that a
+        # framework version does not have to be "A", this part of the Apple toolchain expects it.
         # https://forums.developer.apple.com/thread/65963
+
+# cmake-format: off
         set_target_properties(vulkan-framework PROPERTIES
             OUTPUT_NAME vulkan
             FRAMEWORK TRUE
@@ -277,6 +281,7 @@ else()
             PUBLIC_HEADER DESTINATION vulkan
             FRAMEWORK DESTINATION loader
         )
+# cmake-format: on
     endif(APPLE)
 
     if(NOT APPLE)
@@ -288,8 +293,7 @@ else()
                 set(PRIVATE_LIBS "${PRIVATE_LIBS} -l${LIB}")
             endforeach()
             configure_file("vulkan.pc.in" "vulkan.pc" @ONLY)
-            install(FILES       "${CMAKE_CURRENT_BINARY_DIR}/vulkan.pc"
-                    DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+            install(FILES "${CMAKE_CURRENT_BINARY_DIR}/vulkan.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
         endif()
     endif()
 endif()
index 116d719126373f4a425d5f9ce5d7358a6e4aeb38..32a25964131b24ae6fedd2ba05501cc8a50cf956 100644 (file)
@@ -23,19 +23,19 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
 elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
     add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
 elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
-    if (BUILD_WSI_XCB_SUPPORT)
+    if(BUILD_WSI_XCB_SUPPORT)
         add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
     endif()
 
-    if (BUILD_WSI_XLIB_SUPPORT)
+    if(BUILD_WSI_XLIB_SUPPORT)
         add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
     endif()
 
-    if (BUILD_WSI_WAYLAND_SUPPORT)
+    if(BUILD_WSI_WAYLAND_SUPPORT)
         add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
     endif()
 
-    if (BUILD_WSI_MIR_SUPPORT)
+    if(BUILD_WSI_MIR_SUPPORT)
         add_definitions(-DVK_USE_PLATFORM_MIR_KHR)
         include_directories(${MIR_INCLUDE_DIR})
     endif()
@@ -46,14 +46,13 @@ else()
 endif()
 
 # On Windows, we must pair Debug and Release appropriately
-if (WIN32)
-    # For Windows, since 32-bit and 64-bit items can co-exist, we build each in its own build directory.
-    # 32-bit target data goes in build32, and 64-bit target data goes into build.  So, include/link the
-    # appropriate data at build time.
-    if (CMAKE_CL_64)
-        set (BUILDTGT_DIR build)
-    else ()
-        set (BUILDTGT_DIR build32)
+if(WIN32)
+    # For Windows, since 32-bit and 64-bit items can co-exist, we build each in its own build directory. 32-bit target data goes in
+    # build32, and 64-bit target data goes into build.  So, include/link the appropriate data at build time.
+    if(CMAKE_CL_64)
+        set(BUILDTGT_DIR build)
+    else()
+        set(BUILDTGT_DIR build32)
     endif()
 endif()
 
@@ -63,7 +62,7 @@ if(WIN32)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES")
 
     # If MSVC, disable some signed/unsigned mismatch warnings.
-    if (MSVC)
+    if(MSVC)
         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")
     endif()
 
@@ -71,46 +70,38 @@ else()
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
 endif()
 
-set (LIBGLM_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs)
+set(LIBGLM_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs)
 
-include_directories(
-    ${PROJECT_SOURCE_DIR}/external
-    ${GTEST_SOURCE_DIR}/googletest/include
-    ${CMAKE_CURRENT_BINARY_DIR}
-    ${CMAKE_BINARY_DIR}
-    ${PROJECT_BINARY_DIR}
-)
+include_directories(${PROJECT_SOURCE_DIR}/external
+                    ${GTEST_SOURCE_DIR}/googletest/include
+                    ${CMAKE_CURRENT_BINARY_DIR}
+                    ${CMAKE_BINARY_DIR}
+                    ${PROJECT_BINARY_DIR})
 
-if (NOT WIN32)
+if(NOT WIN32)
     # extra setup for out-of-tree builds
-    if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
+    if(NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
         add_custom_target(binary-dir-symlinks ALL
-            COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_wrap_objects_tests.sh
-            COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_loader_tests.sh
-            COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_extra_loader_tests.sh
-            COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh
-            VERBATIM
-        )
+                          COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_wrap_objects_tests.sh
+                          COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_loader_tests.sh
+                          COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_extra_loader_tests.sh
+                          COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh
+                          VERBATIM)
     endif()
 else()
-    if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
-        FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_run_all_tests.ps1 RUN_ALL)
+    if(NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
+        file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_run_all_tests.ps1 RUN_ALL)
         add_custom_target(binary-dir-symlinks ALL
-            COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} run_all_tests.ps1
-            VERBATIM
-        )
+                          COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} run_all_tests.ps1
+                          VERBATIM)
         set_target_properties(binary-dir-symlinks PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
     endif()
 endif()
 
 add_executable(vk_loader_validation_tests loader_validation_tests.cpp)
-set_target_properties(vk_loader_validation_tests
-    PROPERTIES
-    COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
+set_target_properties(vk_loader_validation_tests PROPERTIES COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
 if(NOT WIN32)
-    set_target_properties(vk_loader_validation_tests
-        PROPERTIES
-        COMPILE_FLAGS "-Wno-sign-compare")
+    set_target_properties(vk_loader_validation_tests PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
 endif()
 
 if(TARGET vulkan)
@@ -135,9 +126,11 @@ endif()
 
 # Copy loader and googletest (gtest) libs to test dir so the test executable can find them.
 if(WIN32)
-    if (CMAKE_GENERATOR MATCHES "^Visual Studio.*")
-        file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googletest/$<CONFIG>/gtest_main$<$<CONFIG:Debug>:d>.dll GTEST_COPY_SRC1)
-        file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googletest/$<CONFIG>/gtest$<$<CONFIG:Debug>:d>.dll GTEST_COPY_SRC2)
+    if(CMAKE_GENERATOR MATCHES "^Visual Studio.*")
+        file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googletest/$<CONFIG>/gtest_main$<$<CONFIG:Debug>:d>.dll
+                            GTEST_COPY_SRC1)
+        file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googletest/$<CONFIG>/gtest$<$<CONFIG:Debug>:d>.dll
+                            GTEST_COPY_SRC2)
         file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG> GTEST_COPY_DEST)
     else()
         file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googeltest/gtest_main.dll GTEST_COPY_SRC1)
@@ -145,13 +138,12 @@ if(WIN32)
         file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR} GTEST_COPY_DEST)
     endif()
     add_custom_command(TARGET vk_loader_validation_tests POST_BUILD
-        COMMAND xcopy /Y /I ${GTEST_COPY_SRC1} ${GTEST_COPY_DEST}
-        COMMAND xcopy /Y /I ${GTEST_COPY_SRC2} ${GTEST_COPY_DEST}
-    )
+                       COMMAND xcopy /Y /I ${GTEST_COPY_SRC1} ${GTEST_COPY_DEST}
+                       COMMAND xcopy /Y /I ${GTEST_COPY_SRC2} ${GTEST_COPY_DEST})
     # Copy the loader shared lib (if built) to the test application directory so the test app finds it.
     if((NOT ENABLE_STATIC_LOADER) AND TARGET vulkan)
         add_custom_command(TARGET vk_loader_validation_tests POST_BUILD
-            COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:vulkan> $<TARGET_FILE_DIR:vk_loader_validation_tests>)
+                           COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:vulkan> $<TARGET_FILE_DIR:vk_loader_validation_tests>)
     endif()
 endif()
 
index 7842169efafbb3da791a3263d599970728222dd7..fa62d57489799168e33faa4c8928649e9b15fdb7 100644 (file)
 # limitations under the License.
 # ~~~
 
-cmake_minimum_required (VERSION 2.8.11)
+cmake_minimum_required(VERSION 2.8.11)
 
-set(LAYER_JSON_FILES
-    VkLayer_wrap_objects
-    VkLayer_test
-    VkLayer_meta
-)
+set(LAYER_JSON_FILES VkLayer_wrap_objects VkLayer_test VkLayer_meta)
 
 set(VK_LAYER_RPATH /usr/lib/x86_64-linux-gnu/vulkan/layer:/usr/lib/i386-linux-gnu/vulkan/layer)
 set(CMAKE_INSTALL_RPATH ${VK_LAYER_RPATH})
 
-if (WIN32)
-    if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
-        add_custom_target(mk_test_layer_config_dir ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
+if(WIN32)
+    if(NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
+        add_custom_target(mk_test_layer_config_dir ALL
+                          COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
         set_target_properties(mk_test_layer_config_dir PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
-        foreach (config_file ${LAYER_JSON_FILES})
-            FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json)
-            if (CMAKE_GENERATOR MATCHES "^Visual Studio.*")
-                FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/${config_file}.json dst_json)
+        foreach(config_file ${LAYER_JSON_FILES})
+            file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json)
+            if(CMAKE_GENERATOR MATCHES "^Visual Studio.*")
+                file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/${config_file}.json dst_json)
             else()
-                FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${config_file}.json dst_json)
+                file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${config_file}.json dst_json)
             endif()
-            add_custom_target(${config_file}-json ALL
-                COMMAND copy ${src_json} ${dst_json}
-                VERBATIM
-                )
+            add_custom_target(${config_file}-json ALL COMMAND copy ${src_json} ${dst_json} VERBATIM)
             add_dependencies(${config_file}-json mk_test_layer_config_dir)
             set_target_properties(${config_file}-json PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
         endforeach(config_file)
     endif()
 elseif(APPLE)
     # extra setup for out-of-tree builds
-    if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
-        if (CMAKE_GENERATOR MATCHES "^Xcode.*")
-            add_custom_target(mk_test_layer_config_dir ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
-            foreach (config_file ${LAYER_JSON_FILES})
+    if(NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
+        if(CMAKE_GENERATOR MATCHES "^Xcode.*")
+            add_custom_target(mk_test_layer_config_dir ALL
+                              COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
+            foreach(config_file ${LAYER_JSON_FILES})
                 add_custom_target(${config_file}-json ALL
-                    DEPENDS mk_test_layer_config_dir
-                    COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/macos/${config_file}.json $<CONFIG>
-                    VERBATIM
-                    )
+                                  DEPENDS mk_test_layer_config_dir
+                                  COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/macos/${config_file}.json $<CONFIG>
+                                  VERBATIM)
             endforeach(config_file)
         else()
-            foreach (config_file ${LAYER_JSON_FILES})
+            foreach(config_file ${LAYER_JSON_FILES})
                 add_custom_target(${config_file}-json ALL
-                    COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/macos/${config_file}.json
-                    VERBATIM
-                    )
+                                  COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/macos/${config_file}.json
+                                  VERBATIM)
             endforeach(config_file)
         endif()
     endif()
 else()
     # extra setup for out-of-tree builds
-    if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
-        foreach (config_file ${LAYER_JSON_FILES})
-            add_custom_target(${config_file}-json ALL
-                COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json
-                VERBATIM
-                )
+    if(NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
+        foreach(config_file ${LAYER_JSON_FILES})
+            add_custom_target(${config_file}-json ALL COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json VERBATIM)
         endforeach(config_file)
     endif()
 endif()
 
-if (WIN32)
+if(WIN32)
     macro(add_vk_layer target)
-    FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/VkLayer_${target}.def DEF_FILE)
-    add_custom_target(copy-${target}-def-file ALL
-        COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEF_FILE} VkLayer_${target}.def
-        VERBATIM
-    )
-    set_target_properties(copy-${target}-def-file PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
-    add_library(VkLayer_${target} SHARED ${ARGN} VkLayer_${target}.def)
-    add_dependencies(VkLayer_${target} generate_helper_files)
+        file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/VkLayer_${target}.def DEF_FILE)
+        add_custom_target(copy-${target}-def-file ALL
+                          COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEF_FILE} VkLayer_${target}.def
+                          VERBATIM)
+        set_target_properties(copy-${target}-def-file PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
+        add_library(VkLayer_${target} SHARED ${ARGN} VkLayer_${target}.def)
+        add_dependencies(VkLayer_${target} generate_helper_files)
     endmacro()
 elseif(APPLE)
     macro(add_vk_layer target)
-    add_library(VkLayer_${target} SHARED ${ARGN})
-    add_dependencies(VkLayer_${target} generate_helper_files)
-    set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl")
+        add_library(VkLayer_${target} SHARED ${ARGN})
+        add_dependencies(VkLayer_${target} generate_helper_files)
+        set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl")
     endmacro()
 else()
     macro(add_vk_layer target)
-    add_library(VkLayer_${target} SHARED ${ARGN})
-    add_dependencies(VkLayer_${target} generate_helper_files)
-    set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic")
+        add_library(VkLayer_${target} SHARED ${ARGN})
+        add_dependencies(VkLayer_${target} generate_helper_files)
+        set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic")
     endmacro()
 endif()
 
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}
-    ${CMAKE_CURRENT_SOURCE_DIR}/../../loader
-    ${PROJECT_SOURCE_DIR}/Vulkan-Headers/include
-    ${CMAKE_CURRENT_BINARY_DIR}
-    ${PROJECT_BINARY_DIR}
-    ${CMAKE_BINARY_DIR}
-)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+                    ${CMAKE_CURRENT_SOURCE_DIR}/../../loader
+                    ${PROJECT_SOURCE_DIR}/Vulkan-Headers/include
+                    ${CMAKE_CURRENT_BINARY_DIR}
+                    ${PROJECT_BINARY_DIR}
+                    ${CMAKE_BINARY_DIR})
 
-if (WIN32)
-    set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS")
-    set (CMAKE_C_FLAGS_RELEASE   "${CMAKE_C_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS")
-    set (CMAKE_CXX_FLAGS_DEBUG   "${CMAKE_CXX_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj")
-    set (CMAKE_C_FLAGS_DEBUG     "${CMAKE_C_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj")
+if(WIN32)
+    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS")
+    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS")
+    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj")
+    set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj")
 else()
-    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith -Wno-unused-function")
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith -Wno-unused-function")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith -Wno-unused-function")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith -Wno-unused-function")
 endif()
 
-set (WRAP_SRCS
-       wrap_objects.cpp
-       vk_layer_table.cpp
-       vk_layer_extension_utils.cpp
-       )
+set(WRAP_SRCS wrap_objects.cpp vk_layer_table.cpp vk_layer_extension_utils.cpp)
 add_vk_layer(wrap_objects ${WRAP_SRCS})
 
-set (TEST_SRCS
-       test.cpp
-       vk_layer_table.cpp
-       vk_layer_extension_utils.cpp
-       )
+set(TEST_SRCS test.cpp vk_layer_table.cpp vk_layer_extension_utils.cpp)
 add_vk_layer(test ${TEST_SRCS})