CMakeLists.txt and doc changes for

1) Ninja build and QTCreator IDE support
2) Out of tree builds that aren't based on using update_external_sources and build_windows_target scripts
3) Allowing the developer to use non-default locations for glslang and SPIRV-Tools binaries and sources
4) Fix linux build when developer chooses not to rename SPIRV-Tools to spirv-tools

Change-Id: Ib6118c47dc780e6721ec0538aae1a6ee444eed78
This commit is contained in:
Mark Mueller 2016-04-18 11:04:36 -06:00
parent 1716b344b8
commit 3f7404b513
3 changed files with 153 additions and 53 deletions

View File

@ -33,10 +33,10 @@ These packages are needed to build this repository:
sudo apt-get install git cmake build-essential bison libx11-dev libxcb1-dev
```
Example debug build:
Example debug build (Note that the update\_external\_sources script used below builds external tools into predefined locations. See **LVL's Dependencies** for more information and other options):
```
cd Vulkan-LoaderAndValidationLayers # cd to the root of the cloned git repository
./update_external_sources.sh # Fetches and builds glslang and spirv-tools
./update_external_sources.sh
cmake -H. -Bdbuild -DCMAKE_BUILD_TYPE=Debug
cd dbuild
make
@ -63,7 +63,7 @@ packaged, and how developers can point to ICDs and layers within their builds.
The test executables can be found in the dbuild/tests directory.
Some of the tests that are available:
- vk_layer_validation_tests: Test Vulkan layers.
- vk\_layer\_validation\_tests: Test Vulkan layers.
There are also a few shell and Python scripts that run test collections (eg,
`run_all_tests.sh`).
@ -81,36 +81,26 @@ Some demos that can be found in the dbuild/demos directory are:
Windows 7+ with additional required software packages:
- Microsoft Visual Studio 2013 Professional. Note: it is possible that lesser/older versions may work, but that has not been tested.
- CMake (from http://www.cmake.org/download/). Notes:
- [CMake](http://www.cmake.org/download/). Notes:
- Tell the installer to "Add CMake to the system PATH" environment variable.
- Python 3 (from https://www.python.org/downloads). Notes:
- [Python 3](https://www.python.org/downloads). Notes:
- Select to install the optional sub-package to add Python to the system PATH environment variable.
- Ensure the pip module is installed (it should be by default)
- Need python3.3 or later to get the Windows py.exe launcher that is used to get python3 rather than python2 if both are installed on Windows
- 32 bit python works
- Git (from http://git-scm.com/download/win).
- Note: If you use Cygwin, you can normally use Cygwin's "git.exe". However, in order to use the "update_external_sources.bat" script, you must have this version.
- [Git](http://git-scm.com/download/win).
- Note: If you use Cygwin, you can normally use Cygwin's "git.exe". However, in order to use the "update\_external\_sources.bat" script, you must have this version.
- Tell the installer to allow it to be used for "Developer Prompt" as well as "Git Bash".
- Tell the installer to treat line endings "as is" (i.e. both DOS and Unix-style line endings).
- Install each a 32-bit and a 64-bit version, as the 64-bit installer does not install the 32-bit libraries and tools.
- glslang is required for demos and tests.
- You can download and configure it (in a peer directory) here: https://github.com/KhronosGroup/glslang/blob/master/README.md
- [You can download and configure it (in a peer directory) here](https://github.com/KhronosGroup/glslang/blob/master/README.md)
- A windows batch file has been included that will pull and build the correct version. Run it from Developer Command Prompt for VS2013 like so:
- update_external_sources.bat --build-glslang
- update\_external\_sources.bat --build-glslang (Note: see **LVL's Dependencies** below for other options)
Optional software packages:
## Windows Build - MSVC
- Cygwin (from https://www.cygwin.com/). Notes:
- Cygwin provides some Linux-like tools, which are valuable for obtaining the source code, and running CMake.
Especially valuable are the BASH shell and git packages.
- If you don't want to use Cygwin, there are other shells and environments that can be used.
You can also use a Git package that doesn't come from Cygwin.
## Windows Build
Cygwin is used in order to obtain a local copy of the Git repository, and to run the CMake command that creates Visual Studio files. Visual Studio is used to build the software, and will re-run CMake as appropriate.
To build all Windows targets (e.g. in a "Developer Command Prompt for VS2013" window):
Build all Windows targets after installing required software and cloning the LVL repo as described above by completing the following steps in a "Developer Command Prompt for VS2013" window (Note that the update\_external\_sources script used below builds external tools into predefined locations. See **LVL's Dependencies** for more information and other options):
```
cd Vulkan-LoaderAndValidationLayers # cd to the root of the cloned git repository
update_external_sources.bat --all
@ -130,8 +120,7 @@ packaged, and how developers can point to ICDs and layers within their builds.
Install the required tools for Linux and Windows covered above, then add the
following.
### Android Studio
- Install Android Studio 2.1, latest Preview (tested with 4):
- http://tools.android.com/download/studio/canary
- Install [Android Studio 2.1](http://tools.android.com/download/studio/canary), latest Preview (tested with 4):
- From the "Welcome to Android Studio" splash screen, add the following components using Configure > SDK Manager:
- SDK Platforms > Android N Preview
- SDK Tools > Android NDK
@ -186,3 +175,50 @@ update_external_sources_android.bat
android-generate.bat
ndk-build
```
## Ninja Builds - All Platforms
The [Qt Creator IDE](https://qt.io/download-open-source/#section-2) can open a root CMakeList.txt as a project directly, and it provides tools within Creator to configure and generate Vulkan SDK build files for one to many targets concurrently, resolving configuration issues as needed. Alternatively, when invoking CMake use the -G Codeblocks Ninja option to generate Ninja build files to be used as project files for QtCreator
- Follow the steps defined elsewhere for the OS using the update\_external\_sources script or as shown in **LVL's Dependencies** below
- Open, configure, and build the gslang and spirv-tools CMakeList.txt files
- Then do the same with the Vulkan-LoaderAndValidationLayers CMakeList.txt file.
- In order to debug with QtCreator, a [Microsoft WDK: eg WDK 10](http://go.microsoft.com/fwlink/p/?LinkId=526733) is required. Note that installing the WDK breaks the MSVC vcvarsall.bat build scripts provided by MSVC, requiring that the LIB, INCLUDE, and PATH env variables be set to the WDK paths by some other means
## LVL's Dependencies
gslang and SPIRV-Tools repos are required to build and run LVL components. They are not git sub-modules of Vulkan-LoaderAndValidationLayers but Vulkan-LoaderAndValidationLayers is linked to specific revisions of gslang and spirv-tools. These can be automatically cloned and built to predefined locations with the update\_external\_sources scripts. If a custom configuration is required, do the following steps:
1) clone the repos:
git clone https://github.com/KhronosGroup/glslang.git
git clone https://github.com/KhronosGroup/SPIRV-Tools.git
2) checkout the correct version of each tree based on the contents of the glslang\_revision and spirv-tools\_revision files at the root of the Vulkan-LoaderAndValidationLayers tree (do the same anytime that Vulkan-LoaderAndValidationLayers is updated from remote)
_on windows_
git checkout < [path to Vulkan-LoaderAndValidationLayers]\glslang_revision [in glslang repo]
git checkout < [path to Vulkan-LoaderAndValidationLayers]\spirv-tools_revision[in spriv-tools repo]
*non windows*
git checkout `cat [path to Vulkan-LoaderAndValidationLayers]\glslang_revision` [in glslang repo]
git checkout `cat [path to Vulkan-LoaderAndValidationLayers]\spirv-tools_revision` [in spriv-tools repo]
3) Configure the gslang and spirv-tools source trees with cmake and build them with your IDE of choice
4) Enable the CUSTOM\_GSLANG\_BIN\_PATH and CUSTOM\_SPIRV\_TOOLS\_BIN\_PATH options in the Vulkan-LoaderAndValidationLayers cmake configuration and point the GSLANG\_BINARY\_PATH and SPIRV\_TOOLS\_BINARY\_PATH variables to the correct location
5) If building on Windows with MSVC, set DISABLE\_BUILDTGT\_DIR\_DECORATION to _On_. If building on Windows, but without MSVC set DISABLE\_BUILD\_PATH\_DECORATION to _On_
## Optional software packages:
- [Cygwin for windows](https://www.cygwin.com/). Notes:
- Cygwin provides some Linux-like tools, which are valuable for obtaining the source code, and running CMake.
Especially valuable are the BASH shell and git packages.
- If you don't want to use Cygwin, there are other shells and environments that can be used.
You can also use a Git package that doesn't come from Cygwin.
- [Ninja on all platforms](https://github.com/ninja-build/ninja/releases). [The Ninja-build project](ninja-build.org). [Ninja Users Manual](ninja-build.org/manual.html)
- [QtCreator as IDE for CMake builds on all platforms](https://qt.io/download-open-source/#section-2)

View File

@ -76,10 +76,17 @@ if(NOT WIN32)
set (BINDATA_DIR Bin)
set (LIBSOURCE_DIR Lib)
else()
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)
# 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)
if (DISABLE_BUILDTGT_DIR_DECORATION)
set (BUILDTGT_DIR "")
set (BINDATA_DIR "")
set (LIBSOURCE_DIR "")
elseif (CMAKE_CL_64)
set (BUILDTGT_DIR build)
set (BINDATA_DIR Bin)
set (LIBSOURCE_DIR Lib)
@ -95,29 +102,88 @@ option(BUILD_TESTS "Build tests" ON)
option(BUILD_LAYERS "Build layers" ON)
option(BUILD_DEMOS "Build demos" ON)
option(BUILD_VKJSON "Build vkjson" 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" OFF)
#Choose natural default paths for glslang and SPIRV-Tools binaries to support custom definition by the user on the CMake command line or in the GUI
set(GLSLANG_BINARY_ROOT "${CMAKE_BINARY_DIR}/../glslang" CACHE STRING "User defined path to the glslang binaries for this project")
set(SPRIV_TOOLS_BINARY_ROOT "${CMAKE_BINARY_DIR}/../SPIRV-Tools" CACHE STRING "User defined path to the SPIRV-Tools binaries for this project")
# Define a variable for a default root location to the gslang, SPIRV-Tools and other external sources and cache it to allow the user to customize it as needed
set(EXTERNAL_SOURCE_ROOT "${CMAKE_SOURCE_DIR}/external" CACHE STRING "Root path to external sources such as glslang and SPIRV-Tools")
if (WIN32)
if(CUSTOM_GLSLANG_BIN_ROOT)
set(GSLANG_FINAL_BINARY_PATH ${GLSLANG_BINARY_ROOT}/${BUILDTGT_DIR})
else()
set(GSLANG_FINAL_BINARY_PATH "${EXTERNAL_SOURCE_ROOT}/glslang/${BUILDTGT_DIR}")
endif()
if(DISABLE_BUILD_PATH_DECORATION)
set (DEBUG_DECORATION "")
set (RELEASE_DECORATION "")
else()
set (DEBUG_DECORATION "Debug")
set (RELEASE_DECORATION "Release")
endif()
# Take some steps to set up a variable pointing to the final glslang binaries given the variety of input options
set (GLSLANG_SEARCH_PATH "${GSLANG_FINAL_BINARY_PATH}/glslang/${RELEASE_DECORATION}"
"${GSLANG_FINAL_BINARY_PATH}/glslang/OSDependent/Windows/${RELEASE_DECORATION}"
"${GSLANG_FINAL_BINARY_PATH}/hlsl/${RELEASE_DECORATION}"
"${GSLANG_FINAL_BINARY_PATH}/OGLCompilersDLL/${RELEASE_DECORATION}"
"${GSLANG_FINAL_BINARY_PATH}/SPIRV/${RELEASE_DECORATION}" )
set (GLSLANG_DEBUG_SEARCH_PATH "${GSLANG_FINAL_BINARY_PATH}/glslang/${DEBUG_DECORATION}"
"${GSLANG_FINAL_BINARY_PATH}/glslang/OSDependent/Windows/${DEBUG_DECORATION}"
"${GSLANG_FINAL_BINARY_PATH}/hlsl/${DEBUG_DECORATION}"
"${GSLANG_FINAL_BINARY_PATH}/OGLCompilersDLL/${DEBUG_DECORATION}"
"${GSLANG_FINAL_BINARY_PATH}/SPIRV/${DEBUG_DECORATION}")
if(CUSTOM_SPIRV_TOOLS_BIN_ROOT)
set (SPIRV_TOOLS_SEARCH_PATH "${SPRIV_TOOLS_BINARY_ROOT}/${BUILDTGT_DIR}/source/${RELEASE_DECORATION}")
set (SPIRV_TOOLS_DEBUG_SEARCH_PATH "${SPRIV_TOOLS_BINARY_ROOT}/${BUILDTGT_DIR}/source/${DEBUG_DECORATION}")
else()
set (SPIRV_TOOLS_SEARCH_PATH "${EXTERNAL_SOURCE_ROOT}/spirv-tools/${BUILDTGT_DIR}/source/${RELEASE_DECORATION}")
set (SPIRV_TOOLS_DEBUG_SEARCH_PATH "${EXTERNAL_SOURCE_ROOT}/spirv-tools/${BUILDTGT_DIR}/source/${DEBUG_DECORATION}")
endif()
else()
#non windows
if(CUSTOM_GLSLANG_BIN_ROOT)
set (GLSLANG_SEARCH_PATH "${GLSLANG_BINARY_ROOT}/install/lib"
"${GLSLANG_BINARY_ROOT}/glslang"
"${GLSLANG_BINARY_ROOT}/glslang/OSDependent/Unix"
"${GLSLANG_BINARY_ROOT}/OGLCompilersDLL"
"${GLSLANG_BINARY_ROOT}/SPIRV"
"${GLSLANG_BINARY_ROOT}/hlsl"
"${GLSLANG_BINARY_ROOT}/StandAlone")
else()
set (GLSLANG_SEARCH_PATH "${EXTERNAL_SOURCE_ROOT}/glslang/${BUILDTGT_DIR}/install/lib" "${CMAKE_SOURCE_DIR}/../x86_64/lib/glslang" )
endif()
if(CUSTOM_SPIRV_TOOLS_BIN_ROOT)
set (SPIRV_TOOLS_SEARCH_PATH "${SPRIV_TOOLS_BINARY_ROOT}/source" )
else()
set (SPIRV_TOOLS_SEARCH_PATH "${EXTERNAL_SOURCE_ROOT}/spirv-tools/${BUILDTGT_DIR}/source" "${CMAKE_SOURCE_DIR}/../x86_64/lib/spirv-tools" )
endif()
endif()
find_program(GLSLANG_VALIDATOR NAMES glslangValidator
HINTS "${CMAKE_SOURCE_DIR}/external/glslang/${BUILDTGT_DIR}/install/bin"
"${PROJECT_SOURCE_DIR}/../${BINDATA_DIR}" )
"${GLSLANG_BINARY_ROOT}/StandAlone"
"${PROJECT_SOURCE_DIR}/external/${BINDATA_DIR}")
find_path(GLSLANG_SPIRV_INCLUDE_DIR SPIRV/spirv.hpp HINTS "${CMAKE_SOURCE_DIR}/external/glslang" DOC "Path to SPIRV/spirv.hpp")
find_path(SPIRV_TOOLS_INCLUDE_DIR spirv-tools/libspirv.h HINTS "${CMAKE_SOURCE_DIR}/external/spirv-tools/include"
"${CMAKE_SOURCE_DIR}/external/source/spirv-tools/include"
"${CMAKE_SOURCE_DIR}/external/spirv-tools/external/include"
"${CMAKE_SOURCE_DIR}/external/source/spirv-tools/external/include"
DOC "Path to spirv-tools/libspirv.h")
find_path(GLSLANG_SPIRV_INCLUDE_DIR SPIRV/spirv.hpp HINTS "${EXTERNAL_SOURCE_ROOT}/glslang"
"${CMAKE_SOURCE_DIR}/../glslang"
DOC "Path to SPIRV/spirv.hpp")
if (WIN32)
set (GLSLANG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/external/glslang/${BUILDTGT_DIR}/glslang/Release"
"${CMAKE_SOURCE_DIR}/external/glslang/${BUILDTGT_DIR}/glslang/OSDependent/Windows/Release"
"${CMAKE_SOURCE_DIR}/external/glslang/${BUILDTGT_DIR}/hlsl/Release"
"${CMAKE_SOURCE_DIR}/external/glslang/${BUILDTGT_DIR}/OGLCompilersDLL/Release"
"${CMAKE_SOURCE_DIR}/external/glslang/${BUILDTGT_DIR}/SPIRV/Release" )
set (SPIRV_TOOLS_SEARCH_PATH "${CMAKE_SOURCE_DIR}/external/spirv-tools/${BUILDTGT_DIR}/source/Release")
else()
set (GLSLANG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/external/glslang/build/install/lib" "${CMAKE_SOURCE_DIR}/../x86_64/lib/glslang" )
set (SPIRV_TOOLS_SEARCH_PATH "${CMAKE_SOURCE_DIR}/external/spirv-tools/build/source" "${CMAKE_SOURCE_DIR}/../x86_64/lib/spirv-tools" )
endif()
find_path(SPIRV_TOOLS_INCLUDE_DIR spirv-tools/libspirv.h HINTS "${EXTERNAL_SOURCE_ROOT}/spirv-tools/include"
"${EXTERNAL_SOURCE_ROOT}/SPIRV-Tools/include"
"${CMAKE_SOURCE_DIR}/../spirv-tools/include"
"${CMAKE_SOURCE_DIR}/../SPIRV-Tools/include"
"${EXTERNAL_SOURCE_ROOT}/source/spirv-tools/external/include"
DOC "Path to spirv-tools/libspirv.h")
find_library(GLSLANG_LIB NAMES glslang
HINTS ${GLSLANG_SEARCH_PATH} )
@ -137,15 +203,7 @@ find_library(SPIRV_LIB NAMES SPIRV
find_library(SPIRV_TOOLS_LIB NAMES SPIRV-Tools
HINTS ${SPIRV_TOOLS_SEARCH_PATH} )
# On Windows, we must pair Debug and Release appropriately
if (WIN32)
set (GLSLANG_DEBUG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/external/glslang/${BUILDTGT_DIR}/glslang/Debug"
"${CMAKE_SOURCE_DIR}/external/glslang/${BUILDTGT_DIR}/glslang/OSDependent/Windows/Debug"
"${CMAKE_SOURCE_DIR}/external/glslang/${BUILDTGT_DIR}/hlsl/Debug"
"${CMAKE_SOURCE_DIR}/external/glslang/${BUILDTGT_DIR}/OGLCompilersDLL/Debug"
"${CMAKE_SOURCE_DIR}/external/glslang/${BUILDTGT_DIR}/SPIRV/Debug")
set (SPIRV_TOOLS_DEBUG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/external/spirv-tools/${BUILDTGT_DIR}/source/Debug")
add_library(glslang STATIC IMPORTED)
add_library(OGLCompiler STATIC IMPORTED)
add_library(OSDependent STATIC IMPORTED)

View File

@ -54,9 +54,15 @@ if (WIN32)
add_library(VKstatic.${MAJOR} STATIC $<TARGET_OBJECTS:loader-opt> $<TARGET_OBJECTS:loader-norm>)
set_target_properties(VKstatic.${MAJOR} PROPERTIES OUTPUT_NAME VKstatic.${MAJOR})
target_link_libraries(vulkan-${MAJOR} shlwapi)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/vulkan-${MAJOR}.dll COPY_SRC_PATH)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../demos/$<CONFIGURATION>/ COPY_DST_PATH)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../tests/$<CONFIGURATION>/ COPY_DST_TEST_PATH)
if (CMAKE_GENERATOR MATCHES "^Visual Studio.*")
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/vulkan-${MAJOR}.dll COPY_SRC_PATH)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../demos/$<CONFIGURATION>/ COPY_DST_PATH)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../tests/$<CONFIGURATION>/ COPY_DST_TEST_PATH)
else()
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/vulkan-${MAJOR}.dll COPY_SRC_PATH)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../demos/ COPY_DST_PATH)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../tests/ COPY_DST_TEST_PATH)
endif()
add_custom_command(TARGET vulkan-${MAJOR} POST_BUILD
COMMAND xcopy /Y /I ${COPY_SRC_PATH} ${COPY_DST_PATH})
add_custom_command(TARGET vulkan-${MAJOR} POST_BUILD