2005-12-14 21:51:08 +03:00
|
|
|
|
2009-09-28 19:46:51 +04: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 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 19:46:51 +04:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
2013-04-14 03:00:19 +04:00
|
|
|
# determine the compiler to use for RC programs
|
|
|
|
# NOTE, a generator may set CMAKE_RC_COMPILER before
|
2004-09-22 22:42:05 +04:00
|
|
|
# loading this file to force a compiler.
|
2013-04-14 03:00:19 +04: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 22:42:05 +04:00
|
|
|
# as a default compiler
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT CMAKE_RC_COMPILER)
|
2013-04-14 03:00:19 +04:00
|
|
|
# prefer the environment variable RC
|
2014-04-11 20:36:08 +04:00
|
|
|
if(NOT $ENV{RC} STREQUAL "")
|
2012-08-13 21:47:32 +04: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 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
if(EXISTS ${CMAKE_RC_COMPILER_INIT})
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message(FATAL_ERROR "Could not find compiler set in environment variable RC:\n$ENV{RC}.")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2004-09-22 22:42:05 +04:00
|
|
|
# next try prefer the compiler specified by the generator
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CMAKE_GENERATOR_RC)
|
|
|
|
if(NOT CMAKE_RC_COMPILER_INIT)
|
|
|
|
set(CMAKE_RC_COMPILER_INIT ${CMAKE_GENERATOR_RC})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2004-09-22 22:42:05 +04:00
|
|
|
|
2006-08-29 21:59:15 +04:00
|
|
|
# finally list compilers to try
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CMAKE_RC_COMPILER_INIT)
|
|
|
|
set(CMAKE_RC_COMPILER_LIST ${CMAKE_RC_COMPILER_INIT})
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_RC_COMPILER_LIST rc)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2006-08-29 21:59:15 +04:00
|
|
|
|
|
|
|
# Find the compiler.
|
2012-08-13 21:47:32 +04: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 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2004-09-22 22:42:05 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
mark_as_advanced(CMAKE_RC_COMPILER)
|
2004-09-22 22:42:05 +04:00
|
|
|
|
2012-08-13 21:47:32 +04: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 22:42:05 +04:00
|
|
|
|
|
|
|
# configure variables set in this file for fast reload later on
|
2012-08-13 21:47:32 +04:00
|
|
|
configure_file(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in
|
2013-11-13 12:50:56 +04:00
|
|
|
${CMAKE_PLATFORM_INFO_DIR}/CMakeRCCompiler.cmake)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_RC_COMPILER_ENV_VAR "RC")
|