Merge remote-tracking branch 'origin/upstream' into tizen
[platform/upstream/Vulkan-LoaderAndValidationLayers.git] / CMakeLists.txt
index 3a8a245..0e99e74 100644 (file)
@@ -2,6 +2,10 @@
 # refer to the root source directory of the project as ${VULKAN_SOURCE_DIR} and
 # to the root binary directory of the project as ${VULKAN_BINARY_DIR}.
 cmake_minimum_required(VERSION 2.8.11)
+
+# This must come before the project command.
+set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
+
 project (VULKAN)
 # set (CMAKE_VERBOSE_MAKEFILE 1)
 
@@ -24,16 +28,26 @@ if (USE_CCACHE)
     endif(CCACHE_FOUND)
 endif()
 
+if(APPLE)
+    # 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})
+endif()
+
 # Enable cmake folders
 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 set(LVL_TARGET_FOLDER lvl_cmake_targets)
 
-if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+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.")
+endif()
 
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
     include(FindPkgConfig)
     option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
     option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON)
@@ -80,7 +94,11 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
         set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -Wimplicit-fallthrough=0")
     endif()
 
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}")
+    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)
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
@@ -112,6 +130,7 @@ else()
     # is WIN32
     option(DISABLE_BUILD_PATH_DECORATION "Disable the decoration of the gslang and SPIRV-Tools build path with MSVC build type info" OFF)
     option(DISABLE_BUILDTGT_DIR_DECORATION "Disable the decoration of the gslang and SPIRV-Tools build path with target info" OFF)
+    option(ENABLE_WIN10_ONECORE "Link the loader with OneCore umbrella libraries" OFF)
 
     # 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
@@ -135,7 +154,11 @@ option(BUILD_LOADER "Build loader" ON)
 option(BUILD_TESTS "Build tests" ON)
 option(BUILD_LAYERS "Build layers" ON)
 option(BUILD_DEMOS "Build demos" ON)
-option(BUILD_VKJSON "Build vkjson" ON)
+if (APPLE)
+    option(BUILD_VKJSON "Build vkjson" OFF)
+else()
+    option(BUILD_VKJSON "Build vkjson" ON)
+endif()
 option(BUILD_ICD "Build icd" ON)
 option(CUSTOM_GLSLANG_BIN_ROOT "Use the user defined GLSLANG_BINARY_ROOT" OFF)
 option(CUSTOM_SPIRV_TOOLS_BIN_ROOT "Use the user defined SPIRV_TOOLS*BINARY_ROOT paths" OFF)
@@ -332,10 +355,12 @@ macro(run_external_revision_generate source_dir symbol_name output)
 endmacro()
 
 # Custom target for generated vulkan helper file dependencies
+set(generate_helper_files_DEPENDS)
+if(BUILD_LAYERS)
+    LIST(APPEND generate_helper_files_DEPENDS spirv_tools_commit_id.h)
+endif()
 add_custom_target(generate_helper_files DEPENDS
     vk_enum_string_helper.h
-    vk_struct_size_helper.h
-    vk_struct_size_helper.c
     vk_safe_struct.h
     vk_safe_struct.cpp
     vk_object_types.h
@@ -343,7 +368,7 @@ add_custom_target(generate_helper_files DEPENDS
     vk_dispatch_table_helper.h
     vk_extension_helper.h
     vk_typemap_helper.h
-    spirv_tools_commit_id.h
+    ${generate_helper_files_DEPENDS}
     )
 set_target_properties(generate_helper_files PROPERTIES FOLDER ${LVL_TARGET_FOLDER})
 
@@ -352,13 +377,13 @@ run_vk_xml_generate(loader_extension_generator.py vk_layer_dispatch_table.h)
 run_vk_xml_generate(dispatch_table_helper_generator.py vk_dispatch_table_helper.h)
 run_vk_xml_generate(helper_file_generator.py vk_safe_struct.h)
 run_vk_xml_generate(helper_file_generator.py vk_safe_struct.cpp)
-run_vk_xml_generate(helper_file_generator.py vk_struct_size_helper.h)
-run_vk_xml_generate(helper_file_generator.py vk_struct_size_helper.c)
 run_vk_xml_generate(helper_file_generator.py vk_enum_string_helper.h)
 run_vk_xml_generate(helper_file_generator.py vk_object_types.h)
 run_vk_xml_generate(helper_file_generator.py vk_extension_helper.h)
 run_vk_xml_generate(helper_file_generator.py vk_typemap_helper.h)
-run_external_revision_generate(${EXTERNAL_SOURCE_ROOT}/glslang/External/spirv-tools SPIRV_TOOLS_COMMIT_ID spirv_tools_commit_id.h)
+if(BUILD_LAYERS)
+    run_external_revision_generate(${EXTERNAL_SOURCE_ROOT}/glslang/External/spirv-tools SPIRV_TOOLS_COMMIT_ID spirv_tools_commit_id.h)
+endif()
 
 
 if(NOT WIN32)