include(${CMAKE_CURRENT_LIST_DIR}/gtest_gmock/gtest_gmock.cmake)

macro(run_after_build TARGET)
    add_custom_command(
        TARGET ${TARGET}
        POST_BUILD
        COMMAND ${TARGET}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    )
endmacro(run_after_build)

macro(optimize_release_for_speed)
if(NOT CSHELF_OPTIMIZE_RELEASE_FOR_SPEED_ENTERED)
set(CSHELF_OPTIMIZE_RELEASE_FOR_SPEED_ENTERED TRUE) 
    if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
        set(CSHELF_OPTIMIZE_RELEASE_FOR_SPEED_FLAGS "-O4")   
    elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
        set(CSHELF_OPTIMIZE_RELEASE_FOR_SPEED_FLAGS "/O2 /Ob2 /Oi /Ot /Oy /GT /GL")          
    endif()
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CSHELF_OPTIMIZE_RELEASE_FOR_SPEED_FLAGS}")
endif()
endmacro(optimize_release_for_speed)

macro(use_cpp11)
if(NOT CSHELF_USE_CPP11_ENTERED)
set(CSHELF_USE_CPP11_ENTERED TRUE) 
    if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
        set(CSHELF_USE_CPP11_FLAGS "-std=c++11")
    endif()   
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CSHELF_USE_CPP11_FLAGS}")
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CSHELF_USE_CPP11_FLAGS}") 
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CSHELF_USE_CPP11_FLAGS}")
endif()
endmacro(use_cpp11) 

macro(use_max_warning_level)
if(NOT CSHELF_USE_MAX_WARNING_LEVEL_ENTERED)
set(CSHELF_USE_MAX_WARNING_LEVEL_ENTERED TRUE) 
    if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
        set(CSHELF_MAX_WARNING_LEVEL_FLAGS "-Weverything")
    elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
        set(CSHELF_MAX_WARNING_LEVEL_FLAGS "-Wall -Wextra")
    elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
        set(CSHELF_MAX_WARNING_LEVEL_FLAGS "/Wall")
    endif()   
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CSHELF_MAX_WARNING_LEVEL_FLAGS}")
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CSHELF_MAX_WARNING_LEVEL_FLAGS}")   
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CSHELF_MAX_WARNING_LEVEL_FLAGS}")	
endif()	
endmacro(use_max_warning_level)

macro(treat_warnings_as_errors)
if(NOT CSHELF_TREAT_WARNINGS_AS_ERRORS_ENTERED)
set(CSHELF_TREAT_WARNINGS_AS_ERRORS_ENTERED TRUE) 
    if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
        set(CSHELF_TREAT_WARNINGS_AS_ERRORS_FLAGS "-Werror")
    elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
        set(CSHELF_TREAT_WARNINGS_AS_ERRORS_FLAGS "/WX")
    endif() 
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CSHELF_TREAT_WARNINGS_AS_ERRORS_FLAGS}")
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CSHELF_TREAT_WARNINGS_AS_ERRORS_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CSHELF_TREAT_WARNINGS_AS_ERRORS_FLAGS}")	
endif()
endmacro(treat_warnings_as_errors)



