1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
5 # This file sets the basic flags for the Windows Resource Compiler.
6 # It also loads the available platform file for the system-compiler
9 # make sure we don't use CMAKE_BASE_NAME from somewhere else
11 if(CMAKE_RC_COMPILER MATCHES "windres[^/]*$")
12 set(CMAKE_BASE_NAME "windres")
14 get_filename_component(CMAKE_BASE_NAME ${CMAKE_RC_COMPILER} NAME_WE)
16 set(CMAKE_SYSTEM_AND_RC_COMPILER_INFO_FILE
17 ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
18 include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
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.
25 if(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}")
31 set(CMAKE_RC_FLAGS_INIT "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}")
33 cmake_initialize_per_config_variable(CMAKE_RC_FLAGS "Flags for Windows Resource Compiler")
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
38 set(CMAKE_RC_FLAG_REGEX "^[-/](D|I)")
40 # now define the following rule variables
41 # CMAKE_RC_COMPILE_OBJECT
42 set(CMAKE_INCLUDE_FLAG_RC "-I")
43 # compile a Resource file into an object file
44 if(NOT CMAKE_RC_COMPILE_OBJECT)
45 set(CMAKE_RC_COMPILE_OBJECT
46 "<CMAKE_RC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /fo <OBJECT> <SOURCE>")
49 # set this variable so we can avoid loading this more than once.
50 set(CMAKE_RC_INFORMATION_LOADED 1)