summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-03-05 16:35:23 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-03-05 16:35:23 +0000
commite7501a4957d99b7cf2e6184092da101ead6ca3df (patch)
tree26b4f90904d87a386784513a2e84e03aa5e32de0
parentAdded current progress to readme (diff)
downloadDiligentEngine-e7501a4957d99b7cf2e6184092da101ead6ca3df.tar.gz
DiligentEngine-e7501a4957d99b7cf2e6184092da101ead6ca3df.zip
Enabled build customization
-rw-r--r--CMakeLists.txt4
m---------DiligentCore0
-rw-r--r--README.md101
-rw-r--r--TestBuildScript.cmake23
-rw-r--r--unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt8
5 files changed, 128 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 83beca2..75250a3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,8 +15,8 @@ if(ENABLE_TESTS)
add_subdirectory(Tests)
endif()
-if(PLATFORM_WIN32)
+if(TARGET Asteroids)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT Asteroids)
-elseif(PLATFORM_UNIVERSAL_WINDOWS)
+elseif(TARGET AtmosphereSample)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT AtmosphereSample)
endif()
diff --git a/DiligentCore b/DiligentCore
-Subproject 0d043410aeccfa59a1259edf8b6a6cbcdbc9b76
+Subproject a515d18c3fe6097445f9e5817a5a6576ca205a4
diff --git a/README.md b/README.md
index 0b4fede..c867b92 100644
--- a/README.md
+++ b/README.md
@@ -125,6 +125,10 @@ To generate build files for Universal Windows platform, you need to define the f
For example, to generate Visual Studio 2017 64-bit solution and project files in *cmk_build/UWP64* folder, run the following command
from the engine's root folder:
+*cmake -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 -H. -B./cmk_build/UWP64 -G "Visual Studio 15 2017 Win64"*
+
+You can target specific SDK version by refining CMAKE_SYSTEM_VERSION, for instance:
+
*cmake -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0.15063.0 -H. -B./cmk_build/UWP64 -G "Visual Studio 15 2017 Win64"*
Set the desired project as startup project (by default, Atmosphere sample will be selected) and run it.
@@ -194,6 +198,103 @@ Run the command below from the engine's root folder to generate Xcode project co
Open Xcode project file in cmk_build/IOS folder and build the engine. To run the applications on an iOS device,
you will need to set the appropriate development team in the project settings.
+## Customizing Build
+
+Diligent Engine allows clients to customize build settings by providing configuration script file that defines two optional functions:
+
+* `custom_configure_build()` - defines global build properties such as build configurations, c/c++ compile flags, link flags etc.
+* `custom_configure_target()` - defines custom settings for every target in the build.
+
+The path to the configuration script should be provided through `BUILD_CONFIGURATION_FILE` variable when running
+cmake and must be relative to the cmake root folder, for example:
+
+*cmake -D BUILD_CONFIGURATION_FILE=BuildConfig.cmake -H. -B./cmk_build/Win64 -G "Visual Studio 15 2017 Win64"*
+
+### Customizing global build settings with custom_configure_build() function
+
+If defined, `custom_configure_build()` function is called before any build target is added. By default,
+cmake defines the following four configurations: Debug, Release, RelWithDebInfo, MinSizeRel. If you want,
+you can define your own build configurations by setting `CMAKE_CONFIGURATION_TYPES` variable. For instance,
+if you want to have only two configuration: Debug and ReleaseMT, add the following line to the `custom_configure_build()`
+function:
+
+```cmake
+set(CMAKE_CONFIGURATION_TYPES Debug ReleaseMT CACHE STRING "Configuration types: Debug, ReleaseMT" FORCE)
+```
+
+The build system needs to know the list of debug and release (optimized) configurations, so the following
+two variables must also be set when `CMAKE_CONFIGURATION_TYPES` variable is defined:
+
+```cmake
+set(DEBUG_CONFIGURATIONS DEBUG CACHE INTERNAL "" FORCE)
+set(RELEASE_CONFIGURATIONS RELEASEMT CACHE INTERNAL "" FORCE)
+```
+
+Note that due to cmake specifics, configuration names listed in `DEBUG_CONFIGURATIONS` and `RELEASE_CONFIGURATIONS`
+**must be capitalized**.
+
+If you define any configuration other than four standard cmake ones, you also need to set the following variables, for every
+new configuration:
+
+* `CMAKE_C_FLAGS_<Config>` - c compile flags
+* `CMAKE_CXX_FLAGS_<Config>` - c++ compile flags
+* `CMAKE_EXE_LINKER_FLAGS_<Config>` - executable link flags
+* `CMAKE_SHARED_LINKER_FLAGS_<Config>` - shared library link flags
+
+For instance:
+
+```cmake
+set(CMAKE_C_FLAGS_RELEASEMT /MT CACHE INTERNAL "" FORCE)
+set(CMAKE_CXX_FLAGS_RELEASEMT /MT CACHE INTERNAL "" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS_RELEASEMT "/OPT:REF" CACHE INTERNAL "" FORCE)
+set(CMAKE_SHARED_LINKER_FLAGS_RELEASEMT "/OPT:REF" CACHE INTERNAL "" FORCE)
+```
+
+Below is an example of custom_configure_build() function:
+
+```cmake
+function(custom_configure_build)
+ if(CMAKE_CONFIGURATION_TYPES)
+ # Debug configurations
+ set(DEBUG_CONFIGURATIONS DEBUG CACHE INTERNAL "" FORCE)
+ # Release (optimized) configurations
+ set(RELEASE_CONFIGURATIONS RELEASEMT CACHE INTERNAL "" FORCE)
+ # CMAKE_CONFIGURATION_TYPES variable defines build configurations generated by cmake
+ set(CMAKE_CONFIGURATION_TYPES Debug ReleaseMT CACHE STRING "Configuration types: Debug, ReleaseMT" FORCE)
+
+ set(CMAKE_CXX_FLAGS_RELEASEMT "/MT" CACHE INTERNAL "" FORCE)
+ set(CMAKE_C_FLAGS_RELEASEMT "/MT" CACHE INTERNAL "" FORCE)
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASEMT "/OPT:REF" CACHE INTERNAL "" FORCE)
+ set(CMAKE_SHARED_LINKER_FLAGS_RELEASEMT "/OPT:REF" CACHE INTERNAL "" FORCE)
+ endif()
+endfunction()
+```
+
+
+### Customizing individual target build settings with custom_configure_target() function
+
+If defined, `custom_configure_target()` is called for every target created by the build system and
+allows configuring target-specific properties.
+
+By default, the build system sets some target properties. If `custom_configure_target()` sets all required properties,
+it can tell the build system that no further processing is required by setting `TARGET_CONFIGURATION_COMPLETE` parent
+scope variable to `TRUE`:
+
+```cmake
+set(TARGET_CONFIGURATION_COMPLETE TRUE PARENT_SCOPE)
+```
+
+The following is an example of `custom_configure_target()` function:
+
+```cmake
+function(custom_configure_target TARGET)
+ set_target_properties(${TARGET} PROPERTIES
+ STATIC_LIBRARY_FLAGS_RELEASEMT /LTCG
+ )
+ set(TARGET_CONFIGURATION_COMPLETE TRUE PARENT_SCOPE)
+endfunction()
+```
+
# Tutorials
## [Tutorial 01 - Hello Triangle](https://github.com/DiligentGraphics/DiligentSamples/blob/master/Tutorials/Tutorial01_HelloTriangle)
diff --git a/TestBuildScript.cmake b/TestBuildScript.cmake
new file mode 100644
index 0000000..c11f812
--- /dev/null
+++ b/TestBuildScript.cmake
@@ -0,0 +1,23 @@
+
+function(custom_configure_build)
+ if(CMAKE_CONFIGURATION_TYPES)
+ # Debug configurations
+ set(DEBUG_CONFIGURATIONS DEBUG CACHE INTERNAL "" FORCE)
+ # Release (optimized) configurations
+ set(RELEASE_CONFIGURATIONS RELEASEMT CACHE INTERNAL "" FORCE)
+ # CMAKE_CONFIGURATION_TYPES variable defines build configurations generated by cmake
+ set(CMAKE_CONFIGURATION_TYPES Debug ReleaseMT CACHE STRING "Configuration types: Debug, ReleaseMT" FORCE)
+
+ set(CMAKE_CXX_FLAGS_RELEASEMT "/MT" CACHE INTERNAL "" FORCE)
+ set(CMAKE_C_FLAGS_RELEASEMT "/MT" CACHE INTERNAL "" FORCE)
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASEMT "/OPT:REF" CACHE INTERNAL "" FORCE)
+ set(CMAKE_SHARED_LINKER_FLAGS_RELEASEMT "/OPT:REF" CACHE INTERNAL "" FORCE)
+ endif()
+endfunction()
+
+function(custom_configure_target TARGET)
+ set_target_properties(${TARGET} PROPERTIES
+ STATIC_LIBRARY_FLAGS_RELEASEMT /LTCG
+ )
+ #set(TARGET_CONFIGURATION_COMPLETE TRUE PARENT_SCOPE)
+endfunction() \ No newline at end of file
diff --git a/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt b/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt
index 29eeed4..d7388ad 100644
--- a/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt
+++ b/unityplugin/GhostCubePlugin/PluginSource/CMakeLists.txt
@@ -43,12 +43,8 @@ if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS)
set(DLL_REL_SUFFIX _${ARCH}r)
set(DLL_DBG_SUFFIX _${ARCH}d)
- set_target_properties(GhostCubePlugin-shared PROPERTIES
- OUTPUT_NAME_DEBUG GhostCubePlugin${DLL_DBG_SUFFIX}
- OUTPUT_NAME_RELEASE GhostCubePlugin${DLL_REL_SUFFIX}
- OUTPUT_NAME_RELWITHDEBINFO GhostCubePlugin${DLL_REL_SUFFIX}
- OUTPUT_NAME_MINSIZEREL GhostCubePlugin${DLL_REL_SUFFIX}
- )
+ set_dll_output_name(GhostCubePlugin-shared GhostCubePlugin)
+
else()
set_target_properties(GhostCubePlugin-shared PROPERTIES
OUTPUT_NAME GhostCubePlugin