Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable build scripts #6

Closed
mctb32 opened this issue Mar 1, 2018 · 1 comment
Closed

Customizable build scripts #6

mctb32 opened this issue Mar 1, 2018 · 1 comment

Comments

@mctb32
Copy link

mctb32 commented Mar 1, 2018

Add ability for the users of the library to easily customize the diligent build options - provide custom list of build targets and pass custom compiler options.

@DiligentGraphics
Copy link
Collaborator

DiligentGraphics commented Mar 5, 2018

Fixed in e7501a4

I added a section to the main repo's readme describing how to use custom build configuration file. To have four configurations (Debug, DebugMT, Release, ReleaseMT) you can start with the following BuildConfig.cmake file:

function(custom_configure_build)
    if(CMAKE_CONFIGURATION_TYPES)
        # Debug configurations
        set(DEBUG_CONFIGURATIONS DEBUG DEBUGMT CACHE INTERNAL "" FORCE)
        # Release (optimized) configurations
        set(RELEASE_CONFIGURATIONS RELEASE RELEASEMT CACHE INTERNAL "" FORCE)
        # CMAKE_CONFIGURATION_TYPES variable defines build configurations generated by cmake
        set(CMAKE_CONFIGURATION_TYPES Debug DebugMT Release ReleaseMT CACHE STRING "Configuration types: Debug, DebugMT, Release, ReleaseMT" FORCE)

        set(DEBUG_CPP_FLAGS "/MTd /Od /W4 /wd4100 /wd4505")
        set(DEBUG_C_FLAGS "/MTd /Od /W4 /wd4100 /wd4505")

        set(CMAKE_CXX_FLAGS_DEBUGMT ${DEBUG_CPP_FLAGS} CACHE INTERNAL "" FORCE)
        set(CMAKE_C_FLAGS_DEBUGMT ${DEBUG_C_FLAGS} CACHE INTERNAL "" FORCE)
        set(CMAKE_EXE_LINKER_FLAGS_DEBUGMT "/OPT:REF" CACHE INTERNAL "" FORCE)
        set(CMAKE_SHARED_LINKER_FLAGS_DEBUGMT "/OPT:REF" CACHE INTERNAL "" FORCE)

        set(RELEASE_CPP_FLAGS "/MT /W4 /wd4100 /wd4505 /arch:AVX2 /wd4189 /GR- /GL /GF")
        set(RELEASE_C_FLAGS "/MT /W4 /wd4100 /wd4505 /arch:AVX2 /wd4189 /GR- /GL /GF")

        set(CMAKE_CXX_FLAGS_RELEASEMT ${RELEASE_CPP_FLAGS}  CACHE INTERNAL "" FORCE)
        set(CMAKE_C_FLAGS_RELEASEMT ${RELEASE_C_FLAGS} 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()

I also fixed build system to properly target 8.1 SDK, so that you can run the following command to generate x86 solution with four configurations defined in the config file:

cmake -D BUILD_CONFIGURATION_FILE=BuildConfig.cmake -D CMAKE_SYSTEM_VERSION=8.1 -H. -B./cmk_build/Win32 -G "Visual Studio 15 2017"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant