1# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2# file Copyright.txt or https://cmake.org/licensing for details.
3
4
5# This file sets the basic flags for the Windows Resource Compiler.
6# It also loads the available platform file for the system-compiler
7# if it exists.
8
9# make sure we don't use CMAKE_BASE_NAME from somewhere else
10set(CMAKE_BASE_NAME)
11if(CMAKE_RC_COMPILER MATCHES "windres[^/]*$")
12 set(CMAKE_BASE_NAME "windres")
13else()
14 get_filename_component(CMAKE_BASE_NAME ${CMAKE_RC_COMPILER} NAME_WE)
15endif()
16set(CMAKE_SYSTEM_AND_RC_COMPILER_INFO_FILE
17  ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
18include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
19
20# This should be included before the _INIT variables are
21# used to initialize the cache.  Since the rule variables
22# have if blocks on them, users can still define them here.
23# But, it should still be after the platform file so changes can
24# be made to those values.
25if(CMAKE_USER_MAKE_RULES_OVERRIDE)
26  # Save the full path of the file so try_compile can use it.
27  include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override)
28  set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}")
29endif()
30
31set(CMAKE_RC_FLAGS_INIT "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}")
32
33cmake_initialize_per_config_variable(CMAKE_RC_FLAGS "Flags for Windows Resource Compiler")
34
35# These are the only types of flags that should be passed to the rc
36# command, if COMPILE_FLAGS is used on a target this will be used
37# to filter out any other flags
38set(CMAKE_RC_FLAG_REGEX "^[-/](D|I)")
39
40# now define the following rule variables
41# CMAKE_RC_COMPILE_OBJECT
42set(CMAKE_INCLUDE_FLAG_RC "-I ")
43# compile a Resource file into an object file
44if(NOT CMAKE_RC_COMPILE_OBJECT)
45  set(CMAKE_RC_COMPILE_OBJECT
46    "<CMAKE_RC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /fo <OBJECT> <SOURCE>")
47endif()
48
49# set this variable so we can avoid loading this more than once.
50set(CMAKE_RC_INFORMATION_LOADED 1)
51