2005-12-14 18:51:08 +00:00
|
|
|
|
2009-09-28 15:46:51 +00:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2004-2009 Kitware, Inc.
|
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2010-08-07 00:48:47 +00:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 15:46:51 +00:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
2013-04-13 23:00:19 +00:00
|
|
|
# determine the compiler to use for RC programs
|
|
|
|
# NOTE, a generator may set CMAKE_RC_COMPILER before
|
2004-09-22 18:42:05 +00:00
|
|
|
# loading this file to force a compiler.
|
2013-04-13 23:00:19 +00:00
|
|
|
# use environment variable RC first if defined by user, next use
|
|
|
|
# the cmake variable CMAKE_GENERATOR_RC which can be defined by a generator
|
2004-09-22 18:42:05 +00:00
|
|
|
# as a default compiler
|
2012-08-13 17:47:32 +00:00
|
|
|
if(NOT CMAKE_RC_COMPILER)
|
2013-04-13 23:00:19 +00:00
|
|
|
# prefer the environment variable RC
|
2014-04-11 16:36:08 +00:00
|
|
|
if(NOT $ENV{RC} STREQUAL "")
|
2012-08-13 17:47:32 +00:00
|
|
|
get_filename_component(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT)
|
|
|
|
if(CMAKE_RC_FLAGS_ENV_INIT)
|
|
|
|
set(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "First argument to RC compiler")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2012-08-13 17:47:32 +00:00
|
|
|
if(EXISTS ${CMAKE_RC_COMPILER_INIT})
|
2012-08-13 17:50:14 +00:00
|
|
|
else()
|
2012-08-13 17:47:32 +00:00
|
|
|
message(FATAL_ERROR "Could not find compiler set in environment variable RC:\n$ENV{RC}.")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2012-08-13 17:42:58 +00:00
|
|
|
|
2004-09-22 18:42:05 +00:00
|
|
|
# next try prefer the compiler specified by the generator
|
2012-08-13 17:47:32 +00:00
|
|
|
if(CMAKE_GENERATOR_RC)
|
|
|
|
if(NOT CMAKE_RC_COMPILER_INIT)
|
|
|
|
set(CMAKE_RC_COMPILER_INIT ${CMAKE_GENERATOR_RC})
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2004-09-22 18:42:05 +00:00
|
|
|
|
2006-08-29 17:59:15 +00:00
|
|
|
# finally list compilers to try
|
2012-08-13 17:47:32 +00:00
|
|
|
if(CMAKE_RC_COMPILER_INIT)
|
|
|
|
set(CMAKE_RC_COMPILER_LIST ${CMAKE_RC_COMPILER_INIT})
|
2012-08-13 17:50:14 +00:00
|
|
|
else()
|
2012-08-13 17:47:32 +00:00
|
|
|
set(CMAKE_RC_COMPILER_LIST rc)
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2006-08-29 17:59:15 +00:00
|
|
|
|
|
|
|
# Find the compiler.
|
2012-08-13 17:47:32 +00:00
|
|
|
find_program(CMAKE_RC_COMPILER NAMES ${CMAKE_RC_COMPILER_LIST} DOC "RC compiler")
|
|
|
|
if(CMAKE_RC_COMPILER_INIT AND NOT CMAKE_RC_COMPILER)
|
|
|
|
set(CMAKE_RC_COMPILER "${CMAKE_RC_COMPILER_INIT}" CACHE FILEPATH "RC compiler" FORCE)
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2004-09-22 18:42:05 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
mark_as_advanced(CMAKE_RC_COMPILER)
|
2004-09-22 18:42:05 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
get_filename_component(_CMAKE_RC_COMPILER_NAME_WE ${CMAKE_RC_COMPILER} NAME_WE)
|
|
|
|
if(_CMAKE_RC_COMPILER_NAME_WE STREQUAL "windres")
|
|
|
|
set(CMAKE_RC_OUTPUT_EXTENSION .obj)
|
|
|
|
else()
|
|
|
|
set(CMAKE_RC_OUTPUT_EXTENSION .res)
|
|
|
|
endif()
|
2004-09-22 18:42:05 +00:00
|
|
|
|
|
|
|
# configure variables set in this file for fast reload later on
|
2012-08-13 17:47:32 +00:00
|
|
|
configure_file(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in
|
2013-11-13 08:50:56 +00:00
|
|
|
${CMAKE_PLATFORM_INFO_DIR}/CMakeRCCompiler.cmake)
|
2012-08-13 17:47:32 +00:00
|
|
|
set(CMAKE_RC_COMPILER_ENV_VAR "RC")
|