1# - Contains a function to sensibly and easily enable the "USE_FOLDERS" global property
2# without burning people using old MSVC Express Editions.
3#
4#  use_folders([option_name]) - Creates an option (default name if you don't pass
5#    one: BUILD_WITH_PROJECT_FOLDERS) that controls the USE_FOLDERS global property.
6#    It has intelligently-set defaults that err on the side of caution (disabling)
7#    on old MSVC versions, since solutions generated with USE_FOLDERS set to ON
8#    cannot be used in some older MSVC Express Editions, so it's explicit opt-in there.
9#
10# Original Author:
11# 2015 Ryan Pavlik <ryan@sensics.com> <abiryan@ryand.net>
12# http://academic.cleardefinition.com
13#
14# Copyright Sensics, Inc. 2015.
15# Distributed under the Boost Software License, Version 1.0.
16# (See accompanying file LICENSE_1_0.txt or copy at
17# http://www.boost.org/LICENSE_1_0.txt)
18
19function(use_folders)
20    set(_option_name BUILD_WITH_PROJECT_FOLDERS)
21    if(ARGV0)
22        set(_option_name ${ARGV0})
23    endif()
24    # Nitpicky TODO: This unnecessarily defaults to project folders off when using
25    # an older toolset in a newer IDE...
26    if(MSVC_IDE AND MSVC_VERSION LESS 1600)
27        # VS 2012 Express and newer has folder support...
28        option(${_option_name} "Enable project folders in the IDE. May only work in non-Express Editions!" OFF)
29    else()
30        option(${_option_name} "Enable project folders in the IDE." ON)
31    endif()
32    set_property(GLOBAL PROPERTY
33        USE_FOLDERS ${${_option_name}})
34endfunction()