1# Cable: CMake Bootstrap Library. 2# Copyright 2018 Pawel Bylica. 3# Licensed under the Apache License, Version 2.0. See the LICENSE file. 4 5if(cable_build_type_included) 6 return() 7endif() 8set(cable_build_type_included TRUE) 9 10macro(cable_set_build_type) 11 if(NOT PROJECT_IS_NESTED) 12 # Do this configuration only in the top project. 13 if(PROJECT_SOURCE_DIR) 14 message(FATAL_ERROR "cable_set_build_type() can be used before project()") 15 endif() 16 17 cmake_parse_arguments(build_type "" DEFAULT CONFIGURATION_TYPES ${ARGN}) 18 19 if(CMAKE_CONFIGURATION_TYPES) 20 if(build_type_CONFIGURATION_TYPES) 21 set( 22 CMAKE_CONFIGURATION_TYPES 23 ${build_type_CONFIGURATION_TYPES} 24 CACHE 25 STRING 26 "Available configurations for multi-configuration generators" 27 FORCE 28 ) 29 endif() 30 cable_log("Configurations: ${CMAKE_CONFIGURATION_TYPES}") 31 else() 32 if(build_type_DEFAULT AND NOT CMAKE_BUILD_TYPE) 33 set( 34 CMAKE_BUILD_TYPE 35 ${build_type_DEFAULT} 36 CACHE STRING 37 "Build type for single-configuration generators" 38 FORCE 39 ) 40 endif() 41 cable_log("Build type: ${CMAKE_BUILD_TYPE}") 42 endif() 43 endif() 44endmacro() 45